예제 #1
0
 /**
  * Updates the value of the last post for this discussion.
  */
 public function updateLastPost()
 {
     $lastPost = $this->_getLastMessageInDiscussion();
     if ($lastPost) {
         $messageStructure = $this->_messageDefinition->getMessageStructure();
         $this->set('last_post_id', $lastPost[$messageStructure['key']]);
         $this->set('last_post_date', $lastPost['post_date']);
         $this->set('last_post_user_id', $lastPost['user_id']);
         $this->set('last_post_username', $lastPost['username']);
     } else {
         $this->set('last_post_id', $this->get('first_post_id'));
         $this->set('last_post_date', $this->get('post_date'));
         $this->set('last_post_user_id', $this->get('user_id'));
         $this->set('last_post_username', $this->get('username'));
     }
 }
예제 #2
0
 /**
  * Gets the fields that are defined for the table. See parent for explanation.
  *
  * @return array
  */
 protected function _getCommonFields()
 {
     $structure = $this->_messageDefinition->getMessageStructure();
     $fields = array($structure['table'] => array($structure['key'] => array('type' => self::TYPE_UINT, 'autoIncrement' => true), $structure['container'] => array('type' => self::TYPE_UINT, 'required' => true), 'user_id' => array('type' => self::TYPE_UINT, 'required' => true), 'username' => array('type' => self::TYPE_STRING, 'required' => true, 'maxLength' => 50, 'requiredError' => 'please_enter_valid_name'), 'post_date' => array('type' => self::TYPE_UINT, 'required' => true, 'default' => XenForo_Application::$time), 'message' => array('type' => self::TYPE_STRING, 'required' => true, 'requiredError' => 'please_enter_valid_message'), 'ip_id' => array('type' => self::TYPE_UINT, 'default' => 0), 'message_state' => array('type' => self::TYPE_STRING, 'default' => 'visible', 'allowedValues' => array('visible', 'moderated', 'deleted')), 'attach_count' => array('type' => self::TYPE_UINT_FORCED, 'default' => 0, 'max' => 65535), 'likes' => array('type' => self::TYPE_UINT_FORCED, 'default' => 0), 'like_users' => array('type' => self::TYPE_SERIALIZED, 'default' => 'a:0:{}'), 'warning_id' => array('type' => self::TYPE_UINT, 'default' => 0), 'warning_message' => array('type' => self::TYPE_STRING, 'default' => '', 'maxLength' => 255)));
     if ($this->_hasParentDiscussion) {
         $fields[$structure['table']]['position'] = array('type' => self::TYPE_UINT_FORCED);
     }
     if ($this->_supportEditLog) {
         $fields[$structure['table']]['last_edit_date'] = array('type' => self::TYPE_UINT, 'default' => 0);
         $fields[$structure['table']]['last_edit_user_id'] = array('type' => self::TYPE_UINT, 'default' => 0);
         $fields[$structure['table']]['edit_count'] = array('type' => self::TYPE_UINT_FORCED, 'default' => 0);
     }
     return $fields;
 }