Beispiel #1
0
 public function display()
 {
     global $dictionary;
     global $current_user;
     global $beanList, $beanFiles;
     global $app_list_strings;
     echo $this->getModuleTitle();
     $this->ss->assign("RETURN_MODULE", "Administration");
     $this->ss->assign("RETURN_ACTION", "index");
     $config = new ZendeskWidgetConfig();
     $records = array();
     foreach (query_module_access_list($current_user) as $module) {
         if ($object_name = $beanList[$module]) {
             if (!in_array($object_name, array('zd_Tickets'))) {
                 $bean = $this->getBeanInstance($object_name);
                 $field_config = $config->getFields($module);
                 $records[$module] = array('key' => $module, 'name' => $app_list_strings['moduleList'][$module], 'enabled' => $field_config != null && $field_config != '', 'fields' => $this->getRecordFields($bean), 'current' => $field_config);
             }
         }
     }
     usort($records, "namecmp");
     $this->ss->assign('records', $records);
     $this->ss->display('modules/zd_Tickets/tpls/crmdataconfig.tpl');
 }
 function crmdata($session, $email)
 {
     global $dictionary;
     global $app_list_strings;
     global $current_user;
     global $beanList, $beanFiles;
     if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', 'Accounts', 'read', 'no_access', new SoapError())) {
         echo "No access";
         return;
     }
     $field_list = array();
     $config = new ZendeskWidgetConfig();
     foreach (query_module_access_list($current_user) as $module) {
         if ($object_name = $beanList[$module]) {
             $field_config = $config->getFields($module);
             if ($field_config != null && $field_config != '') {
                 $field_list[$object_name] = $field_config;
             }
         }
     }
     $root = new SimpleXMLElement('<records></records>');
     $ea = new EmailAddress();
     $beans = $ea->getBeansByEmailAddress($email);
     while ($bean = array_pop($beans)) {
         if (isset($field_list[$bean->object_name])) {
             $record = $root->addChild('record');
             $record->addChild('id', $bean->id);
             $record->addChild('url', htmlspecialchars("/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}"));
             $record->addChild('label', $bean->name);
             $record->addChild('record_type', $bean->object_name);
             $fields = $record->addChild('fields');
             foreach (split(',', $field_list[$bean->object_name]) as $name) {
                 $field_meta = $dictionary[$bean->object_name]['fields'][$name];
                 if ($field_meta['type'] == 'relate') {
                     if ($field_meta['dbType'] == 'id') {
                         $beanType = get_singular_bean_name($field_meta['module']);
                         $newBean = $this->getBeanInstance($beanType);
                         $newBean->retrieve($bean->{$name});
                         $beans[] = $newBean;
                         continue;
                     }
                 }
                 $field = $fields->addChild('field');
                 $field->addChild('label', translate($field_meta['vname'], $bean->module_dir));
                 $value = $bean->{$name};
                 if ($field_meta['type'] == 'enum') {
                     $value = $app_list_strings[$field_meta['options']][$bean->{$name}];
                 }
                 $field->addChild('value', $value);
             }
         }
     }
     return $root->asXML();
 }