/**
  * Returns the HTML code of this comment
  *
  * @return string the HTML code of this comment
  */
 public function fetchFollowUp()
 {
     if ($this->hasEmptyBody()) {
         return null;
     }
     $uh = UserHelper::instance();
     $html = '<div class="tracker_artifact_followup_comment_edited_by">';
     if ($this->parent_id) {
         $html .= $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'last_edited');
         $html .= ' ' . $uh->getLinkOnUserFromUserId($this->submitted_by) . ' ';
         $html .= DateHelper::timeAgoInWords($this->submitted_on, false, true);
     }
     $html .= '</div>';
     if (!empty($this->body)) {
         $html .= '<input type="hidden"
             id="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '"
             name="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '"
             value="' . $this->bodyFormat . '" />';
         $html .= '<div class="tracker_artifact_followup_comment_body">';
         if ($this->parent_id && !trim($this->body)) {
             $html .= '<em>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'comment_cleared') . '</em>';
         } else {
             $html .= $this->getPurifiedBodyForHTML();
         }
         $html .= '</div>';
     }
     return $html;
 }
 private function getRawMailForChangeset(Tracker_Artifact_Changeset $changeset)
 {
     $raw_mails = $this->getCachedRawMailByChangesetsForArtifact($changeset->getArtifact());
     $changeset_id = $changeset->getId();
     if (isset($raw_mails[$changeset_id])) {
         return $raw_mails[$changeset_id];
     }
     return null;
 }
Пример #3
0
 public function addChangeset(Tracker_Artifact_Changeset $changeset)
 {
     $this->changesets[$changeset->getId()] = $changeset;
 }
Пример #4
0
 private function linkRawMailToChangeset($raw_mail, Tracker_Artifact_Changeset $changeset)
 {
     $this->incoming_mail_dao->save($changeset->getId(), $raw_mail);
 }
 public function format(Tracker_Artifact_Changeset $changeset)
 {
     return array('id' => $changeset->getId(), 'submitted_by' => $changeset->getSubmittedBy(), 'submitted_on' => date('c', $changeset->getSubmittedOn()), 'email' => $changeset->getEmail(), 'html' => $this->getChangeContentForJson($changeset));
 }
Пример #6
0
 private function linkRawMailToChangeset($raw_mail, Tracker_Artifact_Changeset $changeset)
 {
     $this->logger->debug('Linking created changeset (' . $changeset->getId() . ') to the raw mail.');
     $this->incoming_mail_dao->save($changeset->getId(), $raw_mail);
 }
Пример #7
0
 /**
  * say if the changeset is the first one for this artifact
  *
  * @return bool
  */
 public function isFirstChangeset(Tracker_Artifact_Changeset $changeset)
 {
     $c = $this->getFirstChangeset();
     return $c->getId() == $changeset->getId();
 }
Пример #8
0
 private function getEmail(PFUser $user, Tracker_Artifact $artifact, Tracker_Artifact_Changeset $changeset)
 {
     return "<" . $artifact->getId() . "-" . $this->getHash($user, $artifact) . "-" . $user->getId() . "-" . $changeset->getId() . "@" . $this->host . ">";
 }
 /**
  * Returns the HTML code of this comment
  *
  * @param String  $format          Format of the output
  * @param Boolean $forMail         If the output is intended for mail notification then value should be true
  * @param Boolean $ignoreEmptyBody If true then display the user and the time even if the body is empty
  *
  * @return string the HTML code of this comment
  */
 public function fetchFollowUp($format = 'html', $forMail = false, $ignoreEmptyBody = false)
 {
     if ($ignoreEmptyBody || !empty($this->body)) {
         $uh = UserHelper::instance();
         $hp = Codendi_HTMLPurifier::instance();
         switch ($format) {
             case 'html':
                 $html = '';
                 if ($forMail) {
                     $html .= '<div class="tracker_artifact_followup_title">';
                     $html .= '<span class="tracker_artifact_followup_title_user">';
                     $user = UserManager::instance()->getUserById($this->submitted_by);
                     if ($user && !$user->isAnonymous()) {
                         $html .= '<a href="mailto:' . $hp->purify($user->getEmail()) . '">' . $hp->purify($user->getRealName()) . ' (' . $hp->purify($user->getUserName()) . ')</a>';
                     } else {
                         $user = UserManager::instance()->getUserAnonymous();
                         $user->setEmail($this->changeset->getEmail());
                         $html .= $GLOBALS['Language']->getText('tracker_include_artifact', 'anon_user');
                     }
                     $html .= '</span></div>';
                     $timezone = '';
                     if ($user->getId() != 0) {
                         $timezone = ' (' . $user->getTimezone() . ')';
                     }
                     $html .= '<div class="tracker_artifact_followup_date">' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $this->submitted_on) . $timezone . '</div>';
                     $html .= '</div>';
                     if (Config::get('sys_enable_avatars')) {
                         $html .= '<div class="tracker_artifact_followup_avatar">';
                         $html .= $user->fetchHtmlAvatar();
                         $html .= '</div>';
                     }
                     $html .= '<div class="tracker_artifact_followup_content">';
                     $html .= '<div class="tracker_artifact_followup_comment">';
                 } else {
                     $html .= '<div class="tracker_artifact_followup_comment_edited_by">';
                     if ($this->parent_id) {
                         $html .= $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'last_edited');
                         $html .= ' ' . $uh->getLinkOnUserFromUserId($this->submitted_by) . ' ';
                         $html .= DateHelper::timeAgoInWords($this->submitted_on, false, true);
                     }
                     $html .= '</div>';
                 }
                 if (!$forMail || !empty($this->body)) {
                     $html .= '<input type="hidden" id="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '" name="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '" value="' . $this->bodyFormat . '" >';
                     $html .= '<div class="tracker_artifact_followup_comment_body">';
                     if ($this->parent_id && !trim($this->body)) {
                         $html .= '<em>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'comment_cleared') . '</em>';
                     } else {
                         $html .= $this->getPurifiedBodyForHTML();
                     }
                     $html .= '</div>';
                 }
                 if ($forMail) {
                     $html .= '</div>';
                 }
                 return $html;
                 break;
             default:
                 $output = '';
                 //if ($this->parent_id) {
                 //$output .= $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'last_edited');
                 //$output .= ' '.$uh->getDisplayNameFromUserId($this->submitted_by);
                 //$output .= ' '.DateHelper::timeAgoInWords($this->submitted_on).PHP_EOL;
                 //}
                 if (!empty($this->body)) {
                     $body = $this->getPurifiedBodyForText();
                     $output .= PHP_EOL . PHP_EOL . $body . PHP_EOL . PHP_EOL;
                 }
                 return $output;
                 break;
         }
     } else {
         return null;
     }
 }
Пример #10
0
 /**
  * Execute actions after transition happens (if there is one)
  *
  * @param PFUser                     $user               The user who changed things
  * @param Array                      $fields_data        Request field data (array[field_id] => data)
  * @param Tracker_Artifact_Changeset $new_changeset      The changeset that has just been created
  * @param Tracker_Artifact_Changeset $previous_changeset The changeset just before (null for a new artifact)
  *
  * @return void
  */
 public function after(array $fields_data, Tracker_Artifact_Changeset $new_changeset, Tracker_Artifact_Changeset $previous_changeset = null)
 {
     $this->logger->defineFingerprint($new_changeset->getArtifact()->getId());
     $this->logger->start(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null');
     if (isset($fields_data[$this->getFieldId()])) {
         $transition = $this->getCurrentTransition($fields_data, $previous_changeset);
         if ($transition) {
             $transition->after($new_changeset);
         }
     }
     $this->trigger_rules_manager->processTriggers($new_changeset);
     $this->logger->end(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null');
 }
Пример #11
0
 public function processTriggers(Tracker_Artifact_Changeset $changeset)
 {
     $this->logger->start(__METHOD__, $changeset->getId());
     $dar_rules = $this->dao->searchForInvolvedRulesIdsByChangesetId($changeset->getId());
     foreach ($dar_rules as $row) {
         $rule = $this->getRuleById($row['rule_id']);
         $this->logger->debug("Found matching rule " . json_encode($rule->fetchFormattedForJson()));
         $this->rules_processor->process($changeset->getArtifact(), $rule);
     }
     $this->logger->end(__METHOD__, $changeset->getId());
 }