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()
 {
     $zendesk_helper = new ZendeskHelper();
     if ($this->error_message != null) {
         echo $this->error_message;
         echo " <a href='index.php?module=zd_Tickets&action=personalconfig&return_module={$this->focus->module_dir}&return_id={$this->focus->id}&return_action=DetailView'>My settings</a>";
     } else {
         $tickets = $this->retrieveTickets();
         if ($this->error_message != null) {
             echo $this->error_message;
         } else {
             global $timedate;
             $this->ss->assign("RETURN_MODULE", $this->focus->module_dir);
             $this->ss->assign("RETURN_ACTION", "DetailView");
             $this->ss->assign("RETURN_ID", $this->focus->id);
             $this->ss->assign('datetimefmt', $timedate->get_cal_date_time_format());
             $this->ss->assign('tickets', $this->retrieveTickets());
             $this->ss->assign('url', $this->connection->url() . "/search?query=" . urlencode($this->getZendeskQuery()));
             $this->ss->assign('base_url', $this->connection->url());
             $this->ss->assign('query', $this->getZendeskQuery());
             $this->ss->assign('count', $this->result_count);
             $this->ss->assign('from_count', $this->per_page * $this->page - $this->per_page + 1);
             $this->ss->assign('to_count', min($this->per_page * $this->page, $this->result_count));
             $this->ss->assign('pages', $this->pages);
             $this->ss->assign('per_page', $this->per_page);
             $this->ss->assign('page', $this->page);
             $this->ss->assign('sort', $this->sort);
             $this->ss->assign('order_by', $this->order_by);
             $this->ss->assign('status_filter', $this->status_filter);
             $this->ss->assign('priority_filter', $this->priority_filter);
             $this->ss->assign('type_filter', $this->type_filter);
             $this->ss->assign('statusoptions', $zendesk_helper->getStatusFilterOptions());
             $this->ss->assign('priorityoptions', $zendesk_helper->getPriorityFilterOptions());
             $this->ss->assign('typeoptions', $zendesk_helper->getTypeFilterOptions());
             $this->ss->display('modules/zd_Tickets/tpls/associated.tpl');
         }
     }
 }
Example #3
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 #4
0
 public function display()
 {
     global $current_user;
     echo $this->getModuleTitle();
     $this->ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
     $this->ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
     $this->ss->assign("RETURN_ID", $_REQUEST['return_id']);
     $zendesk_helper = new ZendeskHelper();
     $zendesk_instance = $zendesk_helper->getConfigValue('instance');
     if ($zendesk_instance == null) {
         echo "Thank you for installing Zendesk for SugarCRM.<br/>";
         echo "Administrators, please start with <a href='index.php?module=zd_Tickets&action=config'>configuring your Zendesk credentials</a>.";
     } else {
         $connection = getZendeskConnection();
         $this->ss->assign('zendesk_instance', $connection->url());
         $this->ss->assign('current_user_id', '_' . $current_user->user_name);
         $this->ss->assign('zendesk_login', $zendesk_helper->getPersonalConfigValue('login'));
         $this->ss->assign('per_page', $zendesk_helper->getConfigValue('per_page', '6'));
         $this->ss->assign('sort', $zendesk_helper->getConfigValue('sort', '1'));
         $this->ss->assign('order_by', $zendesk_helper->getConfigValue('order_by', 'priority'));
         $this->ss->assign('status_filter', $zendesk_helper->getConfigValue('status_filter', 'lsolved'));
         $this->ss->assign('priority_filter', $zendesk_helper->getConfigValue('priority_filter', 'any'));
         $this->ss->assign('type_filter', $zendesk_helper->getConfigValue('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/personalconfig.tpl');
     }
 }