source: extensions/LCAS/trunk/admin/LCAS_admin.php @ 8638

Last change on this file since 8638 was 8638, checked in by LucMorizur, 13 years ago

Properely hook (normally :-/ ...) all cases between LCAS options and $confinsensitive_case_logon , at login as well as at register (normally :-/ ...)

File size: 8.1 KB
RevLine 
[8141]1<?php
2
3global $user, $lang, $conf, $errors;
4
5if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
6// +-----------------------------------------------------------------------+
7// | Check Access and exit when user status is not ok                      |
8// +-----------------------------------------------------------------------+
9check_status(ACCESS_ADMINISTRATOR);
10
11if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
12
13//ini_set('error_reporting', E_ALL);
14//ini_set('display_errors', true);
15
[8181]16include_once(PHPWG_ROOT_PATH.'include/constants.php');
17include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[8141]18$my_base_url = get_admin_plugin_menu_link(__FILE__);
19
20load_language('plugin.lang', LCAS_PATH);
21load_language('help/plugin.lang', LCAS_PATH);
22
23$error = array();
24
[8638]25$t = pwg_db_fetch_row(pwg_query('
26  SELECT `value`
27  FROM `'.CONFIG_TABLE.'`
28  WHERE `param` = "LoginCaseAccentsSensitivity"
29  LIMIT 1;
30'));
31
32$conf['LoginCaseAccentsSensitivity'] = $t[0];
33
[8141]34// +-----------------------------------------------------------------------+
35// |                      Getting plugin version                           |
36// +-----------------------------------------------------------------------+
37$plugin =  LCAS_PluginInfos(LCAS_PATH);
38$version = $plugin['version'];
39
[8638]40        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
[8141]41  {
42
43/* General configuration settings */
[8257]44                $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText'])));
[8638]45   
46                // LCAS configuration is now hereby defined :
47    // $conf_LCAS[0] : "final case", describe how LCAS should behave;
48    // $conf_LCAS[1] : LCAS option, describe the choice of the webmaster;
49    // $conf_LCAS[2] : LCAS_Mail;
50    // $conf_LCAS[3] : LCAS_MailText.
51    $newconf_LCAS= array(
52      LCAS_final_case($_POST['LCAS_Option']),
53      $_POST['LCAS_Option'],
54      // $_POST['LCAS__spare'] : quite lazy, but convenient to not have to
55      // decrease index of each option below everywhere :-/ ...
[8271]56      $_POST['LCAS_Mail'],
[8257]57      $_POST['LCAS_MailText']);
[8141]58
59    $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS);
60
61                $query = '
62                UPDATE '.CONFIG_TABLE.'
63                SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'"
64                WHERE param="LoginCaseAccentsSensitivity"
65                LIMIT 1
66                ;';
67               
68                pwg_query($query);
69
[8638]70    array_push($page['infos'], l10n('LCAS_save_config'));
[8141]71  }
72
[8181]73        $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
[8638]74  $conf_LCAS[0] = LCAS_final_case($conf_LCAS[1]);
75 
76  if (isset($conf_LCAS[0]))
77  {
78    // $conf['insensitive_case_logon'] must be true or false when needed
79    if ($conf_LCAS[0]=='4' or $conf_LCAS[0]=='5')
80     array_push($page['errors'], l10n('LCAS_warning'));
81    elseif ($conf_LCAS[0]=='6' or $conf_LCAS[0]=='7')
82     array_push($page['errors'], l10n('LCAS_warning2'));
[8141]83
[8638]84    $case_ins = (in_array($conf_LCAS[0], array('1', '3','6','7')));
85    $acc_ins = (in_array($conf_LCAS[0], array('2', '5', '3','6','7')));
86
87    if ($case_ins or $acc_ins)
88    {
[8141]89// +-----------------------------------------------------------------------+
90// |                           initialization                              |
91// +-----------------------------------------------------------------------+
92
[8638]93      $lcas_UserToUpdate = -1;
94      if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
95        $lcas_UserToUpdate = $_POST['UserToUpdate'];
96       
97        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
98          // Vérifier si le nom n'est pas déjà pris
99         
100         
101         
102          // Mise à jour du nom
103          $query = '
104            UPDATE '.USERS_TABLE.'
105            SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
106            WHERE id='.$lcas_UserToUpdate.'
107            LIMIT 1
108            ;';
[8141]109
[8638]110          pwg_query($query);
[8271]111
[8638]112        if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true')
113        {
114          LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
115        }
116
117          array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
118        }
119        else {
120          // User is empty
121          array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
122        }
[8271]123      }
124
[8164]125
[8141]126// +-----------------------------------------------------------------------+
127// |                               user list                               |
128// +-----------------------------------------------------------------------+
129
[8638]130      $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
[8141]131
132// +-----------------------------------------------------------------------+
133// |                               user list                               |
134// +-----------------------------------------------------------------------+
135
[8638]136      $lcas_previous_compare_user = '';
137      $visible_user_list          = array();
138      foreach ($page['all_users'] as $local_user)
139      {
140        if ($lcas_previous_compare_user != $local_user['transformed']) {
141          $display = 'orange';
142          $lcas_previous_compare_user = $local_user['transformed'];
143        }
144        else {
145          $display = '';
146        }
147
148        $template->append(
149          'users',
150          array(
151            'ID'          => $local_user['id'],
152            'USERNAME'    => stripslashes($local_user['username']),
153            'COMPARE'     => stripslashes($local_user['transformed']),
154            'EMAIL'       => get_email_address_as_display_text($local_user['email']),
155            'DISPLAY'     => $display,
156          )
157        );
[8141]158      }
[8638]159      /* Plugin version insert */
160      $template->assign(
161        array(
162          'LCAS_VERSION'  => $version,
163          'LCAS_PATH'     => LCAS_PATH,
164        )
165      );   
[8141]166
[8638]167     
[8141]168// +-----------------------------------------------------------------------+
169// |                             errors display                            |
170// +-----------------------------------------------------------------------+
[8638]171      if ( isset ($errors) and count($errors) != 0)
172      {
173        $template->assign('errors',array());
174        foreach ($errors as $error)
175        {
176          array_push($page['errors'], $error);
177        }
178      } 
[8141]179
[8638]180    }
[8181]181  }
182
183
[8271]184// +-----------------------------------------------------------------------+
185// |                           templates init                              |
186// +-----------------------------------------------------------------------+
[8181]187  $template->assign(
188    array(
[8271]189    'LCAS_VERSION'                  => $version,
190    'LCAS_PATH'                     => LCAS_PATH,
[8638]191    'PWG_insensitive_case_logon'    => ($conf['insensitive_case_logon']),
192    'Personalized_not_allowed'      => (!isset($conf['LCAS_replacement_set'][0])),
193                'LCAS_final_case'               => $conf_LCAS[0],
194                'LCAS_Option'                   => $conf_LCAS[1],
[8271]195                'LCAS_MAIL_TRUE'                => $conf_LCAS[2]=='true'          ? 'checked="checked"' : '' ,
196                'LCAS_MAIL_FALSE'               => $conf_LCAS[2]=='false'         ? 'checked="checked"' : '' ,
197    'LCAS_MAILTEXT'                 => $conf_LCAS[3]
[8181]198    )
199  );
200
201
[8141]202// +-----------------------------------------------------------------------+
[8181]203// |                             errors display                            |
[8141]204// +-----------------------------------------------------------------------+
[8181]205  if (isset ($errors) and count($errors) != 0)
[8141]206  {
[8181]207          $template->assign('errors',array());
208          foreach ($errors as $error)
209          {
210                  array_push($page['errors'], $error);
211                }
212        } 
[8141]213
[8181]214// +-----------------------------------------------------------------------+
215// |                           templates display                           |
216// +-----------------------------------------------------------------------+
217  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl');
218  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
219
[8214]220?>
Note: See TracBrowser for help on using the repository browser.