[8152] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | check_status(ACCESS_ADMINISTRATOR); |
---|
[6547] | 4 | |
---|
[8152] | 5 | global $template, $page; |
---|
| 6 | // Include language advices |
---|
| 7 | load_language('plugin.lang', CF_PATH); |
---|
[6547] | 8 | |
---|
[8152] | 9 | $cf_plugin = get_plugin_data($plugin_id); |
---|
| 10 | $cf_config = $cf_plugin->get_config(); |
---|
[6547] | 11 | |
---|
[8152] | 12 | if (isset($_POST['submit'])) { |
---|
| 13 | global $page; |
---|
| 14 | // Allow guest |
---|
| 15 | $new_value = false; |
---|
| 16 | if (isset($_POST['cf_guest_allowed'])) { |
---|
| 17 | if ('1' == $_POST['cf_guest_allowed']) { |
---|
| 18 | $new_value = true; |
---|
| 19 | } |
---|
| 20 | } |
---|
| 21 | $cf_config->set_value(CF_CFG_ALLOW_GUEST, $new_value); |
---|
[6547] | 22 | |
---|
[8152] | 23 | // Mandatory name |
---|
| 24 | $new_value = false; |
---|
| 25 | if (isset($_POST['cf_mandatory_name'])) { |
---|
| 26 | if ('1' == $_POST['cf_mandatory_name']) { |
---|
| 27 | $new_value = true; |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value); |
---|
| 31 | |
---|
| 32 | // Mandatory mail |
---|
| 33 | $new_value = false; |
---|
| 34 | if (isset($_POST['cf_mandatory_mail'])) { |
---|
| 35 | if ('1' == $_POST['cf_mandatory_mail']) { |
---|
| 36 | $new_value = true; |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value); |
---|
| 40 | |
---|
| 41 | // Prefix |
---|
| 42 | $new_value = ''; |
---|
| 43 | if (isset($_POST['cf_mail_prefix'])) { |
---|
| 44 | $new_value = trim(stripslashes($_POST['cf_mail_prefix'])); |
---|
| 45 | $cf_config->set_value(CF_CFG_SUBJECT_PREFIX, $new_value); |
---|
| 46 | } |
---|
[6547] | 47 | |
---|
[8152] | 48 | // Separator |
---|
| 49 | $new_value = ''; |
---|
| 50 | if (isset($_POST['cf_separator'])) { |
---|
| 51 | $new_value = trim(stripslashes($_POST['cf_separator'])); |
---|
| 52 | $cf_config->set_value(CF_CFG_SEPARATOR, $new_value); |
---|
| 53 | } |
---|
| 54 | if (isset($_POST['cf_separator_length'])) { |
---|
| 55 | $new_value = trim(stripslashes($_POST['cf_separator_length'])); |
---|
| 56 | if (ctype_digit($new_value)) { |
---|
| 57 | $cf_config->set_value(CF_CFG_SEPARATOR_LEN, $new_value); |
---|
| 58 | } else { |
---|
| 59 | array_push($page['errors'], l10n('cf_length_not_integer')); |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | // Redirect delay |
---|
| 64 | if (isset($_POST['cf_redirect_delay'])) { |
---|
| 65 | $new_value = trim(stripslashes($_POST['cf_redirect_delay'])); |
---|
| 66 | if (ctype_digit($new_value)) { |
---|
| 67 | $cf_config->set_value(CF_CFG_REDIRECT_DELAY, $new_value); |
---|
| 68 | } else { |
---|
| 69 | array_push($page['errors'], l10n('cf_delay_not_integer')); |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | // Save config |
---|
| 74 | $cf_config->save_config(); |
---|
| 75 | $saved = $cf_config->save_config(); |
---|
| 76 | if ($saved) { |
---|
| 77 | array_push($page['infos'], l10n('cf_config_saved')); |
---|
| 78 | } else { |
---|
| 79 | array_push($page['errors'], l10n('cf_config_saved_with_errors')); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | } |
---|
[6547] | 83 | |
---|
[8152] | 84 | // Define template file |
---|
| 85 | $template->set_filenames(array( |
---|
| 86 | 'plugin_admin_content' => realpath(cf_get_template('cf_config.tpl', |
---|
| 87 | CF_AMDIN_TPL)) |
---|
| 88 | )); |
---|
[6547] | 89 | |
---|
[8152] | 90 | $cf = array( |
---|
| 91 | 'TITLE' => $cf_plugin->get_title(), |
---|
| 92 | 'F_ACTION' => '', |
---|
| 93 | ); |
---|
[6547] | 94 | |
---|
[8152] | 95 | $config_values = array( |
---|
| 96 | 'GUEST' => $cf_config->get_value(CF_CFG_ALLOW_GUEST)? |
---|
| 97 | CF_CHECKED:'', |
---|
| 98 | 'NEED_NAME' => $cf_config->get_value(CF_CFG_NAME_MANDATORY)? |
---|
| 99 | CF_CHECKED:'', |
---|
| 100 | 'NEED_MAIL' => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)? |
---|
| 101 | CF_CHECKED:'', |
---|
| 102 | 'PREFIX' => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX), |
---|
| 103 | 'SEPARATOR' => $cf_config->get_value(CF_CFG_SEPARATOR), |
---|
| 104 | 'SEPARATOR_LENGTH' => $cf_config->get_value(CF_CFG_SEPARATOR_LEN), |
---|
| 105 | 'REDIRECT_DELAY' => $cf_config->get_value(CF_CFG_REDIRECT_DELAY), |
---|
| 106 | ); |
---|
| 107 | $template->assign('CF', $cf); |
---|
| 108 | $template->assign('CF_CONFIG', $config_values); |
---|
[6547] | 109 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 110 | |
---|
| 111 | ?> |
---|