[3742] | 1 | <?php |
---|
| 2 | /* |
---|
[5181] | 3 | Plugin Name: UserAdvManager |
---|
[12247] | 4 | Version: 2.30.0 |
---|
[4957] | 5 | Description: Renforcer la gestion des utilisateurs - Enforce users management |
---|
[9295] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=216 |
---|
[3742] | 7 | Author: Nicco, Eric |
---|
| 8 | Author URI: http://gallery-nicco.no-ip.org, http://www.infernoweb.net |
---|
| 9 | */ |
---|
| 10 | |
---|
[5181] | 11 | /* History: UAM_PATH.'Changelog.txt.php' */ |
---|
[3742] | 12 | |
---|
| 13 | /* |
---|
| 14 | ***** TODO List ***** |
---|
[6783] | 15 | See project bugtracker: http://piwigo.org/bugs/my_view_page.php |
---|
[3742] | 16 | */ |
---|
| 17 | |
---|
[4927] | 18 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
[5181] | 19 | if (!defined('UAM_PATH')) define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
[3742] | 20 | |
---|
[9908] | 21 | global $conf; |
---|
| 22 | |
---|
[5181] | 23 | include_once (UAM_PATH.'include/constants.php'); |
---|
| 24 | include_once (UAM_PATH.'include/functions.inc.php'); |
---|
[3742] | 25 | |
---|
[5181] | 26 | load_language('plugin.lang', UAM_PATH); |
---|
[9908] | 27 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[3858] | 28 | |
---|
| 29 | |
---|
[7955] | 30 | // Plugin administration panel |
---|
[5056] | 31 | add_event_handler('get_admin_plugin_menu_links', 'UAM_admin_menu'); |
---|
[3742] | 32 | |
---|
[4927] | 33 | /* Lastvisit table feed for Ghost Tracker */ |
---|
[5056] | 34 | add_event_handler('loc_begin_index', 'UAM_GhostTracker'); |
---|
[3742] | 35 | |
---|
[7955] | 36 | // User creation |
---|
[5056] | 37 | add_event_handler('register_user', 'UAM_Adduser'); |
---|
[3742] | 38 | |
---|
[7955] | 39 | // User deletion |
---|
[5056] | 40 | add_event_handler('delete_user', 'UAM_Deluser'); |
---|
[3742] | 41 | |
---|
[6990] | 42 | // Check users registration |
---|
[5056] | 43 | add_event_handler('register_user_check', 'UAM_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[3742] | 44 | |
---|
[4124] | 45 | if (script_basename() == 'profile') |
---|
| 46 | { |
---|
[5056] | 47 | add_event_handler('loc_begin_profile', 'UAM_Profile_Init'); |
---|
[3742] | 48 | } |
---|
| 49 | |
---|
[7955] | 50 | // Redirection to profile page |
---|
[8065] | 51 | add_event_handler('login_success', 'UAM_LoginTasks'); |
---|
[6775] | 52 | |
---|
[9135] | 53 | // Adding customized text to lost password email |
---|
| 54 | add_event_handler('render_lost_password_mail_content', 'UAM_lost_password_mail_content'); |
---|
[8065] | 55 | |
---|
[7955] | 56 | // *** Important ! This is necessary to make email exclusion work in admin's users management panel *** |
---|
[5056] | 57 | add_event_handler('init', 'UAM_InitPage'); |
---|
[4124] | 58 | |
---|
[9908] | 59 | // PWG_Stuffs module |
---|
[11018] | 60 | if ((isset($conf_UAM[33]) and $conf_UAM[33] == 'true')) |
---|
[9908] | 61 | { |
---|
| 62 | add_event_handler('get_stuffs_modules', 'register_UAM_stuffs_module'); |
---|
| 63 | } |
---|
[12239] | 64 | |
---|
| 65 | // Add new feature in user_list - Password Reset |
---|
| 66 | if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true')) |
---|
| 67 | { |
---|
| 68 | // add new column on user_list |
---|
| 69 | add_event_handler('loc_visible_user_list', 'UAM_loc_visible_user_list'); |
---|
| 70 | |
---|
| 71 | //add prefilter on user_list |
---|
| 72 | add_event_handler('loc_begin_admin', 'UAM_PwdReset_Action',60); |
---|
| 73 | |
---|
| 74 | function UAM_PwdReset_Action() |
---|
| 75 | { |
---|
| 76 | global $conf, $user, $template, $lang, $errors; |
---|
| 77 | |
---|
| 78 | $page['errors'] = array(); |
---|
| 79 | $page['infos'] = array(); |
---|
| 80 | $page['filtered_users'] = array(); |
---|
| 81 | |
---|
| 82 | if (isset($_POST['pwdreset'])) |
---|
| 83 | { |
---|
| 84 | $collection = array(); |
---|
| 85 | |
---|
| 86 | switch ($_POST['target']) |
---|
| 87 | { |
---|
| 88 | case 'all' : |
---|
| 89 | { |
---|
| 90 | foreach($page['filtered_users'] as $local_user) |
---|
| 91 | { |
---|
| 92 | array_push($collection, $local_user['id']); |
---|
| 93 | } |
---|
| 94 | break; |
---|
| 95 | } |
---|
| 96 | case 'selection' : |
---|
| 97 | { |
---|
| 98 | if (isset($_POST['selection'])) |
---|
| 99 | { |
---|
| 100 | $collection = $_POST['selection']; |
---|
| 101 | } |
---|
| 102 | break; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | if (count($collection) == 0) |
---|
| 107 | { |
---|
| 108 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | if (isset($_POST['pwdreset']) and count($collection) > 0) |
---|
| 113 | { |
---|
| 114 | if (in_array($conf['guest_id'], $collection)) |
---|
| 115 | { |
---|
| 116 | array_push($page['errors'], l10n('UAM_Guest cannot be pwdreset')); |
---|
| 117 | $template->append('errors', l10n('UAM_Guest cannot be pwdreset')); |
---|
| 118 | } |
---|
| 119 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 120 | in_array($conf['default_user_id'], $collection)) |
---|
| 121 | { |
---|
| 122 | array_push($page['errors'], l10n('UAM_Default user cannot be pwgreset')); |
---|
| 123 | $template->append('errors', l10n('UAM_Default user cannot be pwgreset')); |
---|
| 124 | } |
---|
| 125 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 126 | { |
---|
| 127 | array_push($page['errors'], l10n('UAM_Webmaster cannot be pwdreset')); |
---|
| 128 | $template->append('errors', l10n('UAM_Webmaster cannot be pwdreset')); |
---|
| 129 | } |
---|
| 130 | if (in_array($user['id'], $collection)) |
---|
| 131 | { |
---|
| 132 | array_push($page['errors'], l10n('UAM_You cannot pwdreset your account')); |
---|
| 133 | $template->append('errors', l10n('UAM_You cannot pwdreset your account')); |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | if (count($page['errors']) == 0) |
---|
| 137 | { |
---|
| 138 | if (isset($_POST['confirm_pwdreset']) and 1 == $_POST['confirm_pwdreset']) |
---|
| 139 | { |
---|
| 140 | foreach ($collection as $user_id) |
---|
| 141 | { |
---|
| 142 | UAM_Set_PwdReset($user_id); |
---|
| 143 | } |
---|
| 144 | array_push( |
---|
| 145 | $page['infos'], |
---|
| 146 | l10n_dec( |
---|
| 147 | 'UAM %d user pwdreseted', 'UAM %d users pwdreseted', |
---|
| 148 | count($collection) |
---|
| 149 | ) |
---|
| 150 | ); |
---|
| 151 | $template->append('infos', l10n_dec( |
---|
| 152 | 'UAM %d user pwdreseted', 'UAM %d users pwdreseted', |
---|
| 153 | count($collection))); |
---|
| 154 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 155 | { |
---|
| 156 | if (in_array($filter_user['id'], $collection)) |
---|
| 157 | { |
---|
| 158 | unset($page['filtered_users'][$filter_key]); |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | else |
---|
| 163 | { |
---|
| 164 | array_push($page['errors'], l10n('UAM_You need to confirm pwdreset')); |
---|
| 165 | $template->append('errors', l10n('UAM_You need to confirm pwdreset')); |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | $template->set_prefilter('user_list', 'UAM_PwdReset_Prefilter'); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | function UAM_PwdReset_Prefilter($content, &$smarty) |
---|
| 173 | { |
---|
| 174 | $search = ' |
---|
| 175 | <fieldset> |
---|
| 176 | <legend>{\'Deletions\'|@translate}</legend> |
---|
| 177 | <label><input type="checkbox" name="confirm_deletion" value="1"> {\'confirm\'|@translate}</label> |
---|
| 178 | <input class="submit" type="submit" value="{\'Delete selected users\'|@translate}" name="delete"> |
---|
| 179 | </fieldset> |
---|
| 180 | '; |
---|
| 181 | |
---|
| 182 | $addon = ' |
---|
| 183 | <fieldset> |
---|
| 184 | <legend>{\'UAM_PwdReset\'|@translate}</legend> |
---|
| 185 | <label><input type="checkbox" name="confirm_pwdreset" value="1"> {\'confirm\'|@translate}</label> |
---|
| 186 | <input class="submit" type="submit" value="{\'UAM_Password reset selected users\'|@translate}" name="pwdreset"> |
---|
| 187 | </fieldset> |
---|
| 188 | '; |
---|
| 189 | |
---|
| 190 | $replacement = $addon.$search; |
---|
| 191 | |
---|
| 192 | return str_replace($search, $replacement, $content); |
---|
| 193 | } |
---|
| 194 | } |
---|
[3742] | 195 | ?> |
---|