1*0440ff15Schris<?php 2*0440ff15Schris/* 3*0440ff15Schris * User Manager 4*0440ff15Schris * 5*0440ff15Schris * Dokuwiki Admin Plugin 6*0440ff15Schris * 7*0440ff15Schris * This version of the user manager has been modified to only work with 8*0440ff15Schris * objectified version of auth system 9*0440ff15Schris * 10*0440ff15Schris * @author neolao <neolao@neolao.com> 11*0440ff15Schris * @author Chris Smith <chris@jalakai.co.uk> 12*0440ff15Schris */ 13*0440ff15Schrisif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 14*0440ff15Schrisif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15*0440ff15Schrisif(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_BASE.'lib/plugins/usermanager/images/'); 16*0440ff15Schrisrequire_once(DOKU_PLUGIN.'admin.php'); 17*0440ff15Schris 18*0440ff15Schris/** 19*0440ff15Schris * All DokuWiki plugins to extend the admin function 20*0440ff15Schris * need to inherit from this class 21*0440ff15Schris */ 22*0440ff15Schrisclass admin_plugin_usermanager extends DokuWiki_Admin_Plugin { 23*0440ff15Schris 24*0440ff15Schris var $_auth = null; // auth object 25*0440ff15Schris var $_user_total = 0; // number of registered users 26*0440ff15Schris var $_filter = array(); // user selection filter(s) 27*0440ff15Schris var $_start = 0; // index of first user to be displayed 28*0440ff15Schris var $_last = 0; // index of the last user to be displayed 29*0440ff15Schris var $_pagesize = 20; // number of users to list on one page 30*0440ff15Schris var $_user_edit = null; // set to user selected for editing 31*0440ff15Schris 32*0440ff15Schris /** 33*0440ff15Schris * Constructor 34*0440ff15Schris */ 35*0440ff15Schris function admin_plugin_usermanager(){ 36*0440ff15Schris global $auth; 37*0440ff15Schris 38*0440ff15Schris $this->setupLocale(); 39*0440ff15Schris if (isset($auth)) $this->_auth = & $auth; 40*0440ff15Schris } 41*0440ff15Schris 42*0440ff15Schris /** 43*0440ff15Schris * return some info 44*0440ff15Schris */ 45*0440ff15Schris function getInfo(){ 46*0440ff15Schris $disabled = is_null($this->_auth) ? '(disabled)' : ''; 47*0440ff15Schris 48*0440ff15Schris return array( 49*0440ff15Schris 'author' => 'Chris Smith', 50*0440ff15Schris 'email' => 'chris@jalakai.co.uk', 51*0440ff15Schris 'date' => '2005-11-24', 52*0440ff15Schris 'name' => 'User Manager', 53*0440ff15Schris 'desc' => 'Manage users '.$disabled, 54*0440ff15Schris 'url' => 'http://wiki.splitbrain.org/plugin:user_manager', 55*0440ff15Schris ); 56*0440ff15Schris } 57*0440ff15Schris /** 58*0440ff15Schris * return prompt for admin menu 59*0440ff15Schris */ 60*0440ff15Schris function getMenuText($language) { 61*0440ff15Schris 62*0440ff15Schris if (!is_null($this->_auth)) 63*0440ff15Schris return parent::getMenuText($language); 64*0440ff15Schris 65*0440ff15Schris return $this->getLang["menu"]." (objectified auth only)"; 66*0440ff15Schris } 67*0440ff15Schris 68*0440ff15Schris /** 69*0440ff15Schris * return sort order for position in admin menu 70*0440ff15Schris */ 71*0440ff15Schris function getMenuSort() { 72*0440ff15Schris return 2; 73*0440ff15Schris } 74*0440ff15Schris 75*0440ff15Schris /** 76*0440ff15Schris * handle user request 77*0440ff15Schris */ 78*0440ff15Schris function handle() { 79*0440ff15Schris global $ID; 80*0440ff15Schris 81*0440ff15Schris if (is_null($this->_auth)) return false; 82*0440ff15Schris 83*0440ff15Schris // extract the command and any specific parameters 84*0440ff15Schris // submit button name is of the form - fn[cmd][param(s)] 85*0440ff15Schris $fn = $_REQUEST['fn']; 86*0440ff15Schris 87*0440ff15Schris if (is_array($fn)) { 88*0440ff15Schris $cmd = key($fn); 89*0440ff15Schris $param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null; 90*0440ff15Schris } else { 91*0440ff15Schris $cmd = $fn; 92*0440ff15Schris $param = null; 93*0440ff15Schris } 94*0440ff15Schris 95*0440ff15Schris if ($cmd != "search") { 96*0440ff15Schris $this->_start = $_REQUEST['start']; 97*0440ff15Schris $this->_filter = $this->_retrieveFilter(); 98*0440ff15Schris } 99*0440ff15Schris 100*0440ff15Schris switch($cmd){ 101*0440ff15Schris case "add" : $this->_addUser(); break; 102*0440ff15Schris case "delete" : $this->_deleteUser(); break; 103*0440ff15Schris case "modify" : $this->_modifyUser(); break; 104*0440ff15Schris case "edit" : $this->_edit_user = $param; break; // no extra handling required - only html 105*0440ff15Schris case "search" : $this->_setFilter($param); 106*0440ff15Schris $this->_start = 0; 107*0440ff15Schris break; 108*0440ff15Schris } 109*0440ff15Schris 110*0440ff15Schris $this->_user_total = $this->_auth->getUserCount($this->_filter); 111*0440ff15Schris 112*0440ff15Schris // page handling 113*0440ff15Schris switch($cmd){ 114*0440ff15Schris case 'start' : $this->_start = 0; break; 115*0440ff15Schris case 'prev' : $this->_start -= $this->_pagesize; break; 116*0440ff15Schris case 'next' : $this->_start += $this->_pagesize; break; 117*0440ff15Schris case 'last' : $this->_start = $this->_user_total; break; 118*0440ff15Schris } 119*0440ff15Schris $this->_validatePagination(); 120*0440ff15Schris } 121*0440ff15Schris 122*0440ff15Schris /** 123*0440ff15Schris * output appropriate html 124*0440ff15Schris */ 125*0440ff15Schris function html() { 126*0440ff15Schris global $ID; 127*0440ff15Schris 128*0440ff15Schris if(is_null($this->_auth)) { 129*0440ff15Schris print $this->lang['badauth']; 130*0440ff15Schris return false; 131*0440ff15Schris } 132*0440ff15Schris 133*0440ff15Schris $user_list = $this->_auth->retrieveUsers($this->_start, $this->_pagesize, $this->_filter); 134*0440ff15Schris $users = array_keys($user_list); 135*0440ff15Schris 136*0440ff15Schris $page_buttons = $this->_pagination(); 137*0440ff15Schris $edit_disable = $this->_auth->canDo('modifyUser') ? '' : 'disabled="disabled"'; 138*0440ff15Schris $delete_disable = $this->_auth->canDo('deleteUsers') ? '' : 'disabled="disabled"'; 139*0440ff15Schris 140*0440ff15Schris print $this->locale_xhtml('intro'); 141*0440ff15Schris print $this->locale_xhtml('list'); 142*0440ff15Schris 143*0440ff15Schris ptln("<div class=\"level2\" style=\"margin-bottom: 2em;\">"); 144*0440ff15Schris 145*0440ff15Schris if ($this->_user_total) { 146*0440ff15Schris ptln("<p>".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."</p>"); 147*0440ff15Schris } else { 148*0440ff15Schris ptln("<p>".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."</p>"); 149*0440ff15Schris } 150*0440ff15Schris ptln("<form action=\"".wl($ID)."\" method=\"post\">"); 151*0440ff15Schris ptln(" <table class=\"inline\">"); 152*0440ff15Schris ptln(" <thead>"); 153*0440ff15Schris ptln(" <tr>"); 154*0440ff15Schris ptln(" <th colspan=\"2\"> </th><th>".$this->lang["user_id"]."</th><th>".$this->lang["user_name"]."</th><th>".$this->lang["user_mail"]."</th><th>".$this->lang["user_groups"]."</th>"); 155*0440ff15Schris ptln(" </tr>"); 156*0440ff15Schris 157*0440ff15Schris ptln(" <tr>"); 158*0440ff15Schris// ptln(" <td colspan=\"2\"><input type=\"submit\" name=\"fn[search][new]\" value=\"".$this->lang['search']."\" /></td>"); 159*0440ff15Schris ptln(" <td colspan=\"2\" style=\"vertical-align:middle; text-align:right;\"><input type=\"image\" src=\"".DOKU_PLUGIN_IMAGES."search.png\" name=\"fn[search][new]\" title=\"".$this->lang['search_prompt']."\" alt=\"".$this->lang['search']."\" /></td>"); 160*0440ff15Schris ptln(" <td><input type=\"text\" name=\"userid\" value=\"".$this->_htmlFilter('user')."\" /></td>"); 161*0440ff15Schris ptln(" <td><input type=\"text\" name=\"username\" value=\"".$this->_htmlFilter('name')."\" /></td>"); 162*0440ff15Schris ptln(" <td><input type=\"text\" name=\"usermail\" value=\"".$this->_htmlFilter('mail')."\" /></td>"); 163*0440ff15Schris ptln(" <td><input type=\"text\" name=\"usergroups\" value=\"".$this->_htmlFilter('grps')."\" /></td>"); 164*0440ff15Schris ptln(" </tr>"); 165*0440ff15Schris ptln(" </thead>"); 166*0440ff15Schris 167*0440ff15Schris if ($this->_user_total) { 168*0440ff15Schris ptln(" <tbody>"); 169*0440ff15Schris foreach ($user_list as $user => $userinfo) { 170*0440ff15Schris extract($userinfo); 171*0440ff15Schris $groups = join(', ',$grps); 172*0440ff15Schris ptln(" <tr valign=\"top\" align=\"left\">"); 173*0440ff15Schris ptln(" <td class=\"centeralign\"><input type=\"checkbox\" name=\"delete[".$user."]\" ".$delete_disable." /></td>"); 174*0440ff15Schris// ptln(" <td class=\"centeralign\"><input type=\"submit\" name=\"fn[edit][".$user."]\" ".$edit_disable." value=\"".$this->lang['edit']."\"/></td>"); 175*0440ff15Schris ptln(" <td class=\"centeralign\"><input type=\"image\" name=\"fn[edit][".$user."]\" ".$edit_disable." src=\"".DOKU_PLUGIN_IMAGES."user_edit.png\" title=\"".$this->lang['edit_prompt']."\" alt=\"".$this->lang['edit']."\"/></td>"); 176*0440ff15Schris ptln(" <td>".hsc($user)."</td><td>".hsc($name)."</td><td>".hsc($mail)."</td><td>".hsc($groups)."</td>"); 177*0440ff15Schris ptln(" </tr>"); 178*0440ff15Schris } 179*0440ff15Schris ptln(" </tbody>"); 180*0440ff15Schris } 181*0440ff15Schris 182*0440ff15Schris ptln(" <tbody>"); 183*0440ff15Schris ptln(" <tr><td colspan=\"6\" style=\"text-align:center\">"); 184*0440ff15Schris ptln(" <span style=\"float:left\">"); 185*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[delete]\" ".$delete_disable." value=\"".$this->lang['delete_selected']."\"/>"); 186*0440ff15Schris ptln(" </span>"); 187*0440ff15Schris ptln(" <span style=\"float:right\">"); 188*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[start]\" ".$page_buttons['start']." value=\"".$this->lang['start']."\" />"); 189*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[prev]\" ".$page_buttons['prev']." value=\"".$this->lang['prev']."\" />"); 190*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[next]\" ".$page_buttons['next']." value=\"".$this->lang['next']."\" />"); 191*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[last]\" ".$page_buttons['last']." value=\"".$this->lang['last']."\" />"); 192*0440ff15Schris ptln(" </span>"); 193*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[search][clear]\" value=\"".$this->lang['clear']."\" />"); 194*0440ff15Schris ptln(" </td></tr>"); 195*0440ff15Schris ptln(" </tbody>"); 196*0440ff15Schris ptln(" </table>"); 197*0440ff15Schris ptln(" <input type=\"hidden\" name=\"do\" value=\"admin\" />"); 198*0440ff15Schris ptln(" <input type=\"hidden\" name=\"page\" value=\"usermanager\" />"); 199*0440ff15Schris 200*0440ff15Schris $this->_htmlFilterSettings(2); 201*0440ff15Schris 202*0440ff15Schris ptln("</form>"); 203*0440ff15Schris ptln("</div>"); 204*0440ff15Schris 205*0440ff15Schris $style = $this->_edit_user ? " style=\"width: 46%; float: left;\"" : ""; 206*0440ff15Schris 207*0440ff15Schris if ($this->_auth->canDo('createUser')) { 208*0440ff15Schris ptln("<div".$style.">"); 209*0440ff15Schris print $this->locale_xhtml('add'); 210*0440ff15Schris ptln(" <div class=\"level2\">"); 211*0440ff15Schris 212*0440ff15Schris $this->_htmlUserForm('add',null,4); 213*0440ff15Schris 214*0440ff15Schris ptln(" </div>"); 215*0440ff15Schris ptln("</div>"); 216*0440ff15Schris } 217*0440ff15Schris 218*0440ff15Schris if($this->_edit_user && $this->_auth->canDo('modifyUser')){ 219*0440ff15Schris ptln("<div".$style.">"); 220*0440ff15Schris print $this->locale_xhtml('edit'); 221*0440ff15Schris ptln(" <div class=\"level2\">"); 222*0440ff15Schris 223*0440ff15Schris $this->_htmlUserForm('modify',$this->_edit_user,4); 224*0440ff15Schris 225*0440ff15Schris ptln(" </div>"); 226*0440ff15Schris ptln("</div>"); 227*0440ff15Schris } 228*0440ff15Schris } 229*0440ff15Schris 230*0440ff15Schris function _htmlUserForm($cmd,$user=null,$indent=0) { 231*0440ff15Schris 232*0440ff15Schris if ($user) { 233*0440ff15Schris extract($this->_auth->getUserData($user)); 234*0440ff15Schris $groups = join(',',$grps); 235*0440ff15Schris } else { 236*0440ff15Schris $user = $name = $mail = $groups = ''; 237*0440ff15Schris } 238*0440ff15Schris 239*0440ff15Schris ptln("<form action=\"".wl($ID)."\" method=\"post\">",$indent); 240*0440ff15Schris ptln(" <table class=\"inline\">",$indent); 241*0440ff15Schris ptln(" <thead>",$indent); 242*0440ff15Schris ptln(" <tr><th>".$this->lang["field"]."</th><th>".$this->lang["value"]."</th></tr>",$indent); 243*0440ff15Schris ptln(" </thead>",$indent); 244*0440ff15Schris ptln(" <tbody>",$indent); 245*0440ff15Schris ptln(" <tr><td><label for=\"".$cmd."_userid\" >".$this->lang["user_id"]." : </label></td><td><input type=\"text\" id=\"".$cmd."_userid\" name=\"userid\" value=\"".$user."\" /></td></tr>",$indent); 246*0440ff15Schris ptln(" <tr><td><label for=\"".$cmd."_userpass\" >".$this->lang["user_pass"]." : </label></td><td><input type=\"text\" id=\"".$cmd."_userpass\" name=\"userpass\" value=\"\" /></td></tr>",$indent); 247*0440ff15Schris ptln(" <tr><td><label for=\"".$cmd."_username\" >".$this->lang["user_name"]." : </label></td><td><input type=\"text\" id=\"".$cmd."_username\" name=\"username\" value=\"".$name."\" /></td></tr>",$indent); 248*0440ff15Schris ptln(" <tr><td><label for=\"".$cmd."_usermail\" >".$this->lang["user_mail"]." : </label></td><td><input type=\"text\" id=\"".$cmd."_usermail\" name=\"usermail\" value=\"".$mail."\" /></td></tr>",$indent); 249*0440ff15Schris ptln(" <tr><td><label for=\"".$cmd."_usergroups\" >".$this->lang["user_groups"]." : </label></td><td><input type=\"text\" id=\"".$cmd."_usergroups\" name=\"usergroups\" value=\"".$groups."\" /></td></tr>",$indent); 250*0440ff15Schris ptln(" </tbody>",$indent); 251*0440ff15Schris ptln(" <tbody>",$indent); 252*0440ff15Schris ptln(" <tr>",$indent); 253*0440ff15Schris ptln(" <td colspan=\"2\">",$indent); 254*0440ff15Schris ptln(" <input type=\"hidden\" name=\"do\" value=\"admin\" />",$indent); 255*0440ff15Schris ptln(" <input type=\"hidden\" name=\"page\" value=\"usermanager\" />",$indent); 256*0440ff15Schris 257*0440ff15Schris // save current $user, we need this to access details if the name is changed 258*0440ff15Schris if ($user) 259*0440ff15Schris ptln(" <input type=\"hidden\" name=\"userid_old\" value=\"".$user."\" />",$indent); 260*0440ff15Schris 261*0440ff15Schris $this->_htmlFilterSettings($indent+10); 262*0440ff15Schris 263*0440ff15Schris ptln(" <input type=\"submit\" name=\"fn[".$cmd."]\" value=\"".$this->lang[$cmd]."\" />",$indent); 264*0440ff15Schris ptln(" </td>",$indent); 265*0440ff15Schris ptln(" </tr>",$indent); 266*0440ff15Schris ptln(" </tbody>",$indent); 267*0440ff15Schris ptln(" </table>",$indent); 268*0440ff15Schris ptln("</form>",$indent); 269*0440ff15Schris } 270*0440ff15Schris 271*0440ff15Schris function _htmlFilter($key) { 272*0440ff15Schris if (empty($this->_filter)) return ''; 273*0440ff15Schris return (isset($this->_filter[$key]) ? hsc($this->_filter[$key]) : ''); 274*0440ff15Schris } 275*0440ff15Schris 276*0440ff15Schris function _htmlFilterSettings($indent=0) { 277*0440ff15Schris 278*0440ff15Schris ptln("<input type=\"hidden\" name=\"start\" value=\"".$this->_start."\" />",$indent); 279*0440ff15Schris 280*0440ff15Schris foreach ($this->_filter as $key => $filter) { 281*0440ff15Schris ptln("<input type=\"hidden\" name=\"filter[".$key."]\" value=\"".hsc($filter)."\" />",$indent); 282*0440ff15Schris } 283*0440ff15Schris } 284*0440ff15Schris 285*0440ff15Schris function _addUser(){ 286*0440ff15Schris 287*0440ff15Schris if (!$this->_auth->canDo('createUser')) return false; 288*0440ff15Schris 289*0440ff15Schris list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(); 290*0440ff15Schris if (empty($user)) return false; 291*0440ff15Schris 292*0440ff15Schris return $this->_auth->createUser($user,$pass,$name,$mail,$grps); 293*0440ff15Schris } 294*0440ff15Schris 295*0440ff15Schris /** 296*0440ff15Schris * Delete user 297*0440ff15Schris */ 298*0440ff15Schris function _deleteUser(){ 299*0440ff15Schris 300*0440ff15Schris if (!$this->_auth->canDo('deleteUsers')) return false; 301*0440ff15Schris 302*0440ff15Schris $selected = $_REQUEST['delete']; 303*0440ff15Schris if (!is_array($selected) || empty($selected)) return false; 304*0440ff15Schris $selected = array_keys($selected); 305*0440ff15Schris 306*0440ff15Schris $count = $this->_auth->deleteUsers($selected); 307*0440ff15Schris if ($count == count($selected)) { 308*0440ff15Schris $text = str_replace('%d', $count, $this->lang['delete_ok']); 309*0440ff15Schris msg("$text.", 1); 310*0440ff15Schris } else { 311*0440ff15Schris $part1 = str_replace('%d', $count, $this->lang['delete_ok']); 312*0440ff15Schris $part2 = str_replace('%d', (count($selected)-$count), $this->lang['delete_fail']); 313*0440ff15Schris msg("$part1, $part2",-1); 314*0440ff15Schris } 315*0440ff15Schris } 316*0440ff15Schris 317*0440ff15Schris /** 318*0440ff15Schris * Modify user 319*0440ff15Schris */ 320*0440ff15Schris function _modifyUser(){ 321*0440ff15Schris if (!$this->_auth->canDo('modifyUser')) return false; 322*0440ff15Schris 323*0440ff15Schris list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(); 324*0440ff15Schris if (empty($user)) return false; 325*0440ff15Schris 326*0440ff15Schris $changes = array(); 327*0440ff15Schris $user_old = cleanID(preg_replace('/.*:/','',$_REQUEST['userid_old'])); 328*0440ff15Schris if ($user != $user_old) { 329*0440ff15Schris // check $user doesn't already exist 330*0440ff15Schris if ($this->_auth->getUserData($user)) { 331*0440ff15Schris msg(sprintf($this->lang['update_exists'],$user),-1); 332*0440ff15Schris $this->_edit_user = $user = $user_old; 333*0440ff15Schris } else { 334*0440ff15Schris $changes['user'] = $user; 335*0440ff15Schris $user = $user_old; 336*0440ff15Schris } 337*0440ff15Schris } 338*0440ff15Schris 339*0440ff15Schris if (!empty($pass)) $changes['pass'] = $pass; 340*0440ff15Schris if (!empty($name)) $changes['name'] = $name; 341*0440ff15Schris if (!empty($mail)) $changes['mail'] = $mail; 342*0440ff15Schris if (!empty($grps)) $changes['grps'] = $grps; 343*0440ff15Schris 344*0440ff15Schris if ($this->_auth->modifyUser($user, $changes)) { 345*0440ff15Schris msg($this->lang['update_ok'],1); 346*0440ff15Schris } else { 347*0440ff15Schris msg($this->lang['update_fail'],-1); 348*0440ff15Schris } 349*0440ff15Schris } 350*0440ff15Schris 351*0440ff15Schris /* 352*0440ff15Schris * retrieve & clean user data from the form 353*0440ff15Schris * return an array(user, password, full name, email, array(groups)) 354*0440ff15Schris */ 355*0440ff15Schris function _retrieveUser($clean=true) { 356*0440ff15Schris 357*0440ff15Schris $user[0] = ($clean) ? cleanID(preg_replace('/.*:/','',$_REQUEST['userid'])) : $_REQUEST['userid']; 358*0440ff15Schris $user[1] = $_REQUEST['userpass']; 359*0440ff15Schris $user[2] = $_REQUEST['username']; 360*0440ff15Schris $user[3] = $_REQUEST['usermail']; 361*0440ff15Schris $user[4] = preg_split('/\s*,\s*/',$_REQUEST['usergroups'],-1,PREG_SPLIT_NO_EMPTY); 362*0440ff15Schris 363*0440ff15Schris if (is_array($user[4]) && (count($user[4]) == 1) && (trim($user[4][0]) == '')) { 364*0440ff15Schris $user[4] = null; 365*0440ff15Schris } 366*0440ff15Schris 367*0440ff15Schris return $user; 368*0440ff15Schris } 369*0440ff15Schris 370*0440ff15Schris function _setFilter($op) { 371*0440ff15Schris 372*0440ff15Schris $this->_filter = array(); 373*0440ff15Schris 374*0440ff15Schris if ($op == 'new') { 375*0440ff15Schris list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false); 376*0440ff15Schris 377*0440ff15Schris if (!empty($user)) $this->_filter['user'] = $user; 378*0440ff15Schris if (!empty($name)) $this->_filter['name'] = $name; 379*0440ff15Schris if (!empty($mail)) $this->_filter['mail'] = $mail; 380*0440ff15Schris if (!empty($grps)) $this->_filter['grps'] = join('|',$grps); 381*0440ff15Schris } 382*0440ff15Schris } 383*0440ff15Schris 384*0440ff15Schris function _retrieveFilter() { 385*0440ff15Schris 386*0440ff15Schris $t_filter = $_REQUEST['filter']; 387*0440ff15Schris if (!is_array($t_filter)) return array(); 388*0440ff15Schris 389*0440ff15Schris // messy, but this way we ensure we aren't getting any additional crap from malicious users 390*0440ff15Schris $filter = array(); 391*0440ff15Schris 392*0440ff15Schris if (isset($t_filter['user'])) $filter['user'] = $t_filter['user']; 393*0440ff15Schris if (isset($t_filter['name'])) $filter['name'] = $t_filter['name']; 394*0440ff15Schris if (isset($t_filter['mail'])) $filter['mail'] = $t_filter['mail']; 395*0440ff15Schris if (isset($t_filter['grps'])) $filter['grps'] = $t_filter['grps']; 396*0440ff15Schris 397*0440ff15Schris return $filter; 398*0440ff15Schris } 399*0440ff15Schris 400*0440ff15Schris function _validatePagination() { 401*0440ff15Schris 402*0440ff15Schris if ($this->_start >= $this->_user_total) { 403*0440ff15Schris $this->_start = $this->_user_total - $this->_pagesize; 404*0440ff15Schris } 405*0440ff15Schris if ($this->_start < 0) $this->_start = 0; 406*0440ff15Schris 407*0440ff15Schris $this->_last = min($this->_user_total, $this->_start + $this->_pagesize); 408*0440ff15Schris } 409*0440ff15Schris 410*0440ff15Schris /* 411*0440ff15Schris * return an array of strings to enable/disable pagination buttons 412*0440ff15Schris */ 413*0440ff15Schris function _pagination() { 414*0440ff15Schris 415*0440ff15Schris $buttons['start'] = $buttons['prev'] = ($this->_start == 0) ? 'disabled="disabled"' : ''; 416*0440ff15Schris $buttons['last'] = $buttons['next'] = (($this->_start + $this->_pagesize) >= $this->_user_total) ? 'disabled="disabled"' : ''; 417*0440ff15Schris 418*0440ff15Schris return $buttons; 419*0440ff15Schris } 420*0440ff15Schris} 421