コード例 #1
0
ファイル: classes.php プロジェクト: Hildy/cerb5
 function showAddTemplatePeekAction()
 {
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($portal = DevblocksPlatform::importGPC($_REQUEST['portal'], 'string', ''));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('view_id', $view_id);
     $tpl->assign('portal', $portal);
     if (null == ($tool = DAO_CommunityTool::getByCode($portal))) {
         return;
     }
     if (null == ($tool_ext = DevblocksPlatform::getExtension($tool->extension_id, false))) {
         return;
     }
     if (null == ($template_set = @$tool_ext->params['template_set'])) {
         $template_set = '';
     }
     // not null
     $templates = DevblocksPlatform::getTemplates($template_set);
     $existing_templates = DAO_DevblocksTemplate::getWhere(sprintf("%s = %s", DAO_DevblocksTemplate::TAG, C4_ORMHelper::qstr('portal_' . $portal)));
     // Sort templates
     uasort($templates, create_function('$a, $b', "return strcasecmp(\$a->plugin_id.' '.\$a->path,\$b->plugin_id.' '.\$b->path);\n"));
     // Filter out templates implemented by this portal already
     if (is_array($templates)) {
         foreach ($templates as $idx => $template) {
             /* @var $template DevblocksTemplate */
             if (is_array($existing_templates)) {
                 foreach ($existing_templates as $existing) {
                     /* @var $existing Model_DevblocksTemplate */
                     if (0 == strcasecmp($template->plugin_id, $existing->plugin_id) && 0 == strcasecmp($template->path, $existing->path)) {
                         unset($templates[$idx]);
                     }
                 }
             }
         }
     }
     $tpl->assign('templates', $templates);
     $tpl->display('file:' . $this->_TPL_PATH . 'community/display/tabs/templates/add.tpl');
 }
コード例 #2
0
ファイル: App.php プロジェクト: sluther/cerb5-iphone
 function showTab()
 {
     $response = DevblocksPlatform::getHttpResponse();
     $path = $response->path;
     array_shift($path);
     // iphone
     array_shift($path);
     // tickets
     array_shift($path);
     // current ('display')
     $id = array_shift($path);
     // ticket id
     @($active_worker = CerberusApplication::getActiveWorker());
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('expand_all', $expand_all);
     $ticket = DAO_Ticket::getTicket($id);
     $tpl->assign('requesters', $ticket->getRequesters());
     // Drafts
     $drafts = DAO_MailQueue::getWhere(sprintf("%s = %d AND %s = %s", DAO_MailQueue::TICKET_ID, $id, DAO_MailQueue::TYPE, C4_ORMHelper::qstr(Model_MailQueue::TYPE_TICKET_REPLY)));
     if (!empty($drafts)) {
         $tpl->assign('drafts', $drafts);
     }
     // Only unqueued drafts
     $pending_drafts = array();
     if (!empty($drafts) && is_array($drafts)) {
         foreach ($drafts as $draft_id => $draft) {
             if (!$draft->is_queued) {
                 $pending_drafts[$draft_id] = $draft;
             }
         }
     }
     if (!empty($pending_drafts)) {
         $tpl->assign('pending_drafts', $pending_drafts);
     }
     // Messages
     $messages = $ticket->getMessages();
     arsort($messages);
     $tpl->assign('latest_message_id', key($messages));
     $tpl->assign('messages', $messages);
     // Thread comments and messages on the same level
     $convo_timeline = array();
     // Track senders and their orgs
     $message_senders = array();
     $message_sender_orgs = array();
     // Loop messages
     foreach ($messages as $message_id => $message) {
         /* @var $message Model_Message */
         $key = $message->created_date . '_m' . $message_id;
         // build a chrono index of messages
         $convo_timeline[$key] = array('m', $message_id);
         // If we haven't cached this sender address yet
         if (!isset($message_senders[$message->address_id])) {
             if (null != ($sender_addy = DAO_Address::get($message->address_id))) {
                 $message_senders[$sender_addy->id] = $sender_addy;
                 // If we haven't cached this sender org yet
                 if (!isset($message_sender_orgs[$sender_addy->contact_org_id])) {
                     if (null != ($sender_org = DAO_ContactOrg::get($sender_addy->contact_org_id))) {
                         $message_sender_orgs[$sender_org->id] = $sender_org;
                     }
                 }
             }
         }
     }
     $tpl->assign('message_senders', $message_senders);
     $tpl->assign('message_sender_orgs', $message_sender_orgs);
     @($mail_inline_comments = DAO_WorkerPref::get($active_worker->id, 'mail_inline_comments', 1));
     if ($mail_inline_comments) {
         // if inline comments are enabled
         $comments = DAO_TicketComment::getByTicketId($id);
         arsort($comments);
         $tpl->assign('comments', $comments);
         // build a chrono index of comments
         foreach ($comments as $comment_id => $comment) {
             /* @var $comment Model_TicketComment */
             $key = $comment->created . '_c' . $comment_id;
             $convo_timeline[$key] = array('c', $comment_id);
         }
     }
     // Thread drafts into conversation
     if (!empty($drafts)) {
         foreach ($drafts as $draft_id => $draft) {
             /* @var $draft Model_MailQueue */
             $key = $draft->updated . '_d' . $draft_id;
             $convo_timeline[$key] = array('d', $draft_id);
         }
     }
     // sort the timeline
     if (!$expand_all) {
         krsort($convo_timeline);
     } else {
         ksort($convo_timeline);
     }
     $tpl->assign('convo_timeline', $convo_timeline);
     // Message Notes
     $notes = DAO_MessageNote::getByTicketId($id);
     $message_notes = array();
     // Index notes by message id
     if (is_array($notes)) {
         foreach ($notes as $note) {
             if (!isset($message_notes[$note->message_id])) {
                 $message_notes[$note->message_id] = array();
             }
             $message_notes[$note->message_id][$note->id] = $note;
         }
     }
     $tpl->assign('message_notes', $message_notes);
     // Message toolbar items
     $messageToolbarItems = DevblocksPlatform::getExtensions('cerberusweb.message.toolbaritem', true);
     if (!empty($messageToolbarItems)) {
         $tpl->assign('message_toolbaritems', $messageToolbarItems);
     }
     // Workers
     $workers = DAO_Worker::getAll();
     $tpl->assign('workers', $workers);
     $tpl->display('file:' . $this->_TPL_PATH . 'tickets/display/conversation.tpl');
 }