* "Powered by SugarCRM".
 ********************************************************************************/
if (empty($_FILES)) {
    echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_DESC'];
    echo <<<EOQ
<br>
<br>
<form enctype="multipart/form-data" action="index.php" method="POST">
   \t<input type='hidden' name='module' value='Administration'>
   \t<input type='hidden' name='action' value='ImportCustomFieldStructure'>
   {$mod_strings['LBL_IMPORT_CUSTOM_FIELDS_STRUCT']}: <input name="sugfile" type="file" />
    <input type="submit" value="{$mod_strings['LBL_ICF_IMPORT_S']}" class='button'/>
</form>
EOQ;
} else {
    $fmd = new FieldsMetaData();
    echo $mod_strings['LBL_ICF_DROPPING'] . '<br>';
    $lines = file($_FILES['sugfile']['tmp_name']);
    $cur = array();
    foreach ($lines as $line) {
        if (trim($line) == 'DONE') {
            $fmd->new_with_id = true;
            echo 'Adding:' . $fmd->custom_module . '-' . $fmd->name . '<br>';
            $fmd->db->query("DELETE FROM {$fmd->table_name} WHERE id='{$fmd->id}'");
            $fmd->save(false);
            $fmd = new FieldsMetaData();
        } else {
            $ln = explode(':::', $line, 2);
            if (sizeof($ln) == 2) {
                $KEY = trim($ln[0]);
                $fmd->{$KEY} = trim($ln[1]);
示例#2
0
 /**
  * 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;
 }
示例#3
0
 * 
 * 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";
    }
 /**
  * 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;
 }
 function getColumnsName()
 {
     $meta = new FieldsMetaData();
     $arr = array();
     foreach ($meta->getFieldDefinitions() as $key => $value) {
         $arr[] = $key;
     }
     return $arr;
 }
示例#6
0
 function delete_custom_field($id)
 {
     $module_name = $this->module_name;
     $fields_meta_data = new FieldsMetaData($id);
     $column_name = $fields_meta_data->name;
     $fields_meta_data->delete();
     $custom_table_name = $this->_get_custom_tbl_name();
     $custom_fields_table_schema = new CustomFieldsTableSchema($custom_table_name);
     $custom_fields_table_schema->drop_column($column_name);
 }
 *
 * 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/EditCustomFields/FieldsMetaData.php';
require_once 'modules/EditCustomFields/CustomFieldsTableSchema.php';
$fields_meta_data = new FieldsMetaData();
////
//// save the metadata to the fields_meta_data table
////
foreach ($fields_meta_data->column_fields as $field) {
    if (isset($_REQUEST[$field])) {
        $fields_meta_data->{$field} = $_REQUEST[$field];
    }
}
$fields_meta_data->save();
////
//// create/modify the custom field table
////
$new_field = empty($_REQUEST['id']);
$new_field = true;
$custom_table_name = strtolower($fields_meta_data->custom_module) . '_cstm';
 function addField($name, $label = '', $type = 'Text', $max_size = '255', $required_option = 'optional', $default_value = '', $ext1 = '', $ext2 = '', $ext3 = '', $audited = 0, $mass_update = 0, $ext4 = '', $help = '', $duplicate_merge = 0)
 {
     if (empty($label)) {
         $label = $name;
     }
     $label = $this->addLabel($label);
     $object_name = $this->module;
     $db_name = $this->getDBName($name);
     if (isset($this->avail_fields[$db_name])) {
         return;
     }
     if (!array_key_exists($this->module, $this->modules)) {
         $this->createCustomTable();
     }
     require_once 'modules/EditCustomFields/FieldsMetaData.php';
     $fmd = new FieldsMetaData();
     $fmd->id = $object_name . $db_name;
     $fmd->custom_module = $object_name;
     $fmd->name = $db_name;
     $fmd->label = $label;
     $fmd->data_type = $type;
     $fmd->max_size = $max_size;
     $fmd->required_option = $required_option;
     $fmd->default_value = $default_value;
     $fmd->ext1 = $ext1;
     $fmd->ext2 = $ext2;
     $fmd->ext3 = $ext3;
     $fmd->ext4 = $ext4;
     $fmd->help = $help;
     $fmd->mass_update = $mass_update;
     $fmd->duplicate_merge = $duplicate_merge;
     $fmd->audited = $audited;
     $fmd->new_with_id = true;
     $fmd->save();
     $this->cleanSaveToCache();
     if (!array_key_exists($this->module, $this->modules)) {
         $this->createCustomTable();
         $this->saveCustomModulesList();
     }
     $this->avail_fields = array();
     $this->getAvailableFields(true);
     $field = $this->getField($name);
     if ($field) {
         $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
         if (!empty($query)) {
             $this->db->query($query);
         }
     }
 }
 *
 * 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/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);
示例#10
0
//oracle max is 30,
$name_max_length = 60;
if ($GLOBALS['db']->dbType == 'oci8') {
    $name_max_length = 26;
}
///////////////////////////////////////
// Populate the template
///////////////////////////////////////
$style = 'embeded';
if (isset($_REQUEST['style'])) {
    $style = $_REQUEST['style'];
}
$xtpl = new XTemplate('modules/EditCustomFields/EditView.html');
$xtpl->assign('MOD', $mod_strings);
$xtpl->assign('APP', $app_strings);
$focus = new FieldsMetaData();
$data_type_array = array('varchar' => 'Text', 'text' => 'Text Area', 'int' => 'Integer', 'float' => 'Decimal', 'bool' => 'Checkbox', 'date' => 'Date', 'enum' => 'Dropdown');
$enum_keys = array();
foreach ($app_list_strings as $key => $value) {
    if (is_array($value)) {
        $enum_keys[$key] = $key;
    }
}
if (!empty($_REQUEST['file_type'])) {
    $xtpl->assign('FILE_TYPE', $_REQUEST['file_type']);
}
if (!empty($_REQUEST['field_count'])) {
    $xtpl->assign('FIELD_COUNT', $_REQUEST['field_count']);
}
$return_module = 'EditCustomFields';
$return_action = 'index';