Exemplo n.º 1
0
 protected function _publishAndNotify()
 {
     // posting on own profile is status change, which is logged separately
     if ($this->get('user_id') != $this->get('profile_user_id')) {
         parent::_publishAndNotify();
     }
     if ($this->isInsert() && $this->get('profile_user_id') != $this->get('user_id')) {
         $this->_alertUser();
     }
 }
Exemplo n.º 2
0
 protected function _publishAndNotify()
 {
     parent::_publishAndNotify();
     // send an alert if the message is visible, is not posted on the user's own profile
     // is an insert, or is an update with message state changed from 'moderated'
     $isAlertable = $this->get('message_state') == 'visible' && ($this->isInsert() || $this->getExisting('message_state') == 'moderated');
     if ($isAlertable) {
         $alerted = $this->_alertUser();
         $maxTagged = $this->getOption(self::OPTION_MAX_TAGGED_USERS);
         if ($maxTagged && $this->_taggedUsers) {
             if ($maxTagged > 0) {
                 $alertTagged = array_slice($this->_taggedUsers, 0, $maxTagged, true);
             } else {
                 $alertTagged = $this->_taggedUsers;
             }
             if (!($profileUser = $this->getExtraData(self::DATA_PROFILE_USER))) {
                 $profileUser = $this->_getUserModel()->getUserById($this->get('profile_user_id'), array('join' => XenForo_Model_User::FETCH_USER_FULL));
             }
             $profilePost = $this->getMergedData();
             $this->_getProfilePostModel()->alertTaggedMembers($profilePost, $profileUser, $alertTagged, $alerted);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Updates denormalized counters. Used after a message has been deleted.
  *
  * @param XenForo_DataWriter_DiscussionMessage $messageDw
  * @param boolean $deleteIfFirstMessage If true and message if first, delete discussion
  *
  * @return string State changes to discussion: delete means remove discussion; firstDelete means first message was removed but still valid
  */
 public function updateCountersAfterMessageDelete(XenForo_DataWriter_DiscussionMessage $messageDw, $deleteIfFirstMessage = true)
 {
     $messageId = $messageDw->getDiscussionMessageId();
     if ($messageId == $this->get('first_post_id')) {
         if (!$deleteIfFirstMessage && $this->rebuildDiscussion()) {
             return 'firstDelete';
         } else {
             return 'delete';
         }
     }
     if ($messageId == $this->get('last_post_id')) {
         $this->updateLastPost();
     }
     if ($messageDw->get('message_state') == 'visible') {
         $this->set('reply_count', $this->get('reply_count') - 1);
     }
     return '';
 }
Exemplo n.º 4
0
 public function setExtraData($name, $value)
 {
     if ($name == self::DATA_FORUM) {
         if (is_array($value) && isset($value['node_id'])) {
             XenForo_DataWriter_Discussion_Thread::setForumCacheItem($value);
         }
     }
     return parent::setExtraData($name, $value);
 }