Exemplo n.º 1
0
 /**
  * This function checks to make sure that if a client version is supplied it is up to date.
  *
  * @param ServiceBase $api The service api
  * @param array $args The arguments passed in to the function
  * @return bool True if the version was good, false if it wasn't
  */
 public function isSupportedClientVersion(ServiceBase $api, array $args)
 {
     if (!empty($args['client_info']['app']['name']) && !empty($args['client_info']['app']['version'])) {
         $name = $args['client_info']['app']['name'];
         //Non-native mobile clients are bunbled with the sugar build and are therefore exempt from version checks
         if ($name == 'nomad' && isset($args['client_info']['app']['isNative']) && !isTruthy($args['client_info']['app']['isNative'])) {
             return true;
         }
     }
     return parent::isSupportedClientVersion($api, $args);
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function apiFormatField(array &$data, SugarBean $bean, array $args, $fieldName, $properties, array $fieldList = null, ServiceBase $service = null)
 {
     $this->ensureApiFormatFieldArguments($fieldList, $service);
     // this is only for generated links
     if (isset($bean->field_defs[$fieldName]['gen']) && isTruthy($bean->field_defs[$fieldName]['gen'])) {
         $subject = $bean->field_defs[$fieldName]['default'];
         if (!empty($subject)) {
             $data[$fieldName] = replace_sugar_vars($subject, $bean->toArray(), true);
         } else {
             $data[$fieldName] = "";
         }
     } else {
         parent::apiFormatField($data, $bean, $args, $fieldName, $properties, $fieldList, $service);
     }
 }
Exemplo n.º 3
0
<BR>
<?php 
    echo $mod_strings_users['LBL_REASS_MOD_REASSIGN'];
    ?>
<BR>
<select size="6" name='modules[]' multiple="true" id='modulemultiselect' onchange="updateDivDisplay(this);">
<?php 
    if (!isset($_SESSION['reassignRecords']['assignedModuleListCache'])) {
        $beanListDup = $beanList;
        unset($beanListDup['ForecastManagerWorksheets']);
        foreach ($beanListDup as $m => $p) {
            if (empty($beanFiles[$p])) {
                unset($beanListDup[$m]);
            } else {
                $obj = BeanFactory::getBean($m);
                if (!isset($obj->field_defs['assigned_user_id']) || isset($obj->field_defs['assigned_user_id']) && isset($obj->field_defs['assigned_user_id']['source']) && $obj->field_defs['assigned_user_id']['source'] == "non-db" || isset($dictionary[$obj->object_name]['reassignable']) && !isTruthy($dictionary[$obj->object_name]['reassignable'])) {
                    unset($beanListDup[$m]);
                }
            }
        }
        //Get the list of beans without the excluded modules
        $beanListDup = array_diff($beanListDup, $exclude_modules);
        //Leon bug 20739
        $beanListDupDisp = array();
        foreach ($beanListDup as $m => $p) {
            $beanListDupDisp[$m] = isset($app_list_strings['moduleList'][$m]) ? $app_list_strings['moduleList'][$m] : $p;
        }
        asort($beanListDupDisp, SORT_STRING);
        $_SESSION['reassignRecords']['assignedModuleListCache'] = $beanListDup;
        $_SESSION['reassignRecords']['assignedModuleListCacheDisp'] = $beanListDupDisp;
    }
Exemplo n.º 4
0
 /**
  * Update any related calculated fields
  *
  * @param string $linkName      The specific link that needs updating
  */
 public function updateRelatedCalcFields($linkName = "")
 {
     // we don't have an id, lets not run this code.
     if (empty($this->id) || !empty($this->new_with_id)) {
         return;
     }
     global $dictionary, $sugar_config;
     if (!empty($sugar_config['disable_related_calc_fields'])) {
         return;
     }
     if (!static::enterOperation('saving_related')) {
         return;
     }
     // If linkName is empty then we need to handle all links
     if (empty($linkName)) {
         $GLOBALS['log']->debug("Updating records related to {$this->module_dir} {$this->id}");
         if (!empty($dictionary[$this->object_name]['related_calc_fields'])) {
             $links = $dictionary[$this->object_name]['related_calc_fields'];
             foreach ($links as $lname) {
                 if (empty($this->{$lname}) && !$this->load_relationship($lname) || !$this->{$lname} instanceof Link2) {
                     continue;
                 }
                 $this->addParentRecordsToResave($lname);
                 $influencing_fields = $this->get_fields_influencing_linked_bean_calc_fields($lname);
                 $data_changes = $this->db->getDataChanges($this);
                 $changed_fields = array_keys($data_changes);
                 // loop over the influencing_fields to check if any are calculated and enforced formulas
                 // if they are we need to add them to the changed_fields as they could have been
                 // changed from another save that was done` before this one since we don't roll up more than one
                 // level at a time a rollup on a rollup field would never update the parent unless the parent is
                 // saved explicitly
                 foreach ($influencing_fields as $field) {
                     $def = $this->getFieldDefinition($field);
                     if (isset($def['calculated']) && isTruthy($def['calculated']) && isset($def['enforced']) && isTruthy($def['enforced'])) {
                         $changed_fields[] = $field;
                     }
                 }
                 // if fetched_row is empty we have a new record, so don't check for changed_fields
                 // if deleted is 1, we need to update all related items
                 // the only time we want to check if any of the influcenceing fields have changed is when, it's a, non-deleted record
                 // and when we are updating a row.
                 if (!empty($this->fetched_row) && $this->deleted == 0 && !array_intersect($influencing_fields, $changed_fields)) {
                     continue;
                 }
                 $beans = $this->{$lname}->getBeans();
                 //Resave any related beans
                 if (!empty($beans)) {
                     foreach ($beans as $rBean) {
                         if (empty($rBean->deleted)) {
                             SugarRelationship::addToResaveList($rBean);
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->has_calc_field_with_link($linkName)) {
             //Save will update the saved_beans array
             SugarRelationship::addToResaveList($this);
         }
     }
     static::leaveOperation('saving_related');
 }
Exemplo n.º 5
0
 /**
  * Get default value for database from field definition.
  * @param array $fieldDef
  * @return string
  */
 protected function getDefaultFromDefinition($fieldDef)
 {
     $default = '';
     if (!empty($fieldDef['no_default'])) {
         // nothing to do
     } elseif ($this->getFieldType($fieldDef) == 'bool') {
         if (isset($fieldDef['default'])) {
             $default = " DEFAULT " . (int) isTruthy($fieldDef['default']);
         }
     } elseif (isset($fieldDef['default'])) {
         $default = " DEFAULT " . $this->massageValue($fieldDef['default'], $fieldDef);
     }
     return $default;
 }
 /**
  * Sets the sortable property of the fielddef
  *
  * @param string $fieldName  The name of the field being worked on
  * @param array $fieldDef The current fielddef collection for a field
  * @return array The modified fielddef collection
  */
 public function setDefSortable($fieldName, $fieldDef)
 {
     // sorting fields of certain types will cause database engine problems
     $noSortByType = isset($this->_fielddefs[$fieldName]['type']) && isset($this->nonSortableTypes[$this->_fielddefs[$fieldName]['type']]);
     $noSortDBType = isset($this->_fielddefs[$fieldName]['dbType']) && $this->_fielddefs[$fieldName]['dbType'] == 'id';
     $sortable = isset($this->_fielddefs[$fieldName]['sortable']) ? isTruthy($this->_fielddefs[$fieldName]['sortable']) : false;
     $relateSortable = false;
     if (isset($this->_fielddefs[$fieldName]['type']) && $this->_fielddefs[$fieldName]['type'] === 'relate') {
         $hasSortOn = isset($this->_fielddefs[$fieldName]['sort_on']) && is_array($this->_fielddefs[$fieldName]['sort_on']);
         $relateSortable = !$hasSortOn;
     }
     if ($noSortByType || $noSortDBType || $relateSortable) {
         $fieldDef['sortable'] = $sortable;
     }
     return $fieldDef;
 }
Exemplo n.º 7
0
 /**
  * {@inheritDoc}
  */
 public function get_field_def()
 {
     $def = parent::get_field_def();
     // The default value is stored in database as string,
     // however from domain standpoint it has to be boolean
     // @see Data.Validation#requiredValidator()
     $def['default'] = isTruthy($def['default']);
     return $def;
 }
Exemplo n.º 8
0
 /**
  * @param $field
  * @param $value
  * @param bool $bean
  * @param bool $operator
  *
  * @return string
  */
 public function quoteValue($value, $operator = false, $forPrepared = false)
 {
     global $db;
     if ($value instanceof SugarQuery_Builder_Literal) {
         return (string) $value;
     }
     if ($this->field == 'deleted' && empty($this->def)) {
         return (int) isTruthy($value);
     }
     if (!empty($this->def)) {
         $dbtype = $db->getFieldType($this->def);
         if (is_null($value) || $value === false || $value === '') {
             return $db->emptyValue($dbtype, $forPrepared);
         }
         switch ($dbtype) {
             case 'date':
             case 'datetime':
             case 'time':
                 if (strtoupper($value) == 'NOW()') {
                     return $forPrepared ? TimeDate::getInstance()->nowDb() : $db->now();
                 }
                 break;
             case 'bool':
                 return (int) isTruthy($value);
         }
         if ($db->getTypeClass($dbtype) == 'string') {
             if ($operator == 'STARTS') {
                 $value = $value . '%';
             }
             if ($operator == 'CONTAINS' || $operator == 'DOES NOT CONTAIN') {
                 $value = '%' . $value . '%';
             }
             if ($operator == 'ENDS') {
                 $value = '%' . $value;
             }
         }
         return $forPrepared ? $value : $db->quoteType($dbtype, $value);
     }
     return $forPrepared ? $value : $db->quoted($value);
 }