Example #1
0
function getZendeskConnection()
{
    global $current_user;
    $read_only = true;
    $zendesk_https = false;
    $zendesk_helper = new ZendeskHelper();
    $admin = new Administration();
    $admin->retrieveSettings('system');
    if ($admin->settings['system_zendesk_instance']) {
        $zendesk_instance = $admin->settings['system_zendesk_instance'];
    } else {
        throw new Exception('Zendesk credentials not configured');
    }
    if ($admin->settings['system_zendesk_https']) {
        $zendesk_https = true;
    }
    $personal_login = $zendesk_helper->getPersonalConfigValue('login');
    if ($personal_login && $personal_login != '') {
        $read_only = false;
        $zendesk_login = $personal_login;
        $zendesk_password = $zendesk_helper->getPersonalConfigValue('password');
    } else {
        $zendesk_login = $zendesk_helper->getGlobalConfigValue('login');
        $zendesk_password = $zendesk_helper->getGlobalConfigValue('password');
    }
    $c = new Zendesk($zendesk_instance, $zendesk_login, $zendesk_password, true, $zendesk_https);
    $c->read_only = $read_only;
    return $c;
}
Example #2
0
 public function display()
 {
     echo $this->getModuleTitle();
     $this->ss->assign("RETURN_MODULE", "Administration");
     $this->ss->assign("RETURN_ACTION", "index");
     $zendesk_helper = new ZendeskHelper();
     $admin = new Administration();
     $admin->retrieveSettings('zendesk');
     $this->ss->assign('zendesk_instance', $admin->settings['system_zendesk_instance']);
     $this->ss->assign('zendesk_https', $admin->settings['system_zendesk_https']);
     $this->ss->assign("zendesk_https_checkbox", $admin->settings['system_zendesk_https'] ? "checked='checked'" : "");
     $this->ss->assign('zendesk_login', $admin->settings['system_zendesk_login']);
     $this->ss->assign('use_account_name', $zendesk_helper->getGlobalConfigValue('use_account_name'));
     $this->ss->assign('per_page', $zendesk_helper->getGlobalConfigValue('per_page', '6'));
     $this->ss->assign('sort', $zendesk_helper->getGlobalConfigValue('sort', '1'));
     $this->ss->assign('order_by', $zendesk_helper->getGlobalConfigValue('order_by', 'priority'));
     $this->ss->assign('status_filter', $zendesk_helper->getGlobalConfigValue('status_filter', 'lsolved'));
     $this->ss->assign('priority_filter', $zendesk_helper->getGlobalConfigValue('priority_filter', 'any'));
     $this->ss->assign('type_filter', $zendesk_helper->getGlobalConfigValue('type_filter', 'any'));
     $this->ss->assign('statusoptions', $zendesk_helper->getStatusFilterOptions());
     $this->ss->assign('priorityoptions', $zendesk_helper->getPriorityFilterOptions());
     $this->ss->assign('typeoptions', $zendesk_helper->getTypeFilterOptions());
     $this->ss->assign('columns', $zendesk_helper->getColumnOptions());
     $this->ss->display('modules/zd_Tickets/tpls/config.tpl');
 }
Example #3
0
 private function getZendeskQuery()
 {
     $zendesk_helper = new ZendeskHelper();
     $search_query = 'type:ticket';
     $op_map = array('e' => ':', 'g' => '>', 'l' => '<');
     if ($this->status_filter != null && $this->status_filter != "any") {
         $search_query .= ' status' . $op_map[$this->status_filter[0]] . substr($this->status_filter, 1);
     }
     if ($this->priority_filter != null && $this->priority_filter != "any") {
         $search_query .= ' priority' . $op_map[$this->priority_filter[0]] . substr($this->priority_filter, 1);
     }
     if ($this->type_filter != null && $this->type_filter != "any") {
         $search_query .= ' ticket_type' . $op_map[$this->type_filter[0]] . substr($this->type_filter, 1);
     }
     switch ($this->focus->object_name) {
         case 'Contact':
         case 'Lead':
             $search_query .= " requester:{$this->focus->email1}";
             if ($this->focus->email2) {
                 $search_query .= " requester:{$this->focus->email2}";
             }
             break;
         case 'Account':
             if ($this->focus->zendesk_organization_c != null && $this->focus->zendesk_organization_c != '') {
                 $search_query .= " organization:\"{$this->focus->zendesk_organization_c}\"";
             } else {
                 if ($zendesk_helper->getGlobalConfigValue('use_account_name')) {
                     $search_query .= " organization:\"{$this->focus->name}\"";
                 } else {
                     $count = 0;
                     foreach ($this->focus->get_contacts() as $contact) {
                         if ($contact->email1 && $contact->email1 != '') {
                             $search_query .= " requester:{$contact->email1}";
                             $count++;
                         }
                         if ($contact->email2) {
                             $search_query .= " requester:{$contact->email2}";
                             $count++;
                         }
                     }
                     if ($count == 0) {
                         $search_query .= " organization:\"{$this->focus->name}\"";
                     }
                 }
             }
             break;
         case 'Opportunity':
             $this->focus->load_relationship('contacts');
             $query_array = $this->focus->contacts->getQuery(true);
             $query_array['select'] = "SELECT contacts.id, contacts.first_name, contacts.last_name, contacts.title, contacts.phone_work, opportunities_contacts.contact_role as opportunity_role, opportunities_contacts.id as opportunity_rel_id ";
             $query = '';
             foreach ($query_array as $qstring) {
                 $query .= ' ' . $qstring;
             }
             $temp = array('id', 'first_name', 'last_name', 'title', 'phone_work', 'opportunity_role', 'opportunity_rel_id');
             $contacts = $this->focus->build_related_list2($query, new Contact(), $temp);
             $count = 0;
             foreach ($contacts as $contact) {
                 $contact->retrieve();
                 $search_query .= " requester:{$contact->email1}";
                 if ($contact->email2) {
                     $search_query .= " requester:{$contact->email2}";
                 }
                 $count++;
             }
             if ($count == 0) {
                 $search_query .= " organization:\"{$this->focus->account_name}\"";
             }
             break;
         default:
             return "Cannot display tickets for " . $this->focus->object_name;
     }
     return $search_query;
 }