Changeset 8152
- Timestamp:
- Dec 15, 2010, 3:13:25 PM (13 years ago)
- Location:
- extensions/ContactForm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContactForm/admin/cf_config.php
r6547 r8152 1 1 <?php 2 3 2 /* $Id: cf_config.php,v 1.2 2009/08/14 08:05:38 Criss Exp $ */ 4 5 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 6 7 4 check_status(ACCESS_ADMINISTRATOR); 8 5 9 10 11 6 global $template, $page; 12 13 7 // Include language advices 14 15 8 load_language('plugin.lang', CF_PATH); 16 9 17 18 19 10 $cf_plugin = get_plugin_data($plugin_id); 20 21 11 $cf_config = $cf_plugin->get_config(); 22 12 13 if (isset($_POST['submit'])) { 14 global $page; 15 // Allow guest 16 $new_value = false; 17 if (isset($_POST['cf_guest_allowed'])) { 18 if ('1' == $_POST['cf_guest_allowed']) { 19 $new_value = true; 20 } 21 } 22 $cf_config->set_value(CF_CFG_ALLOW_GUEST, $new_value); 23 23 24 25 if (isset($_POST['submit'])) { 26 27 global $page; 28 29 // Allow guest 30 24 // Mandatory name 31 25 $new_value = false; 32 33 if (isset($_POST['cf_guest_allowed'])) { 34 35 if ('1' == $_POST['cf_guest_allowed']) { 36 26 if (isset($_POST['cf_mandatory_name'])) { 27 if ('1' == $_POST['cf_mandatory_name']) { 37 28 $new_value = true; 38 39 29 } 40 30 } 31 $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value); 32 33 // Mandatory mail 34 $new_value = false; 35 if (isset($_POST['cf_mandatory_mail'])) { 36 if ('1' == $_POST['cf_mandatory_mail']) { 37 $new_value = true; 38 } 39 } 40 $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value); 41 42 // Prefix 43 $new_value = ''; 44 if (isset($_POST['cf_mail_prefix'])) { 45 $new_value = trim(stripslashes($_POST['cf_mail_prefix'])); 46 $cf_config->set_value(CF_CFG_SUBJECT_PREFIX, $new_value); 41 47 } 42 48 43 $cf_config->set_value(CF_CFG_ALLOW_GUEST, $new_value); 44 45 46 47 // Mandatory name 48 49 $new_value = false; 50 51 if (isset($_POST['cf_mandatory_name'])) { 52 53 if ('1' == $_POST['cf_mandatory_name']) { 54 55 $new_value = true; 56 57 } 58 49 // Separator 50 $new_value = ''; 51 if (isset($_POST['cf_separator'])) { 52 $new_value = trim(stripslashes($_POST['cf_separator'])); 53 $cf_config->set_value(CF_CFG_SEPARATOR, $new_value); 59 54 } 60 61 $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value); 62 55 if (isset($_POST['cf_separator_length'])) { 56 $new_value = trim(stripslashes($_POST['cf_separator_length'])); 57 if (ctype_digit($new_value)) { 58 $cf_config->set_value(CF_CFG_SEPARATOR_LEN, $new_value); 59 } else { 60 array_push($page['errors'], l10n('cf_length_not_integer')); 61 } 62 } 63 63 64 65 // Mandatory mail 66 67 $new_value = false; 68 69 if (isset($_POST['cf_mandatory_mail'])) { 70 71 if ('1' == $_POST['cf_mandatory_mail']) { 72 73 $new_value = true; 74 75 } 76 64 // Redirect delay 65 if (isset($_POST['cf_redirect_delay'])) { 66 $new_value = trim(stripslashes($_POST['cf_redirect_delay'])); 67 if (ctype_digit($new_value)) { 68 $cf_config->set_value(CF_CFG_REDIRECT_DELAY, $new_value); 69 } else { 70 array_push($page['errors'], l10n('cf_delay_not_integer')); 71 } 77 72 } 78 79 $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value);80 81 73 82 83 // Prefix 84 85 $new_value = ''; 86 87 if (isset($_POST['cf_mail_prefix'])) { 88 89 $new_value = trim(stripslashes($_POST['cf_mail_prefix'])); 90 91 $cf_config->set_value(CF_CFG_SUBJECT_PREFIX, $new_value); 92 74 // Save config 75 $cf_config->save_config(); 76 $saved = $cf_config->save_config(); 77 if ($saved) { 78 array_push($page['infos'], l10n('cf_config_saved')); 79 } else { 80 array_push($page['errors'], l10n('cf_config_saved_with_errors')); 93 81 } 94 95 96 97 // Separator98 99 $new_value = '';100 101 if (isset($_POST['cf_separator'])) {102 103 $new_value = trim(stripslashes($_POST['cf_separator']));104 105 $cf_config->set_value(CF_CFG_SEPARATOR, $new_value);106 107 }108 109 if (isset($_POST['cf_separator_length'])) {110 111 $new_value = trim(stripslashes($_POST['cf_separator_length']));112 113 if (ctype_digit($new_value)) {114 115 $cf_config->set_value(CF_CFG_SEPARATOR_LEN, $new_value);116 117 } else {118 119 array_push($page['errors'], l10n('cf_length_not_integer'));120 121 }122 123 }124 125 82 126 127 // Redirect delay128 129 if (isset($_POST['cf_redirect_delay'])) {130 131 $new_value = trim(stripslashes($_POST['cf_redirect_delay']));132 133 if (ctype_digit($new_value)) {134 135 $cf_config->set_value(CF_CFG_REDIRECT_DELAY, $new_value);136 137 } else {138 139 array_push($page['errors'], l10n('cf_delay_not_integer'));140 141 }142 143 }144 145 146 147 // Save config148 149 $cf_config->save_config();150 151 $saved = $cf_config->save_config();152 153 if ($saved) {154 155 array_push($page['infos'], l10n('cf_config_saved'));156 157 } else {158 159 array_push($page['errors'], l10n('cf_config_saved_with_errors'));160 161 }162 163 164 165 83 } 166 84 167 168 169 85 // Define template file 170 171 86 $template->set_filenames(array( 172 173 87 'plugin_admin_content' => realpath(cf_get_template('cf_config.tpl', 174 175 88 CF_AMDIN_TPL)) 176 177 89 )); 178 90 179 180 181 91 $cf = array( 182 183 92 'TITLE' => $cf_plugin->get_title(), 184 185 93 'VERSION' => $cf_plugin->get_version(), 186 187 94 'F_ACTION' => '', 188 189 95 ); 190 96 191 192 193 97 $config_values = array( 194 195 98 'GUEST' => $cf_config->get_value(CF_CFG_ALLOW_GUEST)? 196 197 99 CF_CHECKED:'', 198 199 100 'NEED_NAME' => $cf_config->get_value(CF_CFG_NAME_MANDATORY)? 200 201 101 CF_CHECKED:'', 202 203 102 'NEED_MAIL' => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)? 204 205 103 CF_CHECKED:'', 206 207 104 'PREFIX' => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX), 208 209 105 'SEPARATOR' => $cf_config->get_value(CF_CFG_SEPARATOR), 210 211 106 'SEPARATOR_LENGTH' => $cf_config->get_value(CF_CFG_SEPARATOR_LEN), 212 213 107 'REDIRECT_DELAY' => $cf_config->get_value(CF_CFG_REDIRECT_DELAY), 214 215 108 ); 216 217 109 $template->assign('CF', $cf); 218 219 110 $template->assign('CF_CONFIG', $config_values); 220 221 111 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 222 112 -
extensions/ContactForm/include/cf_functions.inc.php
r7202 r8152 119 119 } 120 120 121 /* Return template for user template/theme */121 /* Return template for user template/theme */ 122 122 function cf_get_template($file, $dir=CF_TEMPLATE, $prefix='') { 123 123 global $user, $template;
Note: See TracChangeset
for help on using the changeset viewer.