Example #1
0
/**
 * @return bool
 * @param module string, key string, value string
 * @desc Wrapper function that will create a field label for every language.
 */
function create_field_label_all_lang($module, $key, $value, $overwrite = false)
{
    $languages = get_languages();
    $return_value = false;
    foreach ($languages as $lang_key => $lang_value) {
        $return_value = create_field_label($module, $lang_key, $key, $value, $overwrite);
        if (!$return_value) {
            break;
        }
    }
    return $return_value;
}
Example #2
0
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
global $current_language;
$module_name = $_REQUEST['module_name'];
if (isset($_REQUEST['multi_edit'])) {
    unset($_REQUEST['action']);
    unset($_REQUEST['module_name']);
    unset($_REQUEST['module']);
    $the_strings = return_module_language($current_language, $module_name);
    foreach ($_REQUEST as $key => $value) {
        if (isset($the_strings[$key])) {
            create_field_label($module_name, $current_language, $key, $value, true);
        }
    }
    $location = "index.php?action=LabelList&module=LabelEditor&refreshparent=1&sugar_body_only=1";
    header("Location:{$location}");
} else {
    create_field_label($module_name, $current_language, $_REQUEST['record'], $_REQUEST['value'], true);
    $location = "index.php?action=" . $_REQUEST['return_action'] . "&module=" . $_REQUEST['return_module'];
    if (isset($_REQUEST['module_name'])) {
        $location .= "&module_name=" . $_REQUEST['module_name'];
    }
    if (isset($_REQUEST['sugar_body_only'])) {
        $location .= "&sugar_body_only=" . $_REQUEST['sugar_body_only'];
    }
    if (isset($_REQUEST['style']) && $_REQUEST['style'] == 'popup') {
        $location .= '&refreshparent=1';
    }
    header("Location:{$location}");
}
 function addLabel($label)
 {
     global $current_language;
     $limit = 10;
     $count = 0;
     $field_key = $this->getDBName($label);
     $curr_field_key = $this->getDBName($label);
     while (!create_field_label($this->module, $current_language, $curr_field_key, $label)) {
         $curr_field_key = $field_key . "_{$count}";
         if ($count == $limit) {
             return $curr_field_key;
         }
         $count++;
     }
     return $curr_field_key;
 }
 function save_field(&$args)
 {
     global $custom_fields_def;
     global $current_language;
     global $beanList;
     global $beanFiles;
     if (empty($args['field_label']) || empty($args['module_name']) || empty($args['field_type'])) {
         die("correct parameters not set for save field");
     }
     if (empty($beanList[$args['module_name']])) {
         die("module is not defined in the beanList");
     }
     $object_name = $beanList[$args['module_name']];
     require_once $beanFiles[$object_name];
     $bean = new $object_name();
     if (empty($custom_fields_def[$bean->object_name])) {
         $custom_fields_def[$bean->object_name] = array();
     }
     $new_field = array();
     $new_field['name'] = preg_replace("/[^\\w]+/", "_", strtolower($args['field_label']));
     foreach ($bean->column_fields as $column_name) {
         if ($new_field['name'] == $column_name) {
             $new_field['name'] .= '_custom';
         }
     }
     $field_key = "LBL_" . strtoupper($new_field['name']);
     $curr_field_key = $field_key;
     $count = 1;
     $limit = 10;
     while (!create_field_label($args['module_name'], $current_language, $curr_field_key, $args['field_label'])) {
         $curr_field_key = $field_key . "_{$count}";
         if ($count == $limit) {
             sugar_die("can't create field label");
         }
         $count++;
     }
     $new_field['label'] = "MOD." . $curr_field_key;
     $new_field['type'] = $args['field_type'];
     if ($new_field['type'] == 'enum') {
         if (empty($args['options'])) {
             die("options where not defined for this field");
         }
         $new_field['options'] = $args['options'];
     }
     array_push($custom_fields_def[$bean->object_name], $new_field);
     $this->save_custom_file($custom_fields_def);
     return $new_field;
 }
 function handleSaveLabels($module_name, $language)
 {
     $the_strings = return_module_language($language, $module_name);
     foreach ($_REQUEST as $key => $value) {
         if (substr_count($key, 'label_') == 1 && strcmp($value, 'no_change') != 0) {
             $key = substr($key, 6);
             //if(isset($the_strings[$key])){
             create_field_label($module_name, $language, $key, $value, true);
             //}
         }
     }
 }