* 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 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);
/** * Adds a custom field using a field object * * @param Field Object $field * @return boolean */ function addFieldObject(&$field) { Log::debug('adding field'); $object_name = $this->module; $db_name = $field->name; $fmd = new FieldsMetaData(); $id = $fmd->retrieve($object_name . $db_name, true, false); $is_update = false; $label = strtoupper($field->label); if (!empty($id)) { $is_update = true; } else { $db_name = $this->getDBName($field->name); $field->name = $db_name; } $this->createCustomTable(); $fmd->id = $object_name . $db_name; $fmd->custom_module = $object_name; $fmd->name = $db_name; $fmd->vname = $label; $fmd->type = $field->type; $fmd->help = $field->help; if (!empty($field->len)) { $fmd->len = $field->len; } // tyoung bug 15407 - was being set to $field->size so changes weren't being saved $fmd->required = $field->required ? 1 : 0; $fmd->default_value = $field->default; $fmd->ext1 = $field->ext1; $fmd->ext2 = $field->ext2; $fmd->ext3 = $field->ext3; $fmd->ext4 = isset($field->ext4) ? $field->ext4 : ''; $fmd->comments = $field->comment; $fmd->massupdate = $field->massupdate; $fmd->importable = isset($field->importable) ? $field->importable : null; $fmd->duplicate_merge = $field->duplicate_merge; $fmd->audited = $field->audited; $fmd->reportable = $field->reportable ? 1 : 0; if (!$is_update) { $fmd->new_with_id = true; } if ($field) { if (!$is_update) { //Do two SQL calls here in this case //The first is to create the column in the custom table without the default value //The second is to modify the column created in the custom table to set the default value //We do this so that the existing entries in the custom table don't have the default value set $field->default = ''; $field->default_value = ''; // resetting default and default_value does not work for multienum and causes trouble for mssql // so using a temporary variable here to indicate that we don't want default for this query $field->no_default = 1; $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm'); // unsetting temporary member variable unset($field->no_default); if (!empty($query)) { $GLOBALS['db']->query($query, true, "Cannot create column"); $field->default = $fmd->default_value; $field->default_value = $fmd->default_value; $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); if (!empty($query)) { $GLOBALS['db']->query($query, true, "Cannot set default"); } } } else { $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); if (!empty($query)) { $GLOBALS['db']->query($query, true, "Cannot modify field"); } } $fmd->save(); $this->buildCache($this->module); $this->saveExtendedAttributes($field, array_keys($fmd->field_defs)); } return true; }
* 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/EditCustomFields/FieldsMetaData.php'; global $app_list_strings, $app_strings, $current_language; if (empty($_REQUEST['custom_module'])) { $_REQUEST['custom_module'] = $_SESSION['studio']['module']; } require_once 'include/Sugar_Smarty.php'; $custom_field_types = array('varchar' => 'Text', 'text' => 'Text Area', 'int' => 'Integer', 'float' => 'Decimal', 'bool' => 'Checkbox', 'email' => 'Email', 'enum' => 'Dropdown', 'multienum' => 'Multiple Select', 'radioenum' => 'Radio Buttons', 'date' => 'Date', 'url' => 'Web Link', 'html' => 'HTML'); $smarty = new Sugar_Smarty(); $cf = new FieldsMetaData(); if (!empty($_REQUEST['record'])) { $cf->retrieve($_REQUEST['record']); $custom_module = $cf->custom_module; $smarty->assign('NOEDIT', 'diabled'); $old = ob_get_contents(); ob_clean(); require_once $GLOBALS['studioConfig']['dynamicFields'][$cf->data_type]; $body = ob_get_contents(); ob_clean(); echo $old; $smarty->assign('body', $body); } else { $custom_module = $_REQUEST['custom_module']; } $smarty->assign('custom_module', $custom_module); if (empty($_REQUEST['popup'])) { $smarty->assign('inline', 'inline');
/** * Adds a custom field using a field object * * @param Field Object $field * @return boolean */ function addFieldObject(&$field) { $GLOBALS['log']->debug('adding field'); $object_name = $this->module; $db_name = $field->name; $fmd = new FieldsMetaData(); $id = $fmd->retrieve($object_name . $db_name, true, false); $is_update = false; $label = $field->label; if (!empty($id)) { $is_update = true; } else { $db_name = $this->getDBName($field->name); $field->name = $db_name; } $this->createCustomTable(); $fmd->id = $object_name . $db_name; $fmd->custom_module = $object_name; $fmd->name = $db_name; $fmd->vname = $label; $fmd->type = $field->type; $fmd->help = $field->help; $fmd->len = $field->len; // tyoung bug 15407 - was being set to $field->size so changes weren't being saved $fmd->required = $field->required ? 1 : 0; $fmd->default_value = $field->default; $fmd->ext1 = $field->ext1; $fmd->ext2 = $field->ext2; $fmd->ext3 = $field->ext3; $fmd->ext4 = isset($field->ext4) ? $field->ext4 : ''; $fmd->comments = $field->comment; $fmd->massupdate = $field->massupdate; $fmd->importable = isset($field->importable) ? $field->importable : null; $fmd->duplicate_merge = $field->duplicate_merge; $fmd->audited = $field->audited; $fmd->reportable = $field->reportable ? 1 : 0; if (!$is_update) { $fmd->new_with_id = true; } $fmd->save(); $this->buildCache($this->module); if ($field) { if (!$is_update) { $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm'); } else { $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); } if (!empty($query)) { $GLOBALS['db']->query($query); } } return true; }
$xtpl->assign('STYLE', $style); if (empty($_REQUEST['record'])) { $xtpl->assign('form', 'insert'); $header = get_form_header($mod_strings['POPUP_INSERT_HEADER_TITLE'], '', false); $xtpl->assign('header', $header); $xtpl->assign('custom_module', $_REQUEST['module_name']); $data_type_options_html = get_select_options_with_id($data_type_array, ''); $xtpl->assign('data_type_options', $data_type_options_html); $xtpl->assign('ENUM_OPTIONS', get_select_options_with_id($enum_keys, '')); } else { $xtpl->assign('form', 'edit'); $header = get_form_header($mod_strings['POPUP_EDIT_HEADER_TITLE'], '', false); $xtpl->assign('header', $header); // populate the fields if a custom_field_id is given -> editing $record_id = $_REQUEST['record']; $focus->retrieve($record_id); if (!empty($_REQUEST['duplicate'])) { $record_id = ''; $focus->id = ''; } $xtpl->assign('NOEDIT', 'disabled'); $xtpl->assign('custom_field_id', $focus->id); $xtpl->assign('name', $focus->name); $xtpl->assign('label', $focus->label); $xtpl->assign('custom_module', $focus->custom_module); $data_type_options_html = get_select_options_with_id($data_type_array, $focus->data_type); $xtpl->assign('data_type_options', $data_type_options_html); $xtpl->assign('max_size', $focus->max_size); $xtpl->assign('required_option', $focus->required_option); if ($focus->required_option == 'required') { $xtpl->assign('REQUIRED_CHECKED', 'checked');