source: extensions/ContactForm/admin/cf_config.tab.php @ 3748

Last change on this file since 3748 was 3748, checked in by Criss, 15 years ago

Add configuration option to define template variable or not

File size: 3.6 KB
Line 
1<?php
2/* $Id: cf_config.tab.php,v 1.2 2009/08/18 14:10:09 Criss Exp $ */
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4check_status(ACCESS_ADMINISTRATOR);
5
6
7if (isset($_POST['submit'])) {
8  // Allow guest
9  $new_value = false;
10  if (isset($_POST['cf_guest_allowed'])) {
11    if ('1' == $_POST['cf_guest_allowed']) {
12      $new_value = true;
13    }
14  }
15  $cf_config->set_value(CF_CFG_ALLOW_GUEST, $new_value);
16
17  // Mandatory name
18  $new_value = false;
19  if (isset($_POST['cf_mandatory_name'])) {
20    if ('1' == $_POST['cf_mandatory_name']) {
21      $new_value = true;
22    }
23  }
24  $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value);
25 
26  // Mandatory mail
27  $new_value = false;
28  if (isset($_POST['cf_mandatory_mail'])) {
29    if ('1' == $_POST['cf_mandatory_mail']) {
30      $new_value = true;
31    }
32  }
33  $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value);
34
35  // Define link
36  $new_value = false;
37  if (isset($_POST['cf_define_link'])) {
38    if ('1' == $_POST['cf_define_link']) {
39      $new_value = true;
40    }
41  }
42  $cf_config->set_value(CF_CFG_DEFINE_LINK, $new_value);
43 
44  // Link
45  $new_value = '';
46  if (isset($_POST['cf_link'])) {
47    $new_value = trim(stripslashes($_POST['cf_link']));
48    $str_valid = preg_match_all('/\w{1}\w*/i', $new_value, $match);
49    if (1 != $str_valid) {
50      CF_Log::add_error(l10n('cf_link_error'));
51    } else {
52      $cf_config->set_value(CF_CFG_CONTACT_LINK, $new_value);
53    }
54  }
55 
56  // Prefix
57  $new_value = '';
58  if (isset($_POST['cf_mail_prefix'])) {
59    $new_value = trim(stripslashes($_POST['cf_mail_prefix']));
60    $cf_config->set_value(CF_CFG_SUBJECT_PREFIX, $new_value);
61  }
62
63  // Separator
64  $new_value = '';
65  if (isset($_POST['cf_separator'])) {
66    $new_value = trim(stripslashes($_POST['cf_separator']));
67    $cf_config->set_value(CF_CFG_SEPARATOR, $new_value);
68  }
69  if (isset($_POST['cf_separator_length'])) {
70    $new_value = trim(stripslashes($_POST['cf_separator_length']));
71    if (ctype_digit($new_value)) {
72      $cf_config->set_value(CF_CFG_SEPARATOR_LEN, $new_value);
73    } else {
74      CF_Log::add_error(l10n('cf_length_not_integer'));
75    }
76  }
77 
78  // Redirect delay
79  if (isset($_POST['cf_redirect_delay'])) {
80    $new_value = trim(stripslashes($_POST['cf_redirect_delay']));
81    if (ctype_digit($new_value)) {
82      $cf_config->set_value(CF_CFG_REDIRECT_DELAY, $new_value);
83    } else {
84      CF_Log::add_error(l10n('cf_delay_not_integer'));
85    }
86  }
87 
88  // Save config
89  $cf_config->save_config();
90  $saved = $cf_config->save_config();
91  if ($saved) {
92    CF_Log::add_message(l10n('cf_config_saved'));
93  } else {
94    CF_Log::add_error(l10n('cf_config_saved_with_errors'));
95  }
96 
97}
98
99$config_values = array(
100    'GUEST'             => $cf_config->get_value(CF_CFG_ALLOW_GUEST)?
101                              CF_CHECKED:'',
102    'NEED_NAME'         => $cf_config->get_value(CF_CFG_NAME_MANDATORY)?
103                              CF_CHECKED:'',
104    'NEED_MAIL'         => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)?
105                              CF_CHECKED:'',
106    'PREFIX'            => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX),
107    'SEPARATOR'         => $cf_config->get_value(CF_CFG_SEPARATOR),
108    'SEPARATOR_LENGTH'  => $cf_config->get_value(CF_CFG_SEPARATOR_LEN),
109    'REDIRECT_DELAY'    => $cf_config->get_value(CF_CFG_REDIRECT_DELAY),
110    'DEFINE_LINK'       => $cf_config->get_value(CF_CFG_DEFINE_LINK)?
111                              CF_CHECKED:'',
112    'LINK'              => $cf_config->get_value(CF_CFG_CONTACT_LINK),
113  );
114
115$template->assign('CF_CONFIG', $config_values); 
116
117?>
Note: See TracBrowser for help on using the repository browser.