[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 | |
---|
| 26 | $order_combo = array( |
---|
| 27 | __('Descending') => 'desc', |
---|
| 28 | __('Ascending') => 'asc' |
---|
| 29 | ); |
---|
| 30 | |
---|
| 31 | # Actions combo box |
---|
| 32 | $combo_action = array( |
---|
[860] | 33 | __('Set permissions') => 'blogs', |
---|
[0] | 34 | __('Delete') => 'deleteuser' |
---|
| 35 | ); |
---|
| 36 | |
---|
[565] | 37 | # --BEHAVIOR-- adminUsersActionsCombo |
---|
[0] | 38 | $core->callBehavior('adminUsersActionsCombo',array(&$combo_action)); |
---|
[2145] | 39 | |
---|
[2137] | 40 | $show_filters = false; |
---|
[0] | 41 | |
---|
[1474] | 42 | #?Get users |
---|
[1912] | 43 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 44 | $nb_per_page = 30; |
---|
| 45 | |
---|
| 46 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
[2137] | 47 | if ($nb_per_page != $_GET['nb']) { |
---|
| 48 | $show_filters = true; |
---|
| 49 | } |
---|
[0] | 50 | $nb_per_page = $_GET['nb']; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | $q = !empty($_GET['q']) ? $_GET['q'] : ''; |
---|
| 54 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'user_id'; |
---|
| 55 | $order = !empty($_GET['order']) ? $_GET['order'] : 'asc'; |
---|
| 56 | |
---|
| 57 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | # - Search filter |
---|
| 61 | if ($q) { |
---|
| 62 | $params['q'] = $q; |
---|
| 63 | $show_filters = true; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | # - Sortby and order filter |
---|
| 67 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
| 68 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
| 69 | $params['order'] = $sortby.' '.$order; |
---|
[860] | 70 | } else { |
---|
| 71 | $order='asc'; |
---|
| 72 | } |
---|
[2566] | 73 | |
---|
[860] | 74 | if ($sortby != 'user_id' || $order != 'asc') { |
---|
[0] | 75 | $show_filters = true; |
---|
| 76 | } |
---|
[860] | 77 | } else { |
---|
| 78 | $sortby = 'user_id'; |
---|
| 79 | $order = 'asc'; |
---|
[0] | 80 | } |
---|
| 81 | |
---|
[860] | 82 | # Get users |
---|
[0] | 83 | try { |
---|
| 84 | $rs = $core->getUsers($params); |
---|
| 85 | $counter = $core->getUsers($params,1); |
---|
| 86 | $user_list = new adminUserList($core,$rs,$counter->f(0)); |
---|
| 87 | } catch (Exception $e) { |
---|
| 88 | $core->error->add($e->getMessage()); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | /* DISPLAY |
---|
| 93 | -------------------------------------------------------- */ |
---|
[2136] | 94 | |
---|
[2145] | 95 | $form_filter_title = __('Show filters and display options'); |
---|
[2135] | 96 | $starting_script = dcPage::jsLoad('js/_users.js'); |
---|
| 97 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 98 | $starting_script .= |
---|
| 99 | '<script type="text/javascript">'."\n". |
---|
| 100 | "//<![CDATA["."\n". |
---|
| 101 | dcPage::jsVar('dotclear.msg.show_filters', $show_filters ? 'true':'false')."\n". |
---|
| 102 | dcPage::jsVar('dotclear.msg.filter_posts_list',$form_filter_title)."\n". |
---|
[2145] | 103 | dcPage::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". |
---|
[2135] | 104 | "//]]>". |
---|
| 105 | "</script>"; |
---|
| 106 | |
---|
[1358] | 107 | dcPage::open(__('Users'),$starting_script, |
---|
| 108 | dcPage::breadcrumb( |
---|
| 109 | array( |
---|
| 110 | __('System') => '', |
---|
[2166] | 111 | __('Users') => '' |
---|
[1358] | 112 | )) |
---|
| 113 | ); |
---|
[0] | 114 | |
---|
| 115 | if (!$core->error->flag()) |
---|
| 116 | { |
---|
| 117 | if (!empty($_GET['del'])) { |
---|
[907] | 118 | dcPage::message(__('User has been successfully removed.')); |
---|
[0] | 119 | } |
---|
[860] | 120 | if (!empty($_GET['upd'])) { |
---|
[907] | 121 | dcPage::message(__('The permissions have been successfully updated.')); |
---|
[860] | 122 | } |
---|
[2566] | 123 | |
---|
[1332] | 124 | echo |
---|
[2720] | 125 | '<p class="top-add"><strong><a class="button add" href="'.$core->adminurl->get("admin.user").'">'.__('New user').'</a></strong></p>'. |
---|
| 126 | '<form action="'.$core->adminurl->get("admin.users").'" method="get" id="filters-form">'. |
---|
[2135] | 127 | '<h3 class="out-of-screen-if-js">'.$form_filter_title.'</h3>'. |
---|
[2566] | 128 | |
---|
[1426] | 129 | '<div class="table">'. |
---|
| 130 | '<div class="cell">'. |
---|
[1514] | 131 | '<h4>'.__('Filters').'</h4>'. |
---|
[1426] | 132 | '<p><label for="q" class="ib">'.__('Search:').'</label> '. |
---|
| 133 | form::field('q',20,255,html::escapeHTML($q)).'</p>'. |
---|
[0] | 134 | '</div>'. |
---|
[1426] | 135 | |
---|
| 136 | '<div class="cell filters-options">'. |
---|
[1514] | 137 | '<h4>'.__('Display options').'</h4>'. |
---|
[1426] | 138 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 139 | form::combo('sortby',$sortby_combo,$sortby).'</p> '. |
---|
| 140 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 141 | form::combo('order',$order_combo,$order).'</p>'. |
---|
[2566] | 142 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. |
---|
[1474] | 143 | form::field('nb',3,3,$nb_per_page).' '.__('users per page').'</label></p> '. |
---|
[0] | 144 | '</div>'. |
---|
[1426] | 145 | '</div>'. |
---|
| 146 | |
---|
[2566] | 147 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
[1426] | 148 | '<br class="clear" /></p>'. //Opera sucks |
---|
[0] | 149 | '</form>'; |
---|
[2566] | 150 | |
---|
[0] | 151 | # Show users |
---|
| 152 | $user_list->display($page,$nb_per_page, |
---|
[2720] | 153 | '<form action="'.$core->adminurl->get("admin.user.actions").'" method="post" id="form-users">'. |
---|
[2566] | 154 | |
---|
[0] | 155 | '%s'. |
---|
[2566] | 156 | |
---|
[0] | 157 | '<div class="two-cols">'. |
---|
| 158 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2566] | 159 | |
---|
[860] | 160 | '<p class="col right"><label for="action" class="classic">'. |
---|
[0] | 161 | __('Selected users action:').' '. |
---|
[860] | 162 | form::combo('action',$combo_action). |
---|
[0] | 163 | '</label> '. |
---|
| 164 | '<input type="submit" value="'.__('ok').'" />'. |
---|
[860] | 165 | form::hidden(array('q'),html::escapeHTML($q)). |
---|
| 166 | form::hidden(array('sortby'),$sortby). |
---|
| 167 | form::hidden(array('order'),$order). |
---|
| 168 | form::hidden(array('page'),$page). |
---|
| 169 | form::hidden(array('nb'),$nb_per_page). |
---|
| 170 | $core->formNonce(). |
---|
[0] | 171 | '</p>'. |
---|
| 172 | '</div>'. |
---|
[2135] | 173 | '</form>', |
---|
| 174 | $show_filters |
---|
[0] | 175 | ); |
---|
| 176 | } |
---|
[2314] | 177 | dcPage::helpBlock('core_users'); |
---|
[0] | 178 | dcPage::close(); |
---|