Пример #1
0
 protected function _postInsert()
 {
     // Increment room user count
     $room = $this->getRoom();
     //$room->user_count++;
     $room->user_count = new Zend_Db_Expr('user_count + 1');
     $room->save();
     // Announce prescence
     $ids = $this->getRoom()->getUserIds();
     // Remove self
     if (false !== ($index = array_search($this->user_id, $ids))) {
         //unset($ids[$index]);
     }
     if (!empty($ids)) {
         $eventTable = Engine_Api::_()->getDbtable('events', 'chat');
         foreach ($ids as $id) {
             $eventTable->createRow()->setFromArray(array('user_id' => $id, 'date' => date('Y-m-d H:i:s'), 'type' => 'grouppresence', 'body' => array('room_id' => $this->room_id, 'user_id' => $this->user_id, 'state' => '1')))->save();
         }
         // Increment event count for each user
         Engine_Api::_()->getDbtable('users', 'chat')->update(array('event_count' => new Zend_Db_Expr('event_count+1')), array('user_id IN(\'' . join("', '", $ids) . '\')'));
     }
     parent::_insert();
 }
Пример #2
0
 protected function _insert()
 {
     $ids = $this->getUsersToBeNotifiedOfPresence();
     if (!empty($ids)) {
         // Announce presence to all online friends
         $eventTable = Engine_Api::_()->getDbtable('events', 'chat');
         foreach ($ids as $id) {
             $eventTable->insert(array('user_id' => $id, 'date' => date('Y-m-d H:i:s'), 'type' => 'presence', 'body' => array('user_id' => $this->user_id, 'state' => '1')));
         }
         // Increment event count for each user
         Engine_Api::_()->getDbtable('users', 'chat')->update(array('event_count' => new Zend_Db_Expr('event_count+1')), array('user_id IN(\'' . join("', '", $ids) . '\')'));
     }
     parent::_insert();
 }
Пример #3
0
 /**
  * Pre-insert hook. If overridden, should be called at end of function.
  * 
  * @return void
  */
 protected function _insert()
 {
     if ($this->_disableHooks) {
         return;
     }
     parent::_insert();
     if (isset($this->creation_date)) {
         $this->creation_date = date('Y-m-d H:i:s');
     }
     // Should updated be initialized on creation or be left null?
     if (isset($this->modified_date)) {
         $this->modified_date = date('Y-m-d H:i:s');
     }
     Engine_Hooks_Dispatcher::getInstance()->callEvent('on' . $this->getType(true) . 'CreateBefore', $this);
     Engine_Hooks_Dispatcher::getInstance()->callEvent('onItemCreateBefore', $this);
 }