1 | <?php |
---|
2 | |
---|
3 | global $user, $lang, $conf, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | Check Access and exit when user status is not ok | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | check_status(ACCESS_ADMINISTRATOR); |
---|
10 | |
---|
11 | if (!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.'include/constants.php'); |
---|
17 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
18 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
19 | |
---|
20 | load_language('plugin.lang', LCAS_PATH); |
---|
21 | load_language('help/plugin.lang', LCAS_PATH); |
---|
22 | |
---|
23 | $error = array(); |
---|
24 | |
---|
25 | // +-----------------------------------------------------------------------+ |
---|
26 | // | Getting plugin version | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | $plugin = LCAS_PluginInfos(LCAS_PATH); |
---|
29 | $version = $plugin['version']; |
---|
30 | |
---|
31 | if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Case_Sensitive']) and isset($_POST['LCAS_Accent_Sensitive']) and isset($_POST['LCAS_Mail'])) |
---|
32 | { |
---|
33 | |
---|
34 | /* General configuration settings */ |
---|
35 | $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText']))); |
---|
36 | |
---|
37 | $newconf_LCAS= array( |
---|
38 | $_POST['LCAS_Case_Sensitive'], |
---|
39 | $_POST['LCAS_Accent_Sensitive'], |
---|
40 | $_POST['LCAS_Mail'], |
---|
41 | $_POST['LCAS_MailText']); |
---|
42 | |
---|
43 | $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS); |
---|
44 | |
---|
45 | $query = ' |
---|
46 | UPDATE '.CONFIG_TABLE.' |
---|
47 | SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'" |
---|
48 | WHERE param="LoginCaseAccentsSensitivity" |
---|
49 | LIMIT 1 |
---|
50 | ;'; |
---|
51 | |
---|
52 | pwg_query($query); |
---|
53 | |
---|
54 | // $conf['insensitive_case_logon'] have to be True for a full LCAS use |
---|
55 | if ($conf['insensitive_case_logon']) |
---|
56 | { |
---|
57 | array_push($page['infos'], l10n('LCAS_save_config')); |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | array_push($page['infos'], l10n('LCAS_save_config')); |
---|
62 | array_push($page['errors'], l10n('LCAS_warning')); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); |
---|
67 | |
---|
68 | if ((isset($conf_LCAS[0]) and $conf_LCAS[0]=='true') || (isset($conf_LCAS[1]) and $conf_LCAS[1]=='true')) |
---|
69 | { |
---|
70 | // +-----------------------------------------------------------------------+ |
---|
71 | // | initialization | |
---|
72 | // +-----------------------------------------------------------------------+ |
---|
73 | |
---|
74 | $lcas_UserToUpdate = -1; |
---|
75 | if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) { |
---|
76 | $lcas_UserToUpdate = $_POST['UserToUpdate']; |
---|
77 | |
---|
78 | if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) { |
---|
79 | // Vérifier si le nom n'est pas déjà pris |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | // Mise à jour du nom |
---|
84 | $query = ' |
---|
85 | UPDATE '.USERS_TABLE.' |
---|
86 | SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
87 | WHERE id='.$lcas_UserToUpdate.' |
---|
88 | LIMIT 1 |
---|
89 | ;'; |
---|
90 | |
---|
91 | pwg_query($query); |
---|
92 | |
---|
93 | if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true') |
---|
94 | { |
---|
95 | LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]); |
---|
96 | } |
---|
97 | |
---|
98 | array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed')); |
---|
99 | } |
---|
100 | else { |
---|
101 | // User is empty |
---|
102 | array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username')); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | // +-----------------------------------------------------------------------+ |
---|
108 | // | user list | |
---|
109 | // +-----------------------------------------------------------------------+ |
---|
110 | |
---|
111 | if ($conf_LCAS[0]=='true' && $conf_LCAS[1]=='true') |
---|
112 | $lcas_rule = 3; |
---|
113 | else if ($conf_LCAS[0]=='true') |
---|
114 | $lcas_rule = 1; |
---|
115 | else if ($conf_LCAS[1]=='true') |
---|
116 | $lcas_rule = 2; |
---|
117 | else |
---|
118 | $lcas_rule = 0; |
---|
119 | |
---|
120 | $page['all_users'] = LCAS_get_user_list($lcas_rule); |
---|
121 | |
---|
122 | // +-----------------------------------------------------------------------+ |
---|
123 | // | user list | |
---|
124 | // +-----------------------------------------------------------------------+ |
---|
125 | |
---|
126 | $lcas_previous_compare_user = ''; |
---|
127 | $visible_user_list = array(); |
---|
128 | foreach ($page['all_users'] as $local_user) |
---|
129 | { |
---|
130 | if ($lcas_previous_compare_user != $local_user['transformed']) { |
---|
131 | $display = 'orange'; |
---|
132 | $lcas_previous_compare_user = $local_user['transformed']; |
---|
133 | } |
---|
134 | else { |
---|
135 | $display = ''; |
---|
136 | } |
---|
137 | |
---|
138 | $template->append( |
---|
139 | 'users', |
---|
140 | array( |
---|
141 | 'ID' => $local_user['id'], |
---|
142 | 'USERNAME' => stripslashes($local_user['username']), |
---|
143 | 'COMPARE' => stripslashes($local_user['transformed']), |
---|
144 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
145 | 'DISPLAY' => $display, |
---|
146 | ) |
---|
147 | ); |
---|
148 | } |
---|
149 | /* Plugin version insert */ |
---|
150 | $template->assign( |
---|
151 | array( |
---|
152 | 'LCAS_VERSION' => $version, |
---|
153 | 'LCAS_PATH' => LCAS_PATH, |
---|
154 | ) |
---|
155 | ); |
---|
156 | |
---|
157 | |
---|
158 | // +-----------------------------------------------------------------------+ |
---|
159 | // | errors display | |
---|
160 | // +-----------------------------------------------------------------------+ |
---|
161 | if ( isset ($errors) and count($errors) != 0) |
---|
162 | { |
---|
163 | $template->assign('errors',array()); |
---|
164 | foreach ($errors as $error) |
---|
165 | { |
---|
166 | array_push($page['errors'], $error); |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | } |
---|
171 | |
---|
172 | |
---|
173 | // +-----------------------------------------------------------------------+ |
---|
174 | // | templates init | |
---|
175 | // +-----------------------------------------------------------------------+ |
---|
176 | $template->assign( |
---|
177 | array( |
---|
178 | 'LCAS_VERSION' => $version, |
---|
179 | 'LCAS_PATH' => LCAS_PATH, |
---|
180 | 'PWG_insensitive_case_logon' => $conf['insensitive_case_logon']? 'true' : 'false', |
---|
181 | 'LCAS_Case_Sensitive_TRUE' => $conf_LCAS[0]=='true' ? 'checked="checked"' : '' , |
---|
182 | 'LCAS_Case_Sensitive_FALSE' => $conf_LCAS[0]=='false' ? 'checked="checked"' : '' , |
---|
183 | 'LCAS_Accent_Sensitive_TRUE' => $conf_LCAS[1]=='true' ? 'checked="checked"' : '' , |
---|
184 | 'LCAS_Accent_Sensitive_FALSE' => $conf_LCAS[1]=='false' ? 'checked="checked"' : '' , |
---|
185 | 'LCAS_MAIL_TRUE' => $conf_LCAS[2]=='true' ? 'checked="checked"' : '' , |
---|
186 | 'LCAS_MAIL_FALSE' => $conf_LCAS[2]=='false' ? 'checked="checked"' : '' , |
---|
187 | 'LCAS_MAILTEXT' => $conf_LCAS[3] |
---|
188 | ) |
---|
189 | ); |
---|
190 | |
---|
191 | |
---|
192 | // +-----------------------------------------------------------------------+ |
---|
193 | // | errors display | |
---|
194 | // +-----------------------------------------------------------------------+ |
---|
195 | if (isset ($errors) and count($errors) != 0) |
---|
196 | { |
---|
197 | $template->assign('errors',array()); |
---|
198 | foreach ($errors as $error) |
---|
199 | { |
---|
200 | array_push($page['errors'], $error); |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | // +-----------------------------------------------------------------------+ |
---|
205 | // | templates display | |
---|
206 | // +-----------------------------------------------------------------------+ |
---|
207 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
208 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
209 | |
---|
210 | ?> |
---|