source: extensions/ContactForm/admin/cf_config.php @ 8482

Last change on this file since 8482 was 8482, checked in by Gotcha, 13 years ago

Daily MAJ

File size: 3.5 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3check_status(ACCESS_ADMINISTRATOR);
4
5global $template, $page;
6// Include language advices
7load_language('plugin.lang', CF_PATH);
8
9$cf_plugin = get_plugin_data($plugin_id);
10$cf_config = $cf_plugin->get_config();
11
12if (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);
22
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  }
47
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}
83
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  ));
89
90$cf = array(
91    'TITLE'     => $cf_plugin->get_title(),
92    'VERSION'   => $cf_plugin->get_version(),
93    'F_ACTION'  => '',
94  );
95
96$config_values = array(
97    'GUEST'             => $cf_config->get_value(CF_CFG_ALLOW_GUEST)?
98                              CF_CHECKED:'',
99    'NEED_NAME'         => $cf_config->get_value(CF_CFG_NAME_MANDATORY)?
100                              CF_CHECKED:'',
101    'NEED_MAIL'         => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)?
102                              CF_CHECKED:'',
103    'PREFIX'            => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX),
104    'SEPARATOR'         => $cf_config->get_value(CF_CFG_SEPARATOR),
105    'SEPARATOR_LENGTH'  => $cf_config->get_value(CF_CFG_SEPARATOR_LEN),
106    'REDIRECT_DELAY'    => $cf_config->get_value(CF_CFG_REDIRECT_DELAY),
107  );
108$template->assign('CF', $cf); 
109$template->assign('CF_CONFIG', $config_values); 
110$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
111
112?>
Note: See TracBrowser for help on using the repository browser.