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 | $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 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] : "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 :-/ ... |
---|
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 | $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')); |
---|
83 | |
---|
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 | { |
---|
89 | // +-----------------------------------------------------------------------+ |
---|
90 | // | initialization | |
---|
91 | // +-----------------------------------------------------------------------+ |
---|
92 | |
---|
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 | ;'; |
---|
109 | |
---|
110 | pwg_query($query); |
---|
111 | |
---|
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 | } |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | // +-----------------------------------------------------------------------+ |
---|
127 | // | user list | |
---|
128 | // +-----------------------------------------------------------------------+ |
---|
129 | |
---|
130 | $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]); |
---|
131 | |
---|
132 | // +-----------------------------------------------------------------------+ |
---|
133 | // | user list | |
---|
134 | // +-----------------------------------------------------------------------+ |
---|
135 | |
---|
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 | ); |
---|
158 | } |
---|
159 | /* Plugin version insert */ |
---|
160 | $template->assign( |
---|
161 | array( |
---|
162 | 'LCAS_VERSION' => $version, |
---|
163 | 'LCAS_PATH' => LCAS_PATH, |
---|
164 | ) |
---|
165 | ); |
---|
166 | |
---|
167 | |
---|
168 | // +-----------------------------------------------------------------------+ |
---|
169 | // | errors display | |
---|
170 | // +-----------------------------------------------------------------------+ |
---|
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 | } |
---|
179 | |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | // +-----------------------------------------------------------------------+ |
---|
185 | // | templates init | |
---|
186 | // +-----------------------------------------------------------------------+ |
---|
187 | $template->assign( |
---|
188 | array( |
---|
189 | 'LCAS_VERSION' => $version, |
---|
190 | 'LCAS_PATH' => LCAS_PATH, |
---|
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], |
---|
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] |
---|
198 | ) |
---|
199 | ); |
---|
200 | |
---|
201 | |
---|
202 | // +-----------------------------------------------------------------------+ |
---|
203 | // | errors display | |
---|
204 | // +-----------------------------------------------------------------------+ |
---|
205 | if (isset ($errors) and count($errors) != 0) |
---|
206 | { |
---|
207 | $template->assign('errors',array()); |
---|
208 | foreach ($errors as $error) |
---|
209 | { |
---|
210 | array_push($page['errors'], $error); |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
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 | |
---|
220 | ?> |
---|