Ejemplo n.º 1
0
 /**
  * Adds a custom field using a field object
  *
  * @param Field Object $field
  * @return boolean
  */
 function addFieldObject(&$field)
 {
     global $dictionary, $beanList;
     if (empty($beanList[$this->module])) {
         return false;
     }
     $bean_name = get_valid_bean_name($this->module);
     if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) {
         return false;
     }
     $currdef = $dictionary[$bean_name]["fields"][$field->name];
     $this->loadCustomDef($field->name);
     $newDef = $field->get_field_def();
     require_once 'modules/DynamicFields/FieldCases.php';
     $this->baseField = get_widget($field->type);
     foreach ($field->vardef_map as $property => $fmd_col) {
         if ($property == "action" || $property == "label_value" || $property == "label" || substr($property, 0, 3) == 'ext' && strlen($property) == 4) {
             continue;
         }
         // Bug 37043 - Avoid writing out vardef defintions that are the default value.
         if (isset($newDef[$property]) && (!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField) || isset($currdef[$property]) && $currdef[$property] != $newDef[$property])) {
             $this->custom_def[$property] = is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
         }
         if (isset($this->custom_def[$property]) && !isset($newDef[$property])) {
             unset($this->custom_def[$property]);
         }
     }
     if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) {
         unset($this->custom_def["duplicate_merge_dom_value"]);
     }
     $this->writeVardefExtension($bean_name, $field, $this->custom_def);
 }
Ejemplo n.º 2
0
 /**
  * Adds a custom field using a field object
  *
  * @param Field Object $field
  * @return boolean
  */
 function addFieldObject(&$field)
 {
     global $dictionary, $beanList;
     if (empty($beanList[$this->module])) {
         return false;
     }
     $bean_name = get_valid_bean_name($this->module);
     if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) {
         return false;
     }
     $currdef = $dictionary[$bean_name]["fields"][$field->name];
     // set $field->unified_search=true if field supports unified search
     // regarding #51427
     if ($field->supports_unified_search) {
         if (isset($dictionary[$bean_name]['unified_search_default_enabled']) && isset($dictionary[$bean_name]['unified_search']) && $dictionary[$bean_name]['unified_search_default_enabled'] && $dictionary[$bean_name]['unified_search']) {
             $currdef['unified_search'] = $field->unified_search = isset($currdef['unified_search']) ? $currdef['unified_search'] : true;
         }
     }
     // end #51427
     $this->loadCustomDef($field->name);
     $this->loadBaseDef($field->name);
     $newDef = $field->get_field_def();
     require_once 'modules/DynamicFields/FieldCases.php';
     $this->baseField = get_widget($field->type);
     foreach ($field->vardef_map as $property => $fmd_col) {
         if ($property == "action" || $property == "label_value" || $property == "label" || substr($property, 0, 3) == 'ext' && strlen($property) == 4) {
             continue;
         }
         // Bug 37043 - Avoid writing out vardef defintions that are the default value.
         if (isset($newDef[$property]) && (!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField) || isset($currdef[$property]) && $currdef[$property] != $newDef[$property])) {
             $this->custom_def[$property] = is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
         }
         //Remove any orphaned entries
         if (isset($this->custom_def[$property]) && !isset($newDef[$property])) {
             unset($this->custom_def[$property]);
         }
         //Handle overrides of out of the box definitions with empty
         if (!empty($this->base_def[$property]) && !isset($newDef[$property])) {
             //Switch on type of the property to find what the correct 'empty' is.
             if (is_string($this->base_def[$property])) {
                 $this->custom_def[$property] = "";
             } else {
                 if (is_array($this->base_def[$property])) {
                     $this->custom_def[$property] = array();
                 } else {
                     if (is_bool($this->base_def[$property])) {
                         $this->custom_def[$property] = false;
                     } else {
                         $this->custom_def[$property] = null;
                     }
                 }
             }
         }
     }
     if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) {
         unset($this->custom_def["duplicate_merge_dom_value"]);
     }
     $this->writeVardefExtension($bean_name, $field, $this->custom_def);
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     global $dictionary, $bean_list;
     $this->old_dictionary = $dictionary;
     $this->old_bean_list = $bean_list;
     $this->test_standart_field = new TestStandardField();
     $this->test_standart_field->module = 'Accounts';
     loadBean($this->test_standart_field->module);
     $this->test_field = get_widget('varchar');
     $this->test_field->name = 'name';
     $this->bean_name = get_valid_bean_name($this->test_standart_field->module);
 }
Ejemplo n.º 4
0
 /**
  * Builds and runs a query against multiple modules
  * More flexible, yet less performant than what currently exists for searching
  * in the Unified Search API (ElasticSearch & SpotSearch)
  *
  * DO NOT USE FOR NEW PURPOSES
  * This should only used as a stop-gap for Meetings & Calls invitee search until
  * Unified Search API can support related fields (like account_name)
  *
  * @param string $request_id
  * @param array $params
  * @param bool $returnFullBeans
  * @return array
  */
 public function query($request_id, $params, $returnFullBeans = false)
 {
     global $response, $sugar_config;
     $json = getJSONobj();
     // override query limits
     if ($sugar_config['list_max_entries_per_page'] < 31) {
         $sugar_config['list_max_entries_per_page'] = 31;
     }
     $args = $params[0];
     //decode condition parameter values..
     if (is_array($args['conditions'])) {
         foreach ($args['conditions'] as $key => $condition) {
             if (!empty($condition['value'])) {
                 $where = $json->decode(utf8_encode($condition['value']));
                 // cn: bug 12693 - API change due to CSRF security changes.
                 $where = empty($where) ? $condition['value'] : $where;
                 $args['conditions'][$key]['value'] = $where;
             }
         }
     }
     $list_return = array();
     if (!empty($args['module'])) {
         $args['modules'] = array($args['module']);
     }
     foreach ($args['modules'] as $module) {
         $focus = BeanFactory::getBean($module);
         $query_orderby = '';
         if (!empty($args['order'])) {
             $query_orderby = preg_replace('/[^\\w_.-]+/i', '', $args['order']['by']);
             if (!empty($args['order']['desc'])) {
                 $query_orderby .= " DESC";
             } else {
                 $query_orderby .= " ASC";
             }
         }
         $query_limit = '';
         if (!empty($args['limit'])) {
             $query_limit = (int) $args['limit'];
         }
         $query_where = $this->constructWhere($args, $focus->table_name, $module);
         $list_arr = array();
         if ($focus->ACLAccess('ListView', true)) {
             $focus->ungreedy_count = false;
             $curlist = $focus->get_list($query_orderby, $query_where, 0, $query_limit, -1, 0);
             $list_return = array_merge($list_return, $curlist['list']);
         }
     }
     $app_list_strings = null;
     for ($i = 0; $i < count($list_return); $i++) {
         if (isset($list_return[$i]->emailAddress) && is_object($list_return[$i]->emailAddress)) {
             $list_return[$i]->emailAddress->handleLegacyRetrieve($list_return[$i]);
         }
         $list_arr[$i] = array();
         $list_arr[$i]['fields'] = array();
         $list_arr[$i]['module'] = $list_return[$i]->object_name;
         foreach ($args['field_list'] as $field) {
             //handle links
             if (isset($list_return[$i]->field_name_map[$field]) && $list_return[$i]->field_name_map[$field]['type'] == "relate") {
                 $linked = current($list_return[$i]->get_linked_beans($list_return[$i]->field_name_map[$field]['link'], get_valid_bean_name($list_return[$i]->field_name_map[$field]['module'])));
                 $list_return[$i]->{$field} = "";
                 if (is_object($linked)) {
                     $linkFieldName = $list_return[$i]->field_name_map[$field]['rname'];
                     $list_return[$i]->{$field} = $linked->{$linkFieldName};
                 }
             }
             if (!empty($list_return[$i]->field_name_map[$field]['sensitive'])) {
                 continue;
             }
             // handle enums
             if (isset($list_return[$i]->field_name_map[$field]['type']) && $list_return[$i]->field_name_map[$field]['type'] == 'enum' || isset($list_return[$i]->field_name_map[$field]['custom_type']) && $list_return[$i]->field_name_map[$field]['custom_type'] == 'enum') {
                 // get fields to match enum vals
                 if (empty($app_list_strings)) {
                     if (isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
                         $current_language = $_SESSION['authenticated_user_language'];
                     } else {
                         $current_language = $sugar_config['default_language'];
                     }
                     $app_list_strings = return_app_list_strings_language($current_language);
                 }
                 // match enum vals to text vals in language pack for return
                 if (!empty($app_list_strings[$list_return[$i]->field_name_map[$field]['options']])) {
                     $list_return[$i]->{$field} = $app_list_strings[$list_return[$i]->field_name_map[$field]['options']][$list_return[$i]->{$field}];
                 }
             }
             $list_arr[$i]['fields'][$field] = $list_return[$i]->{$field};
         }
         if ($returnFullBeans) {
             $list_arr[$i]['bean'] = $list_return[$i];
         }
     }
     $response['id'] = $request_id;
     $response['result'] = array("list" => $list_arr);
     return $response;
 }