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

Last change on this file since 8209 was 8209, checked in by Whiler, 13 years ago

Each of four cases should now work in LCAS admin page

File size: 6.6 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
16//include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
17include_once(PHPWG_ROOT_PATH.'include/constants.php');
18include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
19$my_base_url = get_admin_plugin_menu_link(__FILE__);
20
21load_language('plugin.lang', LCAS_PATH);
22load_language('help/plugin.lang', LCAS_PATH);
23
24$error = array();
25
26// +-----------------------------------------------------------------------+
27// |                      Getting plugin version                           |
28// +-----------------------------------------------------------------------+
29$plugin =  LCAS_PluginInfos(LCAS_PATH);
30$version = $plugin['version'];
31
32        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Case_Sensitive']) and isset($_POST['LCAS_Accent_Sensitive']) )
33  {
34
35/* General configuration settings */
36
37/* Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them */
38                $newconf_LCAS= array(
39      $_POST['LCAS_Case_Sensitive'],
40      $_POST['LCAS_Accent_Sensitive']);
41
42    $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS);
43
44                $query = '
45                UPDATE '.CONFIG_TABLE.'
46                SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'"
47                WHERE param="LoginCaseAccentsSensitivity"
48                LIMIT 1
49                ;';
50               
51                pwg_query($query);
52
53                array_push($page['infos'], l10n('LCAS_save_config'));
54  }
55
56        $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
57
58  if ((isset($conf_LCAS[0]) and $conf_LCAS[0]=='true') || (isset($conf_LCAS[1]) and $conf_LCAS[1]=='true'))
59  {
60// +-----------------------------------------------------------------------+
61// |                           initialization                              |
62// +-----------------------------------------------------------------------+
63
64    $lcas_UserToUpdate = -1;
65    if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
66        $lcas_UserToUpdate = $_POST['UserToUpdate'];
67       
68        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
69                // Vérifier si le nom n'est pas déjà pris
70               
71               
72               
73                // Mise à jour du nom
74                                $query = '
75                                UPDATE '.USERS_TABLE.'
76                                SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
77                                WHERE id='.$lcas_UserToUpdate.'
78                                LIMIT 1
79                                ;';
80
81                                pwg_query($query);
82               
83                                array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
84        }
85        else {
86                // User is empty
87                                array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
88        }
89    }
90
91
92
93// +-----------------------------------------------------------------------+
94// |                               user list                               |
95// +-----------------------------------------------------------------------+
96
97                if ($conf_LCAS[0]=='true' && $conf_LCAS[1]=='true')
98                        $lcas_rule = 3;
99                else if ($conf_LCAS[0]=='true')
100                        $lcas_rule = 1;
101                else if ($conf_LCAS[1]=='true')
102                        $lcas_rule = 2;
103                else
104                        $lcas_rule = 0;
105               
106                $page['all_users'] = LCAS_get_user_list($lcas_rule);
107
108// +-----------------------------------------------------------------------+
109// |                               user list                               |
110// +-----------------------------------------------------------------------+
111
112                $lcas_previous_compare_user = '';
113    $visible_user_list          = array();
114    foreach ($page['all_users'] as $local_user)
115    {
116      if ($lcas_previous_compare_user != $local_user['transformed']) {
117        $display = 'orange';
118        $lcas_previous_compare_user = $local_user['transformed'];
119      }
120      else {
121        $display = '';
122      }
123
124                $template->append(
125                'users',
126        array(
127                'ID'          => $local_user['id'],
128                'USERNAME'    => stripslashes($local_user['username']),
129                'COMPARE'     => stripslashes($local_user['transformed']),
130                                        'EMAIL'       => get_email_address_as_display_text($local_user['email']),
131          'DISPLAY'     => $display,
132                                )
133                        );
134                }
135    /* Plugin version inserted */
136    $template->assign(
137      array(
138        'LCAS_VERSION'  => $version,
139        'LCAS_PATH'     => LCAS_PATH,
140      )
141    );   
142
143   
144// +-----------------------------------------------------------------------+
145// |                             errors display                            |
146// +-----------------------------------------------------------------------+
147                if ( isset ($errors) and count($errors) != 0)
148                {
149                $template->assign('errors',array());
150                        foreach ($errors as $error)
151                {
152                                array_push($page['errors'], $error);
153                }
154                } 
155
156  }
157
158
159  $template->assign(
160    array(
161    'LCAS_VERSION'                   => $version,
162    'LCAS_PATH'                      => LCAS_PATH,
163    'PWG_insensitive_case_logon'     => $conf['insensitive_case_logon']? 'true'              : 'false',
164                'LCAS_Case_Sensitive_TRUE'       => $conf_LCAS[0]=='true'          ? 'checked="checked"' : '' ,
165                'LCAS_Case_Sensitive_FALSE'      => $conf_LCAS[0]=='false'         ? 'checked="checked"' : '' ,
166                'LCAS_Accent_Sensitive_TRUE'     => $conf_LCAS[1]=='true'          ? 'checked="checked"' : '' ,
167                'LCAS_Accent_Sensitive_FALSE'    => $conf_LCAS[1]=='false'         ? 'checked="checked"' : ''
168    )
169  );
170
171
172// +-----------------------------------------------------------------------+
173// |                             errors display                            |
174// +-----------------------------------------------------------------------+
175  if (isset ($errors) and count($errors) != 0)
176  {
177          $template->assign('errors',array());
178          foreach ($errors as $error)
179          {
180                  array_push($page['errors'], $error);
181                }
182        } 
183
184// +-----------------------------------------------------------------------+
185// |                           templates display                           |
186// +-----------------------------------------------------------------------+
187  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl');
188  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
189
190?>
Note: See TracBrowser for help on using the repository browser.