[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | |
---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::checkSuper(); |
---|
| 16 | |
---|
| 17 | # Creating filter combo boxes |
---|
| 18 | $sortby_combo = array( |
---|
[860] | 19 | __('Username') => 'user_id', |
---|
[0] | 20 | __('Last Name') => 'user_name', |
---|
| 21 | __('First Name') => 'user_firstname', |
---|
| 22 | __('Display name') => 'user_displayname', |
---|
| 23 | __('Number of entries') => 'nb_post' |
---|
| 24 | ); |
---|
| 25 | |
---|
[3360] | 26 | $sortby_lex = array( |
---|
| 27 | // key in sorty_combo (see above) => field in SQL request |
---|
| 28 | 'user_id' => 'U.user_id', |
---|
| 29 | 'user_name' => 'user_name', |
---|
| 30 | 'user_firstname' => 'user_firstname', |
---|
| 31 | 'user_displayname' => 'user_displayname'); |
---|
| 32 | |
---|
[0] | 33 | $order_combo = array( |
---|
| 34 | __('Descending') => 'desc', |
---|
| 35 | __('Ascending') => 'asc' |
---|
| 36 | ); |
---|
| 37 | |
---|
| 38 | # Actions combo box |
---|
| 39 | $combo_action = array( |
---|
[860] | 40 | __('Set permissions') => 'blogs', |
---|
[0] | 41 | __('Delete') => 'deleteuser' |
---|
| 42 | ); |
---|
| 43 | |
---|
[565] | 44 | # --BEHAVIOR-- adminUsersActionsCombo |
---|
[0] | 45 | $core->callBehavior('adminUsersActionsCombo',array(&$combo_action)); |
---|
[2145] | 46 | |
---|
[2137] | 47 | $show_filters = false; |
---|
[0] | 48 | |
---|
[1474] | 49 | #?Get users |
---|
[1912] | 50 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 51 | $nb_per_page = 30; |
---|
| 52 | |
---|
| 53 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
[2137] | 54 | if ($nb_per_page != $_GET['nb']) { |
---|
| 55 | $show_filters = true; |
---|
| 56 | } |
---|
[0] | 57 | $nb_per_page = $_GET['nb']; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | $q = !empty($_GET['q']) ? $_GET['q'] : ''; |
---|
| 61 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'user_id'; |
---|
| 62 | $order = !empty($_GET['order']) ? $_GET['order'] : 'asc'; |
---|
| 63 | |
---|
| 64 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | # - Search filter |
---|
| 68 | if ($q) { |
---|
| 69 | $params['q'] = $q; |
---|
| 70 | $show_filters = true; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | # - Sortby and order filter |
---|
| 74 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
[3360] | 75 | if (array_key_exists($sortby,$sortby_lex)) { |
---|
| 76 | $params['order'] = $core->con->lexFields($sortby_lex[$sortby]); |
---|
| 77 | } else { |
---|
| 78 | $params['order'] = $sortby; |
---|
| 79 | } |
---|
[0] | 80 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
[3360] | 81 | $params['order'] .= ' '.$order; |
---|
[860] | 82 | } else { |
---|
| 83 | $order='asc'; |
---|
| 84 | } |
---|
[2566] | 85 | |
---|
[860] | 86 | if ($sortby != 'user_id' || $order != 'asc') { |
---|
[0] | 87 | $show_filters = true; |
---|
| 88 | } |
---|
[860] | 89 | } else { |
---|
| 90 | $sortby = 'user_id'; |
---|
| 91 | $order = 'asc'; |
---|
[0] | 92 | } |
---|
| 93 | |
---|
[860] | 94 | # Get users |
---|
[0] | 95 | try { |
---|
| 96 | $rs = $core->getUsers($params); |
---|
| 97 | $counter = $core->getUsers($params,1); |
---|
[3105] | 98 | $rsStatic = $rs->toStatic(); |
---|
| 99 | if ($sortby != 'nb_post') { |
---|
| 100 | // Sort user list using lexical order if necessary |
---|
| 101 | $rsStatic->extend('rsExtUser'); |
---|
| 102 | $rsStatic = $rsStatic->toExtStatic(); |
---|
| 103 | $rsStatic->lexicalSort($sortby,$order); |
---|
| 104 | } |
---|
| 105 | $user_list = new adminUserList($core,$rsStatic,$counter->f(0)); |
---|
[0] | 106 | } catch (Exception $e) { |
---|
| 107 | $core->error->add($e->getMessage()); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | /* DISPLAY |
---|
| 112 | -------------------------------------------------------- */ |
---|
[2136] | 113 | |
---|
[2145] | 114 | $form_filter_title = __('Show filters and display options'); |
---|
[2135] | 115 | $starting_script = dcPage::jsLoad('js/_users.js'); |
---|
| 116 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 117 | $starting_script .= |
---|
| 118 | '<script type="text/javascript">'."\n". |
---|
| 119 | "//<![CDATA["."\n". |
---|
| 120 | dcPage::jsVar('dotclear.msg.show_filters', $show_filters ? 'true':'false')."\n". |
---|
| 121 | dcPage::jsVar('dotclear.msg.filter_posts_list',$form_filter_title)."\n". |
---|
[2145] | 122 | dcPage::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". |
---|
[2135] | 123 | "//]]>". |
---|
| 124 | "</script>"; |
---|
| 125 | |
---|
[1358] | 126 | dcPage::open(__('Users'),$starting_script, |
---|
| 127 | dcPage::breadcrumb( |
---|
| 128 | array( |
---|
| 129 | __('System') => '', |
---|
[2166] | 130 | __('Users') => '' |
---|
[1358] | 131 | )) |
---|
| 132 | ); |
---|
[0] | 133 | |
---|
| 134 | if (!$core->error->flag()) |
---|
| 135 | { |
---|
| 136 | if (!empty($_GET['del'])) { |
---|
[907] | 137 | dcPage::message(__('User has been successfully removed.')); |
---|
[0] | 138 | } |
---|
[860] | 139 | if (!empty($_GET['upd'])) { |
---|
[907] | 140 | dcPage::message(__('The permissions have been successfully updated.')); |
---|
[860] | 141 | } |
---|
[2566] | 142 | |
---|
[1332] | 143 | echo |
---|
[2720] | 144 | '<p class="top-add"><strong><a class="button add" href="'.$core->adminurl->get("admin.user").'">'.__('New user').'</a></strong></p>'. |
---|
| 145 | '<form action="'.$core->adminurl->get("admin.users").'" method="get" id="filters-form">'. |
---|
[2135] | 146 | '<h3 class="out-of-screen-if-js">'.$form_filter_title.'</h3>'. |
---|
[2566] | 147 | |
---|
[1426] | 148 | '<div class="table">'. |
---|
| 149 | '<div class="cell">'. |
---|
[1514] | 150 | '<h4>'.__('Filters').'</h4>'. |
---|
[1426] | 151 | '<p><label for="q" class="ib">'.__('Search:').'</label> '. |
---|
| 152 | form::field('q',20,255,html::escapeHTML($q)).'</p>'. |
---|
[0] | 153 | '</div>'. |
---|
[1426] | 154 | |
---|
| 155 | '<div class="cell filters-options">'. |
---|
[1514] | 156 | '<h4>'.__('Display options').'</h4>'. |
---|
[1426] | 157 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 158 | form::combo('sortby',$sortby_combo,$sortby).'</p> '. |
---|
| 159 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 160 | form::combo('order',$order_combo,$order).'</p>'. |
---|
[2566] | 161 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. |
---|
[1474] | 162 | form::field('nb',3,3,$nb_per_page).' '.__('users per page').'</label></p> '. |
---|
[0] | 163 | '</div>'. |
---|
[1426] | 164 | '</div>'. |
---|
| 165 | |
---|
[2566] | 166 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
[1426] | 167 | '<br class="clear" /></p>'. //Opera sucks |
---|
[0] | 168 | '</form>'; |
---|
[2566] | 169 | |
---|
[0] | 170 | # Show users |
---|
| 171 | $user_list->display($page,$nb_per_page, |
---|
[2720] | 172 | '<form action="'.$core->adminurl->get("admin.user.actions").'" method="post" id="form-users">'. |
---|
[2566] | 173 | |
---|
[0] | 174 | '%s'. |
---|
[2566] | 175 | |
---|
[0] | 176 | '<div class="two-cols">'. |
---|
| 177 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2566] | 178 | |
---|
[860] | 179 | '<p class="col right"><label for="action" class="classic">'. |
---|
[0] | 180 | __('Selected users action:').' '. |
---|
[860] | 181 | form::combo('action',$combo_action). |
---|
[0] | 182 | '</label> '. |
---|
[3182] | 183 | '<input id="do-action" type="submit" value="'.__('ok').'" />'. |
---|
[860] | 184 | form::hidden(array('q'),html::escapeHTML($q)). |
---|
| 185 | form::hidden(array('sortby'),$sortby). |
---|
| 186 | form::hidden(array('order'),$order). |
---|
| 187 | form::hidden(array('page'),$page). |
---|
| 188 | form::hidden(array('nb'),$nb_per_page). |
---|
| 189 | $core->formNonce(). |
---|
[0] | 190 | '</p>'. |
---|
| 191 | '</div>'. |
---|
[2135] | 192 | '</form>', |
---|
| 193 | $show_filters |
---|
[0] | 194 | ); |
---|
| 195 | } |
---|
[2314] | 196 | dcPage::helpBlock('core_users'); |
---|
[0] | 197 | dcPage::close(); |
---|