Ejemplo n.º 1
0
    public function setUp()
    {
        global $beanList, $beanFiles, $dictionary;
        //Add entries to simulate custom module
        $beanList['Bug44030_TestPerson'] = 'Bug44030_TestPerson';
        $beanFiles['Bug44030_TestPerson'] = 'modules/Bug44030_TestPerson/Bug44030_TestPerson.php';
        VardefManager::loadVardef('Contacts', 'Contact');
        $dictionary['Bug44030_TestPerson'] = $dictionary['Contact'];
        //Copy over custom SearchFields.php file
        if (!file_exists('custom/modules/Bug44030_TestPerson/metadata')) {
            mkdir_recursive('custom/modules/Bug44030_TestPerson/metadata');
        }
        if ($fh = @fopen('custom/modules/Bug44030_TestPerson/metadata/SearchFields.php', 'w+')) {
            $string = <<<EOQ
<?php
\$searchFields['Bug44030_TestPerson']['email'] = array(
'query_type' => 'default',
'operator' => 'subquery',
'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
'db_field' => array('id',),
'vname' =>'LBL_ANY_EMAIL',
);
?>
EOQ;
            fputs($fh, $string);
            fclose($fh);
        }
        //Remove the cached unified_search_modules.php file
        $this->unified_search_modules_file = $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
        if (file_exists($this->unified_search_modules_file)) {
            copy($this->unified_search_modules_file, $this->unified_search_modules_file . '.bak');
            unlink($this->unified_search_modules_file);
        }
    }
Ejemplo n.º 2
0
 public function setUp()
 {
     global $dictionary;
     $this->_view = 'editview';
     VardefManager::loadVardef('Contacts', 'Contact');
     $this->def = $dictionary['Contact']['fields']['email1'];
 }
Ejemplo n.º 3
0
 public function testSaveUsersVardefs()
 {
     global $dictionary;
     $dynamicField = new DynamicField('Users');
     VardefManager::loadVardef('Users', 'User');
     $dynamicField->saveToVardef('Users', $dictionary['User']['fields']);
     //Test that we have refreshed the Employees vardef
     $this->assertTrue(file_exists('cache/modules/Employees/Employeevardefs.php'), 'cache/modules/Employees/Emloyeevardefs.php file not created');
     //Test that status is not set to be required
     $this->assertFalse($dictionary['Employee']['fields']['status']['required'], 'status field set to required');
     //Test that the studio attribute is set to false for status field
     $this->assertFalse($dictionary['Employee']['fields']['status']['studio'], 'status field studio not set to false');
 }
Ejemplo n.º 4
0
 /**
  * Generates field equality comparison PHP code
  *
  * @param WorkFlowTriggerShell $shell_object
  * @param bool $is_equal
  * @return string
  */
 private function getCompareText($shell_object, $is_equal)
 {
     global $dictionary;
     $parentWorkflow = $shell_object->get_workflow_type();
     if (empty($parentWorkflow->base_module)) {
         $GLOBALS['log']->error("WorkFlowTriggerShell ({$shell_object->id}) " . "parent WorkFlow ({$parentWorkflow->id}) has no base module set.");
     }
     $useStrict = true;
     $moduleName = $parentWorkflow->base_module;
     $objectName = BeanFactory::getObjectName($moduleName);
     $field = $shell_object->field;
     VardefManager::loadVardef($moduleName, $objectName);
     if (!empty($dictionary[$objectName]) && !empty($dictionary[$objectName]['fields'][$field])) {
         $vardef = $dictionary[$objectName]['fields'][$field];
         // Don't use strict for numerical types
         if (!empty($vardef['type']) && in_array($vardef['type'], array('currency', 'double', 'int'))) {
             $useStrict = false;
         }
         // Use to_display_date for Date fields
         if (!empty($vardef['type']) && in_array($vardef['type'], array('date'))) {
             $dateTimeFunction = 'to_display_date';
         }
         // Use to_display_date_time for DateTime fields
         if (!empty($vardef['type']) && in_array($vardef['type'], array('datetime', 'datetimecombo'))) {
             $dateTimeFunction = 'to_display_date_time';
         }
     }
     $sep = $is_equal ? '==' : '!=';
     if ($useStrict) {
         $sep .= '=';
     }
     $equalityCheck = "\$focus->fetched_row['" . $field . "'] " . $sep . " \$focus->" . $field;
     if (!empty($dateTimeFunction)) {
         $equalityCheck = "\$GLOBALS['timedate']->{$dateTimeFunction}(\$focus->fetched_row['" . $field . "'])" . " {$sep} " . "\$GLOBALS['timedate']->{$dateTimeFunction}(\$focus->" . $field . ")";
     }
     // Due to sidecar pushing unchanged fields, we need a check when that happens
     if (!$is_equal) {
         $equalityCheck .= " && !(\$focus->fetched_row['" . $field . "'] === null && strlen(\$focus->" . $field . ") === 0)";
     }
     return " (isset(\$focus->" . $field . ") && " . "(empty(\$focus->fetched_row) || array_key_exists('" . $field . "', \$focus->fetched_row)) " . "&& {$equalityCheck}) ";
 }
Ejemplo n.º 5
0
 /**
  * Updates the cached vardefs with the custom field information stored in result
  *
  * @param string $module
  * @param array $result
  * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true
  */
 function saveToVardef($module, $result, $saveCache = true)
 {
     global $beanList;
     if (!empty($beanList[$module])) {
         $object = BeanFactory::getObjectName($module);
         if (empty($GLOBALS['dictionary'][$object]['fields'])) {
             //if the vardef isn't loaded let's try loading it.
             VardefManager::refreshVardefs($module, $object, null, false);
             //if it's still not loaded we really don't have anything useful to cache
             if (empty($GLOBALS['dictionary'][$object]['fields'])) {
                 return;
             }
         }
         if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) {
             $GLOBALS['dictionary'][$object]['custom_fields'] = false;
         }
         if (!empty($GLOBALS['dictionary'][$object])) {
             if (!empty($result)) {
                 // First loop to add
                 foreach ($result as $field) {
                     foreach ($field as $k => $v) {
                         //allows values for custom fields to be defined outside of the scope of studio
                         if (!isset($GLOBALS['dictionary'][$object]['fields'][$field['name']][$k])) {
                             $GLOBALS['dictionary'][$object]['fields'][$field['name']][$k] = $v;
                         }
                     }
                 }
                 // Second loop to remove
                 foreach ($GLOBALS['dictionary'][$object]['fields'] as $name => $fieldDef) {
                     if (isset($fieldDef['custom_module'])) {
                         if (!isset($result[$name])) {
                             unset($GLOBALS['dictionary'][$object]['fields'][$name]);
                         } else {
                             $GLOBALS['dictionary'][$object]['custom_fields'] = true;
                         }
                     }
                 }
                 //if
             }
         }
         $manager = new VardefManager();
         if ($saveCache) {
             $manager->saveCache($this->module, $object);
         }
         // Everything works off of vardefs, so let's have it save the users vardefs
         // to the employees module, because they both use the same table behind
         // the scenes
         if ($module == 'Users') {
             $manager->loadVardef('Employees', 'Employee', true);
             return;
         }
     }
 }
Ejemplo n.º 6
0
 protected function buildRelationshipCache()
 {
     global $beanList, $dictionary, $buildingRelCache;
     if ($buildingRelCache) {
         return;
     }
     $buildingRelCache = true;
     include_once "modules/TableDictionary.php";
     if (empty($beanList)) {
         include "include/modules.php";
     }
     //Reload ALL the module vardefs....
     foreach ($beanList as $moduleName => $beanName) {
         VardefManager::loadVardef($moduleName, BeanFactory::getObjectName($moduleName));
     }
     $relationships = array();
     //Grab all the relationships from the dictionary.
     foreach ($dictionary as $key => $def) {
         if (!empty($def['relationships'])) {
             foreach ($def['relationships'] as $relKey => $relDef) {
                 if ($key == $relKey) {
                     //Relationship only entry, we need to capture everything
                     $relationships[$key] = array_merge(array('name' => $key), $def, $relDef);
                 } else {
                     $relationships[$relKey] = array_merge(array('name' => $relKey), $relDef);
                     if (!empty($relationships[$relKey]['join_table']) && empty($relationships[$relKey]['fields']) && isset($dictionary[$relationships[$relKey]['join_table']]['fields'])) {
                         $relationships[$relKey]['fields'] = $dictionary[$relationships[$relKey]['join_table']]['fields'];
                     }
                 }
             }
         }
     }
     //Save it out
     sugar_mkdir(dirname($this->getCacheFile()), null, true);
     $out = "<?php \n \$relationships=" . var_export($relationships, true) . ";";
     sugar_file_put_contents($this->getCacheFile(), $out);
     $this->relationships = $relationships;
     $buildingRelCache = false;
 }
Ejemplo n.º 7
0
 /**
  * Gets vardef info for a given module.
  *
  * @param string $moduleName The name of the module to collect vardef information about.
  * @return array The vardef's $dictonary array.
  */
 public function getVarDef($moduleName)
 {
     require_once 'data/BeanFactory.php';
     $obj = BeanFactory::getObjectName($moduleName);
     if ($obj) {
         require_once 'include/SugarObjects/VardefManager.php';
         global $dictionary;
         VardefManager::loadVardef($moduleName, $obj);
         if (isset($dictionary[$obj])) {
             $data = $dictionary[$obj];
         }
         // vardefs are missing something, for consistency let's populate some arrays
         if (!isset($data['fields'])) {
             $data['fields'] = array();
         }
         if (!isset($data['relationships'])) {
             $data['relationships'] = array();
         }
         if (!isset($data['fields'])) {
             $data['fields'] = array();
         }
     }
     // Bug 56505 - multiselect fields default value wrapped in '^' character
     if (!empty($data['fields'])) {
         $data['fields'] = $this->getMetaDataHacks()->normalizeFieldDefs($data);
     }
     if (!isset($data['relationships'])) {
         $data['relationships'] = array();
     }
     return $data;
 }
Ejemplo n.º 8
0
 function display()
 {
     $editModule = $_REQUEST['view_module'];
     if (!isset($_REQUEST['MB'])) {
         global $app_list_strings;
         $moduleNames = array_change_key_case($app_list_strings['moduleList']);
         $translatedEditModule = $moduleNames[strtolower($editModule)];
     }
     $selected_lang = !empty($_REQUEST['selected_lang']) ? $_REQUEST['selected_lang'] : $_SESSION['authenticated_user_language'];
     if (empty($selected_lang)) {
         $selected_lang = $GLOBALS['sugar_config']['default_language'];
     }
     $smarty = new Sugar_Smarty();
     global $mod_strings;
     $smarty->assign('mod_strings', $mod_strings);
     $smarty->assign('available_languages', get_languages());
     global $beanList;
     $objectName = $beanList[$editModule];
     if ($objectName == 'aCase') {
         $objectName = 'Case';
     }
     VardefManager::loadVardef($editModule, $objectName);
     global $dictionary;
     $vnames = array();
     //jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them.
     require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php';
     $parser = new ListLayoutMetaDataParser(MB_LISTVIEW, $editModule);
     foreach ($parser->getLayout() as $key => $def) {
         if (isset($def['label'])) {
             $vnames[$def['label']] = $def['label'];
         }
     }
     require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
     $variableMap = array(MB_EDITVIEW => 'EditView', MB_DETAILVIEW => 'DetailView', MB_QUICKCREATE => 'QuickCreate');
     if ($editModule == 'KBDocuments') {
         $variableMap = array();
     }
     foreach ($variableMap as $key => $value) {
         $gridLayoutMetaDataParserTemp = new GridLayoutMetaDataParser($value, $editModule);
         foreach ($gridLayoutMetaDataParserTemp->getLayout() as $panel) {
             foreach ($panel as $row) {
                 foreach ($row as $fieldArray) {
                     // fieldArray is an array('name'=>name,'label'=>label)
                     if (isset($fieldArray['label'])) {
                         $vnames[$fieldArray['label']] = $fieldArray['label'];
                     }
                 }
             }
         }
     }
     //end
     //Get Subpanel Labels:
     require_once 'include/SubPanel/SubPanel.php';
     $subList = SubPanel::getModuleSubpanels($editModule);
     foreach ($subList as $subpanel => $titleLabel) {
         $vnames[$titleLabel] = $titleLabel;
     }
     foreach ($dictionary[$objectName]['fields'] as $name => $def) {
         if (isset($def['vname'])) {
             $vnames[$def['vname']] = $def['vname'];
         }
     }
     $formatted_mod_strings = array();
     //we shouldn't set the $refresh=true here, or will lost template language mod_strings.
     //return_module_language($selected_lang, $editModule,false) : the mod_strings will be included from cache files here.
     foreach (return_module_language($selected_lang, $editModule, false) as $name => $label) {
         //#25294
         if (isset($vnames[$name]) || preg_match('/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si', $name)) {
             $formatted_mod_strings[$name] = htmlentities($label, ENT_QUOTES, 'UTF-8');
         }
     }
     //Grab everything from the custom files
     $mod_bak = $mod_strings;
     $files = array("custom/modules/{$editModule}/language/{$selected_lang}.lang.php", "custom/modules/{$editModule}/Ext/Language/{$selected_lang}.lang.ext.php");
     foreach ($files as $langfile) {
         $mod_strings = array();
         if (is_file($langfile)) {
             include $langfile;
             foreach ($mod_strings as $key => $label) {
                 $formatted_mod_strings[$key] = htmlentities($label, ENT_QUOTES, 'UTF-8');
             }
         }
     }
     $mod_strings = $mod_bak;
     ksort($formatted_mod_strings);
     $smarty->assign('MOD', $formatted_mod_strings);
     $smarty->assign('view_module', $editModule);
     $smarty->assign('APP', $GLOBALS['app_strings']);
     $smarty->assign('selected_lang', $selected_lang);
     $smarty->assign('defaultHelp', 'labelsBtn');
     $smarty->assign('assistant', array('key' => 'labels', 'group' => 'module'));
     $ajax = new AjaxCompose();
     $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
     $ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $editModule . '")');
     $ajax->addCrumb($mod_strings['LBL_LABELS'], '');
     $html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl');
     $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html);
     echo $ajax->getJavascript();
 }
Ejemplo n.º 9
0
 /**
  * Merges the fields together and stores them in $this->mergedFields
  *
  */
 protected function mergeFields()
 {
     if ($this->sugarMerge instanceof SugarMerge && is_file($this->sugarMerge->getNewPath() . 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php')) {
         require_once $this->sugarMerge->getNewPath() . 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php';
     } else {
         require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php';
     }
     $objectName = BeanFactory::getBeanName($this->module);
     VardefManager::loadVardef($this->module, $objectName);
     foreach ($this->customFields as $field => $data) {
         $fieldName = strtolower($data['loc']['row']);
         if (!empty($GLOBALS['dictionary'][$objectName]['fields'][$fieldName])) {
             $data['data'] = array_merge(ListLayoutMetaDataParser::createViewDefsByFieldDefs($GLOBALS['dictionary'][$objectName]['fields'][$fieldName]), $data['data']);
         }
         //if we have this field in both the new fields and the original fields - it has existed since the last install/upgrade
         if (isset($this->newFields[$field]) && isset($this->originalFields[$field])) {
             //if both the custom field and the original match then we take the location of the custom field since it hasn't moved
             $loc = $this->customFields[$field]['loc'];
             $loc['source'] = 'custom';
             //echo var_export($loc, true);
             //but we still merge the meta data of the three
             $this->mergedFields[$field] = array('data' => $this->mergeField($this->originalFields[$field]['data'], $this->newFields[$field]['data'], $this->customFields[$field]['data']), 'loc' => $loc);
             //if it's not set in the new fields then it was a custom field or an original field so we take the custom fields data and set the location source to custom
         } else {
             if (!isset($this->newFields[$field])) {
                 $this->mergedFields[$field] = $data;
                 $this->mergedFields[$field]['loc']['source'] = 'custom';
             } else {
                 //otherwise  the field is in both new and custom but not in the orignal so we merge the new and custom data together and take the location from the custom
                 $this->mergedFields[$field] = array('data' => $this->mergeField('', $this->newFields[$field]['data'], $this->customFields[$field]['data']), 'loc' => $this->customFields[$field]['loc']);
                 $this->mergedFields[$field]['loc']['source'] = 'custom';
                 //echo var_export($this->mergedFields[$field], true);
             }
         }
         //then we clear out the field from
         unset($this->originalFields[$field]);
         unset($this->customFields[$field]);
         unset($this->newFields[$field]);
     }
     /**
      * These are fields that were removed by the customer
      */
     foreach ($this->originalFields as $field => $data) {
         unset($this->originalFields[$field]);
         unset($this->newFields[$field]);
     }
     foreach ($this->newFields as $field => $data) {
         $data['loc']['source'] = 'new';
         $this->mergedFields[$field] = array('data' => $data['data'], 'loc' => $data['loc']);
         unset($this->newFields[$field]);
     }
 }
Ejemplo n.º 10
0
/**
 * upgradeTeamColumn
 * Helper function to create a team_set_id column and also set team_set_id column
 * to have the value of the $column_name parameter
 * 
 * @param $bean SugarBean which we are adding team_set_id column to
 * @param $column_name The name of the column containing the default team_set_id value
 */
function upgradeTeamColumn($bean, $column_name)
{
    //first let's check to ensure that the team_set_id field is defined, if not it could be the case that this is an older
    //module that does not use the SugarObjects
    if (empty($bean->field_defs['team_set_id']) && $bean->module_dir != 'Trackers') {
        //at this point we could assume that since we have a team_id defined and not a team_set_id that we need to
        //add that field and the corresponding relationships
        $object = $bean->object_name;
        $module = $bean->module_dir;
        $object_name = $object;
        $_object_name = strtolower($object_name);
        if (!empty($GLOBALS['dictionary'][$object]['table'])) {
            $table_name = $GLOBALS['dictionary'][$object]['table'];
        } else {
            $table_name = strtolower($module);
        }
        $path = 'include/SugarObjects/implements/team_security/vardefs.php';
        require $path;
        //go through each entry in the vardefs from team_security and unset anything that is already set in the core module
        //this will ensure we have the proper ordering.
        $fieldDiff = array_diff_assoc($vardefs['fields'], $GLOBALS['dictionary'][$bean->object_name]['fields']);
        $file = 'custom/Extension/modules/' . $bean->module_dir . '/Ext/Vardefs/teams.php';
        $contents = "<?php\n";
        if (!empty($fieldDiff)) {
            foreach ($fieldDiff as $key => $val) {
                $contents .= "\n\$GLOBALS['dictionary']['" . $object . "']['fields']['" . $key . "']=" . var_export_helper($val) . ";";
            }
        }
        $relationshipDiff = array_diff_assoc($vardefs['relationships'], $GLOBALS['dictionary'][$bean->object_name]['relationships']);
        if (!empty($relationshipDiff)) {
            foreach ($relationshipDiff as $key => $val) {
                $contents .= "\n\$GLOBALS['dictionary']['" . $object . "']['relationships']['" . $key . "']=" . var_export_helper($val) . ";";
            }
        }
        $indexDiff = array_diff_assoc($vardefs['indices'], $GLOBALS['dictionary'][$bean->object_name]['indices']);
        if (!empty($indexDiff)) {
            foreach ($indexDiff as $key => $val) {
                $contents .= "\n\$GLOBALS['dictionary']['" . $object . "']['indices']['" . $key . "']=" . var_export_helper($val) . ";";
            }
        }
        if ($fh = @sugar_fopen($file, 'wt')) {
            fputs($fh, $contents);
            fclose($fh);
        }
        //we have written out the teams.php into custom/Extension/modules/{$module_dir}/Ext/Vardefs/teams.php'
        //now let's merge back into vardefs.ext.php
        require_once 'ModuleInstall/ModuleInstaller.php';
        $mi = new ModuleInstaller();
        $mi->merge_files('Ext/Vardefs/', 'vardefs.ext.php');
        VardefManager::loadVardef($bean->module_dir, $bean->object_name, true);
        $bean->field_defs = $GLOBALS['dictionary'][$bean->object_name]['fields'];
    }
    if (isset($bean->field_defs['team_set_id'])) {
        //Create the team_set_id column
        $FieldArray = $GLOBALS['db']->helper->get_columns($bean->table_name);
        if (!isset($FieldArray['team_set_id'])) {
            $GLOBALS['db']->addColumn($bean->table_name, $bean->field_defs['team_set_id']);
        }
        $indexArray = $GLOBALS['db']->helper->get_indices($bean->table_name);
        $indexDef = array(array('name' => 'idx_' . strtolower($bean->table_name) . '_tmst_id', 'type' => 'index', 'fields' => array('team_set_id')));
        if (!isset($indexArray['idx_' . strtolower($bean->table_name) . '_tmst_id'])) {
            $GLOBALS['db']->addIndexes($bean->table_name, $indexDef);
        }
        //Update the table's team_set_id column to have the same values as team_id
        $GLOBALS['db']->query("UPDATE {$bean->table_name} SET team_set_id = {$column_name}");
    }
}
Ejemplo n.º 11
0
/**
 * repairSearchFields
 *
 * This method goes through the list of SearchFields files based and calls TemplateRange::repairCustomSearchFields
 * method on the files in an attempt to ensure the range search attributes are properly set in SearchFields.php.
 *
 * @param $globString String value used for glob search defaults to searching for all SearchFields.php files in modules directory
 * @param $path String value used to point to log file should logging be required.  Defaults to empty.
 *
 */
function repairSearchFields($globString = 'modules/*/metadata/SearchFields.php', $path = '')
{
    if (!empty($path)) {
        logThis('Begin repairSearchFields', $path);
    }
    require_once 'include/dir_inc.php';
    require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
    require 'include/modules.php';
    global $beanList;
    $searchFieldsFiles = glob($globString);
    foreach ($searchFieldsFiles as $file) {
        if (preg_match('/modules\\/(.*?)\\/metadata\\/SearchFields\\.php/', $file, $matches) && isset($beanList[$matches[1]])) {
            $module = $matches[1];
            $beanName = $beanList[$module];
            VardefManager::loadVardef($module, $beanName);
            if (isset($GLOBALS['dictionary'][$beanName]['fields'])) {
                if (!empty($path)) {
                    logThis('Calling TemplateRange::repairCustomSearchFields for module ' . $module, $path);
                }
                TemplateRange::repairCustomSearchFields($GLOBALS['dictionary'][$beanName]['fields'], $module);
            }
        }
    }
    if (!empty($path)) {
        logThis('End repairSearchFields', $path);
    }
}
Ejemplo n.º 12
0
 function display()
 {
     global $locale;
     $editModule = $_REQUEST['view_module'];
     $allLabels = !empty($_REQUEST['labels']) && $_REQUEST['labels'] == 'all';
     if (!isset($_REQUEST['MB'])) {
         global $app_list_strings;
         $moduleNames = array_change_key_case($app_list_strings['moduleList']);
         $translatedEditModule = $moduleNames[strtolower($editModule)];
     }
     $selected_lang = null;
     if (!empty($_REQUEST['selected_lang'])) {
         $selected_lang = $_REQUEST['selected_lang'];
     } else {
         $selected_lang = $locale->getAuthenticatedUserLanguage();
     }
     $smarty = new Sugar_Smarty();
     global $mod_strings;
     $smarty->assign('mod_strings', $mod_strings);
     $smarty->assign('available_languages', get_languages());
     $objectName = BeanFactory::getObjectName($editModule);
     VardefManager::loadVardef($editModule, $objectName);
     global $dictionary;
     $vnames = array();
     //jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them.
     $parser = ParserFactory::getParser(MB_LISTVIEW, $editModule);
     foreach ($parser->getLayout() as $key => $def) {
         if (isset($def['label'])) {
             $vnames[$def['label']] = $def['label'];
         }
     }
     require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
     $variableMap = $this->getVariableMap($editModule);
     foreach ($variableMap as $key => $value) {
         $gridLayoutMetaDataParserTemp = ParserFactory::getParser($key, $editModule);
         foreach ($gridLayoutMetaDataParserTemp->getLayout() as $panel) {
             foreach ($panel as $row) {
                 foreach ($row as $fieldArray) {
                     // fieldArray is an array('name'=>name,'label'=>label)
                     if (isset($fieldArray['label'])) {
                         $vnames[$fieldArray['label']] = $fieldArray['label'];
                     }
                 }
             }
         }
     }
     //end
     //Get Subpanel Labels:
     require_once 'include/SubPanel/SubPanel.php';
     $subList = SubPanel::getModuleSubpanels($editModule);
     foreach ($subList as $subpanel => $titleLabel) {
         $vnames[$titleLabel] = $titleLabel;
     }
     foreach ($dictionary[$objectName]['fields'] as $name => $def) {
         if (isset($def['vname'])) {
             $vnames[$def['vname']] = $def['vname'];
         }
     }
     $formatted_mod_strings = array();
     // we shouldn't set the $refresh=true here, or will lost template language
     // mod_strings.
     // return_module_language($selected_lang, $editModule,false) :
     // the mod_strings will be included from cache files here.
     foreach (return_module_language($selected_lang, $editModule, false) as $name => $label) {
         //#25294
         if ($allLabels || isset($vnames[$name]) || preg_match('/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si', $name)) {
             // Bug 58174 - Escaped labels are sent to the client escaped
             // even in the label editor in studio
             $formatted_mod_strings[$name] = html_entity_decode($label, null, 'UTF-8');
         }
     }
     //Grab everything from the custom files
     $mod_bak = $mod_strings;
     $files = array("custom/modules/{$editModule}/language/{$selected_lang}.lang.php", "custom/modules/{$editModule}/Ext/Language/{$selected_lang}.lang.ext.php");
     foreach ($files as $langfile) {
         $mod_strings = array();
         if (is_file($langfile)) {
             include $langfile;
             foreach ($mod_strings as $key => $label) {
                 // Bug 58174 - Escaped labels are sent to the client escaped
                 // even in the label editor in studio
                 $formatted_mod_strings[$key] = html_entity_decode($label, null, 'UTF-8');
             }
         }
     }
     $mod_strings = $mod_bak;
     ksort($formatted_mod_strings);
     $smarty->assign('MOD', $formatted_mod_strings);
     $smarty->assign('view_module', $editModule);
     $smarty->assign('APP', $GLOBALS['app_strings']);
     $smarty->assign('selected_lang', $selected_lang);
     $smarty->assign('defaultHelp', 'labelsBtn');
     $smarty->assign('assistant', array('key' => 'labels', 'group' => 'module'));
     $smarty->assign('labels_choice', $mod_strings['labelTypes']);
     $smarty->assign('labels_current', $allLabels ? "all" : "");
     $ajax = new AjaxCompose();
     $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
     $ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $editModule . '")');
     $ajax->addCrumb($mod_strings['LBL_LABELS'], '');
     $html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl');
     $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html);
     echo $ajax->getJavascript();
 }
Ejemplo n.º 13
0
 function display()
 {
     $smarty = new Sugar_Smarty();
     global $mod_strings;
     $bak_mod_strings = $mod_strings;
     $smarty->assign('mod_strings', $mod_strings);
     $module_name = $_REQUEST['view_module'];
     global $current_language;
     $module_strings = return_module_language($current_language, $module_name);
     $fieldsData = array();
     $customFieldsData = array();
     //use fieldTypes variable to map field type to displayed field type
     $fieldTypes = $mod_strings['fieldTypes'];
     //add datetimecombo type field from the vardef overrides to point to Datetime type
     $fieldTypes['datetime'] = $fieldTypes['datetimecombo'];
     if (!isset($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
         //$this->loadPackageHelp($module_name);
         $studioClass = new stdClass();
         $studioClass->name = $module_name;
         $objectName = BeanFactory::getObjectName($module_name);
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $f = array($mod_strings['LBL_HCUSTOM'] => array(), $mod_strings['LBL_HDEFAULT'] => array());
         foreach ($dictionary[$objectName]['fields'] as $def) {
             if (!$this->isValidStudioField($def)) {
                 continue;
             }
             if (!empty($def['vname'])) {
                 $def['label'] = translate($def['vname'], $module_name);
             } elseif (!empty($def['label'])) {
                 $def['label'] = translate($def['label'], $module_name);
             } else {
                 $def['label'] = $def['name'];
             }
             //Custom relate fields will have a non-db source, but custom_module set
             if (isset($def['source']) && $def['source'] == 'custom_fields' || isset($def['custom_module'])) {
                 $f[$mod_strings['LBL_HCUSTOM']][$def['name']] = $def;
                 $def['custom'] = true;
             } else {
                 $f[$mod_strings['LBL_HDEFAULT']][$def['name']] = $def;
                 $def['custom'] = false;
             }
             $def['type'] = isset($fieldTypes[$def['type']]) ? $fieldTypes[$def['type']] : ucfirst($def['type']);
             $fieldsData[] = $def;
             $customFieldsData[$def['name']] = $def['custom'];
         }
         $studioClass->mbvardefs->vardefs['fields'] = $f;
         $smarty->assign('module', $studioClass);
         $package = new stdClass();
         $package->name = '';
         $smarty->assign('package', $package);
         global $current_user;
         $sortPreferences = $current_user->getPreference('fieldsTableColumn', 'ModuleBuilder');
         $smarty->assign('sortPreferences', $sortPreferences);
         $smarty->assign('fieldsData', getJSONobj()->encode($fieldsData));
         $smarty->assign('customFieldsData', getJSONobj()->encode($customFieldsData));
         $smarty->assign('studio', true);
         $ajax = new AjaxCompose();
         $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
         $ajax->addCrumb(translate($module_name), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $module_name . '")');
         $ajax->addCrumb($mod_strings['LBL_FIELDS'], '');
         $ajax->addSection('center', $mod_strings['LBL_EDIT_FIELDS'], $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
         $_REQUEST['field'] = '';
         echo $ajax->getJavascript();
     } else {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $mb->getPackage($_REQUEST['view_package']);
         $package = $mb->packages[$_REQUEST['view_package']];
         $package->getModule($module_name);
         $this->mbModule = $package->modules[$module_name];
         // We need the type to determine true custom fields
         $moduleType = $this->mbModule->getModuleType();
         $this->loadPackageHelp($module_name);
         $this->mbModule->getVardefs(true);
         $this->mbModule->mbvardefs->vardefs['fields'] = array_reverse($this->mbModule->mbvardefs->vardefs['fields'], true);
         $loadedFields = array();
         if (file_exists($this->mbModule->path . '/language/' . $current_language . '.lang.php')) {
             include $this->mbModule->path . '/language/' . $current_language . '.lang.php';
             $this->mbModule->setModStrings($current_language, $mod_strings);
         } elseif (file_exists($this->mbModule->path . '/language/en_us.lang.php')) {
             include $this->mbModule->path . '/language/en_us.lang.php';
             $this->mbModule->setModStrings('en_us', $mod_strings);
         }
         foreach ($this->mbModule->mbvardefs->vardefs['fields'] as $k => $v) {
             if ($k != $this->mbModule->name) {
                 foreach ($v as $field => $def) {
                     if (in_array($field, array_keys($this->mbModule->mbvardefs->vardefs['fields'][$this->mbModule->name]))) {
                         $this->mbModule->mbvardefs->vardefs['fields'][$k][$field] = $this->mbModule->mbvardefs->vardefs['fields'][$this->mbModule->name][$field];
                         unset($this->mbModule->mbvardefs->vardefs['fields'][$this->mbModule->name][$field]);
                     }
                 }
             }
         }
         foreach ($this->mbModule->mbvardefs->vardefs['fields'] as $k => $v) {
             if ($k != $module_name) {
                 $titleLBL[$k] = translate("LBL_" . strtoupper($k), 'ModuleBuilder');
             } else {
                 $titleLBL[$k] = $k;
             }
             foreach ($v as $field => $def) {
                 if (isset($loadedFields[$field])) {
                     unset($this->mbModule->mbvardefs->vardefs['fields'][$k][$field]);
                 } else {
                     $this->mbModule->mbvardefs->vardefs['fields'][$k][$field]['label'] = isset($def['vname']) && isset($this->mbModule->mblanguage->strings[$current_language . '.lang.php'][$def['vname']]) ? $this->mbModule->mblanguage->strings[$current_language . '.lang.php'][$def['vname']] : $field;
                     // It's only custom if the module name is the same as the key AND not the same as the module type
                     $custom = $k == $this->mbModule->name && $this->mbModule->name != $moduleType;
                     $customFieldsData[$field] = $custom ? true : false;
                     $loadedFields[$field] = true;
                     $type = $this->mbModule->mbvardefs->vardefs['fields'][$k][$field]['type'];
                     $this->mbModule->mbvardefs->vardefs['fields'][$k][$field]['type'] = isset($fieldTypes[$type]) ? $fieldTypes[$type] : ucfirst($type);
                     if ($this->isValidStudioField($this->mbModule->mbvardefs->vardefs['fields'][$k][$field])) {
                         $fieldsData[] = $this->mbModule->mbvardefs->vardefs['fields'][$k][$field];
                     }
                 }
             }
         }
         $this->mbModule->mbvardefs->vardefs['fields'][$module_name] = $this->cullFields($this->mbModule->mbvardefs->vardefs['fields'][$module_name]);
         $smarty->assign('fieldsData', getJSONobj()->encode($fieldsData));
         $smarty->assign('customFieldsData', getJSONobj()->encode($customFieldsData));
         global $current_user;
         $sortPreferences = $current_user->getPreference('fieldsTableColumn', 'ModuleBuilder');
         $smarty->assign('sortPreferences', $sortPreferences);
         $smarty->assign('title', $titleLBL);
         $smarty->assign('package', $package);
         $smarty->assign('module', $this->mbModule);
         $smarty->assign('editLabelsMb', '1');
         $smarty->assign('studio', false);
         $ajax = new AjaxCompose();
         $ajax->addCrumb($bak_mod_strings['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
         $ajax->addCrumb($package->name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $package->name . '")');
         $ajax->addCrumb($module_name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $package->name . '&view_module=' . $module_name . '")');
         $ajax->addCrumb($bak_mod_strings['LBL_FIELDS'], '');
         $ajax->addSection('center', $bak_mod_strings["LBL_FIELDS"], $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
         $_REQUEST['field'] = '';
         echo $ajax->getJavascript();
     }
 }
Ejemplo n.º 14
0
 /**
  * Registration of $dictionary in global scope
  *
  * @static
  * @return bool is variable setuped or not
  */
 protected static function setUp_dictionary()
 {
     self::setUp('beanFiles');
     self::setUp('beanList');
     self::$registeredVars['dictionary'] = true;
     global $dictionary;
     $dictionary = array();
     $moduleInstaller = new ModuleInstaller();
     $moduleInstaller->silent = true;
     $moduleInstaller->rebuild_tabledictionary();
     require 'modules/TableDictionary.php';
     foreach ($GLOBALS['beanList'] as $k => $v) {
         VardefManager::loadVardef($k, $v);
     }
     return true;
 }
Ejemplo n.º 15
0
 static function findFieldAttributes($attributes = array(), $modules = null, $byModule = false, $byType = false)
 {
     $fields = array();
     if (empty($modules)) {
         $modules = VardefBrowser::getModules();
     }
     foreach ($modules as $module) {
         if (!empty($GLOBALS['beanList'][$module])) {
             $object = $GLOBALS['beanList'][$module];
             if ($object == 'aCase') {
                 $object = 'Case';
             }
             VardefManager::loadVardef($module, $object);
             if (empty($GLOBALS['dictionary'][$object]['fields'])) {
                 continue;
             }
             foreach ($GLOBALS['dictionary'][$object]['fields'] as $name => $def) {
                 $fieldAttributes = !empty($attributes) ? $attributes : array_keys($def);
                 foreach ($fieldAttributes as $k) {
                     if (isset($def[$k])) {
                         $v = var_export($def[$k], true);
                         $key = is_array($def[$k]) ? null : $def[$k];
                         if ($k == 'type') {
                             if (isset($def['dbType'])) {
                                 $v = var_export($def['dbType'], true);
                             }
                         }
                         if ($byModule) {
                             $fields[$module][$object][$def['type']][$k][$key] = $v;
                         } else {
                             if ($byType) {
                                 $fields[$def['type']][$k][$key] = $v;
                             } else {
                                 if (!is_array($def[$k])) {
                                     if (isset($fields[$k][$key])) {
                                         $fields[$k][$key]['refs']++;
                                     } else {
                                         $fields[$k][$key] = array('attribute' => $v, 'refs' => 1);
                                     }
                                 } else {
                                     $fields[$k]['_array'][] = $def[$k];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $fields;
 }
Ejemplo n.º 16
0
 function fetch($ac = false)
 {
     $fv = new FieldViewer();
     if (empty($_REQUEST['field']) && !empty($_REQUEST['name'])) {
         $_REQUEST['field'] = $_REQUEST['name'];
     }
     $field_name = '';
     if (!empty($this->view_object_map['field_name'])) {
         $field_name = $this->view_object_map['field_name'];
     } elseif (!empty($_REQUEST['field'])) {
         $field_name = $_REQUEST['field'];
     }
     // If this is a new field mark it as such
     $isNew = empty($field_name) || !empty($_REQUEST['is_new']);
     $action = 'saveField';
     // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
     // fields we override this so don't create a new dynamic field instead of updating the existing field
     $isClone = false;
     if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] && strcmp($field_name, "name") != 0) {
         $isClone = true;
     }
     /*
     $field_types =  array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
     		'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
     		'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
     */
     $field_types = $GLOBALS['mod_strings']['fieldTypes'];
     //bug 22264: Field name must not be an SQL keyword.
     $field_name_exceptions = array_merge(array_keys($GLOBALS['db']->getReservedWords()), array('ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID'));
     //C.L. - Add support to mark related module id columns as reserved keywords
     require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
     $relatedModules = array_keys(DeployedRelationships::findRelatableModules());
     global $beanList, $current_language;
     foreach ($relatedModules as $relModule) {
         if (isset($beanList[$relModule])) {
             $field_name_exceptions[] = strtoupper($beanList[$relModule]) . '_ID';
         }
     }
     if (empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
         $moduleName = $_REQUEST['view_module'];
         $objectName = BeanFactory::getObjectName($moduleName);
         $module = BeanFactory::getBean($moduleName);
         VardefManager::loadVardef($moduleName, $objectName, true);
         global $dictionary;
         if (empty($module->mbvardefs)) {
             $module->mbvardefs = new stdClass();
         }
         $module->mbvardefs->vardefs = $dictionary[$objectName];
         $module->name = $moduleName;
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         if ($isClone) {
             unset($vardef['name']);
         }
         // If this is a new field but we are loading this form a second time,
         // like from coming back from a dropdown create on a new field, then
         // keep the 'name' field open to allow the create field process to
         // continue like normal
         if (empty($vardef['name']) || $isNew) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } elseif (isset($vardef['custom_module'])) {
             $fv->ss->assign('hideLevel', 2);
         } else {
             $action = 'saveSugarField';
             // tyoung - for OOB fields we currently only support modifying the label
             $fv->ss->assign('hideLevel', 3);
         }
         if ($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime') {
             $vardef['type'] = 'datetimecombo';
         }
         require_once 'modules/DynamicFields/FieldCases.php';
         $tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
         $tf->module = $module;
         $tf->populateFromRow($vardef);
         $vardef = array_merge($vardef, $tf->get_field_def());
         //          $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
         //Check if autoincrement fields are allowed
         $allowAutoInc = true;
         $enumFields = array();
         foreach ($module->field_defs as $field => $def) {
             if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) {
                 $allowAutoInc = false;
                 continue;
             }
             if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
                 if (!empty($def['studio']) && $def['studio'] == "false") {
                     continue;
                 }
                 //bug51866
                 $enumFields[$field] = translate($def['vname'], $moduleName);
                 if (substr($enumFields[$field], -1) == ":") {
                     $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
                 }
             }
         }
         $fv->ss->assign('allowAutoInc', $allowAutoInc);
         $GLOBALS['log']->warn('view.modulefield: hidelevel ' . $fv->ss->get_template_vars('hideLevel') . " " . print_r($vardef, true));
         if (!empty($vardef['vname'])) {
             $fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8'));
         }
         $fv->ss->assign('module', $module);
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $edit_or_add = 'editField';
     } else {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $moduleName = $_REQUEST['view_module'];
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $moduleName);
         $package =& $mb->packages[$_REQUEST['view_package']];
         $module->getVardefs();
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         if ($isClone) {
             unset($vardef['name']);
         }
         if (empty($vardef['name'])) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } else {
             if (!empty($module->mbvardefs->vardef['fields'][$vardef['name']])) {
                 $fv->ss->assign('hideLevel', 1);
             } elseif (isset($vardef['custom_module'])) {
                 $fv->ss->assign('hideLevel', 2);
             } else {
                 $fv->ss->assign('hideLevel', 3);
                 // tyoung bug 17350 - effectively mark template derived fields as readonly
             }
         }
         require_once 'modules/DynamicFields/FieldCases.php';
         $tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
         $tf->module = $module;
         $tf->populateFromRow($vardef);
         $vardef = array_merge($vardef, $tf->get_field_def());
         $fv->ss->assign('module', $module);
         $fv->ss->assign('package', $package);
         $fv->ss->assign('MB', '1');
         if (isset($vardef['vname'])) {
             $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us', $vardef['vname']), ENT_QUOTES, 'UTF-8'));
         }
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $enumFields = array();
         if (!empty($module->mbvardefs->vardefs['fields'])) {
             foreach ($module->mbvardefs->vardefs['fields'] as $field => $def) {
                 if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
                     $enumFields[$field] = isset($module->mblanguage->strings[$current_language][$def['vname']]) ? $this->mbModule->mblanguage->strings[$current_language][$def['vname']] : translate($field);
                     if (substr($enumFields[$field], -1) == ":") {
                         $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
                     }
                 }
             }
         }
         $edit_or_add = 'mbeditField';
     }
     if ($_REQUEST['action'] == 'RefreshField') {
         require_once 'modules/DynamicFields/FieldCases.php';
         $field = get_widget($_POST['type']);
         $field->populateFromPost();
         $vardef = $field->get_field_def();
         $vardef['options'] = $_REQUEST['new_dropdown'];
         $fv->ss->assign('lbl_value', htmlentities($_REQUEST['labelValue'], ENT_QUOTES, 'UTF-8'));
     }
     foreach (array("formula", "default", "comments", "help", "visiblityGrid") as $toEscape) {
         if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) {
             $vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8');
         }
     }
     if (!empty($vardef['studio']['no_duplicate']) || $field_name === 'name' || $field_name === 'parent_type' || $field_name === 'parent_id' || $field_name === 'parent_name' || isset($vardef['type']) && $vardef['type'] === 'name') {
         $fv->ss->assign('no_duplicate', true);
     }
     $fv->ss->assign('action', $action);
     $fv->ss->assign('isClone', $isClone ? 1 : 0);
     $fv->ss->assign('isNew', $isNew);
     $fv->ss->assign("module_dd_fields", $enumFields);
     $json = getJSONobj();
     $fv->ss->assign('field_name_exceptions', $json->encode($field_name_exceptions));
     ksort($field_types);
     $fv->ss->assign('field_types', $field_types);
     $ftsEngineType = getFTSEngineType();
     $usa = new UnifiedSearchAdvanced();
     if (SugarSearchEngineFactory::getInstance()->isTypeFtsEnabled($vardef['type']) && (!empty($_REQUEST['view_package']) && $_REQUEST['view_package'] != 'studio' || $usa->shouldShowModule($moduleName))) {
         $ftsBoostOptions = getFTSBoostOptions($ftsEngineType . '_boost_options');
         $fv->ss->assign('fts_options', $ftsBoostOptions);
         $fv->ss->assign('show_fts', true);
     } else {
         $fv->ss->assign('show_fts', false);
     }
     //Ensure certain field types always have correct formula return types for validation.
     if (!empty($vardef['type'])) {
         switch ($vardef['type']) {
             case 'date':
             case 'datetime':
                 $fv->ss->assign('calcFieldType', 'date');
                 break;
             case 'bool':
                 $fv->ss->assign('calcFieldType', 'boolean');
                 break;
             default:
                 $fv->ss->assign('calcFieldType', '');
                 break;
         }
     }
     $fv->ss->assign('importable_options', $GLOBALS['app_list_strings']['custom_fields_importable_dom']);
     $fv->ss->assign('duplicate_merge_options', $GLOBALS['app_list_strings']['custom_fields_merge_dup_dom']);
     $triggers = array();
     $existing_field_names = array();
     foreach ($module->mbvardefs->vardefs['fields'] as $field) {
         if ($field['type'] == 'enum' || $field['type'] == 'multienum') {
             $triggers[] = $field['name'];
         }
         if (!isset($field['source']) || $field['source'] != 'non-db') {
             if (preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) {
                 $existing_field_names[] = strtoupper($matches[1]);
             }
         }
     }
     $fv->ss->assign('triggers', $triggers);
     $fv->ss->assign('existing_field_names', $json->encode($existing_field_names));
     $fv->ss->assign('mod_strings', $GLOBALS['mod_strings']);
     // jchi #24880
     if (!isset($vardef['reportable'])) {
         $vardef['reportable'] = 1;
     }
     // end
     $layout = $fv->getLayout($vardef);
     $fv->ss->assign('fieldLayout', $layout);
     if (empty($vardef['type'])) {
         $vardef['type'] = 'varchar';
     }
     $fv->ss->assign('vardef', $vardef);
     if (empty($_REQUEST['field'])) {
         $edit_or_add = 'addField';
     }
     $fv->ss->assign('help_group', $edit_or_add);
     $body = $this->fetchTemplate($fv, 'modules/ModuleBuilder/tpls/MBModule/field.tpl');
     $ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR', 'ModuleBuilder'), $body);
     return $ac;
 }
Ejemplo n.º 17
0
 public function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     // Bug 56789 - Set the client from the view to ensure the proper viewdef file
     $client = MetaDataFiles::getClientByView($_REQUEST['view']);
     if (isModuleBWC($_REQUEST['view_module'])) {
         $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $client);
     } else {
         $client = empty($client) ? 'base' : $client;
         $parser = new SidecarFilterLayoutMetaDataParser($_REQUEST['view_module'], $packageName, $client);
     }
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }
Ejemplo n.º 18
0
 function fetch($ac = false)
 {
     $fv = new FieldViewer();
     if (empty($_REQUEST['field']) && !empty($_REQUEST['name'])) {
         $_REQUEST['field'] = $_REQUEST['name'];
     }
     $field_name = '';
     if (!empty($this->view_object_map['field_name'])) {
         $field_name = $this->view_object_map['field_name'];
     } elseif (!empty($_REQUEST['field'])) {
         $field_name = $_REQUEST['field'];
     } else {
         $field_name = '';
     }
     $action = 'saveField';
     // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
     // fields we override this so don't create a new dynamic field instead of updating the existing field
     $isClone = false;
     if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone']) {
         $isClone = true;
     }
     /*
     $field_types =  array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
     		'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
     		'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
     */
     $field_types = $GLOBALS['mod_strings']['fieldTypes'];
     $field_name_exceptions = array('ADD', 'EXCEPT', 'PERCENT', 'ALL', 'EXEC', 'PLAN', 'ALTER', 'EXECUTE', 'PRECISION', 'AND', 'EXISTS', 'PRIMARY', 'ANY', 'EXIT', 'PRINT', 'AS', 'FETCH', 'PROC', 'ASC', 'FILE', 'PROCEDURE', 'AUTHORIZATION', 'FILLFACTOR', 'PUBLIC', 'BACKUP', 'FOR', 'RAISERROR', 'BEGIN', 'FOREIGN', 'READ', 'BETWEEN', 'FREETEXT', 'READTEXT', 'BREAK', 'FREETEXTTABLE', 'RECONFIGURE', 'BROWSE', 'FROM', 'REFERENCES', 'BULK', 'FULL', 'REPLICATION', 'BY', 'FUNCTION', 'RESTORE', 'CASCADE', 'GOTO', 'RESTRICT', 'CASE', 'GRANT', 'RETURN', 'CHECK', 'GROUP', 'REVOKE', 'CHECKPOINT', 'HAVING', 'RIGHT', 'CLOSE', 'HOLDLOCK', 'ROLLBACK', 'CLUSTERED', 'IDENTITY', 'ROWCOUNT', 'COALESCE', 'IDENTITY_INSERT', 'ROWGUIDCOL', 'COLLATE', 'IDENTITYCOL', 'RULE', 'COLUMN', 'IF', 'SAVE', 'COMMIT', 'IN', 'SCHEMA', 'COMPUTE', 'INDEX', 'SELECT', 'CONSTRAINT', 'INNER', 'SESSION_USER', 'CONTAINS', 'INSERT', 'SET', 'CONTAINSTABLE', 'INTERSECT', 'SETUSER', 'CONTINUE', 'INTO', 'SHUTDOWN', 'CONVERT', 'IS', 'SOME', 'CREATE', 'JOIN', 'STATISTICS', 'CROSS', 'KEY', 'SYSTEM_USER', 'CURRENT', 'KILL', 'TABLE', 'CURRENT_DATE', 'LEFT', 'TEXTSIZE', 'CURRENT_TIME', 'LIKE', 'THEN', 'CURRENT_TIMESTAMP', 'LINENO', 'TO', 'CURRENT_USER', 'LOAD', 'TOP', 'CURSOR', 'NATIONAL', 'TRAN', 'DATABASE', 'NOCHECK', 'TRANSACTION', 'DBCC', 'NONCLUSTERED', 'TRIGGER', 'DEALLOCATE', 'NOT', 'TRUNCATE', 'DECLARE', 'NULL', 'TSEQUAL', 'DEFAULT', 'NULLIF', 'UNION', 'DELETE', 'OF', 'UNIQUE', 'DENY', 'OFF', 'UPDATE', 'DESC', 'OFFSETS', 'UPDATETEXT', 'DISK', 'ON', 'USE', 'DISTINCT', 'OPEN', 'USER', 'DISTRIBUTED', 'OPENCONNECTOR', 'VALUES', 'DOUBLE', 'OPENQUERY', 'VARYING', 'DROP', 'OPENROWSET', 'VIEW', 'DUMMY', 'OPENXML', 'WAITFOR', 'DUMP', 'OPTION', 'WHEN', 'ELSE', 'OR', 'WHERE', 'END', 'ORDER', 'WHILE', 'ERRLVL', 'OUTER', 'WITH', 'ESCAPE', 'OVER', 'WRITETEXT', 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN', 'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE', 'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', 'DATE', 'VARCHAR', 'VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'NUMBER', 'PLS_INTEGER', 'BINARY_INTEGER', 'LONG', 'TIMESTAMP', 'INTERVAL', 'RAW', 'ROWID', 'UROWID', 'MLSLABEL', 'CLOB', 'NCLOB', 'BLOB', 'BFILE', 'XMLTYPE');
     if (!isset($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio' || empty($_REQUEST['view_package'])) {
         $module = new stdClass();
         $moduleName = $_REQUEST['view_module'];
         global $beanList;
         $objectName = $beanList[$moduleName];
         if ($objectName == 'aCase') {
             // Bug 17614 - renamed aCase as Case in vardefs for backwards compatibililty with 451 modules
             $objectName = 'Case';
         }
         VardefManager::loadVardef($moduleName, $objectName);
         global $dictionary;
         $module->mbvardefs->vardefs = $dictionary[$objectName];
         //          $GLOBALS['log']->debug('vardefs from dictionary = '.print_r($module->mbvardefs->vardefs,true));
         $module->name = $moduleName;
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         //          $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
         if ($isClone) {
             unset($vardef['name']);
         }
         if (empty($vardef['name'])) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } elseif (isset($vardef['custom_module'])) {
             $fv->ss->assign('hideLevel', 2);
         } else {
             $action = 'saveLabel';
             // tyoung - for OOB fields we currently only support modifying the label
             $fv->ss->assign('hideLevel', 10);
         }
         $GLOBALS['log']->warn('view.modulefield: hidelevel ' . $fv->ss->get_template_vars('hideLevel') . " " . print_r($vardef, true));
         if (!empty($vardef['vname'])) {
             $fv->ss->assign('lbl_value', translate($vardef['vname'], $moduleName));
         }
         //$package = new stdClass;
         //$package->name = 'studio';
         //$fv->ss->assign('package', $package);
         $fv->ss->assign('module', $module);
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $edit_or_add = 'editField';
     } else {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
         $package =& $mb->packages[$_REQUEST['view_package']];
         $module->getVardefs();
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         if ($isClone) {
             unset($vardef['name']);
         }
         if (empty($vardef['name'])) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } else {
             if (!empty($module->mbvardefs->vardef['fields'][$vardef['name']])) {
                 $fv->ss->assign('hideLevel', 1);
             } elseif (isset($vardef['custom_module'])) {
                 $fv->ss->assign('hideLevel', 2);
             } else {
                 $action = 'saveLabel';
                 // tyoung - for template fields we currently only support modifying the label
                 $fv->ss->assign('hideLevel', 10);
                 // tyoung bug 17350 - effectively mark template derived fields as readonly
             }
         }
         $fv->ss->assign('module', $module);
         $fv->ss->assign('package', $package);
         $fv->ss->assign('MB', '1');
         if (isset($vardef['vname'])) {
             $fv->ss->assign('lbl_value', $module->getLabel('en_us', $vardef['vname']));
         }
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $edit_or_add = 'mbeditField';
     }
     if ($_REQUEST['action'] == 'RefreshField') {
         require_once 'modules/DynamicFields/FieldCases.php';
         $field = get_widget($_POST['type']);
         $field->populateFromPost();
         $vardef = $field->get_field_def();
         $vardef['options'] = $_REQUEST['new_dropdown'];
         $fv->ss->assign('lbl_value', $_REQUEST['labelValue']);
     }
     if (!empty($vardef['formula'])) {
         $vardef['formula'] = htmlspecialchars($vardef['formula']);
     }
     $fv->ss->assign('action', $action);
     $fv->ss->assign('isClone', $isClone ? 1 : 0);
     $json = getJSONobj();
     $fv->ss->assign('field_name_exceptions', $json->encode($field_name_exceptions));
     ksort($field_types);
     $fv->ss->assign('field_types', $field_types);
     $fv->ss->assign('importable_options', $GLOBALS['app_list_strings']['custom_fields_importable_dom']);
     $fv->ss->assign('duplicate_merge_options', $GLOBALS['app_list_strings']['custom_fields_merge_dup_dom']);
     $triggers = array();
     foreach ($module->mbvardefs->vardefs['fields'] as $field) {
         if ($field['type'] == 'enum' || $field['type'] == 'multienum') {
             $triggers[] = $field['name'];
         }
     }
     $fv->ss->assign('triggers', $triggers);
     $fv->ss->assign('mod_strings', $GLOBALS['mod_strings']);
     // jchi #24880
     // end
     $layout = $fv->getLayout($vardef);
     $fv->ss->assign('fieldLayout', $layout);
     if (empty($vardef['type'])) {
         $vardef['type'] = 'varchar';
     }
     $fv->ss->assign('vardef', $vardef);
     if (empty($_REQUEST['field'])) {
         $edit_or_add = 'addField';
     }
     $fv->ss->assign('help_group', $edit_or_add);
     $body = $fv->ss->fetch('modules/ModuleBuilder/tpls/MBModule/field.tpl');
     $ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR', 'ModuleBuilder'), $body);
     return $ac;
 }
Ejemplo n.º 19
0
 function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php';
     $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName);
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }
Ejemplo n.º 20
0
 function fetch($ac = false)
 {
     $fv = new FieldViewer();
     if (empty($_REQUEST['field']) && !empty($_REQUEST['name'])) {
         $_REQUEST['field'] = $_REQUEST['name'];
     }
     $field_name = '';
     if (!empty($this->view_object_map['field_name'])) {
         $field_name = $this->view_object_map['field_name'];
     } elseif (!empty($_REQUEST['field'])) {
         $field_name = $_REQUEST['field'];
     } else {
         $field_name = '';
     }
     $action = 'saveField';
     // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
     // fields we override this so don't create a new dynamic field instead of updating the existing field
     $isClone = false;
     if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] && strcmp($field_name, "name") != 0) {
         $isClone = true;
     }
     /*
     $field_types =  array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
     		'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
     		'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
     */
     $field_types = $GLOBALS['mod_strings']['fieldTypes'];
     if (isset($field_types['encrypt'])) {
         unset($field_types['encrypt']);
     }
     $field_name_exceptions = array('ADD', 'EXCEPT', 'PERCENT', 'ALL', 'EXEC', 'PLAN', 'ALTER', 'EXECUTE', 'PRECISION', 'AND', 'EXISTS', 'PRIMARY', 'ANY', 'EXIT', 'PRINT', 'AS', 'FETCH', 'PROC', 'ASC', 'FILE', 'PROCEDURE', 'AUTHORIZATION', 'FILLFACTOR', 'PUBLIC', 'BACKUP', 'FOR', 'RAISERROR', 'BEGIN', 'FOREIGN', 'READ', 'BETWEEN', 'FREETEXT', 'READTEXT', 'BREAK', 'FREETEXTTABLE', 'RECONFIGURE', 'BROWSE', 'FROM', 'REFERENCES', 'BULK', 'FULL', 'REPLICATION', 'BY', 'FUNCTION', 'RESTORE', 'CASCADE', 'GOTO', 'RESTRICT', 'CASE', 'GRANT', 'RETURN', 'CHECK', 'GROUP', 'REVOKE', 'CHECKPOINT', 'HAVING', 'RIGHT', 'CLOSE', 'HOLDLOCK', 'ROLLBACK', 'CLUSTERED', 'IDENTITY', 'ROWCOUNT', 'COALESCE', 'IDENTITY_INSERT', 'ROWGUIDCOL', 'COLLATE', 'IDENTITYCOL', 'RULE', 'COLUMN', 'IF', 'SAVE', 'COMMIT', 'IN', 'SCHEMA', 'COMPUTE', 'INDEX', 'SELECT', 'CONSTRAINT', 'INNER', 'SESSION_USER', 'CONTAINS', 'INSERT', 'SET', 'CONTAINSTABLE', 'INTERSECT', 'SETUSER', 'CONTINUE', 'INTO', 'SHUTDOWN', 'CONVERT', 'IS', 'SOME', 'CREATE', 'JOIN', 'STATISTICS', 'CROSS', 'KEY', 'SYSTEM_USER', 'CURRENT', 'KILL', 'TABLE', 'CURRENT_DATE', 'LEFT', 'TEXTSIZE', 'CURRENT_TIME', 'LIKE', 'THEN', 'CURRENT_TIMESTAMP', 'LINENO', 'TO', 'CURRENT_USER', 'LOAD', 'TOP', 'CURSOR', 'NATIONAL', 'TRAN', 'DATABASE', 'NOCHECK', 'TRANSACTION', 'DBCC', 'NONCLUSTERED', 'TRIGGER', 'DEALLOCATE', 'NOT', 'TRUNCATE', 'DECLARE', 'NULL', 'TSEQUAL', 'DEFAULT', 'NULLIF', 'UNION', 'DELETE', 'OF', 'UNIQUE', 'DENY', 'OFF', 'UPDATE', 'DESC', 'OFFSETS', 'UPDATETEXT', 'DISK', 'ON', 'USE', 'DISTINCT', 'OPEN', 'USER', 'DISTRIBUTED', 'OPENCONNECTOR', 'VALUES', 'DOUBLE', 'OPENQUERY', 'VARYING', 'DROP', 'OPENROWSET', 'VIEW', 'DUMMY', 'OPENXML', 'WAITFOR', 'DUMP', 'OPTION', 'WHEN', 'ELSE', 'OR', 'WHERE', 'END', 'ORDER', 'WHILE', 'ERRLVL', 'OUTER', 'WITH', 'ESCAPE', 'OVER', 'WRITETEXT', 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN', 'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE', 'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', 'DATE', 'VARCHAR', 'VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'NUMBER', 'PLS_INTEGER', 'BINARY_INTEGER', 'LONG', 'TIMESTAMP', 'INTERVAL', 'RAW', 'ROWID', 'UROWID', 'MLSLABEL', 'CLOB', 'NCLOB', 'BLOB', 'BFILE', 'XMLTYPE', 'ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID');
     //C.L. - Add support to mark related module id columns as reserved keywords
     require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
     $relatedModules = array_keys(DeployedRelationships::findRelatableModules());
     global $beanList, $current_language;
     foreach ($relatedModules as $relModule) {
         if (isset($beanList[$relModule])) {
             $field_name_exceptions[] = strtoupper($beanList[$relModule]) . '_ID';
         }
     }
     if (empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
         $moduleName = $_REQUEST['view_module'];
         $objectName = BeanFactory::getObjectName($moduleName);
         $module = BeanFactory::getBean($moduleName);
         VardefManager::loadVardef($moduleName, $objectName, true);
         global $dictionary;
         // Fix for issue #1177 - when trying to add or edit fields in a module an error message is shown:
         // "Warning: Creating default object from empty value"
         if (!isset($module->mbvardefs) || is_null($module->mbvardefs)) {
             $module->mbvardefs = new stdClass();
         }
         $module->mbvardefs->vardefs = $dictionary[$objectName];
         $module->name = $moduleName;
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         if ($isClone) {
             unset($vardef['name']);
         }
         if (empty($vardef['name'])) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } elseif (isset($vardef['custom_module'])) {
             $fv->ss->assign('hideLevel', 2);
         } else {
             $action = 'saveSugarField';
             // tyoung - for OOB fields we currently only support modifying the label
             $fv->ss->assign('hideLevel', 3);
         }
         if ($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime') {
             $vardef['type'] = 'datetimecombo';
         }
         require_once 'modules/DynamicFields/FieldCases.php';
         $tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
         $tf->module = $module;
         $tf->populateFromRow($vardef);
         $vardef = array_merge($vardef, $tf->get_field_def());
         //          $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
         //Check if autoincrement fields are allowed
         $allowAutoInc = true;
         $enumFields = array();
         foreach ($module->field_defs as $field => $def) {
             if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) {
                 $allowAutoInc = false;
                 continue;
             }
             if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
                 if (!empty($def['studio']) && $def['studio'] == "false") {
                     continue;
                 }
                 //bug51866
                 $enumFields[$field] = translate($def['vname'], $moduleName);
                 if (substr($enumFields[$field], -1) == ":") {
                     $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
                 }
             }
         }
         $fv->ss->assign('allowAutoInc', $allowAutoInc);
         $GLOBALS['log']->warn('view.modulefield: hidelevel ' . $fv->ss->get_template_vars('hideLevel') . " " . print_r($vardef, true));
         if (!empty($vardef['vname'])) {
             $fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8'));
         }
         $fv->ss->assign('module', $module);
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $edit_or_add = 'editField';
     } else {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $moduleName = $_REQUEST['view_module'];
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $moduleName);
         $package =& $mb->packages[$_REQUEST['view_package']];
         $module->getVardefs();
         if (!$ac) {
             $ac = new AjaxCompose();
         }
         $vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
         if ($isClone) {
             unset($vardef['name']);
         }
         if (empty($vardef['name'])) {
             if (!empty($_REQUEST['type'])) {
                 $vardef['type'] = $_REQUEST['type'];
             }
             $fv->ss->assign('hideLevel', 0);
         } else {
             if (!empty($module->mbvardefs->vardef['fields'][$vardef['name']])) {
                 $fv->ss->assign('hideLevel', 1);
             } elseif (isset($vardef['custom_module'])) {
                 $fv->ss->assign('hideLevel', 2);
             } else {
                 $fv->ss->assign('hideLevel', 3);
                 // tyoung bug 17350 - effectively mark template derived fields as readonly
             }
         }
         require_once 'modules/DynamicFields/FieldCases.php';
         $tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
         $tf->module = $module;
         $tf->populateFromRow($vardef);
         $vardef = array_merge($vardef, $tf->get_field_def());
         $fv->ss->assign('module', $module);
         $fv->ss->assign('package', $package);
         $fv->ss->assign('MB', '1');
         if (isset($vardef['vname'])) {
             $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us', $vardef['vname']), ENT_QUOTES, 'UTF-8'));
         }
         if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || isset($vardef['type']) && $vardef['type'] == 'parent') {
             $field_types['parent'] = $GLOBALS['mod_strings']['parent'];
         }
         $enumFields = array();
         if (!empty($module->mbvardefs->vardefs['fields'])) {
             foreach ($module->mbvardefs->vardefs['fields'] as $field => $def) {
                 if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
                     $enumFields[$field] = isset($module->mblanguage->strings[$current_language][$def['vname']]) ? $this->mbModule->mblanguage->strings[$current_language][$def['vname']] : translate($field);
                     if (substr($enumFields[$field], -1) == ":") {
                         $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
                     }
                 }
             }
         }
         $edit_or_add = 'mbeditField';
     }
     if ($_REQUEST['action'] == 'RefreshField') {
         require_once 'modules/DynamicFields/FieldCases.php';
         $field = get_widget($_POST['type']);
         $field->populateFromPost();
         $vardef = $field->get_field_def();
         $vardef['options'] = $_REQUEST['new_dropdown'];
         $fv->ss->assign('lbl_value', htmlentities($_REQUEST['labelValue'], ENT_QUOTES, 'UTF-8'));
     }
     foreach (array("formula", "default", "comments", "help", "visiblityGrid") as $toEscape) {
         if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) {
             $vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8');
         }
     }
     if (!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true || strcmp($field_name, "name") == 0 || isset($vardef['type']) && $vardef['type'] == 'name') {
         $fv->ss->assign('no_duplicate', true);
     }
     $fv->ss->assign('action', $action);
     $fv->ss->assign('isClone', $isClone ? 1 : 0);
     $fv->ss->assign("module_dd_fields", $enumFields);
     $json = getJSONobj();
     $fv->ss->assign('field_name_exceptions', $json->encode($field_name_exceptions));
     ksort($field_types);
     $fv->ss->assign('field_types', $field_types);
     $fv->ss->assign('importable_options', $GLOBALS['app_list_strings']['custom_fields_importable_dom']);
     $fv->ss->assign('duplicate_merge_options', $GLOBALS['app_list_strings']['custom_fields_merge_dup_dom']);
     $triggers = array();
     $existing_field_names = array();
     foreach ($module->mbvardefs->vardefs['fields'] as $field) {
         if ($field['type'] == 'enum' || $field['type'] == 'multienum') {
             $triggers[] = $field['name'];
         }
         if (!isset($field['source']) || $field['source'] != 'non-db') {
             if (preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) {
                 $existing_field_names[] = strtoupper($matches[1]);
             }
         }
     }
     $fv->ss->assign('triggers', $triggers);
     $fv->ss->assign('existing_field_names', $json->encode($existing_field_names));
     $fv->ss->assign('mod_strings', $GLOBALS['mod_strings']);
     // jchi #24880
     // end
     $layout = $fv->getLayout($vardef);
     $fv->ss->assign('fieldLayout', $layout);
     if (empty($vardef['type'])) {
         $vardef['type'] = 'varchar';
     }
     $fv->ss->assign('vardef', $vardef);
     if (empty($_REQUEST['field'])) {
         $edit_or_add = 'addField';
     }
     $fv->ss->assign('help_group', $edit_or_add);
     $body = $this->fetchTemplate($fv, 'modules/ModuleBuilder/tpls/MBModule/field.tpl');
     $ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR', 'ModuleBuilder'), $body);
     return $ac;
 }
Ejemplo n.º 21
0
 /**
  * @param string $module
  * @param string $id
  * @param array $fields
  * @param array $return_array
  */
 public function getRelatedFields($module, $id, $fields, $return_array = false)
 {
     if (empty($GLOBALS['beanList'][$module])) {
         return '';
     }
     $object = BeanFactory::getObjectName($module);
     VardefManager::loadVardef($module, $object);
     if (empty($GLOBALS['dictionary'][$object]['table'])) {
         return '';
     }
     $table = $GLOBALS['dictionary'][$object]['table'];
     $hasCustomFields = false;
     $query = 'SELECT id';
     foreach ($fields as $field => $alias) {
         if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) {
             $query .= ' ,' . $this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias;
         } else {
             if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) {
                 if ('_c' == strtolower(substr($field, -2))) {
                     $query .= ' ,' . $table . '_cstm.' . $field . ' as ' . $alias;
                     $hasCustomFields = true;
                 } else {
                     $query .= ' ,' . $table . '.' . $field . ' as ' . $alias;
                 }
             }
         }
         if (!$return_array) {
             $this->{$alias} = '';
         }
     }
     if ($query == 'SELECT id' || empty($id)) {
         return '';
     }
     if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) {
         $query .= " , " . $table . ".assigned_user_id owner";
     } else {
         if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) {
             $query .= " , " . $table . ".created_by owner";
         }
     }
     if ($hasCustomFields) {
         $query .= ' FROM ' . $table . ', ' . $table . '_cstm WHERE deleted=0 AND id=id_c AND id=';
     } else {
         $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id=';
     }
     $result = $GLOBALS['db']->query($query . "'{$id}'");
     $row = $GLOBALS['db']->fetchByAssoc($result);
     if ($return_array) {
         return $row;
     }
     $owner = empty($row['owner']) ? '' : $row['owner'];
     foreach ($fields as $alias) {
         $this->{$alias} = !empty($row[$alias]) ? $row[$alias] : '';
         $alias = $alias . '_owner';
         $this->{$alias} = $owner;
         $a_mod = $alias . '_mod';
         $this->{$a_mod} = $module;
     }
 }
 /**
  * Generate unifed search fields for a particular module even if the module does not participate in the unified search.
  *
  * @param string $moduleName
  * @return array An array of fields to be searched against.
  */
 function generateUnifiedSearchFields($moduleName)
 {
     global $beanList, $beanFiles, $dictionary;
     if (!isset($beanList[$moduleName])) {
         return array();
     }
     $beanName = $beanList[$moduleName];
     if (!isset($beanFiles[$beanName])) {
         return array();
     }
     $beanName = BeanFactory::getObjectName($moduleName);
     $manager = new VardefManager();
     $manager->loadVardef($moduleName, $beanName);
     // obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
     if (file_exists('custom/modules/' . $moduleName . '/metadata/metafiles.php')) {
         require 'custom/modules/' . $moduleName . '/metadata/metafiles.php';
     } elseif (file_exists('modules/' . $moduleName . '/metadata/metafiles.php')) {
         require 'modules/' . $moduleName . '/metadata/metafiles.php';
     }
     if (!empty($metafiles[$moduleName]['searchfields'])) {
         require $metafiles[$moduleName]['searchfields'];
     } elseif (file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
         require "modules/{$moduleName}/metadata/SearchFields.php";
     }
     $fields = array();
     foreach ($dictionary[$beanName]['fields'] as $field => $def) {
         if (strpos($field, 'email') !== false) {
             $field = 'email';
         }
         //bug: 38139 - allow phone to be searched through Global Search
         if (strpos($field, 'phone') !== false) {
             $field = 'phone';
         }
         if (isset($def['unified_search']) && $def['unified_search'] && isset($searchFields[$moduleName][$field])) {
             $fields[$field] = $searchFields[$moduleName][$field];
         }
     }
     //If no fields with the unified flag have been set then lets add a default field.
     if (empty($fields)) {
         if (isset($dictionary[$beanName]['fields']['name']) && isset($searchFields[$moduleName]['name'])) {
             $fields['name'] = $searchFields[$moduleName]['name'];
         } else {
             if (isset($dictionary[$beanName]['fields']['first_name']) && isset($searchFields[$moduleName]['first_name'])) {
                 $fields['first_name'] = $searchFields[$moduleName]['first_name'];
             }
             if (isset($dictionary[$beanName]['fields']['last_name']) && isset($searchFields[$moduleName]['last_name'])) {
                 $fields['last_name'] = $searchFields[$moduleName]['last_name'];
             }
         }
     }
     return $fields;
 }
Ejemplo n.º 23
0
 function uninstall_relationships($include_studio_relationships = false)
 {
     $relationships = array();
     //Find and remove studio created relationships.
     global $beanList, $beanFiles, $dictionary;
     //Load up the custom relationship definitions.
     if (file_exists('custom/application/Ext/TableDictionary/tabledictionary.ext.php')) {
         include 'custom/application/Ext/TableDictionary/tabledictionary.ext.php';
     }
     //Find all the relatioships/relate fields involving this module.
     $rels_to_remove = array();
     foreach ($beanList as $mod => $bean) {
         //Some modules like cases have a bean name that doesn't match the object name
         $bean = BeanFactory::getObjectName($mod);
         VardefManager::loadVardef($mod, $bean);
         //We can skip modules that are in this package as they will be removed anyhow
         if (!in_array($mod, $this->modulesInPackage) && !empty($dictionary[$bean]) && !empty($dictionary[$bean]['fields'])) {
             $field_defs = $dictionary[$bean]['fields'];
             foreach ($field_defs as $field => $def) {
                 //Weed out most fields first
                 if (isset($def['type'])) {
                     //Custom relationships created in the relationship editor
                     if ($def['type'] == "link" && !empty($def['relationship']) && !empty($dictionary[$def['relationship']])) {
                         $rel_name = $def['relationship'];
                         $rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
                         //Check against mods to be removed.
                         foreach ($this->modulesInPackage as $removed_mod) {
                             if ($rel_def['lhs_module'] == $removed_mod || $rel_def['rhs_module'] == $removed_mod) {
                                 $dictionary[$rel_name]['from_studio'] = true;
                                 $relationships[$rel_name] = $dictionary[$rel_name];
                             }
                         }
                     }
                     //Custom "relate" fields created in studio also need to be removed
                     if ($def['type'] == 'relate' && isset($def['module'])) {
                         foreach ($this->modulesInPackage as $removed_mod) {
                             if ($def['module'] == $removed_mod) {
                                 require_once 'modules/ModuleBuilder/Module/StudioModule.php';
                                 $studioMod = new StudioModule($mod);
                                 $studioMod->removeFieldFromLayouts($field);
                                 if (isset($def['custom_module'])) {
                                     require_once 'modules/DynamicFields/DynamicField.php';
                                     require_once $beanFiles[$bean];
                                     $seed = new $bean();
                                     $df = new DynamicField($mod);
                                     $df->setup($seed);
                                     //Need to load the entire field_meta_data for some field types
                                     $field_obj = $df->getFieldWidget($mod, $field);
                                     $field_obj->delete($df);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->uninstall_relationship(null, $relationships);
     if (isset($this->installdefs['relationships'])) {
         $relationships = $this->installdefs['relationships'];
         $this->log(translate('LBL_MI_UN_RELATIONSHIPS'));
         foreach ($relationships as $relationship) {
             // remove the metadata entry
             $filename = basename($relationship['meta_data']);
             $pathname = file_exists("custom/metadata/{$filename}") ? "custom/metadata/{$filename}" : "metadata/{$filename}";
             if (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables']) {
                 $this->uninstall_relationship($pathname);
             }
             if (file_exists($pathname)) {
                 unlink($pathname);
             }
         }
     }
     if (file_exists("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php")) {
         unlink("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php");
     }
     Relationship::delete_cache();
     $this->rebuild_tabledictionary();
 }
Ejemplo n.º 24
0
 /**
  * Loads Quick Search Object for any object (if suitable method is defined)
  *
  * @param string $module the given module we want to load the vardefs for
  * @param string $object the given object we wish to load the vardefs for
  * @param string $relationName the name of the relation between entities
  * @param type $nameField the name of the field to populate
  * @param type $idField the id of the field to populate
  */
 function loadQSObject($module, $object, $relationName, $nameField, $idField)
 {
     $result = array();
     VardefManager::loadVardef($module, $object);
     if (isset($GLOBALS['dictionary'][$object]['relationships']) && array_key_exists($relationName, $GLOBALS['dictionary'][$object]['relationships'])) {
         if (method_exists($this, 'getQS' . $module)) {
             $result = $this->{'getQS' . $module};
         } elseif (method_exists($this, 'getQS' . $object)) {
             $result = $this->{'getQS' . $object};
         }
     } else {
         if (method_exists($this, 'getQS' . $module)) {
             $result = $this->{'getQS' . $module}($nameField, $idField);
         } elseif (method_exists($this, 'getQS' . $object)) {
             $result = $this->{'getQS' . $object}($nameField, $idField);
         }
     }
     return $result;
 }
Ejemplo n.º 25
0
 function display()
 {
     $smarty = new Sugar_Smarty();
     global $mod_strings;
     $bak_mod_strings = $mod_strings;
     $smarty->assign('mod_strings', $mod_strings);
     $module_name = $_REQUEST['view_module'];
     if (!isset($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
         //$this->loadPackageHelp($module_name);
         $studioClass = new stdClass();
         $studioClass->name = $module_name;
         global $beanList;
         $objectName = $beanList[$module_name];
         if ($objectName == 'aCase') {
             // Bug 17614 - renamed aCase as Case in vardefs for backwards compatibililty with 451 modules
             $objectName = 'Case';
         }
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $f = array($mod_strings['LBL_HCUSTOM'] => array(), $mod_strings['LBL_HDEFAULT'] => array());
         // TODO: replace this section to select fields to list with the algorithm in AbstractMetaDataImplmentation::validField()
         $def = $this->cullFields($dictionary[$objectName]['fields']);
         foreach ($dictionary[$objectName]['fields'] as $def) {
             if ($this->isValidStudioField($def)) {
                 //Custom relate fields will have a non-db source, but custom_module set
                 if (isset($def['source']) && $def['source'] == 'custom_fields' || isset($def['custom_module'])) {
                     $f[$mod_strings['LBL_HCUSTOM']][$def['name']] = $def;
                 } else {
                     $f[$mod_strings['LBL_HDEFAULT']][$def['name']] = $def;
                 }
             }
         }
         $studioClass->mbvardefs->vardefs['fields'] = $f;
         $smarty->assign('module', $studioClass);
         $package = new stdClass();
         $package->name = '';
         $smarty->assign('package', $package);
         $ajax = new AjaxCompose();
         $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
         $ajax->addCrumb(translate($module_name), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $module_name . '")');
         $ajax->addCrumb($mod_strings['LBL_FIELDS'], '');
         $ajax->addSection('center', $mod_strings['LBL_EDIT_FIELDS'], $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
         $_REQUEST['field'] = '';
         echo $ajax->getJavascript();
     } else {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $mb->getPackage($_REQUEST['view_package']);
         $package = $mb->packages[$_REQUEST['view_package']];
         $package->getModule($module_name);
         $this->module = $package->modules[$module_name];
         $this->loadPackageHelp($module_name);
         $this->module->getVardefs(true);
         $this->module->mbvardefs->vardefs['fields'] = array_reverse($this->module->mbvardefs->vardefs['fields'], true);
         $loadedFields = array();
         foreach ($this->module->mbvardefs->vardefs['fields'] as $k => $v) {
             if ($k != $module_name) {
                 $titleLBL[$k] = translate("LBL_" . strtoupper($k), 'ModuleBuilder');
             } else {
                 $titleLBL[$k] = $k;
             }
             foreach ($v as $field => $def) {
                 if (isset($loadedFields[$field])) {
                     unset($this->module->mbvardefs->vardefs['fields'][$k][$field]);
                 } else {
                     $loadedFields[$field] = true;
                 }
             }
         }
         $this->module->mbvardefs->vardefs['fields'][$module_name] = $this->cullFields($this->module->mbvardefs->vardefs['fields'][$module_name]);
         if (file_exists($this->module->path . '/language/' . $GLOBALS['current_language'] . '.lang.php')) {
             include $this->module->path . '/language/' . $GLOBALS['current_language'] . '.lang.php';
             $this->module->setModStrings($GLOBALS['current_language'], $mod_strings);
         } elseif (file_exists($this->module->path . '/language/en_us.lang.php')) {
             include $this->module->path . '/language/en_us.lang.php';
             $this->module->setModStrings('en_us', $mod_strings);
         }
         $smarty->assign('title', $titleLBL);
         $smarty->assign('package', $package);
         $smarty->assign('module', $this->module);
         $smarty->assign('editLabelsMb', '1');
         //need to merge MB labels and studio labels. quick fix for now.
         $ajax = new AjaxCompose();
         $ajax->addCrumb($bak_mod_strings['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
         $ajax->addCrumb($package->name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $package->name . '")');
         $ajax->addCrumb($module_name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $package->name . '&view_module=' . $module_name . '")');
         $ajax->addCrumb($bak_mod_strings['LBL_FIELDS'], '');
         $ajax->addSection('center', $bak_mod_strings["LBL_FIELDS"], $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
         $_REQUEST['field'] = '';
         echo $ajax->getJavascript();
     }
 }
Ejemplo n.º 26
0
 public function testGetControlVardef()
 {
     VardefManager::loadVardef('Contacts', 'Contact');
     $vardef = $GLOBALS['dictionary']['Contact']['fields']['assigned_user_id'];
     $html = getControl('Contacts', 'assigned_user_id', $vardef);
     $this->assertRegExp('/name=\'assigned_user_id\'/', $html);
     $this->assertRegExp('/id=\'assigned_user_id\'/', $html);
     $this->assertRegExp('/type=\'text\'/', $html);
 }
Ejemplo n.º 27
0
 function buildCache()
 {
     global $beanList, $beanFiles, $dictionary;
     $supported_modules = array();
     foreach ($beanList as $moduleName => $beanName) {
         if (!isset($beanFiles[$beanName])) {
             continue;
         }
         $beanName = BeanFactory::getObjectName($moduleName);
         $manager = new VardefManager();
         $manager->loadVardef($moduleName, $beanName);
         // obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
         if (file_exists('custom/modules/' . $moduleName . '/metadata/metafiles.php')) {
             require 'custom/modules/' . $moduleName . '/metadata/metafiles.php';
         } elseif (file_exists('modules/' . $moduleName . '/metadata/metafiles.php')) {
             require 'modules/' . $moduleName . '/metadata/metafiles.php';
         }
         if (!empty($metafiles[$moduleName]['searchfields'])) {
             require $metafiles[$moduleName]['searchfields'];
         } else {
             if (file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
                 require "modules/{$moduleName}/metadata/SearchFields.php";
             }
         }
         //Load custom SearchFields.php if it exists
         if (file_exists("custom/modules/{$moduleName}/metadata/SearchFields.php")) {
             require "custom/modules/{$moduleName}/metadata/SearchFields.php";
         }
         //If there are $searchFields are empty, just continue, there are no search fields defined for the module
         if (empty($searchFields[$moduleName])) {
             continue;
         }
         $isCustomModule = preg_match('/^([a-z0-9]{1,5})_([a-z0-9_]+)$/i', $moduleName);
         //If the bean supports unified search or if it's a custom module bean and unified search is not defined
         if (!empty($dictionary[$beanName]['unified_search']) || $isCustomModule) {
             $fields = array();
             foreach ($dictionary[$beanName]['fields'] as $field => $def) {
                 // We cannot enable or disable unified_search for email in the vardefs as we don't actually have a vardef entry for 'email'
                 // the searchFields entry for 'email' doesn't correspond to any vardef entry. Instead it contains SQL to directly perform the search.
                 // So as a proxy we allow any field in the vardefs that has a name starting with 'email...' to be tagged with the 'unified_search' parameter
                 if (strpos($field, 'email') !== false) {
                     $field = 'email';
                 }
                 //bug: 38139 - allow phone to be searched through Global Search
                 if (strpos($field, 'phone') !== false) {
                     $field = 'phone';
                 }
                 if (!empty($def['unified_search']) && isset($searchFields[$moduleName][$field])) {
                     $fields[$field] = $searchFields[$moduleName][$field];
                 }
             }
             foreach ($searchFields[$moduleName] as $field => $def) {
                 if (isset($def['force_unifiedsearch']) and $def['force_unifiedsearch']) {
                     $fields[$field] = $def;
                 }
             }
             if (count($fields) > 0) {
                 $supported_modules[$moduleName]['fields'] = $fields;
                 if (isset($dictionary[$beanName]['unified_search_default_enabled']) && $dictionary[$beanName]['unified_search_default_enabled'] === TRUE) {
                     $supported_modules[$moduleName]['default'] = true;
                 } else {
                     $supported_modules[$moduleName]['default'] = false;
                 }
             }
         }
     }
     ksort($supported_modules);
     write_array_to_file('unified_search_modules', $supported_modules, $this->cache_search);
 }
Ejemplo n.º 28
0
 /**
  * testActionAdvancedSearchSaveWithoutAnyRangeSearchFields
  * One last test to check what would happen if we had a module that did not have any range search fields enabled
  */
 public function testActionAdvancedSearchSaveWithoutAnyRangeSearchFields()
 {
     //Load the vardefs for the module to pass to TemplateRange
     VardefManager::loadVardef('Cases', 'aCase', true);
     global $dictionary;
     $vardefs = $dictionary['Case']['fields'];
     foreach ($vardefs as $key => $def) {
         if (!empty($def['enable_range_search'])) {
             unset($vardefs[$key]['enable_range_search']);
         }
     }
     require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
     TemplateRange::repairCustomSearchFields($vardefs, 'Cases');
     //In this case there would be no custom SearchFields.php file created
     $this->assertTrue(!file_exists('custom/modules/Cases/metadata/SearchFields.php'));
     //Yet we have the defaults set still in out of box settings
     require 'modules/Cases/metadata/SearchFields.php';
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']['enable_range_search']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']['enable_range_search']));
 }
Ejemplo n.º 29
0
 function getRelatedFields($module, $id, $fields, $return_array = false)
 {
     if (empty($GLOBALS['beanList'][$module])) {
         return '';
     }
     $object = $GLOBALS['beanList'][$module];
     if ($object == 'aCase') {
         $object = 'Case';
     }
     VardefManager::loadVardef($module, $object);
     if (empty($GLOBALS['dictionary'][$object]['table'])) {
         return '';
     }
     $table = $GLOBALS['dictionary'][$object]['table'];
     $query = 'SELECT id';
     foreach ($fields as $field => $alias) {
         if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) {
             $query .= ' ,' . db_concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias;
         } else {
             if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) {
                 $query .= ' ,' . $table . '.' . $field . ' as ' . $alias;
             }
         }
         if (!$return_array) {
             $this->{$alias} = '';
         }
     }
     if ($query == 'SELECT id' || empty($id)) {
         return '';
     }
     if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) {
         $query .= " , " . $table . ".assigned_user_id owner";
     } else {
         if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) {
             $query .= " , " . $table . ".created_by owner";
         }
     }
     $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id=';
     $result = $GLOBALS['db']->query($query . "'{$id}'");
     $row = $GLOBALS['db']->fetchByAssoc($result);
     if ($return_array) {
         return $row;
     }
     $owner = empty($row['owner']) ? '' : $row['owner'];
     foreach ($fields as $alias) {
         $this->{$alias} = !empty($row[$alias]) ? $row[$alias] : '';
         $alias = $alias . '_owner';
         $this->{$alias} = $owner;
         $a_mod = $alias . '_mod';
         $this->{$a_mod} = $module;
     }
 }
Ejemplo n.º 30
0
 public static function isModuleSearchable($module, $beanName)
 {
     $whiteList = array("DocumentRevisions", "Cases");
     if (in_array($module, $whiteList)) {
         return true;
     }
     $blackList = array("AOD_IndexEvent", "AOD_Index", "AOW_Actions", "AOW_Conditions", "AOW_Processed", "SchedulersJobs");
     if (in_array($module, $blackList)) {
         return false;
     }
     $manager = new VardefManager();
     $manager->loadVardef($module, $beanName);
     if (empty($GLOBALS['dictionary'][$beanName]['unified_search'])) {
         return false;
     }
     return true;
 }