示例#1
0
文件: App.php 项目: joegeck/cerb4
 function render()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->cache_lifetime = "0";
     $tpl_path = $this->plugin_path . '/templates/';
     $tpl->assign('path', $tpl_path);
     $visit = CerberusApplication::getVisit();
     $translate = DevblocksPlatform::getTranslationService();
     $response = DevblocksPlatform::getHttpResponse();
     $stack = $response->path;
     array_shift($stack);
     // crm
     $module = array_shift($stack);
     // opps
     switch ($module) {
         default:
         case 'opps':
             @($opp_id = intval(array_shift($stack)));
             if (null == ($opp = DAO_CrmOpportunity::get($opp_id))) {
                 break;
                 // [TODO] Not found
             }
             $tpl->assign('opp', $opp);
             $address = DAO_Address::get($opp->primary_email_id);
             $tpl->assign('address', $address);
             $workers = DAO_Worker::getAll();
             $tpl->assign('workers', $workers);
             $task_count = DAO_Task::getCountBySourceObjectId('cerberusweb.tasks.opp', $opp_id);
             $tpl->assign('tasks_total', $task_count);
             $visit = CerberusApplication::getVisit();
             // Does a series exist?
             if (null != ($series_info = $visit->get('ch_opp_series', null))) {
                 @($series = $series_info['series']);
                 // Is this ID part of the series?  If not, invalidate
                 if (!isset($series[$opp_id])) {
                     $visit->set('ch_opp_series', null);
                 } else {
                     $series_stats = array('title' => $series_info['title'], 'total' => $series_info['total'], 'count' => count($series));
                     reset($series);
                     $cur = 1;
                     while (current($series)) {
                         $pos = key($series);
                         if (intval($pos) == intval($opp_id)) {
                             $series_stats['cur'] = $cur;
                             if (false !== prev($series)) {
                                 @($series_stats['prev'] = $series[key($series)][SearchFields_CrmOpportunity::ID]);
                                 next($series);
                                 // skip to current
                             } else {
                                 reset($series);
                             }
                             next($series);
                             // next
                             @($series_stats['next'] = $series[key($series)][SearchFields_CrmOpportunity::ID]);
                             break;
                         }
                         next($series);
                         $cur++;
                     }
                     $tpl->assign('series_stats', $series_stats);
                 }
             }
             $tpl->display($tpl_path . 'crm/opps/display/index.tpl');
             break;
     }
 }
示例#2
0
 function render()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->cache_lifetime = "0";
     $tpl->assign('path', $this->_TPL_PATH);
     $visit = CerberusApplication::getVisit();
     /* @var $visit CerberusVisit */
     $response = DevblocksPlatform::getHttpResponse();
     $active_worker = CerberusApplication::getActiveWorker();
     $translate = DevblocksPlatform::getTranslationService();
     $url = DevblocksPlatform::getUrlService();
     $stack = $response->path;
     @array_shift($stack);
     // display
     @($id = array_shift($stack));
     // Tabs
     $tab_manifests = DevblocksPlatform::getExtensions('cerberusweb.ticket.tab', false);
     $tpl->assign('tab_manifests', $tab_manifests);
     @($tab_selected = array_shift($stack));
     if (empty($tab_selected)) {
         $tab_selected = 'conversation';
     }
     $tpl->assign('tab_selected', $tab_selected);
     switch ($tab_selected) {
         case 'conversation':
             @($mail_always_show_all = DAO_WorkerPref::get($active_worker->id, 'mail_always_show_all', 0));
             @($tab_option = array_shift($stack));
             if ($mail_always_show_all || 0 == strcasecmp("read_all", $tab_option)) {
                 $tpl->assign('expand_all', true);
             }
             break;
     }
     // [JAS]: Translate Masks
     if (!is_numeric($id)) {
         $id = DAO_Ticket::getTicketIdByMask($id);
     }
     $ticket = DAO_Ticket::getTicket($id);
     if (empty($ticket)) {
         echo "<H1>" . $translate->_('display.invalid_ticket') . "</H1>";
         return;
     }
     // Permissions
     $active_worker_memberships = $active_worker->getMemberships();
     // Check group membership ACL
     if (!isset($active_worker_memberships[$ticket->team_id])) {
         echo "<H1>" . $translate->_('common.access_denied') . "</H1>";
         return;
     }
     $tpl->assign('ticket', $ticket);
     // TicketToolbarItem Extensions
     $ticketToolbarItems = DevblocksPlatform::getExtensions('cerberusweb.ticket.toolbaritem', true);
     if (!empty($ticketToolbarItems)) {
         $tpl->assign('ticket_toolbaritems', $ticketToolbarItems);
     }
     // Next+Prev: Does a series exist?
     if (null != ($series_info = $visit->get('ch_display_series', null))) {
         @($series = $series_info['series']);
         $cur = 1;
         $found = false;
         // Is this ID part of the series?  If not, invalidate
         if (is_array($series)) {
             while ($mask = current($series)) {
                 // Stop if we find it.
                 if ($mask == $ticket->mask) {
                     $found = true;
                     break;
                 }
                 next($series);
                 $cur++;
             }
         }
         if (!$found) {
             // not found
             $visit->set('ch_display_series', null);
         } else {
             // found
             $series_stats = array('title' => $series_info['title'], 'total' => $series_info['total'], 'count' => count($series));
             $series_stats['cur'] = $cur;
             if (false !== prev($series)) {
                 @($series_stats['prev'] = current($series));
                 next($series);
                 // skip to current
             } else {
                 reset($series);
             }
             next($series);
             // next
             @($series_stats['next'] = current($series));
             $tpl->assign('series_stats', $series_stats);
         }
     }
     $quick_search_type = $visit->get('quick_search_type');
     $tpl->assign('quick_search_type', $quick_search_type);
     // Comments [TODO] Eventually this can be cached on ticket.num_comments
     $comments_total = DAO_TicketComment::getCountByTicketId($id);
     $tpl->assign('comments_total', $comments_total);
     // Tasks Total [TODO] Eventually this can be ticket.num_tasks
     $tasks_total = DAO_Task::getCountBySourceObjectId('cerberusweb.tasks.ticket', $id);
     $tpl->assign('tasks_total', $tasks_total);
     $workers = DAO_Worker::getAll();
     $tpl->assign('workers', $workers);
     $teams = DAO_Group::getAll();
     $tpl->assign('teams', $teams);
     $team_categories = DAO_Bucket::getTeams();
     $tpl->assign('team_categories', $team_categories);
     // Log Activity
     DAO_Worker::logActivity($active_worker->id, new Model_Activity('activity.display_ticket', array(sprintf("<a href='%s' title='[%s] %s'>#%s</a>", $url->write("c=display&id=" . $ticket->mask), htmlspecialchars(@$teams[$ticket->team_id]->name, ENT_QUOTES, LANG_CHARSET_CODE), htmlspecialchars($ticket->subject, ENT_QUOTES, LANG_CHARSET_CODE), $ticket->mask))));
     $tpl->display('file:' . $this->_TPL_PATH . 'display/index.tpl');
 }
示例#3
0
文件: contacts.php 项目: Hildy/cerb5
 function render()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $visit = CerberusApplication::getVisit();
     $response = DevblocksPlatform::getHttpResponse();
     $stack = $response->path;
     @array_shift($stack);
     // contacts
     @($selected_tab = array_shift($stack));
     // orgs|addresses|*
     $tpl->assign('selected_tab', $selected_tab);
     // Allow a non-tab renderer
     switch ($selected_tab) {
         case 'import':
             switch (@array_shift($stack)) {
                 case 'step2':
                     $type = $visit->get('import.last.type', '');
                     switch ($type) {
                         case 'orgs':
                             $fields = DAO_ContactOrg::getFields();
                             $tpl->assign('fields', $fields);
                             $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Org::ID);
                             $tpl->assign('custom_fields', $custom_fields);
                             break;
                         case 'addys':
                             $fields = DAO_Address::getFields();
                             $tpl->assign('fields', $fields);
                             $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Address::ID);
                             $tpl->assign('custom_fields', $custom_fields);
                             break;
                     }
                     $tpl->display('file:' . $this->_TPL_PATH . 'contacts/import/mapping.tpl');
                     return;
                     break;
             }
             break;
             // [TODO] The org display page should probably move to its own controller
         // [TODO] The org display page should probably move to its own controller
         case 'orgs':
             switch (@array_shift($stack)) {
                 case 'display':
                     $tab_manifests = DevblocksPlatform::getExtensions('cerberusweb.org.tab', false);
                     $tpl->assign('tab_manifests', $tab_manifests);
                     $id = array_shift($stack);
                     $contact = DAO_ContactOrg::get($id);
                     $tpl->assign('contact', $contact);
                     $task_count = DAO_Task::getCountBySourceObjectId('cerberusweb.tasks.org', $contact->id);
                     $tpl->assign('tasks_total', $task_count);
                     $people_count = DAO_Address::getCountByOrgId($contact->id);
                     $tpl->assign('people_total', $people_count);
                     // Does a series exist?
                     // [TODO] This is highly redundant
                     if (null != ($series_info = $visit->get('ch_org_series', null))) {
                         @($series = $series_info['series']);
                         // Is this ID part of the series?  If not, invalidate
                         if (!isset($series[$contact->id])) {
                             $visit->set('ch_org_series', null);
                         } else {
                             $series_stats = array('title' => $series_info['title'], 'total' => $series_info['total'], 'count' => count($series));
                             reset($series);
                             $cur = 1;
                             while ($pos = key($series)) {
                                 if (intval($pos) == intval($contact->id)) {
                                     $series_stats['cur'] = $cur;
                                     if (false !== prev($series)) {
                                         @($series_stats['prev'] = key($series));
                                         next($series);
                                         // skip to current
                                     } else {
                                         reset($series);
                                     }
                                     next($series);
                                     // next
                                     @($series_stats['next'] = key($series));
                                     break;
                                 }
                                 next($series);
                                 $cur++;
                             }
                             $tpl->assign('series_stats', $series_stats);
                         }
                     }
                     $tpl->display('file:' . $this->_TPL_PATH . 'contacts/orgs/display.tpl');
                     return;
                     break;
                     // case 'orgs/display'
             }
             // switch (action)
             break;
     }
     // switch (tab)
     $tpl->display('file:' . $this->_TPL_PATH . 'contacts/index.tpl');
     return;
     //			case 'people':
     //				$view = C4_AbstractViewLoader::getView('addybook_people'); // C4_AddressView::DEFAULT_ID
     //
     //				if(null == $view) {
     //					$view = new C4_AddressView();
     //					$view->id = 'addybook_people';
     //					$view->name = 'People';
     //					$view->params = array(
     //						new DevblocksSearchCriteria(SearchFields_Address::CONTACT_ORG_ID,'!=',0),
     //					);
     //
     //					C4_AbstractViewLoader::setView('addybook_people', $view);
     //				}
     //
     //				$tpl->assign('view', $view);
     //				$tpl->assign('contacts_page', 'people');
     //				$tpl->assign('view_fields', C4_AddressView::getFields());
     //				$tpl->assign('view_searchable_fields', C4_AddressView::getSearchFields());
     //				$tpl->display('file:' . $this->_TPL_PATH . 'contacts/people/index.tpl');
     //				break;
 }