protected function _getOrGenerateRssKey()
 {
     static $key;
     $key = $key === null ? framework\Settings::getUserSetting($this->getID(), framework\Settings::USER_RSS_KEY) : $key;
     if ($key === null) {
         $key = $this->regenerateRssKey();
     }
     return $key;
 }
Exemple #2
0
 protected function _postSave($is_new)
 {
     if ($is_new) {
         $tty = $this->getTargetType();
         $tid = $this->getTargetID();
         if (array_key_exists($tty, self::$_comment_count) && array_key_exists($tid, self::$_comment_count[$tty]) && array_key_exists((int) $this->isSystemComment(), self::$_comment_count[$tty][$tid])) {
             self::$_comment_count[$tty][$tid][(int) $this->isSystemComment()]++;
         }
         if (!$this->isSystemComment()) {
             if ($this->_getParser()->hasMentions()) {
                 foreach ($this->_getParser()->getMentions() as $user) {
                     if ($user->getID() == framework\Context::getUser()->getID()) {
                         continue;
                     }
                     if ($user->getNotificationSetting(framework\Settings::SETTINGS_USER_NOTIFY_MENTIONED, false)->isOn()) {
                         $this->_addNotificationIfNotNotified(Notification::TYPE_COMMENT_MENTIONED, $user, $this->getPostedBy());
                     }
                 }
             }
             if ($this->getTargetType() == self::TYPE_ISSUE) {
                 if (framework\Settings::getUserSetting(framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ISSUES, $this->getPostedByID())) {
                     $this->getTarget()->addSubscriber($this->getPostedByID());
                 }
             }
             if ($this->getTargetType() == self::TYPE_ARTICLE) {
                 if (framework\Settings::getUserSetting(framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ARTICLES, $this->getPostedByID())) {
                     $this->getTarget()->addSubscriber($this->getPostedByID());
                 }
             }
             $this->_addTargetNotifications();
         }
     } else {
         switch ($this->getTargetType()) {
             case self::TYPE_ISSUE:
                 \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\core\\entities\\Comment::_postSave', $this, array('issue' => $this->getTarget()))->trigger();
                 break;
             case self::TYPE_ARTICLE:
                 \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\core\\entities\\Comment::_postSave', $this, array('article' => $this->getTarget()))->trigger();
                 break;
             default:
                 return;
         }
     }
     $this->touchTargetIfItsIssue();
 }
Exemple #3
0
 protected function _postSave($is_new)
 {
     $this->_saveCustomFieldValues();
     if (!$is_new) {
         $related_issues_to_save = $this->_processChanges();
         $comment = isset($this->_save_comment) ? $this->_save_comment : $this->addSystemComment('', framework\Context::getUser()->getID());
         $this->triggerSaveEvent($comment, framework\Context::getUser());
         if (count($related_issues_to_save)) {
             foreach (array_keys($related_issues_to_save) as $i_id) {
                 $related_issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $i_id);
                 $related_issue->save();
             }
         }
     } else {
         $_description_parser = $this->_getDescriptionParser();
         $_reproduction_steps_parser = $this->_getReproductionStepsParser();
         if (!is_null($_description_parser) && $_description_parser->hasMentions()) {
             foreach ($_description_parser->getMentions() as $user) {
                 if ($user->getID() == framework\Context::getUser()->getID()) {
                     continue;
                 }
                 $this->_addNotification(Notification::TYPE_ISSUE_MENTIONED, $user, $this->getPostedBy());
             }
         }
         if (!is_null($_reproduction_steps_parser) && $_reproduction_steps_parser->hasMentions()) {
             foreach ($_reproduction_steps_parser->getMentions() as $user) {
                 if ($user->getID() == framework\Context::getUser()->getID()) {
                     continue;
                 }
                 $this->_addNotification(Notification::TYPE_ISSUE_MENTIONED, $user, $this->getPostedBy());
             }
         }
         $this->addLogEntry(tables\Log::LOG_ISSUE_CREATED, null, false, $this->getPosted());
         $this->_addCreateNotifications($this->getPostedBy());
         \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\core\\entities\\Issue::createNew', $this)->trigger();
     }
     if (in_array(\thebuggenie\core\framework\Settings::getUserSetting(\thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ISSUES, framework\Context::getUser()->getID()), array(null, true))) {
         $this->addSubscriber(framework\Context::getUser()->getID());
     }
     $this->_clearChangedProperties();
     $this->_log_items_added = array();
     $this->getProject()->clearRecentActivities();
     if ($this->isChildIssue() && ($this->hasEstimatedTime() || $this->hasSpentTime())) {
         foreach ($this->getParentIssues() as $issue) {
             $issue->calculateTime();
             $issue->save();
         }
     }
     if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
         $this->getMilestone()->updateStatus();
         $this->getMilestone()->save();
     }
     return true;
 }
Exemple #4
0
 protected function _postSave($is_new)
 {
     if ($is_new) {
         $tty = $this->getTargetType();
         $tid = $this->getTargetID();
         if (array_key_exists($tty, self::$_comment_count) && array_key_exists($tid, self::$_comment_count[$tty]) && array_key_exists((int) $this->isSystemComment(), self::$_comment_count[$tty][$tid])) {
             self::$_comment_count[$tty][$tid][(int) $this->isSystemComment()]++;
         }
         if (!$this->isSystemComment()) {
             if ($this->_getParser()->hasMentions()) {
                 foreach ($this->_getParser()->getMentions() as $user) {
                     if ($user->getID() == framework\Context::getUser()->getID()) {
                         continue;
                     }
                     $this->_addNotification(Notification::TYPE_COMMENT_MENTIONED, $user);
                 }
             }
             if ($this->getTargetType() == self::TYPE_ISSUE) {
                 $this->_addIssueNotifications();
                 if (framework\Settings::getUserSetting(framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ISSUES, $this->getPostedByID())) {
                     $this->getTarget()->addSubscriber($this->getPostedByID());
                 }
             }
             if ($this->getTargetType() == self::TYPE_ARTICLE) {
                 if (framework\Settings::getUserSetting(framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ARTICLES, $this->getPostedByID())) {
                     $this->getTarget()->addSubscriber($this->getPostedByID());
                 }
             }
         }
     }
 }