Ignore:
Timestamp:
Dec 15, 2010, 3:13:25 PM (13 years ago)
Author:
Gotcha
Message:

Minors changes

Location:
extensions/ContactForm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContactForm/admin/cf_config.php

    r6547 r8152  
    11<?php
    2 
    32/* $Id: cf_config.php,v 1.2 2009/08/14 08:05:38 Criss Exp $ */
    4 
    53if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    6 
    74check_status(ACCESS_ADMINISTRATOR);
    85
    9 
    10 
    116global $template, $page;
    12 
    137// Include language advices
    14 
    158load_language('plugin.lang', CF_PATH);
    169
    17 
    18 
    1910$cf_plugin = get_plugin_data($plugin_id);
    20 
    2111$cf_config = $cf_plugin->get_config();
    2212
     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);
    2323
    24 
    25 if (isset($_POST['submit'])) {
    26 
    27   global $page;
    28 
    29   // Allow guest
    30 
     24  // Mandatory name
    3125  $new_value = false;
    32 
    33   if (isset($_POST['cf_guest_allowed'])) {
    34 
    35       if ('1' == $_POST['cf_guest_allowed']) {
    36 
     26  if (isset($_POST['cf_mandatory_name'])) {
     27      if ('1' == $_POST['cf_mandatory_name']) {
    3728          $new_value = true;
    38 
    3929      }
    40 
     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);
    4147  }
    4248
    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 
     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);
    5954  }
    60 
    61   $cf_config->set_value(CF_CFG_NAME_MANDATORY, $new_value);
    62 
     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  }
    6363 
    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 
     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    }
    7772  }
    78 
    79   $cf_config->set_value(CF_CFG_MAIL_MANDATORY, $new_value);
    80 
    8173 
    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 
     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'));
    9381  }
    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 
    12582 
    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 
    16583}
    16684
    167 
    168 
    16985// Define template file
    170 
    17186$template->set_filenames(array(
    172 
    17387    'plugin_admin_content' => realpath(cf_get_template('cf_config.tpl',
    174 
    17588                                                       CF_AMDIN_TPL))
    176 
    17789  ));
    17890
    179 
    180 
    18191$cf = array(
    182 
    18392    'TITLE'     => $cf_plugin->get_title(),
    184 
    18593    'VERSION'   => $cf_plugin->get_version(),
    186 
    18794    'F_ACTION'  => '',
    188 
    18995  );
    19096
    191 
    192 
    19397$config_values = array(
    194 
    19598    'GUEST'             => $cf_config->get_value(CF_CFG_ALLOW_GUEST)?
    196 
    19799                              CF_CHECKED:'',
    198 
    199100    'NEED_NAME'         => $cf_config->get_value(CF_CFG_NAME_MANDATORY)?
    200 
    201101                              CF_CHECKED:'',
    202 
    203102    'NEED_MAIL'         => $cf_config->get_value(CF_CFG_MAIL_MANDATORY)?
    204 
    205103                              CF_CHECKED:'',
    206 
    207104    'PREFIX'            => $cf_config->get_value(CF_CFG_SUBJECT_PREFIX),
    208 
    209105    'SEPARATOR'         => $cf_config->get_value(CF_CFG_SEPARATOR),
    210 
    211106    'SEPARATOR_LENGTH'  => $cf_config->get_value(CF_CFG_SEPARATOR_LEN),
    212 
    213107    'REDIRECT_DELAY'    => $cf_config->get_value(CF_CFG_REDIRECT_DELAY),
    214 
    215108  );
    216 
    217109$template->assign('CF', $cf); 
    218 
    219110$template->assign('CF_CONFIG', $config_values); 
    220 
    221111$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    222112
  • extensions/ContactForm/include/cf_functions.inc.php

    r7202 r8152  
    119119}
    120120
    121 /* Return template for user template/theme*/
     121/* Return template for user template/theme */
    122122function cf_get_template($file, $dir=CF_TEMPLATE, $prefix='') {
    123123  global $user, $template;
Note: See TracChangeset for help on using the changeset viewer.