Beispiel #1
0
 function showEntryAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $tpl->assign('path', $tpl_path);
     $tpl->cache_lifetime = "0";
     /*
      * [IMPORTANT -- Yes, this is simply a line in the sand.]
      * You're welcome to modify the code to meet your needs, but please respect 
      * our licensing.  Buy a legitimate copy to help support the project!
      * http://www.cerberusweb.com/
      */
     $license = CerberusLicense::getInstance();
     //		if(empty($id) && (empty($license['serial']) || (!empty($license['serial']) && !empty($license['users'])))
     //			&& 10 <= DAO_TimeTrackingEntry::getItemCount()) {
     //			$tpl->display('file:' . $tpl_path . 'calls/ajax/trial.tpl');
     //			return;
     //		}
     /*
      * This treats procedurally created model objects
      * the same as existing objects
      */
     //		if(!empty($id)) { // Were we given a model ID to load?
     //			if(null != ($model = DAO_TimeTrackingEntry::get($id)))
     //				$tpl->assign('model', $model);
     //		} elseif (!empty($model)) { // Were we passed a model object without an ID?
     //			$tpl->assign('model', $model);
     //		}
     // Org Name
     //		if(!empty($model->debit_org_id)) {
     //			if(null != ($org = DAO_ContactOrg::get($model->debit_org_id)))
     //				$tpl->assign('org', $org);
     //		}
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     $tpl->display('file:' . $tpl_path . 'calls/ajax/call_entry_panel.tpl');
 }
Beispiel #2
0
 function getRoleAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $worker = FegApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     @($id = DevblocksPlatform::importGPC($_REQUEST['id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $plugins = DevblocksPlatform::getPluginRegistry();
     $tpl->assign('plugins', $plugins);
     $acl = DevblocksPlatform::getAclRegistry();
     $tpl->assign('acl', $acl);
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     $role = DAO_WorkerRole::get($id);
     $tpl->assign('role', $role);
     $role_privs = DAO_WorkerRole::getRolePrivileges($id);
     $tpl->assign('role_privs', $role_privs);
     $role_roster = DAO_WorkerRole::getRoleWorkers($id);
     $tpl->assign('role_workers', $role_roster);
     $tpl->assign('license', FegLicense::getInstance());
     $tpl->display('file:' . $this->_TPL_PATH . 'setup/tabs/acl/edit_role.tpl');
 }
Beispiel #3
0
 function showPropertiesAction()
 {
     @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer'));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('ticket_id', $ticket_id);
     $ticket = DAO_Ticket::getTicket($ticket_id);
     $tpl->assign('ticket', $ticket);
     $requesters = DAO_Ticket::getRequestersByTicket($ticket_id);
     $tpl->assign('requesters', $requesters);
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     // Groups (for custom fields)
     $groups = DAO_Group::getAll();
     $tpl->assign('groups', $groups);
     // Custom fields
     $fields = DAO_CustomField::getBySource(ChCustomFieldSource_Ticket::ID);
     $tpl->assign('ticket_fields', $fields);
     $field_values = DAO_CustomFieldValue::getValuesBySourceIds(ChCustomFieldSource_Ticket::ID, $ticket_id);
     if (isset($field_values[$ticket->id])) {
         $tpl->assign('ticket_field_values', $field_values[$ticket->id]);
     }
     $tpl->display('file:' . $this->_TPL_PATH . 'display/modules/properties/index.tpl');
 }
Beispiel #4
0
 function showOppBulkPanelAction()
 {
     @($ids = DevblocksPlatform::importGPC($_REQUEST['ids']));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', dirname(__FILE__) . '/templates/');
     $tpl->assign('view_id', $view_id);
     if (!empty($ids)) {
         $id_list = DevblocksPlatform::parseCsvString($ids);
         $tpl->assign('opp_ids', implode(',', $id_list));
     }
     // Workers
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     // Custom Fields
     $custom_fields = DAO_CustomField::getBySource(CrmCustomFieldSource_Opportunity::ID);
     $tpl->assign('custom_fields', $custom_fields);
     $tpl->cache_lifetime = "0";
     $tpl->display('file:' . dirname(dirname(__FILE__)) . '/templates/crm/opps/bulk.tpl');
 }
Beispiel #5
0
 function showTabMembersAction()
 {
     @($group_id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = $this->_TPL_PATH;
     $tpl->assign('path', $tpl_path);
     $active_worker = CerberusApplication::getActiveWorker();
     if (!$active_worker->isTeamManager($group_id) && !$active_worker->is_superuser) {
         return;
     } else {
         $group = DAO_Group::getTeam($group_id);
         $tpl->assign('team', $group);
     }
     $members = DAO_Group::getTeamMembers($group_id);
     $tpl->assign('members', $members);
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     $tpl->display('file:' . $tpl_path . 'groups/manage/members.tpl');
 }
Beispiel #6
0
 function doImportAction()
 {
     $active_worker = CerberusApplication::getActiveWorker();
     if (!$active_worker->hasPriv('crm.opp.actions.import')) {
         return;
     }
     @($pos = DevblocksPlatform::importGPC($_REQUEST['pos'], 'array', array()));
     @($field = DevblocksPlatform::importGPC($_REQUEST['field'], 'array', array()));
     @($sync_dupes = DevblocksPlatform::importGPC($_REQUEST['sync_dupes'], 'array', array()));
     @($include_first = DevblocksPlatform::importGPC($_REQUEST['include_first'], 'integer', 0));
     @($is_blank_unset = DevblocksPlatform::importGPC($_REQUEST['is_blank_unset'], 'integer', 0));
     @($opt_assign = DevblocksPlatform::importGPC($_REQUEST['opt_assign'], 'integer', 0));
     @($opt_assign_worker_id = DevblocksPlatform::importGPC($_REQUEST['opt_assign_worker_id'], 'integer', 0));
     $visit = CerberusApplication::getVisit();
     $db = DevblocksPlatform::getDatabaseService();
     $workers = DAO_Worker::getAllActive();
     $csv_file = $visit->get('crm.import.last.csv', '');
     $fp = fopen($csv_file, "rt");
     if (!$fp) {
         return;
     }
     // [JAS]: Do we need to consume a first row of headings?
     if (!$include_first) {
         @fgetcsv($fp, 8192, ',', '"');
     }
     while (!feof($fp)) {
         $parts = fgetcsv($fp, 8192, ',', '"');
         if (empty($parts) || 1 == count($parts) && is_null($parts[0])) {
             continue;
         }
         $fields = array();
         $custom_fields = array();
         $sync_fields = array();
         foreach ($pos as $idx => $p) {
             $key = $field[$idx];
             $val = $parts[$idx];
             // Special handling
             if (!empty($key)) {
                 switch ($key) {
                     case 'amount':
                         if (0 != strlen($val) && is_numeric($val)) {
                             @($val = floatval($val));
                         } else {
                             unset($key);
                         }
                         break;
                         // Translate e-mail address to ID
                     // Translate e-mail address to ID
                     case 'email':
                         if (null != ($addy = CerberusApplication::hashLookupAddress($val, true))) {
                             $key = 'primary_email_id';
                             $val = $addy->id;
                         } else {
                             unset($key);
                         }
                         break;
                         // Bools
                     // Bools
                     case 'is_won':
                     case 'is_closed':
                         if (0 != strlen($val)) {
                             @($val = !empty($val) ? 1 : 0);
                         } else {
                             unset($key);
                         }
                         break;
                         // Dates
                     // Dates
                     case 'created_date':
                     case 'updated_date':
                     case 'closed_date':
                         if (0 != strlen($val)) {
                             @($val = !is_numeric($val) ? strtotime($val) : $val);
                         } else {
                             unset($key);
                         }
                         break;
                         // Worker by name
                     // Worker by name
                     case 'worker':
                         unset($key);
                         if (is_array($workers)) {
                             foreach ($workers as $worker_id => $worker) {
                                 if (0 == strcasecmp($val, $worker->getName())) {
                                     $key = 'worker_id';
                                     $val = $worker_id;
                                 }
                             }
                         }
                         break;
                 }
                 if (!isset($key)) {
                     continue;
                 }
                 // Custom fields
                 if ('cf_' == substr($key, 0, 3)) {
                     $custom_fields[substr($key, 3)] = $val;
                 } elseif (!empty($key)) {
                     $fields[$key] = $val;
                 }
                 // Find dupe combos
                 if (in_array($idx, $sync_dupes)) {
                     $search_field = '';
                     $search_val = '';
                     switch ($key) {
                         case 'primary_email_id':
                             $search_field = SearchFields_CrmOpportunity::PRIMARY_EMAIL_ID;
                             $search_val = intval($val);
                             break;
                         case 'title':
                             $search_field = SearchFields_CrmOpportunity::NAME;
                             $search_val = $val;
                             break;
                         case 'amount':
                             $search_field = SearchFields_CrmOpportunity::AMOUNT;
                             $search_val = floatval($val);
                             break;
                         case 'is_won':
                             $search_field = SearchFields_CrmOpportunity::IS_WON;
                             $search_val = intval($val);
                             break;
                         case 'is_closed':
                             $search_field = SearchFields_CrmOpportunity::IS_CLOSED;
                             $search_val = intval($val);
                             break;
                         case 'created_date':
                             $search_field = SearchFields_CrmOpportunity::CREATED_DATE;
                             $search_val = intval($val);
                             break;
                         case 'updated_date':
                             $search_field = SearchFields_CrmOpportunity::UPDATED_DATE;
                             $search_val = intval($val);
                             break;
                         case 'closed_date':
                             $search_field = SearchFields_CrmOpportunity::CLOSED_DATE;
                             $search_val = intval($val);
                             break;
                         case 'worker_id':
                             $search_field = SearchFields_CrmOpportunity::WORKER_ID;
                             $search_val = intval($val);
                             break;
                         default:
                             // Custom field dupe
                             if ('cf_' == substr($key, 0, 3)) {
                                 $search_field = $key;
                                 // [TODO] Need to format this for proper custom fields
                                 $search_val = $val;
                             }
                             break;
                     }
                     if (!empty($search_field) && !empty($search_val)) {
                         $sync_fields[$search_field] = new DevblocksSearchCriteria($search_field, '=', $search_val);
                     }
                 }
             }
         }
         // end foreach($pos)
         // Dupe checking
         if (!empty($fields) && !empty($sync_fields)) {
             list($dupes, $null) = DAO_CrmOpportunity::search(array(), $sync_fields, 1, 0, null, false, false);
         }
         if (!empty($fields)) {
             if (isset($fields['primary_email_id'])) {
                 // Make sure a minimum amount of fields are provided
                 if (!isset($fields[DAO_CrmOpportunity::UPDATED_DATE])) {
                     $fields[DAO_CrmOpportunity::UPDATED_DATE] = time();
                 }
                 if ($opt_assign && !isset($fields[DAO_CrmOpportunity::WORKER_ID])) {
                     $fields[DAO_CrmOpportunity::WORKER_ID] = $opt_assign_worker_id;
                 }
                 if (empty($dupes)) {
                     // [TODO] Provide an import prefix for blank names
                     if (!isset($fields[DAO_CrmOpportunity::NAME]) && isset($addy)) {
                         $fields[DAO_CrmOpportunity::NAME] = $addy->email;
                     }
                     if (!isset($fields[DAO_CrmOpportunity::CREATED_DATE])) {
                         $fields[DAO_CrmOpportunity::CREATED_DATE] = time();
                     }
                     $id = DAO_CrmOpportunity::create($fields);
                 } else {
                     $id = key($dupes);
                     DAO_CrmOpportunity::update($id, $fields);
                 }
             }
         }
         if (!empty($custom_fields) && !empty($id)) {
             // Format (typecast) and set the custom field types
             $source_ext_id = CrmCustomFieldSource_Opportunity::ID;
             DAO_CustomFieldValue::formatAndSetFieldValues($source_ext_id, $id, $custom_fields, $is_blank_unset);
         }
     }
     @unlink($csv_file);
     // nuke the imported file
     $visit->set('crm.import.last.csv', null);
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('activity', 'opps')));
 }
Beispiel #7
0
 function showTaskBulkPanelAction()
 {
     @($ids = DevblocksPlatform::importGPC($_REQUEST['ids']));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('view_id', $view_id);
     if (!empty($ids)) {
         $id_list = DevblocksPlatform::parseCsvString($ids);
         $tpl->assign('ids', implode(',', $id_list));
     }
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     // Custom Fields
     $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Task::ID);
     $tpl->assign('custom_fields', $custom_fields);
     $tpl->cache_lifetime = "0";
     $tpl->display('file:' . $this->_TPL_PATH . 'tasks/rpc/bulk.tpl');
 }
Beispiel #8
0
 function showTabNotesAction()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     @($org_id = DevblocksPlatform::importGPC($_REQUEST['org']));
     $org = DAO_ContactOrg::get($org_id);
     $tpl->assign('org', $org);
     list($notes, $null) = DAO_Note::search(array(new DevblocksSearchCriteria(SearchFields_Note::SOURCE_EXT_ID, '=', ChNotesSource_Org::ID), new DevblocksSearchCriteria(SearchFields_Note::SOURCE_ID, '=', $org->id)), 25, 0, SearchFields_Note::CREATED, false, false);
     $tpl->assign('notes', $notes);
     $active_workers = DAO_Worker::getAllActive();
     $tpl->assign('active_workers', $active_workers);
     $workers = DAO_Worker::getAllWithDisabled();
     $tpl->assign('workers', $workers);
     $tpl->display('file:' . $this->_TPL_PATH . 'contacts/orgs/tabs/notes.tpl');
 }
Beispiel #9
0
 private function _sendForwards($event, $is_inbound)
 {
     @($ticket_id = $event->params['ticket_id']);
     @($message_id = $event->params['message_id']);
     @($send_worker_id = $event->params['worker_id']);
     $ticket = DAO_Ticket::getTicket($ticket_id);
     $helpdesk_senders = CerberusApplication::getHelpdeskSenders();
     $workers = DAO_Worker::getAllActive();
     // [JAS]: Don't send obvious spam to watchers.
     if ($ticket->spam_score >= 0.9) {
         return true;
     }
     @($notifications = DAO_WorkerMailForward::getWhere(sprintf("%s = %d", DAO_WorkerMailForward::GROUP_ID, $ticket->team_id)));
     // Bail out early if we have no forwards for this group
     if (empty($notifications)) {
         return;
     }
     $message = DAO_Ticket::getMessage($message_id);
     $headers = $message->getHeaders();
     // The whole flipping Swift section needs wrapped to catch exceptions
     try {
         $settings = CerberusSettings::getInstance();
         $reply_to = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM, '');
         // See if we need a group-specific reply-to
         if (!empty($ticket->team_id)) {
             @($group_from = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_REPLY_FROM, ''));
             if (!empty($group_from)) {
                 $reply_to = $group_from;
             }
         }
         $sender = DAO_Address::get($message->address_id);
         $sender_email = strtolower($sender->email);
         $sender_split = explode('@', $sender_email);
         if (!is_array($sender_split) || count($sender_split) != 2) {
             return;
         }
         // If return-path is blank
         if (isset($headers['return-path']) && $headers['return-path'] == '<>') {
             return;
         }
         // Ignore bounces
         if ($sender_split[1] == "postmaster" || $sender_split[1] == "mailer-daemon") {
             return;
         }
         // Ignore autoresponses autoresponses
         if (isset($headers['auto-submitted']) && $headers['auto-submitted'] != 'no') {
             return;
         }
         // Headers
         //==========
         // Build mailing list
         $send_to = array();
         foreach ($notifications as $n) {
             /* @var $n Model_WorkerMailForward */
             if (!isset($n->group_id) || !isset($n->bucket_id)) {
                 continue;
             }
             // if worker no longer exists or is disabled
             if (!isset($workers[$n->worker_id])) {
                 continue;
             }
             // Don't allow a worker to usurp a helpdesk address
             if (isset($helpdesk_senders[$n->email])) {
                 continue;
             }
             if ($n->group_id == $ticket->team_id && ($n->bucket_id == -1 || $n->bucket_id == $ticket->category_id)) {
                 // Event checking
                 if ($is_inbound && ($n->event == 'i' || $n->event == 'io') || !$is_inbound && ($n->event == 'o' || $n->event == 'io') || $is_inbound && $n->event == 'r' && $ticket->next_worker_id == $n->worker_id) {
                     $send_to[$n->email] = true;
                 }
             }
         }
         // Attachments
         $attachments = $message->getAttachments();
         $mime_attachments = array();
         if (is_array($attachments)) {
             foreach ($attachments as $attachment) {
                 if (0 == strcasecmp($attachment->display_name, 'original_message.html')) {
                     continue;
                 }
                 $attachment_path = APP_STORAGE_PATH . '/attachments/';
                 // [TODO] This is highly redundant in the codebase
                 if (!file_exists($attachment_path . $attachment->filepath)) {
                     continue;
                 }
                 $file =& new Swift_File($attachment_path . $attachment->filepath);
                 $mime_attachments[] =& new Swift_Message_Attachment($file, $attachment->display_name, $attachment->mime_type);
             }
         }
         // Send copies
         if (is_array($send_to) && !empty($send_to)) {
             $mail_service = DevblocksPlatform::getMailService();
             $mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
             foreach ($send_to as $to => $bool) {
                 // Proxy the message
                 $rcpt_to = new Swift_RecipientList();
                 $a_rcpt_to = array();
                 $mail_from = new Swift_Address($sender->email);
                 $rcpt_to->addTo($to);
                 $a_rcpt_to = new Swift_Address($to);
                 $mail = $mail_service->createMessage();
                 /* @var $mail Swift_Message */
                 $mail->setTo($a_rcpt_to);
                 $mail->setFrom($mail_from);
                 $mail->setReplyTo($reply_to);
                 $mail->setReturnPath($reply_to);
                 $mail->setSubject(sprintf("[%s #%s]: %s", $is_inbound ? 'inbound' : 'outbound', $ticket->mask, $ticket->subject));
                 if (false !== @($msgid = $headers['message-id'])) {
                     $mail->headers->set('Message-Id', $msgid);
                 }
                 if (false !== @($in_reply_to = $headers['in-reply-to'])) {
                     $mail->headers->set('References', $in_reply_to);
                     $mail->headers->set('In-Reply-To', $in_reply_to);
                 }
                 $mail->headers->set('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
                 $mail->headers->set('Precedence', 'List');
                 $mail->headers->set('Auto-Submitted', 'auto-generated');
                 $mail->attach(new Swift_Message_Part($message->getContent(), 'text/plain', 'base64', LANG_CHARSET_CODE));
                 // Send message attachments with watcher
                 if (is_array($mime_attachments)) {
                     foreach ($mime_attachments as $mime_attachment) {
                         $mail->attach($mime_attachment);
                     }
                 }
                 $mailer->send($mail, $rcpt_to, $mail_from);
             }
         }
     } catch (Exception $e) {
         $fields = array(DAO_MessageNote::MESSAGE_ID => $message_id, DAO_MessageNote::CREATED => time(), DAO_MessageNote::WORKER_ID => 0, DAO_MessageNote::CONTENT => 'Exception thrown while sending watcher email: ' . $e->getMessage(), DAO_MessageNote::TYPE => Model_MessageNote::TYPE_ERROR);
         DAO_MessageNote::create($fields);
     }
 }
Beispiel #10
0
 function renderCriteria($field)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('id', $this->id);
     switch ($field) {
         case SearchFields_WorkerEvent::TITLE:
         case SearchFields_WorkerEvent::CONTENT:
         case SearchFields_WorkerEvent::URL:
             $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__string.tpl');
             break;
             //			case SearchFields_WorkerEvent::ID:
             //			case SearchFields_WorkerEvent::MESSAGE_ID:
             //			case SearchFields_WorkerEvent::TICKET_ID:
             //			case SearchFields_WorkerEvent::FILE_SIZE:
             //				$tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__number.tpl');
             //				break;
         //			case SearchFields_WorkerEvent::ID:
         //			case SearchFields_WorkerEvent::MESSAGE_ID:
         //			case SearchFields_WorkerEvent::TICKET_ID:
         //			case SearchFields_WorkerEvent::FILE_SIZE:
         //				$tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__number.tpl');
         //				break;
         case SearchFields_WorkerEvent::IS_READ:
             $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__bool.tpl');
             break;
         case SearchFields_WorkerEvent::CREATED_DATE:
             $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__date.tpl');
             break;
         case SearchFields_WorkerEvent::WORKER_ID:
             $workers = DAO_Worker::getAllActive();
             $tpl->assign('workers', $workers);
             $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/internal/views/criteria/__worker.tpl');
             break;
         default:
             echo '';
             break;
     }
 }
Beispiel #11
0
 function showBatchPanelAction()
 {
     @($ids = DevblocksPlatform::importGPC($_REQUEST['ids']));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('view_id', $view_id);
     $unique_sender_ids = array();
     $unique_subjects = array();
     if (!empty($ids)) {
         $ticket_ids = DevblocksPlatform::parseCsvString($ids);
         if (empty($ticket_ids)) {
             break;
         }
         $tickets = DAO_Ticket::getTickets($ticket_ids);
         if (is_array($tickets)) {
             foreach ($tickets as $ticket) {
                 /* @var $ticket CerberusTicket */
                 $ptr =& $unique_sender_ids[$ticket->first_wrote_address_id];
                 $ptr = intval($ptr) + 1;
                 $ptr =& $unique_subjects[$ticket->subject];
                 $ptr = intval($ptr) + 1;
             }
         }
         arsort($unique_subjects);
         // sort by occurrences
         $senders = DAO_Address::getWhere(sprintf("%s IN (%s)", DAO_Address::ID, implode(',', array_keys($unique_sender_ids))));
         foreach ($senders as $sender) {
             $ptr =& $unique_senders[$sender->email];
             $ptr = intval($ptr) + 1;
         }
         arsort($unique_senders);
         unset($senders);
         unset($unique_sender_ids);
         @$tpl->assign('ticket_ids', $ticket_ids);
         @$tpl->assign('unique_senders', $unique_senders);
         @$tpl->assign('unique_subjects', $unique_subjects);
     }
     // Teams
     $teams = DAO_Group::getAll();
     $tpl->assign('teams', $teams);
     // Categories
     $team_categories = DAO_Bucket::getTeams();
     // [TODO] Cache these
     $tpl->assign('team_categories', $team_categories);
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     // Custom Fields
     $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Ticket::ID);
     $tpl->assign('custom_fields', $custom_fields);
     $tpl->display('file:' . $this->_TPL_PATH . 'tickets/rpc/batch_panel.tpl');
 }
Beispiel #12
0
 function showTaskNotesTabAction()
 {
     @($task_id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer'));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     $tpl->assign('path', $tpl_path);
     $visit = CerberusApplication::getVisit();
     //		$visit->set(self::SESSION_OPP_TAB, 'notes');
     $task = DAO_Task::get($task_id);
     $tpl->assign('task', $task);
     list($notes, $null) = DAO_Note::search(array(new DevblocksSearchCriteria(SearchFields_Note::SOURCE_EXT_ID, '=', ChNotesSource_Task::ID), new DevblocksSearchCriteria(SearchFields_Note::SOURCE_ID, '=', $task->id)), 25, 0, SearchFields_Note::CREATED, false, false);
     $tpl->assign('notes', $notes);
     $active_workers = DAO_Worker::getAllActive();
     $tpl->assign('active_workers', $active_workers);
     $workers = DAO_Worker::getAllWithDisabled();
     $tpl->assign('workers', $workers);
     $tpl->display('file:' . $tpl_path . 'tasks/display/tabs/notes.tpl');
 }
Beispiel #13
0
 function showAlertPeekAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('view_id', $view_id);
     $active_worker = PortSensorApplication::getActiveWorker();
     if (null != ($alert = DAO_Alert::get($id))) {
         $tpl->assign('alert', $alert);
     }
     if (null == @($worker_id = $alert->worker_id)) {
         $worker_id = $active_worker->id;
     }
     $sensor_type_mfts = DevblocksPlatform::getExtensions('portsensor.sensor', false);
     $tpl->assign('sensor_type_mfts', $sensor_type_mfts);
     $tpl->assign('workers', DAO_Worker::getAllActive());
     $tpl->assign('all_workers', DAO_Worker::getAll());
     // Custom Fields: Sensor
     $sensor_fields = DAO_CustomField::getBySource(PsCustomFieldSource_Sensor::ID);
     $tpl->assign('sensor_fields', $sensor_fields);
     // Criteria extensions
     $alert_criteria_exts = DevblocksPlatform::getExtensions('portsensor.alert.criteria', true);
     $tpl->assign('alert_criteria_exts', $alert_criteria_exts);
     // Action extensions
     $alert_action_exts = DevblocksPlatform::getExtensions('portsensor.alert.action', true);
     $tpl->assign('alert_action_exts', $alert_action_exts);
     $tpl->display('file:' . $this->_TPL_PATH . 'alerts/peek.tpl');
 }
Beispiel #14
0
 function showWatcherPanelAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('view_id', $view_id);
     $active_worker = CerberusApplication::getActiveWorker();
     if (null != ($filter = DAO_WatcherMailFilter::get($id))) {
         $tpl->assign('filter', $filter);
     }
     $groups = DAO_Group::getAll();
     $tpl->assign('groups', $groups);
     $buckets = DAO_Bucket::getAll();
     $tpl->assign('buckets', $buckets);
     $group_buckets = DAO_Bucket::getTeams();
     $tpl->assign('group_buckets', $group_buckets);
     $memberships = $active_worker->getMemberships();
     $tpl->assign('memberships', $memberships);
     if (null == @($worker_id = $filter->worker_id)) {
         $worker_id = $active_worker->id;
     }
     $addresses = DAO_AddressToWorker::getByWorker($worker_id);
     $tpl->assign('addresses', $addresses);
     $tpl->assign('workers', DAO_Worker::getAllActive());
     $tpl->assign('all_workers', DAO_Worker::getAll());
     // Custom Fields: Ticket
     $ticket_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Ticket::ID);
     $tpl->assign('ticket_fields', $ticket_fields);
     // Custom Fields: Address
     $address_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Address::ID);
     $tpl->assign('address_fields', $address_fields);
     // Custom Fields: Orgs
     $org_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Org::ID);
     $tpl->assign('org_fields', $org_fields);
     $tpl->display('file:' . $this->_TPL_PATH . 'preferences/peek.tpl');
 }
Beispiel #15
0
 protected function _renderCriteriaCustomField($tpl, $field_id)
 {
     $field = DAO_CustomField::get($field_id);
     $tpl_path = APP_PATH . '/features/feg.core/templates/';
     switch ($field->type) {
         case Model_CustomField::TYPE_DROPDOWN:
         case Model_CustomField::TYPE_MULTI_PICKLIST:
         case Model_CustomField::TYPE_MULTI_CHECKBOX:
             $tpl->assign('field', $field);
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__cfield_picklist.tpl');
             break;
         case Model_CustomField::TYPE_CHECKBOX:
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__cfield_checkbox.tpl');
             break;
         case Model_CustomField::TYPE_DATE:
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__date.tpl');
             break;
         case Model_CustomField::TYPE_NUMBER:
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__number.tpl');
             break;
         case Model_CustomField::TYPE_WORKER:
             $tpl->assign('workers', DAO_Worker::getAllActive());
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__worker.tpl');
             break;
         default:
             $tpl->display('file:' . $tpl_path . 'internal/views/criteria/__string.tpl');
             break;
     }
 }
Beispiel #16
0
 function getTeamAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $worker = CerberusApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     @($id = DevblocksPlatform::importGPC($_REQUEST['id']));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $teams = DAO_Group::getAll();
     $tpl->assign('teams', $teams);
     @($team = $teams[$id]);
     $tpl->assign('team', $team);
     if (!empty($id)) {
         @($members = DAO_Group::getTeamMembers($id));
         $tpl->assign('members', $members);
     }
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     $tpl->assign('license', CerberusLicense::getInstance());
     $tpl->display('file:' . $this->_TPL_PATH . 'configuration/tabs/groups/edit_group.tpl');
 }
Beispiel #17
0
 function render()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $response = DevblocksPlatform::getHttpResponse();
     $translate = DevblocksPlatform::getTranslationService();
     // are we displaying the main home page?
     $path = $response->path;
     array_shift($path);
     // iphone
     //			array_shift($path); // activity
     array_shift($path);
     // opportunities
     $action = array_shift($path);
     // current action
     $id = array_shift($path);
     // opp id
     switch ($action) {
         case 'display':
             $tab_manifests = DevblocksPlatform::getExtensions('cerberusweb.iphone.opportunity.display.tab', false);
             $tpl->assign('tab_manifests', $tab_manifests);
             $tpl->assign('opp_id', $id);
             $selected_tab = array_shift($path);
             $selected_tab = null != $selected_tab ? $selected_tab : 'notes';
             // tab
             foreach ($tab_manifests as $tab_mft) {
                 if ($selected_tab == $tab_mft->params['uri']) {
                     $tab = DevblocksPlatform::getExtension($tab_mft->id, true);
                 }
             }
             $tpl->assign('tab', $tab);
             $tpl->assign('selected_tab', $selected_tab);
             $opp = DAO_CrmOpportunity::get($id);
             $tpl->assign('opp', $opp);
             $address = DAO_Address::get($opp->primary_email_id);
             $tpl->assign('address', $address);
             $workers = DAO_Worker::getAllActive();
             $tpl->assign('workers', $workers);
             $tpl->display('file:' . $this->_TPL_PATH . 'display.tpl');
             break;
         case null:
             $defaults = new C4_AbstractViewModel();
             $defaults->class_name = 'View_CrmOpportunity_iPhone';
             $defaults->id = self::VIEW_OPPS;
             $defaults->name = $translate->_('crm.tab.title');
             $defaults->renderSortBy = SearchFields_CrmOpportunity::UPDATED_DATE;
             $defaults->renderSortAsc = 0;
             $view = C4_AbstractViewLoader::getView(self::VIEW_OPPS, $defaults);
             $tpl->assign('view', $view);
             $tpl->display('file:' . $this->_TPL_PATH . 'home.tpl');
             break;
         default:
             break;
     }
 }