[8141] | 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 | |
---|
[8181] | 16 | include_once(PHPWG_ROOT_PATH.'include/constants.php'); |
---|
| 17 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[8141] | 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 | |
---|
[8271] | 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'])) |
---|
[8141] | 32 | { |
---|
| 33 | |
---|
| 34 | /* General configuration settings */ |
---|
[8257] | 35 | $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText']))); |
---|
[8141] | 36 | |
---|
| 37 | $newconf_LCAS= array( |
---|
[8147] | 38 | $_POST['LCAS_Case_Sensitive'], |
---|
[8257] | 39 | $_POST['LCAS_Accent_Sensitive'], |
---|
[8271] | 40 | $_POST['LCAS_Mail'], |
---|
[8257] | 41 | $_POST['LCAS_MailText']); |
---|
[8141] | 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 | |
---|
[8257] | 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 | } |
---|
[8141] | 64 | } |
---|
| 65 | |
---|
[8181] | 66 | $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); |
---|
[8141] | 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 | |
---|
[8164] | 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] != '')) { |
---|
[8209] | 79 | // Vérifier si le nom n'est pas déjà pris |
---|
[8164] | 80 | |
---|
| 81 | |
---|
| 82 | |
---|
[8209] | 83 | // Mise à jour du nom |
---|
[8164] | 84 | $query = ' |
---|
| 85 | UPDATE '.USERS_TABLE.' |
---|
| 86 | SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
| 87 | WHERE id='.$lcas_UserToUpdate.' |
---|
| 88 | LIMIT 1 |
---|
| 89 | ;'; |
---|
[8141] | 90 | |
---|
[8164] | 91 | pwg_query($query); |
---|
[8271] | 92 | |
---|
| 93 | if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true') |
---|
| 94 | { |
---|
| 95 | LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]); |
---|
| 96 | } |
---|
| 97 | |
---|
[8164] | 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 | |
---|
[8141] | 107 | // +-----------------------------------------------------------------------+ |
---|
| 108 | // | user list | |
---|
| 109 | // +-----------------------------------------------------------------------+ |
---|
| 110 | |
---|
[8143] | 111 | if ($conf_LCAS[0]=='true' && $conf_LCAS[1]=='true') |
---|
[8209] | 112 | $lcas_rule = 3; |
---|
[8143] | 113 | else if ($conf_LCAS[0]=='true') |
---|
| 114 | $lcas_rule = 1; |
---|
| 115 | else if ($conf_LCAS[1]=='true') |
---|
[8209] | 116 | $lcas_rule = 2; |
---|
[8143] | 117 | else |
---|
| 118 | $lcas_rule = 0; |
---|
| 119 | |
---|
| 120 | $page['all_users'] = LCAS_get_user_list($lcas_rule); |
---|
[8141] | 121 | |
---|
| 122 | // +-----------------------------------------------------------------------+ |
---|
| 123 | // | user list | |
---|
| 124 | // +-----------------------------------------------------------------------+ |
---|
| 125 | |
---|
[8147] | 126 | $lcas_previous_compare_user = ''; |
---|
| 127 | $visible_user_list = array(); |
---|
| 128 | foreach ($page['all_users'] as $local_user) |
---|
[8141] | 129 | { |
---|
[8147] | 130 | if ($lcas_previous_compare_user != $local_user['transformed']) { |
---|
| 131 | $display = 'orange'; |
---|
| 132 | $lcas_previous_compare_user = $local_user['transformed']; |
---|
[8141] | 133 | } |
---|
[8147] | 134 | else { |
---|
| 135 | $display = ''; |
---|
| 136 | } |
---|
[8141] | 137 | |
---|
| 138 | $template->append( |
---|
| 139 | 'users', |
---|
| 140 | array( |
---|
| 141 | 'ID' => $local_user['id'], |
---|
[8147] | 142 | 'USERNAME' => stripslashes($local_user['username']), |
---|
| 143 | 'COMPARE' => stripslashes($local_user['transformed']), |
---|
[8141] | 144 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 145 | 'DISPLAY' => $display, |
---|
| 146 | ) |
---|
| 147 | ); |
---|
| 148 | } |
---|
[8257] | 149 | /* Plugin version insert */ |
---|
[8141] | 150 | $template->assign( |
---|
| 151 | array( |
---|
| 152 | 'LCAS_VERSION' => $version, |
---|
| 153 | 'LCAS_PATH' => LCAS_PATH, |
---|
| 154 | ) |
---|
| 155 | ); |
---|
[8164] | 156 | |
---|
| 157 | |
---|
[8141] | 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 | |
---|
[8181] | 170 | } |
---|
| 171 | |
---|
| 172 | |
---|
[8271] | 173 | // +-----------------------------------------------------------------------+ |
---|
| 174 | // | templates init | |
---|
| 175 | // +-----------------------------------------------------------------------+ |
---|
[8181] | 176 | $template->assign( |
---|
| 177 | array( |
---|
[8271] | 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] |
---|
[8181] | 188 | ) |
---|
| 189 | ); |
---|
| 190 | |
---|
| 191 | |
---|
[8141] | 192 | // +-----------------------------------------------------------------------+ |
---|
[8181] | 193 | // | errors display | |
---|
[8141] | 194 | // +-----------------------------------------------------------------------+ |
---|
[8181] | 195 | if (isset ($errors) and count($errors) != 0) |
---|
[8141] | 196 | { |
---|
[8181] | 197 | $template->assign('errors',array()); |
---|
| 198 | foreach ($errors as $error) |
---|
| 199 | { |
---|
| 200 | array_push($page['errors'], $error); |
---|
| 201 | } |
---|
| 202 | } |
---|
[8141] | 203 | |
---|
[8181] | 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 | |
---|
[8214] | 210 | ?> |
---|