|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * Copyright (C) 2014 OpenSIPS Project |
| 4 | + * |
| 5 | + * This file is part of opensips-cp, a free Web Control Panel Application for |
| 6 | + * OpenSIPS SIP server. |
| 7 | + * |
| 8 | + * opensips-cp is free software; you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU General Public License as published by |
| 10 | + * the Free Software Foundation; either version 2 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * opensips-cp is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License |
| 19 | + * along with this program; if not, write to the Free Software |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | + */ |
| 22 | + |
| 23 | +############################################################################### |
| 24 | +# Attention : advanced options !! |
| 25 | + |
| 26 | + //this is a very important parameter |
| 27 | + $module_id = "config"; |
| 28 | + $custom_config[$module_id] = array (); |
| 29 | + |
| 30 | + // a custom global name for the tool |
| 31 | + $custom_config[$module_id]['custom_name'] = "Config"; |
| 32 | + |
| 33 | + |
| 34 | +//if you want submenu (horizontal) items add them here: |
| 35 | + |
| 36 | +// $custom_config[$module_id]['submenu_items'] = array( |
| 37 | +// "0" => "Submenu1", |
| 38 | +// "1" => "Submenu2" |
| 39 | +// ); |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +/* config for each submenu item */ |
| 45 | + |
| 46 | +/* |
| 47 | +Example table: table1 |
| 48 | ++---------------+------------------+------+-----+---------+----------------+ |
| 49 | +| Field | Type | Null | Key | Default | Extra | |
| 50 | ++---------------+------------------+------+-----+---------+----------------+ |
| 51 | +| id | int(10) unsigned | NO | PRI | NULL | auto_increment | |
| 52 | +| name | char(128) | NO | UNI | | | |
| 53 | +| address | char(128) | NO | | | | |
| 54 | +| age | int(10) unsigned | NO | | 0 | | |
| 55 | +| married | int(10) unsigned | NO | | 0 | | |
| 56 | ++---------------+------------------+------+-----+---------+----------------+ |
| 57 | +
|
| 58 | +#################################################################################### |
| 59 | +# # |
| 60 | +# Uncomment bellow this line - follow the example and adapt it to your DB table # |
| 61 | +# # |
| 62 | +#################################################################################### |
| 63 | +*/ |
| 64 | + |
| 65 | +$custom_config[$module_id][0]['custom_table'] = get_settings_value("table"); |
| 66 | +$custom_config[$module_id][0]['custom_table_primary_key'] = get_settings_value("id"); |
| 67 | +$custom_config[$module_id][0]['custom_table_order_by'] = $custom_config[$module_id][0]['custom_table_primary_key']; |
| 68 | +$custom_config[$module_id][0]['per_page'] = 50; |
| 69 | +$custom_config[$module_id][0]['page_range'] = 3; |
| 70 | + |
| 71 | +/* |
| 72 | + Columns definition: |
| 73 | + - header - the header title used to label this column (mandatory) |
| 74 | + - type - how to display/handle the data - text / combo / textarea (mandatory) |
| 75 | + - key - the key restrictions for this column (they will be checked prior to DB op) - PRI/UNI (optional) |
| 76 | + - tip - tip/explanation to be attached to this column in the add/edit forms (optional) |
| 77 | + - validation_regex - a regular expression to check the inserted value; only for text type (optional) |
| 78 | + - is_optional - if a value must be provided or not for the column (mandatory) |
| 79 | +
|
| 80 | + - show_in_add_form - if to be shown in the add form (optional) |
| 81 | + - show_in_edit_form - if to be shown in the edit form (optional) |
| 82 | + - searchable - if to be listed as field in the search form (optional) |
| 83 | + - disabled - if the disabled attribute should be set to this column (optional) |
| 84 | + - readonly - if the readonly attribute should be set to this column (optional) |
| 85 | + - visible - if the column should be displayed in the table (optional) |
| 86 | + - value_wrapper_func - php function like func($key, $text, $link) to return |
| 87 | + a custom string to be displayed instead of the real value; parameters are: |
| 88 | + - $key - the name of the column |
| 89 | + - $text - the value of the column |
| 90 | + - $link - an assoc array with all the values of the DB row( i.e $text = $link[$key] ) |
| 91 | + This function can be use to build links or images around the values to be displayed (optional). |
| 92 | +
|
| 93 | + - default_value - optional default value to pre-populate the column in the add form |
| 94 | + - default_display - a default display text corresponding to the default value if the type is COMBO |
| 95 | + - combo_default_values - assoc array (value -> display) for definiting static COMBOs |
| 96 | + Example: array("1"=>"Yes","0"=>"No") |
| 97 | + - combo_table, combo_value_col, combo_display_col, combo_hook_col - set of attributes for |
| 98 | + defininig dynamic combos, with data from DB; table and value are mandatory in this |
| 99 | + configuration; display may be optionaly used; similar the hook - this has no impact |
| 100 | + over the display of the combo; it simply creates a "hook" attribute inside the |
| 101 | + "option" html tag, which may be used by JS function to enable/disable/remove |
| 102 | + the value during runtime. |
| 103 | + |
| 104 | + - events - a string that optionaly may define JS events for the input/select field |
| 105 | + Example: "onChange=\"runJSfunction();\" " |
| 106 | + |
| 107 | + - textarea_display_size - optional value used when a textarea_label_column is not specified, and |
| 108 | + indicates how many characters should be shown from the text area content. Default is 50. |
| 109 | +*/ |
| 110 | + |
| 111 | + $config_name = get_settings_value("name"); |
| 112 | + $config_value = get_settings_value("value"); |
| 113 | + $config_desc = get_settings_value("description"); |
| 114 | + |
| 115 | + $custom_config[$module_id][0]['custom_table_column_defs'] = array ( |
| 116 | + $custom_config[$module_id][0]['custom_table_primary_key'] => array ( |
| 117 | + "header" => "ID", |
| 118 | + "type" => "text", |
| 119 | + "key" => "PRI", |
| 120 | + "show_in_add_form" => false, |
| 121 | + "show_in_edit_form" => false, |
| 122 | + "searchable" => false, |
| 123 | + "visible" => false |
| 124 | + ), |
| 125 | + $config_name => array ( |
| 126 | + "header" => "Name", |
| 127 | + "type" => "text", |
| 128 | + "key" => NULL, |
| 129 | + "tip" => "Name of the configuration to be used in the OpenSIPS script.", |
| 130 | + "validation_regex" => NULL, |
| 131 | + "show_in_add_form" => true, |
| 132 | + "show_in_edit_form" => true, |
| 133 | + "searchable" => true, |
| 134 | + "is_optional" => "n", |
| 135 | + "validation_regex" => "^[^:]+$", |
| 136 | + ), |
| 137 | + $config_value => array ( |
| 138 | + "header" => "Value", |
| 139 | + "type" => "text", |
| 140 | + "key" => NULL, |
| 141 | + "tip" => "The value of the configuration. If empty, NULL value is used.", |
| 142 | + "validation_regex" => ".*", |
| 143 | + "show_in_add_form" => true, |
| 144 | + "show_in_edit_form" => true, |
| 145 | + "searchable" => false, |
| 146 | + "is_optional" => "y", |
| 147 | + ), |
| 148 | + $config_desc => array ( |
| 149 | + "header" => "Description", |
| 150 | + "type" => "text", |
| 151 | + "key" => NULL, |
| 152 | + "tip" => "Description of what the configuration does.", |
| 153 | + "validation_regex" => ".*", |
| 154 | + "show_in_add_form" => true, |
| 155 | + "show_in_edit_form" => true, |
| 156 | + "searchable" => false, |
| 157 | + "is_optional" => "y", |
| 158 | + "default_value" => "", |
| 159 | + "keep_empty_str_val" => true, |
| 160 | + ), |
| 161 | + ); |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + //need to reload 0 or 1 |
| 166 | + $custom_config[$module_id][0]['reload'] = 1; |
| 167 | + |
| 168 | + //if you need reload please specify the MI command to be ran |
| 169 | + $custom_config[$module_id][0]['custom_mi_command'] = "sql_cacher_reload"; |
| 170 | + |
| 171 | + if (get_settings_value("config_id") != NULL) |
| 172 | + $custom_config[$module_id][0]['custom_mi_command'] .= " " . get_settings_value("config_id"); |
| 173 | + |
| 174 | + |
| 175 | + //the system ID to send the reload MI command to |
| 176 | + $talk_to_this_assoc_id = 1; |
| 177 | + |
| 178 | + |
| 179 | +############################################## |
| 180 | +######### CUSTOM SEARCH OPTIONS ############## |
| 181 | +############################################## |
| 182 | +$custom_config[$module_id][0]['custom_search'] = array ( "enabled" => true, |
| 183 | + "action_script" => "custom_actions/search.php" |
| 184 | + ); |
| 185 | + |
| 186 | +############################################## |
| 187 | +####### CUSTOM ACTIONS COLUMNS ############### |
| 188 | +############################################## |
| 189 | + |
| 190 | + $custom_config[$module_id][0]['custom_action_columns'] = array ( |
| 191 | + "0" => array( |
| 192 | + "header" => "Edit", |
| 193 | + "show_header" => false, |
| 194 | + "type" => "link", |
| 195 | + "action" => "edit", |
| 196 | + "icon" => "../../../images/share/edit.png", |
| 197 | + "action_script" => "custom_actions/edit.php", |
| 198 | + "action_template" => "template/custom_templates/edit.php" |
| 199 | + ), |
| 200 | + "1" => array( |
| 201 | + "header" => "Delete", |
| 202 | + "show_header" => false, |
| 203 | + "type" => "link", |
| 204 | + "action" => "delete", |
| 205 | + "icon" => "../../../images/share/delete.png", |
| 206 | + "action_script" => "custom_actions/delete.php", |
| 207 | + "action_template" => "template/custom_templates/delete.php", |
| 208 | + "events" => "onclick=\"return confirmDelete()\"" |
| 209 | + ) |
| 210 | + ); |
| 211 | +############################################## |
| 212 | +####### CUSTOM ACTIONS BUTTON ############### |
| 213 | +############################################## |
| 214 | + |
| 215 | + $custom_config[$module_id][0]['custom_action_buttons'] = array ( |
| 216 | + "0" => array( |
| 217 | + "text" => "Add", |
| 218 | + "action" => "add", |
| 219 | + "style" => "formButton", |
| 220 | + "action_script" => "custom_actions/add.php", |
| 221 | + "action_template" => "template/custom_templates/add.php" |
| 222 | + ) |
| 223 | + ); |
| 224 | + |
0 commit comments