public function setUp() { SugarTestHelper::setUp('beanList'); SugarTestHelper::setUp('beanFiles'); SugarTestHelper::setUp('app_strings'); SugarTestHelper::setUp('app_list_strings'); SugarTestHelper::setUp('mod_strings', array('ModuleBuilder')); SugarTestHelper::setUp('current_user', array(true, 1)); $_POST = $_REQUEST = $this->getPostData(); $this->accountFieldWidget = get_widget($_REQUEST['type']); $this->accountFieldWidget->populateFromPost(); $module = $_REQUEST['view_module']; $this->accountField = new DynamicField($module); $class_name = $GLOBALS['beanList'][$module]; require_once $GLOBALS['beanFiles'][$class_name]; $mod = new $class_name(); $this->accountField->setup($mod); $this->accountFieldWidget->save($this->accountField); $_POST['view_module'] = $_REQUEST['view_module'] = 'Opportunities'; $this->opportunityFieldWidget = get_widget($_REQUEST['type']); $this->opportunityFieldWidget->populateFromPost(); $module = $_REQUEST['view_module']; $this->opportunityField = new DynamicField($module); $class_name = $GLOBALS['beanList'][$module]; require_once $GLOBALS['beanFiles'][$class_name]; $mod = new $class_name(); $this->opportunityField->setup($mod); $this->opportunityFieldWidget->save($this->opportunityField); $repair = new RepairAndClear(); $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs'), array($GLOBALS['beanList']['Accounts'], $GLOBALS['beanList']['Opportunities']), true, false); }
public function testGetRelateJoin() { require_once 'modules/DynamicFields/DynamicField.php'; $dynamicField = new DynamicField(); $account = new Account(); $dynamicField->bean = $account; $field_def = array('dependency' => '', 'required' => '', 'source' => 'non-db', 'name' => 'm1_related_c', 'vname' => 'LBL_M1_RELATED', 'type' => 'relate', 'massupdate' => 0, 'default' => '', 'comments' => '', 'help' => '', 'importable' => true, 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => 0, 'audited' => '', 'reportable' => 1, 'calculated' => '', 'len' => 255, 'size' => 20, 'id_name' => 'def_m1_id_c', 'ext2' => 'Accounts', 'module' => 'Accounts', 'rname' => 'name', 'quicksearch' => 'enabled', 'studio' => 'visible', 'id' => 'def_M1m1_related_c', 'custom_module' => 'Accounts'); $joinTableAlias = 'jt1'; $relatedJoinInfo = $dynamicField->getRelateJoin($field_def, $joinTableAlias); //echo var_export($relatedJoinInfo, true); $this->assertEquals(', accounts_cstm.def_m1_id_c, jt1.name m1_related_c ', $relatedJoinInfo['select']); }
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'); }
/** * Removing field, account, contact */ public function tearDown() { SugarTestContactUtilities::removeAllCreatedContacts(); SugarTestAccountUtilities::removeAllCreatedAccounts(); $this->dynamicField->deleteField($this->field); SugarTestHelper::tearDown(); }
/** * Create the custom field with type 'relate' */ protected function createCustomField() { $field = get_widget('relate'); $field->id = 'Contacts' . $this->field_name_c; $field->name = $this->field_name_c; $field->type = 'relate'; $field->label = 'LBL_' . strtoupper($this->field_name_c); $field->ext2 = 'Accounts'; $field->view_module = 'Contacts'; $this->relateField = $field; $this->bean = BeanFactory::getBean('Contacts'); $this->df = new DynamicField($this->bean->module_name); $this->df->setup($this->bean); $field->save($this->df); $this->rc = new RepairAndClear(); $this->rc->repairAndClearAll(array("rebuildExtensions", "clearVardefs"), array('Contact'), false, false); }
function process($option) { switch ($option) { case 'ViewCustomFields': parent::process($option); require_once 'modules/Studio/EditCustomFields/ListView.php'; break; case 'CreateCustomFields': if (empty($_REQUEST['to_pdf'])) { parent::process($option); } require_once 'modules/Studio/EditCustomFields/EditView.php'; break; case 'SaveCustomField': require_once 'modules/Studio/EditCustomFields/Save.php'; break; case 'DeleteCustomField': require_once 'modules/Studio/EditCustomFields/Delete.php'; break; case 'EditCustomField': parent::process($option); require_once 'modules/Studio/EditCustomFields/EditView.php'; break; case 'ClearCache': require_once 'modules/DynamicFields/DynamicField.php'; DynamicField::deleteCache(); echo '<script>YAHOO.util.Event.addListener(window, "load", function(){ajaxStatus.showStatus("cache cleared");window.setTimeout(\'ajaxStatus.hideStatus();\', 2000);});</script>'; parent::process($option); break; case 'RepairCustomFields': header('Location: index.php?module=Administration&action=UpgradeFields'); sugar_cleanup(true); default: parent::process($option); } }
/** * Save label for id field * * @param string $idLabelName * @param DynamicField $df */ protected function saveIdLabel($idLabelName, $df) { if ($df instanceof DynamicField) { $module = $df->module; } elseif ($df instanceof MBModule) { $module = $df->name; } else { Log::fatal('Unsupported DynamicField type'); } $viewPackage = isset($df->package) ? $df->package : null; $idLabelValue = string_format($GLOBALS['mod_strings']['LBL_RELATED_FIELD_ID_NAME_LABEL'], array($this->label_value, $GLOBALS['app_list_strings']['moduleListSingular'][$this->ext2])); $idFieldLabelArr = array("label_{$idLabelName}" => $idLabelValue); foreach (ModuleBuilder::getModuleAliases($module) as $moduleName) { if ($df instanceof DynamicField) { $parser = new ParserLabel($moduleName, $viewPackage); $parser->handleSave($idFieldLabelArr, $GLOBALS['current_language']); } elseif ($df instanceof MBModule) { $df->setLabel($GLOBALS['current_language'], $idLabelName, $idLabelValue); $df->save(); } } }
function __construct($module = '') { parent::DynamicField($module); }
/** * Given a module, search all of the specified locations, and any others as specified * in order to refresh the cache file * * @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 array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search */ static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array()) { // Some of the vardefs do not correctly define dictionary as global. Declare it first. global $dictionary, $beanList; $vardef_paths = array('modules/' . $module . '/vardefs.php', 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php'); // Add in additional search paths if they were provided. if (!empty($additional_search_paths) && is_array($additional_search_paths)) { $vardef_paths = array_merge($vardef_paths, $additional_search_paths); } $found = false; //search a predefined set of locations for the vardef files foreach ($vardef_paths as $path) { if (file_exists($path)) { require $path; $found = true; } } //Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name if (!$found) { $temp = BeanFactory::newBean($module); if ($temp) { $object_name = BeanFactory::getObjectName($temp->module_dir); if ($temp && $temp->module_dir != $temp->module_name && !empty($object_name)) { self::refreshVardefs($temp->module_dir, $object_name, $additional_search_paths, $cacheCustom); } } } //Some modules like cases have a bean name that doesn't match the object name if (empty($dictionary[$object])) { $newName = BeanFactory::getObjectName($module); $object = $newName != false ? $newName : $object; } //load custom fields into the vardef cache if ($cacheCustom) { require_once "modules/DynamicFields/DynamicField.php"; $df = new DynamicField($module); $df->buildCache($module, false); } //great! now that we have loaded all of our vardefs. //let's go save them to the cache file. if (!empty($dictionary[$object])) { VardefManager::saveCache($module, $object); } }
/** * Find custom address fields added to modules that modulebuilder created and deployed */ public function upgradeVardefsInDeployedModules() { //Created for access to a field's vardef_map $tempField = new TemplateField(); foreach (glob('modules/*/vardefs.php') as $file) { //Get module name from file name $fileParts = explode('/', $file); $module = $fileParts[1]; require $file; if (!empty($dictionary[$module]['fields'])) { //Set up vardef extension save mechanism $bean = BeanFactory::getBean($module); if (empty($bean)) { continue; } $df = new DynamicField($module); $df->setup($bean); //Find all custom street fields foreach ($dictionary[$module]['fields'] as $fieldName => $field) { if ($this->validateStreetField($dictionary[$module]['fields'], $fieldName)) { $upgradeField = new stdClass(); $upgradeField->type = 'text'; $upgradeField->dbType = 'varchar'; $upgradeField->name = $fieldName; $upgradeField->vardef_map = $tempField->vardef_map; $upgradeField->vardef_map['dbType'] = 'dbType'; $df->saveExtendedAttributes($upgradeField, array()); } } } } }
/** * Removes all custom fields created in studio * * @return html output record of the field deleted */ function removeCustomFields() { $moduleName = $this->module; $class_name = $GLOBALS['beanList'][$moduleName]; require_once $GLOBALS['beanFiles'][$class_name]; $seed = new $class_name(); $df = new DynamicField($moduleName); $df->setup($seed); $module = StudioModuleFactory::getStudioModule($moduleName); $customFields = array(); foreach ($seed->field_defs as $def) { if (isset($def['source']) && $def['source'] == 'custom_fields') { $field = $df->getFieldWidget($moduleName, $def['name']); $field->delete($df); $module->removeFieldFromLayouts($def['name']); $customFields[] = $def['name']; } } $out = ""; foreach ($customFields as $field) { $out .= "Removed field {$field}<br/>"; } return $out; }
* Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ require_once 'modules/EditCustomFields/EditCustomFields.php'; require_once 'modules/DynamicFields/DynamicField.php'; require_once 'modules/DynamicFields/DynamicField.php'; if (!empty($_REQUEST['record'])) { $fields_meta_data = new FieldsMetaData($_REQUEST['record']); $fields_meta_data->retrieve($_REQUEST['record']); $module = $fields_meta_data->custom_module; $custom_fields = new DynamicField($module); if (!empty($module)) { $class_name = $beanList[$module]; $class_file = $class_name; if ($class_file == 'aCase') { $class_file = 'Case'; } require_once "modules/{$module}/{$class_file}.php"; $mod = new $class_name(); $custom_fields->setup($mod); } else { echo "\nNo Module Included Could Not Delete"; } $custom_fields->deleteField($fields_meta_data->name); $fields_meta_data->mark_deleted($_REQUEST['record']); }
<?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } /********************************************************************************* * The contents of this file are subject to the SugarCRM Public License Version * 1.1.3 ("License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ // adding custom fields: require_once 'modules/DynamicFields/DynamicField.php'; $custom_fields = new DynamicField(); $custom_fields->setup($focus); $custom_fields->populateXTPL($xtpl, 'detail');
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(); }
/** * Delete the primary table for the module implementing the class. * If custom fields were added to this table/module, the custom table will be removed too, along with the cache * entries that define the custom fields. * */ function drop_tables() { global $dictionary; $key = $this->getObjectName(); if (!array_key_exists($key, $dictionary)) { $GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist"); echo "meta data absent for table " . $this->table_name . "<br>\n"; } else { if (empty($this->table_name)) { return; } if ($this->db->tableExists($this->table_name)) { $this->dbManager->dropTable($this); } if ($this->db->tableExists($this->table_name . '_cstm')) { $this->dbManager->dropTableName($this->table_name . '_cstm'); DynamicField::deleteCache(); } if ($this->db->tableExists($this->get_audit_table_name())) { $this->dbManager->dropTableName($this->get_audit_table_name()); } } }
public function __construct($module = '') { parent::__construct($module); }
$custom_table_name = strtolower($fields_meta_data->custom_module) . '_cstm'; $custom_fields_table_schema = new CustomFieldsTableSchema($custom_table_name); if (!CustomFieldsTableSchema::custom_table_exists($custom_table_name)) { $custom_fields_table_schema->create_table(); } $column_name = $fields_meta_data->name; $field_label = $fields_meta_data->label; $data_type = $fields_meta_data->data_type; $max_size = $fields_meta_data->max_size; $required = $fields_meta_data->required_option; $default_value = $fields_meta_data->default_value; $module_dir = $fields_meta_data->custom_module; if ($new_field) { $custom_fields_table_schema->add_column($column_name, $data_type, $required, $default_value); $class_name = $beanList[$fields_meta_data->custom_module]; $custom_field = new DynamicField($fields_meta_data->custom_module); require_once "modules/{$module_dir}/{$class_name}.php"; $sugarbean_module = new $class_name(); $custom_field->setup($sugarbean_module); $custom_field->addField($field_label, $data_type, $max_size, 'optional', $default_value, '', ''); } if (isset($_REQUEST['form'])) { // we are doing the save from a popup window echo '<script>opener.window.location.reload();self.close();</script>'; die; } else { // need to refresh the page properly $return_module = empty($_REQUEST['return_module']) ? 'EditCustomFields' : $_REQUEST['return_module']; $return_action = empty($_REQUEST['return_action']) ? 'index' : $_REQUEST['return_action']; $return_module_select = empty($_REQUEST['return_module_select']) ? 0 : $_REQUEST['return_module_select']; header("Location: index.php?action={$return_action}&module={$return_module}&module_select={$return_module_select}");
public function action_DeleteField() { $field = get_widget($_REQUEST['type']); $field->name = $_REQUEST['name']; if (!isset($_REQUEST['view_package'])) { if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) { $moduleName = $_REQUEST['view_module']; // bug 51325 make sure we make this switch or delete will not work if ($moduleName == 'Employees') { $moduleName = 'Users'; } $seed = BeanFactory::getBean($moduleName); $df = new DynamicField($moduleName); $df->setup($seed); //Need to load the entire field_meta_data for some field types $field = $df->getFieldWidget($moduleName, $field->name); $field->delete($df); $GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules'; $_REQUEST['execute_sql'] = true; include_once 'modules/Administration/QuickRepairAndRebuild.php'; $repair = new RepairAndClear(); $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($moduleName), true, false); require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php'; $module = StudioModuleFactory::getStudioModule($moduleName); } } else { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $field = $module->getField($field->name); $field->delete($module); $mb->save(); } $module->removeFieldFromLayouts($field->name); $this->view = 'modulefields'; if (isset($GLOBALS['current_language']) && isset($_REQUEST['label']) && isset($_REQUEST['labelValue']) && isset($_REQUEST['view_module'])) { $this->DeleteLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue'], $_REQUEST['view_module']); $this->metadataApiCacheCleared = true; } // Clear the metadata cache if it hasn't been done already if (!$this->metadataApiCacheCleared && !empty($moduleName)) { // This removes the labels associated with the field and rebuilds // the api cache for the module $repair->module_list = array($moduleName); $repair->repairMetadataAPICache('labels'); } }
function getLayout($vardef) { if (empty($vardef['type'])) { $vardef['type'] = 'varchar'; } $mod = return_module_language($GLOBALS['current_language'], 'DynamicFields'); $this->ss->assign('vardef', $vardef); $this->ss->assign('MOD', $mod); $this->ss->assign('APP', $GLOBALS['app_strings']); //Only display range search option if in Studio, not ModuleBuilder $this->ss->assign('range_search_option_enabled', empty($_REQUEST['view_package'])); if (isset($vardef['name']) && in_array($vardef['name'], self::$fieldNameBlacklist) || isset($vardef['type']) && in_array($vardef['type'], self::$fieldTypeBlacklist)) { $this->ss->assign('hideDuplicatable', 'true'); } if ($fieldRangeValue = DynamicField::getFieldRangeValueByType($vardef['type'])) { $this->ss->assign('field_range_value', $fieldRangeValue); } if (isset($vardef['name']) && in_array($vardef['name'], self::$fieldNameNoRequired)) { $this->ss->assign('hideRequired', true); } else { $this->ss->assign('hideRequired', false); } $GLOBALS['log']->debug('FieldViewer.php->getLayout() = ' . $vardef['type']); switch ($vardef['type']) { case 'address': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/address.tpl'); case 'bool': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/bool.tpl'); case 'int': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/int.tpl'); case 'float': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/float.tpl'); case 'decimal': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/float.tpl'); case 'date': require_once 'modules/DynamicFields/templates/Fields/Forms/date.php'; return get_body($this->ss, $vardef); case 'datetimecombo': case 'datetime': require_once 'modules/DynamicFields/templates/Fields/Forms/datetimecombo.php'; return get_body($this->ss, $vardef); case 'enum': require_once 'modules/DynamicFields/templates/Fields/Forms/enum2.php'; return get_body($this->ss, $vardef); case 'multienum': require_once 'modules/DynamicFields/templates/Fields/Forms/multienum.php'; return get_body($this->ss, $vardef); case 'radioenum': require_once 'modules/DynamicFields/templates/Fields/Forms/radioenum.php'; return get_body($this->ss, $vardef); case 'html': require_once 'modules/DynamicFields/templates/Fields/Forms/html.php'; return get_body($this->ss, $vardef); case 'currency': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/currency.tpl'); case 'relate': require_once 'modules/DynamicFields/templates/Fields/Forms/relate.php'; return get_body($this->ss, $vardef); case 'parent': require_once 'modules/DynamicFields/templates/Fields/Forms/parent.php'; return get_body($this->ss, $vardef); case 'text': return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/text.tpl'); case 'encrypt': require_once 'modules/DynamicFields/templates/Fields/Forms/encrypt.php'; return get_body($this->ss, $vardef); case 'iframe': require_once 'modules/DynamicFields/templates/Fields/Forms/iframe.php'; return get_body($this->ss, $vardef); case 'url': require_once 'modules/DynamicFields/templates/Fields/Forms/url.php'; return get_body($this->ss, $vardef); case 'phone': require_once 'modules/DynamicFields/templates/Fields/Forms/phone.php'; return get_body($this->ss, $vardef); default: if (SugarAutoLoader::requireWithCustom('modules/DynamicFields/templates/Fields/Forms/' . $vardef['type'] . '.php')) { return get_body($this->ss, $vardef); } else { return $this->ss->fetch('modules/DynamicFields/templates/Fields/Forms/varchar.tpl'); } } }
/** * Removes all custom fields created in studio * * @return html output record of the field deleted */ function removeCustomFields() { $moduleName = $this->module; $seed = BeanFactory::getBean($moduleName); $df = new DynamicField($moduleName); $df->setup($seed); $module = StudioModuleFactory::getStudioModule($moduleName); $customFields = array(); foreach ($seed->field_defs as $def) { if (isset($def['custom_module']) && $def['custom_module'] === $moduleName) { $field = $df->getFieldWidget($moduleName, $def['name']); // the field may have already been deleted if ($field) { $field->delete($df); } $module->removeFieldFromLayouts($def['name']); $customFields[] = $def['name']; } } $out = ""; foreach ($customFields as $field) { $out .= "Removed field {$field}<br/>"; } return $out; }
function action_DeleteField() { require_once 'modules/DynamicFields/FieldCases.php'; $field = get_widget($_REQUEST['type']); $field->name = $_REQUEST['name']; if (!isset($_REQUEST['view_package'])) { if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) { require_once 'modules/DynamicFields/DynamicField.php'; $moduleName = $_REQUEST['view_module']; // bug 51325 make sure we make this switch or delete will not work if ($moduleName == 'Employees') { $moduleName = 'Users'; } $class_name = $GLOBALS['beanList'][$moduleName]; require_once $GLOBALS['beanFiles'][$class_name]; $seed = new $class_name(); $df = new DynamicField($moduleName); $df->setup($seed); //Need to load the entire field_meta_data for some field types $field = $df->getFieldWidget($moduleName, $field->name); $field->delete($df); $GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules'; $_REQUEST['execute_sql'] = true; include_once 'modules/Administration/QuickRepairAndRebuild.php'; $repair = new RepairAndClear(); $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false); require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php'; $module = StudioModuleFactory::getStudioModule($moduleName); } } else { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $field = $module->getField($field->name); $field->delete($module); $mb->save(); } $module->removeFieldFromLayouts($field->name); $this->view = 'modulefields'; if (isset($GLOBALS['current_language']) && isset($_REQUEST['label']) && isset($_REQUEST['labelValue']) && isset($_REQUEST['view_module'])) { $this->DeleteLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue'], $_REQUEST['view_module']); } }
/** * Proxy method for DynamicField::getJOIN * * @param bool $expandedList * @param bool $includeRelates * @param string|bool $where * * @return array */ public function getCustomJoin($expandedList = false, $includeRelates = false, &$where = false) { $result = ['select' => '', 'join' => '']; if (isset($this->custom_fields)) { $result = $this->custom_fields->getJOIN($expandedList, $includeRelates, $where); } return $result; }
function action_DeleteField() { require_once 'modules/DynamicFields/FieldCases.php'; $field = get_widget($_POST['type']); $field->name = $_REQUEST['name']; if (!isset($_REQUEST['view_package'])) { if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) { require_once 'modules/DynamicFields/DynamicField.php'; $moduleName = $_REQUEST['view_module']; $class_name = $GLOBALS['beanList'][$moduleName]; require_once $GLOBALS['beanFiles'][$class_name]; $seed = new $class_name(); $df = new DynamicField($moduleName); $df->setup($seed); //Need to load the entire field_meta_data for some field types $field = $df->getFieldWidget($moduleName, $field->name); $field->delete($df); require_once 'modules/ModuleBuilder/Module/StudioModule.php'; $module = new StudioModule($moduleName); } } else { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $field->delete($module); $mb->save(); } $module->removeFieldFromLayouts($field->name); $this->view = 'modulefields'; }
/** * @param DynamicField $df */ function delete($df) { //If a dropdown uses the field that is being delted as a parent dropdown, we need to remove that dependency $seed = BeanFactory::getBean($df->getModuleName()); if ($seed) { $fields = $seed->field_defs; foreach ($fields as $field => $def) { if (!empty($def['visibility_grid']['trigger']) && $def['visibility_grid']['trigger'] == $this->name) { $field = get_widget($def['type']); unset($def['visibility_grid']); $field->populateFromRow($def); if (isset($def['source']) && $def['source'] == "custom_fields") { $field->save($df); } else { //Out of the box field that we need to use a StandardField rather than DynamicFIeld object to save require_once 'modules/ModuleBuilder/parsers/StandardField.php'; $sf = new StandardField($df->getModuleName()); $sf->setup($seed); $field->module = $seed; $field->save($sf); } } } } parent::delete($df); }
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ require_once 'modules/DynamicFields/DynamicField.php'; $module = $_REQUEST['module_name']; $custom_fields = new DynamicField($module); if (!empty($module)) { $class_name = $beanList[$module]; $class_file = $class_name; if ($class_file == 'aCase') { $class_file = 'Case'; } require_once "modules/{$module}/{$class_file}.php"; $mod = new $class_name(); $custom_fields->setup($mod); } else { echo "\nNo Module Included Could Not Save"; } $name = $_REQUEST['field_label']; $options = ''; if ($_REQUEST['field_type'] == 'enum') {
//otherwise we must be editing field layout \ require_once 'modules/DynamicLayout/AddField.php'; $addfield = new AddField(); if ($fileType != 'other') { require_once 'modules/DynamicFields/DynamicField.php'; if (!empty($_REQUEST['mod_class'])) { $temp_mod = $_REQUEST['mod_class']; $class_name = $beanList[$temp_mod]; $class_file = $beanFiles[$class_name]; require_once $class_file; $customFields = new DynamicField($temp_mod); } else { $class_name = $beanList[$the_module]; $class_file = $beanFiles[$class_name]; require_once $class_file; $customFields = new DynamicField($the_module); } $mod = new $class_name(); $customFields->setup($mod); $result = $customFields->getAllBeanFieldsView($fileType, 'html'); foreach ($result as $f_name => $f_field) { $addfield->add_field($f_name, $f_field['html'], $f_field['label'], '', 'sugar_fields_MSI'); } } $deleteFields->load_deleted_fields(); foreach ($deleteFields->deleted_fields as $dl) { $addfield->add_deleted_field($dl); } $sp->parse_file($file); echo $sp->get_javascript_swap(); //$view = str_replace('<!-- END: main -->', $addfield->get_script()."\n<!-- END: main -->", $sp->get_edit_view() );
} unset($fields[$col]); echo "Dropping Column {$col} from {$mod->table_name}" . "_cstm for module {$the_module}<br>"; } else { if ($col != 'id_c') { //$db_data_type = $dbManager->helper->getColumnType(strtolower($the_field->data_type)); $db_data_type = strtolower(str_replace(' ', '', $the_field->get_db_type())); $type = strtolower(str_replace(' ', '', $type)); if (strcmp($db_data_type, $type) != 0) { echo "Fixing Column Type for {$col} changing {$type} to " . $db_data_type . "<br>"; if (!$simulate) { $db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); } } } unset($fields[$col]); } } echo sizeof($fields) . " field(s) missing from {$mod->table_name}" . "_cstm<br>"; foreach ($fields as $field) { echo "Adding Column {$field} to {$mod->table_name}" . "_cstm<br>"; if (!$simulate) { $mod->custom_fields->add_existing_custom_field($field); } } } DynamicField::deleteCache(); echo '<br>Done<br>'; if ($simulate) { echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; }
/** * Given a module, search all of the specified locations, and any others as specified * in order to refresh the cache file * * @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 array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search */ function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true) { // Some of the vardefs do not correctly define dictionary as global. Declare it first. global $dictionary; $vardef_paths = array('modules/' . $module . '/vardefs.php', 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php'); // Add in additional search paths if they were provided. if (!empty($additional_search_paths) && is_array($additional_search_paths)) { $vardef_paths = array_merge($vardef_paths, $additional_search_paths); } //search a predefined set of locations for the vardef files foreach ($vardef_paths as $path) { if (file_exists($path)) { require $path; } } //load custom fields into the vardef cache if ($cacheCustom) { require_once "modules/DynamicFields/DynamicField.php"; $df = new DynamicField($module); $df->buildCache($module); } //great! now that we have loaded all of our vardefs. //let's go save them to the cache file. if (!empty($GLOBALS['dictionary'][$object])) { VardefManager::saveCache($module, $object); } }
die('Not A Valid Entry Point'); } /********************************************************************************* * The contents of this file are subject to the SugarCRM Public License Version * 1.1.3 ("License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ require_once 'modules/DynamicFields/DynamicField.php'; if (!empty($_REQUEST['record'])) { DynamicField::dropFieldById($_REQUEST['record']); } $return_module = empty($_REQUEST['return_module']) ? 'Studio' : $_REQUEST['return_module']; $return_action = empty($_REQUEST['return_action']) ? 'wizard' : $_REQUEST['return_action']; $return_module_select = empty($_REQUEST['module_name']) ? 0 : '&wizard=EditCustomFieldsWizard&option=ViewCustomFields'; header("Location: index.php?action={$return_action}&module={$return_module}{$return_module_select}");
/** * save * * This function says the field template by calling the DynamicField addFieldObject function. It then * checks to see if updates are needed for the SearchFields.php file. In the event that the unified_search * member variable is set to true, a search field definition is updated/created to the SearchFields.php file. * * @param DynamicField $df */ function save($df) { // $GLOBALS['log']->debug('saving field: '.print_r($this,true)); $df->addFieldObject($this); require_once 'modules/ModuleBuilder/parsers/parser.searchfields.php'; $searchFieldParser = new ParserSearchFields($df->getModuleName(), $df->getPackageName()); //If unified_search is enabled for this field, then create the SearchFields entry $fieldName = $this->get_field_name($df->getModuleName(), $this->name); if ($this->unified_search && !isset($searchFieldParser->searchFields[$df->getModuleName()][$fieldName])) { $searchFieldParser->addSearchField($fieldName, array('query_type' => 'default')); $searchFieldParser->saveSearchFields($searchFieldParser->searchFields); } }