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

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

LCAS takes completely care for case sensitivity: $confinsensitive_case_logon set to false by LCAS

File size: 7.0 KB
Line 
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
16include_once(PHPWG_ROOT_PATH.'include/constants.php');
17include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
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
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
34// +-----------------------------------------------------------------------+
35// |                      Getting plugin version                           |
36// +-----------------------------------------------------------------------+
37$plugin =  LCAS_PluginInfos(LCAS_PATH);
38$version = $plugin['version'];
39
40        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
41  {
42
43/* General configuration settings */
44                $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText'])));
45   
46                // LCAS configuration is now hereby defined :
47    // $conf_LCAS[0] : spare // quite lazy, but convenient to not have to
48      // decrease index of each option below everywhere :-/ ...
49    // $conf_LCAS[1] : LCAS option, describe the choice of the webmaster;
50    // $conf_LCAS[2] : LCAS_Mail;
51    // $conf_LCAS[3] : LCAS_MailText.
52    $newconf_LCAS= array(
53      '', // quite lazy, but convenient to not have to
54      // decrease index of each option everywhere :-/ ...
55      $_POST['LCAS_Option'],
56      $_POST['LCAS_Mail'],
57      $_POST['LCAS_MailText']);
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
70    array_push($page['infos'], l10n('LCAS_save_config'));
71  }
72
73        $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
74 
75  if (isset($conf_LCAS[1]))
76  {
77    $case_ins = ($conf_LCAS[1] == '1' or $conf_LCAS[1] == '3');
78    $acc_ins = ($conf_LCAS[1] == '2' or $conf_LCAS[1] == '3');
79
80    if ($case_ins or $acc_ins)
81    {
82// +-----------------------------------------------------------------------+
83// |                           initialization                              |
84// +-----------------------------------------------------------------------+
85
86      $lcas_UserToUpdate = -1;
87      if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
88        $lcas_UserToUpdate = $_POST['UserToUpdate'];
89       
90        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
91          // Vérifier si le nom n'est pas déjà pris
92         
93         
94         
95          // Mise à jour du nom
96          $query = '
97            UPDATE '.USERS_TABLE.'
98            SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
99            WHERE id='.$lcas_UserToUpdate.'
100            LIMIT 1
101            ;';
102
103          pwg_query($query);
104
105        if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true')
106        {
107          LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
108        }
109
110          array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
111        }
112        else {
113          // User is empty
114          array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
115        }
116      }
117
118
119// +-----------------------------------------------------------------------+
120// |                               user list                               |
121// +-----------------------------------------------------------------------+
122
123      $page['all_users'] = LCAS_get_user_list($conf_LCAS[1]);
124
125// +-----------------------------------------------------------------------+
126// |                               user list                               |
127// +-----------------------------------------------------------------------+
128
129      $lcas_previous_compare_user = '';
130      $visible_user_list          = array();
131      foreach ($page['all_users'] as $local_user)
132      {
133        if ($lcas_previous_compare_user != $local_user['transformed']) {
134          $display = 'orange';
135          $lcas_previous_compare_user = $local_user['transformed'];
136        }
137        else {
138          $display = '';
139        }
140
141        $template->append(
142          'users',
143          array(
144            'ID'          => $local_user['id'],
145            'USERNAME'    => stripslashes($local_user['username']),
146            'COMPARE'     => stripslashes($local_user['transformed']),
147            'EMAIL'       => get_email_address_as_display_text($local_user['email']),
148            'DISPLAY'     => $display,
149          )
150        );
151      }
152     
153    }
154  }
155
156
157// +-----------------------------------------------------------------------+
158// |                           templates init                              |
159// +-----------------------------------------------------------------------+
160  $template->assign(
161    array(
162    'LCAS_VERSION'                  => $version,
163    'LCAS_PATH'                     => LCAS_PATH,
164    'Personalized_not_allowed'      => (!isset($conf['LCAS_replacement_set'][0])),
165                'LCAS_Option'                   => $conf_LCAS[1],
166                'LCAS_MAIL_TRUE'                => $conf_LCAS[2] == 'true'  ? 'checked = "checked"' : '' ,
167                'LCAS_MAIL_FALSE'               => $conf_LCAS[2] == 'false' ? 'checked = "checked"' : '' ,
168    'LCAS_MAILTEXT'                 => $conf_LCAS[3]
169    )
170  );
171
172
173// +-----------------------------------------------------------------------+
174// |                             errors display                            |
175// +-----------------------------------------------------------------------+
176  if (isset ($errors) and count($errors) != 0)
177  {
178          $template->assign('errors',array());
179          foreach ($errors as $error)
180          {
181                  array_push($page['errors'], $error);
182                }
183        } 
184
185// +-----------------------------------------------------------------------+
186// |                           templates display                           |
187// +-----------------------------------------------------------------------+
188  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl');
189  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
190
191?>
Note: See TracBrowser for help on using the repository browser.