Exemple #1
0
 public function process()
 {
     if ('save_extra_default' == $_REQUEST['_process']) {
         if (!module_config::can_i('edit', 'Settings')) {
             die('No perms to save extra field settings.');
         }
         if (isset($_REQUEST['butt_del'])) {
             if (module_form::confirm_delete('extra_default_id', _l("Really delete this extra field and ALL extra data linked to this field?"), $_SERVER['REQUEST_URI'])) {
                 $extra_default = module_extra::get_extra_default($_REQUEST['extra_default_id']);
                 if ($extra_default && $extra_default['extra_default_id'] == $_REQUEST['extra_default_id'] && $extra_default['owner_table'] && $extra_default['extra_key']) {
                     $extra_values = get_multiple('extra', array('owner_table' => $extra_default['owner_table'], 'extra_key' => $extra_default['extra_key']), 'extra_id', 'exact', 'owner_id');
                     if ($extra_values) {
                         foreach ($extra_values as $extra_value) {
                             if ($extra_value['owner_table'] == $extra_default['owner_table'] && $extra_value['extra_key'] == $extra_default['extra_key']) {
                                 delete_from_db('extra', 'extra_id', $extra_value['extra_id']);
                             }
                         }
                     }
                 }
                 delete_from_db('extra_default', 'extra_default_id', $_REQUEST['extra_default_id']);
                 set_message('Extra field deleted successfully.');
                 redirect_browser(str_replace('extra_default_id', 'extra_default_id_deleted', $_SERVER['REQUEST_URI']));
             }
         }
         if ((int) $_REQUEST['extra_default_id'] > 0) {
             $extra_default = module_extra::get_extra_default($_REQUEST['extra_default_id']);
             if ($extra_default && $extra_default['extra_default_id'] == $_REQUEST['extra_default_id'] && $extra_default['owner_table'] && $extra_default['extra_key']) {
                 if (isset($_POST['extra_key']) && !empty($_POST['extra_key']) && $_POST['extra_key'] != $extra_default['extra_key']) {
                     // they have renamed the key, rename all the existing ones in the system.
                     $extra_values = get_multiple('extra', array('owner_table' => $extra_default['owner_table'], 'extra_key' => $extra_default['extra_key']), 'extra_id', 'exact', 'owner_id');
                     if ($extra_values) {
                         foreach ($extra_values as $extra_value) {
                             if ($extra_value['owner_table'] == $extra_default['owner_table'] && $extra_value['extra_key'] == $extra_default['extra_key']) {
                                 update_insert('extra_id', $extra_value['extra_id'], 'extra', array('extra_key' => $_POST['extra_key']));
                             }
                         }
                     }
                 }
             }
         }
         $data = $_POST;
         if (isset($data['options']) && is_array($data['options'])) {
             $data['options'] = json_encode($data['options']);
         }
         update_insert('extra_default_id', $_REQUEST['extra_default_id'], 'extra_default', $data);
         set_message('Extra field saved successfully');
         redirect_browser($_SERVER['REQUEST_URI']);
     }
 }
/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_config::can_i('edit', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
if (isset($_REQUEST['extra_default_id']) && $_REQUEST['extra_default_id']) {
    $show_other_settings = false;
    $extra_default = module_extra::get_extra_default($_REQUEST['extra_default_id']);
    ?>
     <form action="" method="post">
        <input type="hidden" name="_process" value="save_extra_default">
        <input type="hidden" name="extra_default_id" value="<?php 
    echo (int) $_REQUEST['extra_default_id'];
    ?>
" />
     <?php 
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Edit Extra Default Field'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array(array('title' => 'Name/Label', 'field' => array('type' => 'text', 'name' => 'extra_key', 'value' => $extra_default['extra_key'])), array('title' => 'Table', 'field' => array('type' => 'html', 'value' => $extra_default['owner_table'])), array('title' => 'Visibility', 'field' => array('type' => 'select', 'name' => 'display_type', 'value' => $extra_default['display_type'], 'options' => module_extra::get_display_types(), 'blank' => false, 'help' => 'Default will display the extra field when opening an item (eg: opening a customer). If a user can view the customer they will be able to view the extra field information when viewing the customer. Public In Column means that this extra field will also display in the overall listing (eg: customer listing). More options coming soon (eg: private)')), array('title' => 'Order', 'field' => array('type' => 'text', 'name' => 'order', 'value' => $extra_default['order'])), array('title' => 'Searchable', 'field' => array('type' => 'select', 'name' => 'searchable', 'value' => $extra_default['searchable'], 'options' => get_yes_no(), 'blank' => false, 'help' => 'If this field is searchable it will display in the main search bar. Also quick search will return results matching this field. Note: Making every field searchable will slow down the "Quick Search".')), array('title' => 'Field Type', 'field' => array('type' => 'select', 'name' => 'field_type', 'value' => $extra_default['field_type'], 'options' => array('' => 'Text', 'date' => 'Date', 'textarea' => 'Text Area', 'wysiwyg' => 'Rich Text/WYSIWYG', 'checkbox' => 'Tick Box', 'select' => 'Dropdown / Select'), 'blank' => false)), array('title' => 'Dropdown Options', 'field' => array('type' => 'textarea', 'name' => 'options[select]', 'value' => isset($extra_default['options']['select']) ? $extra_default['options']['select'] : '', 'help' => 'Put the drop down options here, one per line (only valid when Field Type is "Dropdown / Select").'))));
    echo module_form::generate_fieldset($fieldset_data);
    $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete'))));
    echo module_form::generate_form_actions($form_actions);
    if ($extra_default['owner_table'] && $extra_default['extra_key']) {
        $extra_values = get_multiple('extra', array('owner_table' => $extra_default['owner_table'], 'extra_key' => $extra_default['extra_key']), 'extra_id', 'exact', 'owner_id');
        if ($extra_values) {