Ejemplo n.º 1
0
if (dpGetParam($_REQUEST, 'field_id', NULL) != NULL) {
    $custom_fields = new CustomFields($module, 'addedit', NULL, 'edit');
    if ($delete_field) {
        $custom_fields->deleteField($field_id);
        $AppUI->setMsg('Selected field has been deleted.', UI_MSG_INFO);
        echo $AppUI->getMsg();
        exit;
    }
    $cf =& $custom_fields->fieldWithId($field_id);
    if (is_object($cf)) {
        $field_name = $cf->fieldName();
        $field_description = $cf->fieldDescription();
        $field_htmltype = $cf->fieldHtmlType();
        $field_extratags = $cf->fieldExtraTags();
        if ($field_htmltype == 'select') {
            $select_options = new CustomOptionList($field_id);
            $select_options->load();
            $select_items = $select_options->getOptions();
        }
    } else {
        $AppUI->setMsg('Couldnt load the Custom Field,<br/>It might have been deleted somehow.', UI_MSG_ERROR);
        echo $AppUI->getMsg();
        exit;
    }
    $edit_title = $AppUI->_('Edit Custom Field In');
} else {
    $edit_title = $AppUI->_('New Custom Field In');
    $field_name = dpGetParam($_POST, 'field_name', NULL);
    $field_description = dpGetParam($_POST, 'field_description', NULL);
    $field_htmltype = dpGetParam($_POST, 'field_htmltype', 'textinput');
    $field_extratags = dpGetParam($_POST, 'field_extratags', NULL);
Ejemplo n.º 2
0
    $field_htmltype = dpGetParam($_POST, "field_htmltype", NULL);
    $field_datatype = dpGetParam($_POST, "field_datatype", "alpha");
    $field_extratags = db_escape(dpGetParam($_POST, "field_extratags", NULL));
    $list_select_items = dpGetParam($_POST, "select_items", NULL);
    $custom_fields = new CustomFields(strtolower($edit_module), 'addedit', null, null);
    if ($edit_field_id == 0) {
        $fid = $custom_fields->add($field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $msg);
    } else {
        $fid = $custom_fields->update($edit_field_id, $field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $msg);
    }
    // Add or Update a Custom Field
    if ($msg) {
        $AppUI->setMsg($AppUI->_('Error adding custom field:') . $msg, UI_MSG_ALERT, true);
    } else {
        if ($field_htmltype == "select") {
            $opts = new CustomOptionList($fid);
            $opts->setOptions($list_select_items);
            if ($edit_field_id == 0) {
                $o_msg = $opts->store();
            } else {
                // To update each list would be a lot more complex than rewriting it
                // So it is, but it is needed in order for it to work properly. (Pedro A. Bug 1163)
                $o_msg = $opts->store();
            }
            if ($o_msg) {
                // Select List Failed - Delete CustomField also
            }
        }
        $AppUI->setMsg($AppUI->_('Custom field added successfully'), UI_MSG_OK, true);
    }
}