[6547] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* $Id: cf_config.php,v 1.2 2009/08/14 08:05:38 Criss Exp $ */ |
---|
| 4 | |
---|
| 5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 6 | |
---|
| 7 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | global $template, $page; |
---|
| 12 | |
---|
| 13 | // Include language advices |
---|
| 14 | |
---|
| 15 | load_language('plugin.lang', CF_PATH); |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | $cf_plugin = get_plugin_data($plugin_id); |
---|
| 20 | |
---|
| 21 | $cf_config = $cf_plugin->get_config(); |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | if (isset($_POST['submit'])) { |
---|
| 26 | |
---|
| 27 | global $page; |
---|
| 28 | |
---|
| 29 | // Allow guest |
---|
| 30 | |
---|
| 31 | $new_value = false; |
---|
| 32 | |
---|
| 33 | if (isset($_POST['cf_guest_allowed'])) { |
---|
| 34 | |
---|
| 35 | if ('1' == $_POST['cf_guest_allowed']) { |
---|
| 36 | |
---|
| 37 | $new_value = true; |
---|
| 38 | |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | } |
---|
| 42 | |
---|
| 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 | |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value); |
---|
| 62 | |
---|
| 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 | |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value); |
---|
| 80 | |
---|
| 81 | |
---|
| 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 | |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | // Separator |
---|
| 98 | |
---|
| 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 | |
---|
| 126 | |
---|
| 127 | // Redirect delay |
---|
| 128 | |
---|
| 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 config |
---|
| 148 | |
---|
| 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 | } |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | // Define template file |
---|
| 170 | |
---|
| 171 | $template->set_filenames(array( |
---|
| 172 | |
---|
| 173 | 'plugin_admin_content' => realpath(cf_get_template('cf_config.tpl', |
---|
| 174 | |
---|
| 175 | CF_AMDIN_TPL)) |
---|
| 176 | |
---|
| 177 | )); |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | $cf = array( |
---|
| 182 | |
---|
| 183 | 'TITLE' => $cf_plugin->get_title(), |
---|
| 184 | |
---|
| 185 | 'VERSION' => $cf_plugin->get_version(), |
---|
| 186 | |
---|
| 187 | 'F_ACTION' => '', |
---|
| 188 | |
---|
| 189 | ); |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | $config_values = array( |
---|
| 194 | |
---|
| 195 | 'GUEST' => $cf_config->get_value(CF_CFG_ALLOW_GUEST)? |
---|
| 196 | |
---|
| 197 | CF_CHECKED:'', |
---|
| 198 | |
---|
| 199 | 'NEED_NAME' => $cf_config->get_value(CF_CFG_NAME_MANDATORY)? |
---|
| 200 | |
---|
| 201 | CF_CHECKED:'', |
---|
| 202 | |
---|
| 203 | 'NEED_MAIL' => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)? |
---|
| 204 | |
---|
| 205 | CF_CHECKED:'', |
---|
| 206 | |
---|
| 207 | 'PREFIX' => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX), |
---|
| 208 | |
---|
| 209 | 'SEPARATOR' => $cf_config->get_value(CF_CFG_SEPARATOR), |
---|
| 210 | |
---|
| 211 | 'SEPARATOR_LENGTH' => $cf_config->get_value(CF_CFG_SEPARATOR_LEN), |
---|
| 212 | |
---|
| 213 | 'REDIRECT_DELAY' => $cf_config->get_value(CF_CFG_REDIRECT_DELAY), |
---|
| 214 | |
---|
| 215 | ); |
---|
| 216 | |
---|
| 217 | $template->assign('CF', $cf); |
---|
| 218 | |
---|
| 219 | $template->assign('CF_CONFIG', $config_values); |
---|
| 220 | |
---|
| 221 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 222 | |
---|
| 223 | ?> |
---|