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 | /* Not useful */ |
---|
26 | /*$t = pwg_db_fetch_row(pwg_query(' |
---|
27 | SELECT `value` |
---|
28 | FROM `'.CONFIG_TABLE.'` |
---|
29 | WHERE `param` = "LoginCaseAccentsSensitivity" |
---|
30 | LIMIT 1; |
---|
31 | ')); |
---|
32 | |
---|
33 | $conf['LoginCaseAccentsSensitivity'] = $t[0];*/ |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Getting plugin version | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | $plugin = LCAS_PluginInfos(LCAS_PATH); |
---|
39 | $version = $plugin['version']; |
---|
40 | |
---|
41 | if (isset($_POST['submit']) and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail'])) |
---|
42 | { |
---|
43 | |
---|
44 | /* General configuration settings */ |
---|
45 | $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText']))); |
---|
46 | |
---|
47 | $newconf_LCAS= array( |
---|
48 | $_POST['LCAS_Option'], |
---|
49 | $_POST['LCAS_Mail'], |
---|
50 | $_POST['LCAS_MailText']); |
---|
51 | |
---|
52 | $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS); |
---|
53 | |
---|
54 | $query = ' |
---|
55 | UPDATE '.CONFIG_TABLE.' |
---|
56 | SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'" |
---|
57 | WHERE param="LoginCaseAccentsSensitivity" |
---|
58 | LIMIT 1 |
---|
59 | ;'; |
---|
60 | |
---|
61 | pwg_query($query); |
---|
62 | |
---|
63 | array_push($page['infos'], l10n('LCAS_save_config')); |
---|
64 | } |
---|
65 | |
---|
66 | $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); |
---|
67 | |
---|
68 | if (isset($conf_LCAS[0])) |
---|
69 | { |
---|
70 | $case_ins = ($conf_LCAS[0] == '1' or $conf_LCAS[0] == '3'); |
---|
71 | $acc_ins = ($conf_LCAS[0] == '2' or $conf_LCAS[0] == '3'); |
---|
72 | |
---|
73 | if ($case_ins or $acc_ins) |
---|
74 | { |
---|
75 | // +-----------------------------------------------------------------------+ |
---|
76 | // | initialization | |
---|
77 | // +-----------------------------------------------------------------------+ |
---|
78 | |
---|
79 | $lcas_UserToUpdate = -1; |
---|
80 | if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) { |
---|
81 | $lcas_UserToUpdate = $_POST['UserToUpdate']; |
---|
82 | |
---|
83 | if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) { |
---|
84 | // Vérifier si le nom n'est pas déjà pris |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | // Mise à jour du nom |
---|
89 | $query = ' |
---|
90 | UPDATE '.USERS_TABLE.' |
---|
91 | SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
92 | WHERE id='.$lcas_UserToUpdate.' |
---|
93 | LIMIT 1 |
---|
94 | ;'; |
---|
95 | |
---|
96 | pwg_query($query); |
---|
97 | |
---|
98 | if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true') |
---|
99 | { |
---|
100 | LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]); |
---|
101 | } |
---|
102 | |
---|
103 | array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed')); |
---|
104 | } |
---|
105 | else { |
---|
106 | // Username is empty |
---|
107 | array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username')); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | // +-----------------------------------------------------------------------+ |
---|
113 | // | user list | |
---|
114 | // +-----------------------------------------------------------------------+ |
---|
115 | |
---|
116 | $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]); |
---|
117 | |
---|
118 | // +-----------------------------------------------------------------------+ |
---|
119 | // | user list | |
---|
120 | // +-----------------------------------------------------------------------+ |
---|
121 | |
---|
122 | $lcas_previous_compare_user = ''; |
---|
123 | $visible_user_list = array(); |
---|
124 | foreach ($page['all_users'] as $local_user) |
---|
125 | { |
---|
126 | if ($lcas_previous_compare_user != $local_user['transformed']) { |
---|
127 | $display = 'orange'; |
---|
128 | $lcas_previous_compare_user = $local_user['transformed']; |
---|
129 | } |
---|
130 | else { |
---|
131 | $display = ''; |
---|
132 | } |
---|
133 | |
---|
134 | $template->append( |
---|
135 | 'users', |
---|
136 | array( |
---|
137 | 'ID' => $local_user['id'], |
---|
138 | 'USERNAME' => stripslashes($local_user['username']), |
---|
139 | 'COMPARE' => stripslashes($local_user['transformed']), |
---|
140 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
141 | 'DISPLAY' => $display, |
---|
142 | ) |
---|
143 | ); |
---|
144 | } |
---|
145 | |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | // +-----------------------------------------------------------------------+ |
---|
151 | // | templates init | |
---|
152 | // +-----------------------------------------------------------------------+ |
---|
153 | $template->assign( |
---|
154 | array( |
---|
155 | 'LCAS_VERSION' => $version, |
---|
156 | 'LCAS_PATH' => LCAS_PATH, |
---|
157 | 'LCAS_Option' => $conf_LCAS[0], |
---|
158 | 'LCAS_MAIL_TRUE' => $conf_LCAS[1] == 'true' ? 'checked = "checked"' : '' , |
---|
159 | 'LCAS_MAIL_FALSE' => $conf_LCAS[1] == 'false' ? 'checked = "checked"' : '' , |
---|
160 | 'LCAS_MAILTEXT' => $conf_LCAS[2] |
---|
161 | ) |
---|
162 | ); |
---|
163 | |
---|
164 | |
---|
165 | // +-----------------------------------------------------------------------+ |
---|
166 | // | errors display | |
---|
167 | // +-----------------------------------------------------------------------+ |
---|
168 | if (isset ($errors) and count($errors) != 0) |
---|
169 | { |
---|
170 | $template->assign('errors',array()); |
---|
171 | foreach ($errors as $error) |
---|
172 | { |
---|
173 | array_push($page['errors'], $error); |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | // +-----------------------------------------------------------------------+ |
---|
178 | // | templates display | |
---|
179 | // +-----------------------------------------------------------------------+ |
---|
180 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
181 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
182 | |
---|
183 | ?> |
---|