| [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'; | 
|---|
| [3536] | 62 | $order = !empty($_GET['order']) ? $_GET['order'] : 'asc'; | 
|---|
| [0] | 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 | 
|---|
| [3536] | 74 | if ($sortby !== '' && in_array($sortby,$sortby_combo,true)) { | 
|---|
| [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 | } | 
|---|
| [3536] | 80 | if ($order !== '' && in_array($order,$order_combo,true)) { | 
|---|
| [3360] | 81 | $params['order'] .= ' '.$order; | 
|---|
| [860] | 82 | } else { | 
|---|
|  | 83 | $order='asc'; | 
|---|
|  | 84 | } | 
|---|
|  | 85 | } else { | 
|---|
|  | 86 | $sortby = 'user_id'; | 
|---|
|  | 87 | $order = 'asc'; | 
|---|
| [0] | 88 | } | 
|---|
| [3536] | 89 | if ($sortby != 'user_id' || $order != 'asc') { | 
|---|
|  | 90 | $show_filters = true; | 
|---|
|  | 91 | } | 
|---|
| [0] | 92 |  | 
|---|
| [860] | 93 | # Get users | 
|---|
| [0] | 94 | try { | 
|---|
|  | 95 | $rs = $core->getUsers($params); | 
|---|
|  | 96 | $counter = $core->getUsers($params,1); | 
|---|
| [3105] | 97 | $rsStatic = $rs->toStatic(); | 
|---|
|  | 98 | if ($sortby != 'nb_post') { | 
|---|
|  | 99 | // Sort user list using lexical order if necessary | 
|---|
|  | 100 | $rsStatic->extend('rsExtUser'); | 
|---|
|  | 101 | $rsStatic = $rsStatic->toExtStatic(); | 
|---|
|  | 102 | $rsStatic->lexicalSort($sortby,$order); | 
|---|
|  | 103 | } | 
|---|
|  | 104 | $user_list = new adminUserList($core,$rsStatic,$counter->f(0)); | 
|---|
| [0] | 105 | } catch (Exception $e) { | 
|---|
|  | 106 | $core->error->add($e->getMessage()); | 
|---|
|  | 107 | } | 
|---|
|  | 108 |  | 
|---|
|  | 109 |  | 
|---|
|  | 110 | /* DISPLAY | 
|---|
|  | 111 | -------------------------------------------------------- */ | 
|---|
| [2136] | 112 |  | 
|---|
| [3397] | 113 | dcPage::open(__('Users'), | 
|---|
|  | 114 | dcPage::jsLoad('js/_users.js').dcPage::jsFilterControl($show_filters), | 
|---|
| [1358] | 115 | dcPage::breadcrumb( | 
|---|
|  | 116 | array( | 
|---|
|  | 117 | __('System') => '', | 
|---|
| [2166] | 118 | __('Users') => '' | 
|---|
| [1358] | 119 | )) | 
|---|
|  | 120 | ); | 
|---|
| [0] | 121 |  | 
|---|
|  | 122 | if (!$core->error->flag()) | 
|---|
|  | 123 | { | 
|---|
|  | 124 | if (!empty($_GET['del'])) { | 
|---|
| [907] | 125 | dcPage::message(__('User has been successfully removed.')); | 
|---|
| [0] | 126 | } | 
|---|
| [860] | 127 | if (!empty($_GET['upd'])) { | 
|---|
| [907] | 128 | dcPage::message(__('The permissions have been successfully updated.')); | 
|---|
| [860] | 129 | } | 
|---|
| [2566] | 130 |  | 
|---|
| [1332] | 131 | echo | 
|---|
| [2720] | 132 | '<p class="top-add"><strong><a class="button add" href="'.$core->adminurl->get("admin.user").'">'.__('New user').'</a></strong></p>'. | 
|---|
|  | 133 | '<form action="'.$core->adminurl->get("admin.users").'" method="get" id="filters-form">'. | 
|---|
| [3397] | 134 | '<h3 class="out-of-screen-if-js">'.__('Show filters and display options').'</h3>'. | 
|---|
| [2566] | 135 |  | 
|---|
| [1426] | 136 | '<div class="table">'. | 
|---|
|  | 137 | '<div class="cell">'. | 
|---|
| [1514] | 138 | '<h4>'.__('Filters').'</h4>'. | 
|---|
| [1426] | 139 | '<p><label for="q" class="ib">'.__('Search:').'</label> '. | 
|---|
|  | 140 | form::field('q',20,255,html::escapeHTML($q)).'</p>'. | 
|---|
| [0] | 141 | '</div>'. | 
|---|
| [1426] | 142 |  | 
|---|
|  | 143 | '<div class="cell filters-options">'. | 
|---|
| [1514] | 144 | '<h4>'.__('Display options').'</h4>'. | 
|---|
| [1426] | 145 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. | 
|---|
|  | 146 | form::combo('sortby',$sortby_combo,$sortby).'</p> '. | 
|---|
|  | 147 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. | 
|---|
|  | 148 | form::combo('order',$order_combo,$order).'</p>'. | 
|---|
| [2566] | 149 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. | 
|---|
| [1474] | 150 | form::field('nb',3,3,$nb_per_page).' '.__('users per page').'</label></p> '. | 
|---|
| [0] | 151 | '</div>'. | 
|---|
| [1426] | 152 | '</div>'. | 
|---|
|  | 153 |  | 
|---|
| [3560] | 154 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. | 
|---|
|  | 155 | '<br class="clear" /></p>'. //Opera sucks | 
|---|
| [0] | 156 | '</form>'; | 
|---|
| [2566] | 157 |  | 
|---|
| [0] | 158 | # Show users | 
|---|
|  | 159 | $user_list->display($page,$nb_per_page, | 
|---|
| [2720] | 160 | '<form action="'.$core->adminurl->get("admin.user.actions").'" method="post" id="form-users">'. | 
|---|
| [2566] | 161 |  | 
|---|
| [0] | 162 | '%s'. | 
|---|
| [2566] | 163 |  | 
|---|
| [0] | 164 | '<div class="two-cols">'. | 
|---|
|  | 165 | '<p class="col checkboxes-helpers"></p>'. | 
|---|
| [2566] | 166 |  | 
|---|
| [860] | 167 | '<p class="col right"><label for="action" class="classic">'. | 
|---|
| [0] | 168 | __('Selected users action:').' '. | 
|---|
| [860] | 169 | form::combo('action',$combo_action). | 
|---|
| [0] | 170 | '</label> '. | 
|---|
| [3182] | 171 | '<input id="do-action" type="submit" value="'.__('ok').'" />'. | 
|---|
| [860] | 172 | form::hidden(array('q'),html::escapeHTML($q)). | 
|---|
|  | 173 | form::hidden(array('sortby'),$sortby). | 
|---|
|  | 174 | form::hidden(array('order'),$order). | 
|---|
|  | 175 | form::hidden(array('page'),$page). | 
|---|
|  | 176 | form::hidden(array('nb'),$nb_per_page). | 
|---|
|  | 177 | $core->formNonce(). | 
|---|
| [0] | 178 | '</p>'. | 
|---|
|  | 179 | '</div>'. | 
|---|
| [2135] | 180 | '</form>', | 
|---|
|  | 181 | $show_filters | 
|---|
| [0] | 182 | ); | 
|---|
|  | 183 | } | 
|---|
| [2314] | 184 | dcPage::helpBlock('core_users'); | 
|---|
| [0] | 185 | dcPage::close(); | 
|---|