예제 #1
0
 public function store($unused = null)
 {
     $stored = false;
     $q = $this->_getQuery();
     if ($this->{$this->_tbl_key} && $this->canEdit()) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         $stored = parent::store();
     }
     if (0 == $this->{$this->_tbl_key} && $this->canCreate()) {
         $this->message_date = $q->dbfnNowWithTZ();
         $stored = parent::store();
         if ($stored) {
             $q->addTable('forum_messages');
             $q->addQuery('count(message_id), MAX(message_date)');
             $q->addWhere('message_forum = ' . (int) $this->message_forum);
             $reply = $q->fetchRow();
             //update forum descriptor
             $forum = new CForum();
             $forum->overrideDatabase($this->_query);
             $forum->load($this->message_forum);
             $forum->forum_message_count = $reply[0];
             /*
              * Note: the message_date here has already been adjusted for the
              *    timezone above, so don't do it again!
              */
             $forum->forum_last_date = $this->message_date;
             $forum->forum_last_id = $this->message_id;
             $forum->store();
             $this->sendWatchMail(false);
         }
     }
     return $stored;
 }
예제 #2
0
 public function store()
 {
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = $this->_getQuery();
     //TODO: this is an oddball permissions object where the module doesn't determine the access..
     if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'edit', $this->{$this->_tbl_module})) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $stored = true;
         }
     }
     if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'add')) {
         $this->message_date = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $q->addTable('forum_messages');
             $q->addQuery('count(message_id), MAX(message_date)');
             $q->addWhere('message_forum = ' . (int) $this->message_forum);
             $reply = $q->fetchRow();
             //update forum descriptor
             $forum = new CForum();
             $forum->overrideDatabase($this->_query);
             $forum->load(null, $this->message_forum);
             $forum->forum_message_count = $reply[0];
             /*
              * Note: the message_date here has already been adjusted for the
              *    timezone above, so don't do it again!
              */
             $forum->forum_last_date = $this->message_date;
             $forum->forum_last_id = $this->message_id;
             $forum->store();
             $this->sendWatchMail(false);
             $stored = true;
         }
     }
     return $stored;
 }