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

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

Minors changes

File size: 3.6 KB
Line 
1<?php
2/* $Id: cf_config.php,v 1.2 2009/08/14 08:05:38 Criss Exp $ */
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4check_status(ACCESS_ADMINISTRATOR);
5
6global $template, $page;
7// Include language advices
8load_language('plugin.lang', CF_PATH);
9
10$cf_plugin = get_plugin_data($plugin_id);
11$cf_config = $cf_plugin->get_config();
12
13if (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
24  // Mandatory name
25  $new_value = false;
26  if (isset($_POST['cf_mandatory_name'])) {
27      if ('1' == $_POST['cf_mandatory_name']) {
28          $new_value = true;
29      }
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);
47  }
48
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);
54  }
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 
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    }
72  }
73 
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'));
81  }
82 
83}
84
85// Define template file
86$template->set_filenames(array(
87    'plugin_admin_content' => realpath(cf_get_template('cf_config.tpl',
88                                                       CF_AMDIN_TPL))
89  ));
90
91$cf = array(
92    'TITLE'     => $cf_plugin->get_title(),
93    'VERSION'   => $cf_plugin->get_version(),
94    'F_ACTION'  => '',
95  );
96
97$config_values = array(
98    'GUEST'             => $cf_config->get_value(CF_CFG_ALLOW_GUEST)?
99                              CF_CHECKED:'',
100    'NEED_NAME'         => $cf_config->get_value(CF_CFG_NAME_MANDATORY)?
101                              CF_CHECKED:'',
102    'NEED_MAIL'         => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)?
103                              CF_CHECKED:'',
104    'PREFIX'            => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX),
105    'SEPARATOR'         => $cf_config->get_value(CF_CFG_SEPARATOR),
106    'SEPARATOR_LENGTH'  => $cf_config->get_value(CF_CFG_SEPARATOR_LEN),
107    'REDIRECT_DELAY'    => $cf_config->get_value(CF_CFG_REDIRECT_DELAY),
108  );
109$template->assign('CF', $cf); 
110$template->assign('CF_CONFIG', $config_values); 
111$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
112
113?>
Note: See TracBrowser for help on using the repository browser.