Example #1
0
 function process($checkFormName = false, $formName = '')
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings;
     //the retrieve already did this work;
     //$this->focus->fill_in_relationship_fields();
     if (!$this->th->checkTemplate($this->module, $this->view, $checkFormName, $formName)) {
         $this->render();
     }
     if (isset($_REQUEST['offset'])) {
         $this->offset = $_REQUEST['offset'] - 1;
     }
     if ($this->showVCRControl) {
         $this->th->ss->assign('PAGINATION', SugarVCR::menu($this->module, $this->offset, $this->focus->is_AuditEnabled(), $this->view == 'EditView'));
     }
     if (isset($_REQUEST['return_module'])) {
         $this->returnModule = $_REQUEST['return_module'];
     }
     if (isset($_REQUEST['return_action'])) {
         $this->returnAction = $_REQUEST['return_action'];
     }
     if (isset($_REQUEST['return_id'])) {
         $this->returnId = $_REQUEST['return_id'];
     }
     if (isset($_REQUEST['return_relationship'])) {
         $this->returnRelationship = $_REQUEST['return_relationship'];
     }
     if (isset($_REQUEST['return_name'])) {
         $this->returnName = $this->getValueFromRequest($_REQUEST, 'return_name');
     }
     // handle Create $module then Cancel
     if (empty($this->returnId)) {
         $this->returnAction = 'index';
     }
     $is_owner = $this->focus->isOwner($GLOBALS['current_user']->id);
     $this->fieldDefs = array();
     if ($this->focus) {
         global $current_user;
         if (!empty($this->focus->assigned_user_id)) {
             $this->focus->assigned_user_name = get_assigned_user_name($this->focus->assigned_user_id);
         }
         foreach ($this->focus->toArray() as $name => $value) {
             $valueFormatted = false;
             //if ($this->focus->field_defs[$name]['type']=='link')continue;
             $this->fieldDefs[$name] = !empty($this->fieldDefs[$name]) && !empty($this->fieldDefs[$name]['value']) ? array_merge($this->focus->field_defs[$name], $this->fieldDefs[$name]) : $this->focus->field_defs[$name];
             foreach (array("formula", "default", "comments", "help") as $toEscape) {
                 if (!empty($this->fieldDefs[$name][$toEscape])) {
                     $this->fieldDefs[$name][$toEscape] = htmlentities($this->fieldDefs[$name][$toEscape], ENT_QUOTES, 'UTF-8');
                 }
             }
             if (isset($this->fieldDefs[$name]['options']) && isset($app_list_strings[$this->fieldDefs[$name]['options']])) {
                 $this->fieldDefs[$name]['options'] = $app_list_strings[$this->fieldDefs[$name]['options']];
                 if (isset($GLOBALS['sugar_config']['enable_autocomplete']) && $GLOBALS['sugar_config']['enable_autocomplete'] == true) {
                     $this->fieldDefs[$name]['autocomplete'] = true;
                     $this->fieldDefs[$name]['autocomplete_options'] = $this->fieldDefs[$name]['options'];
                     // we need the name for autocomplete
                 } else {
                     $this->fieldDefs[$name]['autocomplete'] = false;
                 }
             }
             if (isset($this->fieldDefs[$name]['function'])) {
                 $function = $this->fieldDefs[$name]['function'];
                 $function = is_array($function) && isset($function['name']) ? $this->fieldDefs[$name]['function']['name'] : $this->fieldDefs[$name]['function'];
                 if (!empty($this->fieldDefs[$name]['function']['returns']) && $this->fieldDefs[$name]['function']['returns'] == 'html') {
                     if (!empty($this->fieldDefs[$name]['function']['include'])) {
                         require_once $this->fieldDefs[$name]['function']['include'];
                     }
                     $value = $function($this->focus, $name, $value, $this->view);
                     $valueFormatted = true;
                 } else {
                     $this->fieldDefs[$name]['options'] = $function($this->focus, $name, $value, $this->view);
                 }
             }
             if (isset($this->fieldDefs[$name]['function'])) {
                 $function = $this->fieldDefs[$name]['function'];
                 if (is_array($function) && isset($function['name'])) {
                     $function = $this->fieldDefs[$name]['function']['name'];
                 } else {
                     $function = $this->fieldDefs[$name]['function'];
                 }
                 if (!empty($this->fieldDefs[$name]['function']['returns']) && $this->fieldDefs[$name]['function']['returns'] == 'html') {
                     if (!empty($this->fieldDefs[$name]['function']['include'])) {
                         require_once $this->fieldDefs[$name]['function']['include'];
                     }
                     $value = $function($this->focus, $name, $value, $this->view);
                     $valueFormatted = true;
                 } else {
                     $this->fieldDefs[$name]['options'] = $function($this->focus, $name, $value, $this->view);
                 }
             }
             if (isset($this->fieldDefs[$name]['type']) && $this->fieldDefs[$name]['type'] == 'function' && isset($this->fieldDefs[$name]['function_name'])) {
                 $value = $this->callFunction($this->fieldDefs[$name]);
                 $valueFormatted = true;
             }
             if (!$valueFormatted) {
                 // $this->focus->format_field($this->focus->field_defs[$name]);
                 $value = isset($this->focus->{$name}) ? $this->focus->{$name} : '';
             }
             if (empty($this->fieldDefs[$name]['value'])) {
                 $this->fieldDefs[$name]['value'] = $value;
             }
             //This code is used for QuickCreates that go to Full Form view.  We want to overwrite the values from the bean
             //with values from the request if they are set
             if ($this->populateBean && (isset($_REQUEST['full_form']) || $_REQUEST['action'] == "SubpanelCreates" && empty($this->focus->id)) && (!isset($this->fieldDefs[$name]['function']['returns']) || $this->fieldDefs[$name]['function']['returns'] != 'html') && isset($_REQUEST[$name])) {
                 $this->fieldDefs[$name]['value'] = $this->getValueFromRequest($_REQUEST, $name);
             }
             /*
              * Populate any relate fields that are linked by a relationship to the calling module.
              * Clicking the create button on a subpanel for example will populate three values in the $_REQUEST:
              * 1. return_module => the name of the calling module
              * 2. return_id => the id of the record in the calling module that the user was viewing and that should be associated with this new record
              * 3. return_name => the display value of the return_id record - the value to show in any relate field in this EditView
              * Only do if this fieldDef does not already have a value; if it does it will have been explicitly set, and that should overrule this less specific mechanism
              */
             if (isset($this->returnModule) && isset($this->returnName) && empty($this->focus->id) && empty($this->fieldDefs['name']['value'])) {
                 if ($this->focus->field_defs[$name]['type'] == 'relate' && isset($this->focus->field_defs[$name]['module']) && $this->focus->field_defs[$name]['module'] == $this->returnModule) {
                     if (isset($this->fieldDefs[$name]['id_name']) && !empty($this->returnRelationship) && isset($this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship']) && $this->returnRelationship == $this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship']) {
                         $this->fieldDefs[$name]['value'] = $this->returnName;
                         // set the hidden id field for this relate field to the correct value i.e., return_id
                         $this->fieldDefs[$this->fieldDefs[$name]['id_name']]['value'] = $this->returnId;
                     }
                 }
             }
         }
     }
     if (isset($this->focus->additional_meta_fields)) {
         $this->fieldDefs = array_merge($this->fieldDefs, $this->focus->additional_meta_fields);
     }
     if ($this->isDuplicate) {
         foreach ($this->fieldDefs as $name => $defs) {
             if (!empty($defs['auto_increment'])) {
                 $this->fieldDefs[$name]['value'] = '';
             }
         }
     }
 }
Example #2
0
 function process($checkFormName = false, $formName = '')
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings;
     //the retrieve already did this work;
     //$this->focus->fill_in_relationship_fields();
     //Bug#53261: If quickeditview is loaded after editview.tpl is created,
     //           the th->checkTemplate will return true. So, the following
     //           code prevent avoid rendering popup editview container.
     if (!empty($this->formName)) {
         $formName = $this->formName;
         $checkFormName = true;
     }
     if (!$this->th->checkTemplate($this->module, $this->view, $checkFormName, $formName)) {
         $this->render();
     }
     if (isset($_REQUEST['offset'])) {
         $this->offset = $_REQUEST['offset'] - 1;
     }
     if ($this->showVCRControl) {
         $this->th->ss->assign('PAGINATION', SugarVCR::menu($this->module, $this->offset, $this->focus->is_AuditEnabled(), $this->view == 'EditView'));
     }
     if (isset($_REQUEST['return_module'])) {
         $this->returnModule = $_REQUEST['return_module'];
     }
     if (isset($_REQUEST['return_action'])) {
         $this->returnAction = $_REQUEST['return_action'];
     }
     if (isset($_REQUEST['return_id'])) {
         $this->returnId = $_REQUEST['return_id'];
     }
     if (isset($_REQUEST['return_relationship'])) {
         $this->returnRelationship = $_REQUEST['return_relationship'];
     }
     if (isset($_REQUEST['return_name'])) {
         $this->returnName = $this->getValueFromRequest($_REQUEST, 'return_name');
     }
     // handle Create $module then Cancel
     if (empty($this->returnId)) {
         $this->returnAction = 'index';
     }
     $is_owner = $this->focus->isOwner($GLOBALS['current_user']->id);
     $this->fieldDefs = array();
     if ($this->focus) {
         global $current_user;
         if (!empty($this->focus->job) && $this->focus->job_function == '') {
             $this->focus->job_function = $this->focus->job;
         }
         if (empty($this->focus->team_id)) {
             $this->focus->team_id = $current_user->default_team;
             $this->focus->team_name = $current_user->default_team_name;
         } else {
             if (empty($this->focus->team_name)) {
                 $this->focus->team_name = Team::getTeamName($this->focus->team_id);
             }
         }
         foreach ($this->focus->toArray() as $name => $value) {
             $valueFormatted = false;
             //if ($this->focus->field_defs[$name]['type']=='link')continue;
             $this->fieldDefs[$name] = !empty($this->fieldDefs[$name]) && !empty($this->fieldDefs[$name]['value']) ? array_merge($this->focus->field_defs[$name], $this->fieldDefs[$name]) : $this->focus->field_defs[$name];
             foreach (array("formula", "default", "comments", "help") as $toEscape) {
                 if (!empty($this->fieldDefs[$name][$toEscape])) {
                     $this->fieldDefs[$name][$toEscape] = htmlentities($this->fieldDefs[$name][$toEscape], ENT_QUOTES, 'UTF-8');
                 }
             }
             if (isset($this->fieldDefs[$name]['options']) && isset($app_list_strings[$this->fieldDefs[$name]['options']])) {
                 if (isset($GLOBALS['sugar_config']['enable_autocomplete']) && $GLOBALS['sugar_config']['enable_autocomplete'] == true) {
                     $this->fieldDefs[$name]['autocomplete'] = true;
                     $this->fieldDefs[$name]['autocomplete_options'] = $this->fieldDefs[$name]['options'];
                     // we need the name for autocomplete
                 } else {
                     $this->fieldDefs[$name]['autocomplete'] = false;
                 }
                 // Bug 57472 - $this->fieldDefs[$name]['autocomplete_options' was set too late, it didn't retrieve the list's name, but the list itself (the developper comment show us that developper expected to retrieve list's name and not the options array)
                 $this->fieldDefs[$name]['options'] = $app_list_strings[$this->fieldDefs[$name]['options']];
             }
             if (isset($this->fieldDefs[$name]['options']) && is_array($this->fieldDefs[$name]['options']) && isset($this->fieldDefs[$name]['default_empty']) && !isset($this->fieldDefs[$name]['options'][$this->fieldDefs[$name]['default_empty']])) {
                 $this->fieldDefs[$name]['options'] = array_merge(array($this->fieldDefs[$name]['default_empty'] => $this->fieldDefs[$name]['default_empty']), $this->fieldDefs[$name]['options']);
             }
             if (isset($this->fieldDefs[$name]['function'])) {
                 $functionBean = isset($this->fieldDefs[$name]['function_bean']) ? $this->fieldDefs[$name]['function_bean'] : null;
                 $function = $this->fieldDefs[$name]['function'];
                 $functionArgs = array($this->focus, $name, $value, $this->view);
                 // since we are on the old edit view, we need to revert to the old way to get the currency
                 // drop down and not the new fancy way that REST needs to get it.
                 $setValueFormatted = false;
                 if ($function == 'getCurrencies' && $functionBean == 'Currencies') {
                     $function = array('returns' => 'html', 'name' => 'getCurrencyDropDown');
                     $functionBean = array();
                     $setValueFormatted = true;
                 }
                 $value = getFunctionValue($functionBean, $function, $functionArgs);
                 if ($setValueFormatted || !empty($this->fieldDefs[$name]['function']['returns']) && $this->fieldDefs[$name]['function']['returns'] == 'html') {
                     $valueFormatted = true;
                 } else {
                     $this->fieldDefs[$name]['options'] = $value;
                 }
             }
             if (isset($this->fieldDefs[$name]['type']) && $this->fieldDefs[$name]['type'] == 'function' && isset($this->fieldDefs[$name]['function_name'])) {
                 $value = $this->callFunction($this->fieldDefs[$name]);
                 $valueFormatted = true;
             }
             if (!$valueFormatted) {
                 // $this->focus->format_field($this->focus->field_defs[$name]);
                 $value = isset($this->focus->{$name}) ? $this->focus->{$name} : '';
             }
             if (empty($this->fieldDefs[$name]['value'])) {
                 $this->fieldDefs[$name]['value'] = $value;
             }
             //This code is used for QuickCreates that go to Full Form view.  We want to overwrite the values from the bean
             //with values from the request if they are set and either the bean is brand new (such as a create from a subpanels) or the 'full form' button has been clicked
             if (($this->populateBean && empty($this->focus->id) || isset($_REQUEST['full_form'])) && (!isset($this->fieldDefs[$name]['function']['returns']) || $this->fieldDefs[$name]['function']['returns'] != 'html') && isset($_REQUEST[$name])) {
                 $this->fieldDefs[$name]['value'] = $this->getValueFromRequest($_REQUEST, $name);
             }
             /*
              * Populate any relate fields that are linked by a relationship to the calling module.
              * Clicking the create button on a subpanel for example will populate three values in the $_REQUEST:
              * 1. return_module => the name of the calling module
              * 2. return_id => the id of the record in the calling module that the user was viewing and that should be associated with this new record
              * 3. return_name => the display value of the return_id record - the value to show in any relate field in this EditView
              * Only do if this fieldDef does not already have a value; if it does it will have been explicitly set, and that should overrule this less specific mechanism
              */
             if (isset($this->returnModule) && isset($this->returnName) && empty($this->focus->id) && empty($this->fieldDefs['name']['value'])) {
                 if ($this->focus->field_defs[$name]['type'] == 'relate' && isset($this->focus->field_defs[$name]['module']) && $this->focus->field_defs[$name]['module'] == $this->returnModule) {
                     if (isset($this->fieldDefs[$name]['id_name']) && !empty($this->returnRelationship) && isset($this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship']) && $this->returnRelationship == $this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship'] || !empty($this->fieldDefs[$name]['custom_module']) && !empty($this->focus->module_dir) && $this->focus->module_dir == $this->fieldDefs[$name]['custom_module']) {
                         $this->fieldDefs[$name]['value'] = $this->returnName;
                         // set the hidden id field for this relate field to the correct value i.e., return_id
                         $this->fieldDefs[$this->fieldDefs[$name]['id_name']]['value'] = $this->returnId;
                     }
                 }
             }
         }
         $this->focus->ACLFilterFieldList($this->fieldDefs, array(), array("add_acl" => true));
     }
     if (isset($this->focus->additional_meta_fields)) {
         $this->fieldDefs = array_merge($this->fieldDefs, $this->focus->additional_meta_fields);
     }
     if ($this->isDuplicate) {
         foreach ($this->fieldDefs as $name => $defs) {
             if (!empty($defs['auto_increment'])) {
                 $this->fieldDefs[$name]['value'] = '';
             }
         }
     }
 }