Beispiel #1
0
 public function process_event(&$event)
 {
     $this->force_connect();
     switch ($event->type) {
         case 'newsletter_freelancer':
             $uid = (int) $event->data['uid'];
             //$op  = $event->data['op'];
             $ms = new MemStorage('newsletter_freelancer');
             if ($ms->isExistData()) {
                 $item = freelancer::GetPrjRecp($uid);
                 $page_id = $ms->isExistItem($uid);
                 $this->log->notice('getDebugInfo: ' . $ms->getDebugInfo());
                 $this->log->notice('BEFORE: ' . print_r($ms->getItem($uid), true));
                 if ($item) {
                     if ($page_id === false) {
                         //insert
                         $ms->insertItem($uid, $item);
                         $this->log->notice("insertItem {$uid}");
                     } else {
                         //update
                         $ms->updateItem($uid, $item, $page_id);
                         $this->log->notice("updateItem {$uid}");
                     }
                 } elseif ($page_id) {
                     //delete
                     $ms->deleteItem($uid, $page_id);
                     $this->log->notice("deleteItem {$uid}");
                 }
                 $this->log->notice('AFTER: ' . print_r($ms->getItem($uid), true));
             }
             break;
     }
     return PGQ_EVENT_OK;
 }