function sendNotifReviewer($reviewer)
 {
     // Project
     $pm = ProjectManager::instance();
     $group = $pm->getProject($this->item->getGroupId());
     // Url
     $reviewUrl = $this->getReviewUrl() . '&review=1';
     $subject = $this->getNotificationSubject();
     $body = $this->getNotificationBodyText();
     return $this->mail_notification_builder->buildAndSendEmail($group, array($reviewer->getEmail()), $subject, '', $body, $reviewUrl, DocmanPlugin::TRUNCATED_SERVICE_NAME, new MailEnhancer());
 }
 /**
  * Send a notification
  *
  * @param array  $recipients the list of recipients
  * @param array  $headers    the additional headers
  * @param string $from       the mail of the sender
  * @param string $subject    the subject of the message
  * @param string $htmlBody   the html content of the message
  * @param string $txtBody    the text content of the message
  * @param string $message_id the id of the message
  *
  * @return void
  */
 protected function sendNotification($recipients, $headers, $from, $subject, $htmlBody, $txtBody, $message_id)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $breadcrumbs = array();
     $tracker = $this->getTracker();
     $project = $tracker->getProject();
     $artifactId = $this->getArtifact()->getID();
     $project_unix_name = $project->getUnixName(true);
     $tracker_name = $tracker->getItemName();
     $mail_enhancer = new MailEnhancer();
     if ($message_id) {
         $mail_enhancer->setMessageId($message_id);
     }
     $breadcrumbs[] = '<a href="' . get_server_url() . '/projects/' . $project_unix_name . '" />' . $project->getPublicName() . '</a>';
     $breadcrumbs[] = '<a href="' . get_server_url() . '/plugins/tracker/?tracker=' . (int) $tracker->getId() . '" />' . $hp->purify($this->getTracker()->getName()) . '</a>';
     $breadcrumbs[] = '<a href="' . get_server_url() . '/plugins/tracker/?aid=' . (int) $artifactId . '" />' . $hp->purify($this->getTracker()->getName() . ' #' . $artifactId) . '</a>';
     $mail_enhancer->addPropertiesToLookAndFeel('breadcrumbs', $breadcrumbs);
     $mail_enhancer->addPropertiesToLookAndFeel('unsubscribe_link', $this->getUnsubscribeLink());
     $mail_enhancer->addPropertiesToLookAndFeel('title', $hp->purify($subject));
     $mail_enhancer->addHeader("X-Codendi-Project", $project->getUnixName());
     $mail_enhancer->addHeader("X-Codendi-Tracker", $tracker_name);
     $mail_enhancer->addHeader("X-Codendi-Artifact-ID", $this->artifact->getId());
     $mail_enhancer->addHeader('From', $from);
     foreach ($headers as $header) {
         $mail_enhancer->addHeader($header['name'], $header['value']);
     }
     if ($htmlBody) {
         $htmlBody .= $this->getHTMLBodyFilter($project_unix_name, $tracker_name);
     }
     $txtBody .= $this->getTextBodyFilter($project_unix_name, $tracker_name);
     $mail_notification_builder = new MailNotificationBuilder(new MailBuilder(TemplateRendererFactory::build()));
     $mail_notification_builder->buildAndSendEmail($project, $recipients, $subject, $htmlBody, $txtBody, get_server_url() . $this->getUri(), trackerPlugin::TRUNCATED_SERVICE_NAME, $mail_enhancer);
 }
 /**
  * Get the list of all futur obsolete documents and warn document owner
  * about this obsolescence.
  */
 function notifyFuturObsoleteDocuments()
 {
     $pm = ProjectManager::instance();
     $itemFactory = new Docman_ItemFactory(0);
     //require_once('common/mail/TestMail.class.php');
     //$mail = new TestMail();
     //$mail->_testDir = '/local/vm16/codev/servers/docman-2.0/var/spool/mail';
     $itemIter = $itemFactory->findFuturObsoleteItems();
     $itemIter->rewind();
     while ($itemIter->valid()) {
         $item =& $itemIter->current();
         // Users
         $um =& UserManager::instance();
         $owner =& $um->getUserById($item->getOwnerId());
         // Project
         $group = $pm->getProject($item->getGroupId());
         // Date
         $obsoDate = util_timestamp_to_userdateformat($item->getObsolescenceDate(), true);
         // Urls
         $baseUrl = get_server_url() . $this->pluginPath . '/index.php?group_id=' . $item->getGroupId() . '&id=' . $item->getId();
         $directUrl = $baseUrl . '&action=show';
         $detailUrl = $baseUrl . '&action=details';
         $subj = $this->txt('obso_warn_email_subject', array($GLOBALS['sys_name'], $item->getTitle()));
         $body = $this->txt('obso_warn_email_body', array($item->getTitle(), $group->getPublicName(), $obsoDate, $directUrl, $detailUrl));
         $mail_notification_builder = new MailNotificationBuilder(new MailBuilder(TemplateRendererFactory::build()));
         $mail_notification_builder->buildAndSendEmail($group, array($owner->getEmail()), $subj, '', $body, $baseUrl, DocmanPlugin::TRUNCATED_SERVICE_NAME, new MailEnhancer());
         $itemIter->next();
     }
 }
Пример #4
0
 /**
  * Remind a user about the document he is supposed to review
  *
  * @param Docman_ApprovalTable $table      Approval table
  * @param Integer              $reviewerId Id of the reviewer
  *
  * @return Boolean
  */
 private function notifyIndividual(Docman_ApprovalTable $table, $reviewerId)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $um = UserManager::instance();
     $reviewer = $um->getUserById($reviewerId);
     if (!$reviewer->getEmail()) {
         return;
     }
     if ($table instanceof Docman_ApprovalTableFile) {
         $versionFactory = new Docman_VersionFactory();
         $version = $versionFactory->getSpecificVersionById($table->getVersionId(), 'plugin_docman_version');
         $itemId = "";
         if ($version) {
             $itemId = $version->getItemId();
         }
     } elseif ($table) {
         $itemId = $table->getItemId();
     }
     if (!$itemId) {
         return;
     }
     $itemFactory = new Docman_ItemFactory();
     $docmanItem = $itemFactory->getItemFromDb($itemId);
     if (!$docmanItem) {
         return;
     }
     $subject = $GLOBALS['Language']->getText('plugin_docman', 'approval_reminder_mail_subject', array($GLOBALS['sys_name'], $docmanItem->getTitle()));
     $mailMgr = new MailManager();
     $mailPrefs = $mailMgr->getMailPreferencesByUser($reviewer);
     if ($mailPrefs == Codendi_Mail_Interface::FORMAT_HTML) {
         $html_body = $this->getBodyHtml($table, $docmanItem);
     }
     $text_body = $this->getBodyText($table, $docmanItem);
     $mail_notification_builder = new MailNotificationBuilder(new MailBuilder(TemplateRendererFactory::build()));
     return $mail_notification_builder->buildAndSendEmail($this->getItemProject($docmanItem), array($reviewer->getEmail()), $subject, $html_body, $text_body, $this->getReviewUrl($docmanItem), DocmanPlugin::TRUNCATED_SERVICE_NAME, new MailEnhancer());
 }