コード例 #1
0
ファイル: App.php プロジェクト: rmiddle/cerb5_plugins
 function showTab()
 {
     @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer', 0));
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $tpl = DevblocksPlatform::getTemplateService();
     //$visit = CerberusApplication::getVisit();
     //$visit->set(Extension_ConfigTab::POINT, 'attachments');
     $message_ids = array_keys(DAO_Message::getMessagesByTicket($ticket_id));
     $comment_ids = array_keys(DAO_Comment::getByContext(CerberusContexts::CONTEXT_TICKET, $ticket_id));
     $attachment_links = array_merge(DAO_AttachmentLink::getByContextIds(CerberusContexts::CONTEXT_MESSAGE, $message_ids), DAO_AttachmentLink::getByContextIds(CerberusContexts::CONTEXT_COMMENT, $comment_ids));
     $defaults = new C4_AbstractViewModel();
     $defaults->class_name = 'View_AttachmentLink';
     $defaults->name = 'Attachements';
     $defaults->id = '_ticket_view_attachements';
     $defaults->renderLimit = 15;
     $view = C4_AbstractViewLoader::getView($defaults->id, $defaults);
     $view->renderPage = 0;
     $view->addParams(array(SearchFields_AttachmentLink::GUID => new DevblocksSearchCriteria(SearchFields_AttachmentLink::GUID, 'in', array_keys($attachment_links))), true);
     C4_AbstractViewLoader::setView($view->id, $view);
     $tpl->assign('view', $view);
     $tpl->display('file:' . $tpl_path . 'attachments/index.tpl');
 }
コード例 #2
0
ファイル: App.php プロジェクト: rmiddle/cerb5_plugins
 private function _workerAssignedTask($event)
 {
     $translate = DevblocksPlatform::getTranslationService();
     $events = DevblocksPlatform::getEventService();
     $worker_id = $event->params['worker_id'];
     $context = $event->params['context'];
     $task_id = $event->params['context_id'];
     $mail_service = DevblocksPlatform::getMailService();
     $mailer = null;
     // lazy load
     $settings = DevblocksPlatform::getPluginSettingsService();
     $reply_to = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM, CerberusSettingsDefaults::DEFAULT_REPLY_FROM);
     $reply_personal = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_PERSONAL, CerberusSettingsDefaults::DEFAULT_REPLY_PERSONAL);
     $task = DAO_Task::get($task_id);
     // Sanitize and combine all the destination addresses
     $next_worker = DAO_Worker::get($worker_id);
     $notify_emails = $next_worker->email;
     if (empty($notify_emails)) {
         return;
     }
     try {
         if (null == $mailer) {
             $mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
         }
         // Create the message
         $mail = $mail_service->createMessage();
         $mail->setTo(array($notify_emails));
         $mail->setFrom(array($reply_to => $reply_personal));
         $mail->setReplyTo($reply_to);
         $mail->setSubject(sprintf("[Task Assignment #%d]: %s", $task->id, $task->title));
         $headers = $mail->getHeaders();
         $headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
         $headers->addTextHeader('Precedence', 'List');
         $headers->addTextHeader('Auto-Submitted', 'auto-generated');
         $body = sprintf("[Task Assignment #%d]: %s", $task->id, $task->title);
         $mft = DevblocksPlatform::getExtension($context, false, true);
         $ext = $mft->createInstance();
         $url = $ext->getPermalink($task_id);
         $body .= "\r\n" . $url;
         // Comments
         $comments = DAO_Comment::getByContext(CerberusContexts::CONTEXT_TASK, $task_id);
         foreach ($comments as $comment_id => $comment) {
             $address = DAO_Address::get($comment->address_id);
             $body .= "\r\nCommented By: " . $address->first_name . " " . $address->last_name;
             $body .= "\r\n" . $comment->comment;
         }
         unset($comments);
         $body .= "\r\n";
         $mail->setBody($body);
         $result = $mailer->send($mail);
     } catch (Exception $e) {
         echo "Task Email Notification failed to send<br>";
     }
 }