[Pureuseradmin-cvs] PureUserAdmin pureuserclass.php,1.4,1.5 index.php,1.1,1.2
Status: Abandoned
Brought to you by:
mvanbaak
|
From: Michiel v. B. <mva...@us...> - 2004-10-16 10:18:17
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27802 Modified Files: pureuserclass.php index.php Log Message: added search and paging in userlist Index: pureuserclass.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pureuserclass.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pureuserclass.php 4 Oct 2004 19:26:20 -0000 1.4 --- pureuserclass.php 16 Oct 2004 10:18:06 -0000 1.5 *************** *** 41,44 **** --- 41,45 ---- * @access private */ + //{{{ private function mkpass ($passwd) { if ($this->settings["pwcrypt"] == "password") { *************** *** 54,58 **** return $ret; } ! /** * Database connection --- 55,59 ---- return $ret; } ! //}}} /** * Database connection *************** *** 63,66 **** --- 64,68 ---- * @access private */ + //{{{ private function db_init () { if ($this->settings["sql_type"] == "mysql") { *************** *** 73,77 **** } } ! /** * PHP database support --- 75,79 ---- } } ! //}}} /** * PHP database support *************** *** 83,86 **** --- 85,89 ---- * @access private */ + //{{{ private function load_sql ($sql_type) { if ($sql_type == "mysql") { *************** *** 106,113 **** } else { // unsupported database type ! gen_error("We dont support database system $sql_type"); ! exit(); } } /** --- 109,117 ---- } else { // unsupported database type ! //gen_error("We dont support database system $sql_type"); ! //exit(); } } + //}}} /** *************** *** 117,120 **** --- 121,125 ---- * @access private */ + //{{{ private function load_uids() { $lines = file("/etc/passwd"); *************** *** 126,129 **** --- 131,135 ---- return $uids; } + //}}} /** *************** *** 133,136 **** --- 139,143 ---- * @access private */ + //{{{ private function load_gids() { $lines = file("/etc/group"); *************** *** 142,145 **** --- 149,153 ---- return $gids; } + //}}} /** *************** *** 151,154 **** --- 159,163 ---- * @access protected */ + //{{{ function __construct() { /* global settings */ *************** *** 188,191 **** --- 197,201 ---- self::db_init(); } + //}}} /** *************** *** 196,199 **** --- 206,210 ---- * @access public */ + //{{{ public function changeSetting ($setting, $value) { $this->settings[$setting] = $value; *************** *** 255,258 **** --- 266,270 ---- return true; } + //}}} /** *************** *** 263,266 **** --- 275,279 ---- * @access public */ + //{{{ public function delete_user($userinfo) { $sql = "DELETE FROM ".$this->settings["sql_table"]." WHERE ".$this->settings["field_user"]."='".$userinfo["username"]."'"; *************** *** 268,272 **** return true; } ! /** * Get a user from the database. --- 281,285 ---- return true; } ! //}}} /** * Get a user from the database. *************** *** 276,279 **** --- 289,293 ---- * @access public */ + //{{{ public function get_user($userinfo) { $sql = "SELECT * FROM ".$this->settings["sql_table"]." WHERE ".$this->settings["field_user"]."='".$userinfo["username"]."'"; *************** *** 282,294 **** return $userinfo; } ! /** * Get all users from the database, in alphabetic order. * <code> $userlist = $instance->get_all_users(); </code> * @return array All users with all info that is in the database. * @access public */ ! public function get_all_users() { ! $sql = "SELECT * FROM ".$this->settings["sql_table"]." ORDER BY ".$this->settings["field_user"]; $res = sql_query($sql); $users = Array(); --- 296,318 ---- return $userinfo; } ! //}}} /** * Get all users from the database, in alphabetic order. * <code> $userlist = $instance->get_all_users(); </code> + * @param string $search Searchstring to limit results. + * @param integer $start Record in database to start output. + * @param integer $pagesize Number of users to show on a page. * @return array All users with all info that is in the database. * @access public */ ! //{{{ ! public function get_all_users($search = "", $start = 0, $pagesize = 0) { ! if (!$pagesize) { $pagesize = $this->settings["page_size"]; } ! if ($search) { ! $q = " WHERE ".$this->settings["field_user"]." LIKE '%$search%' OR ".$this->settings["field_dir"]." LIKE '%$search%'"; ! } else { ! $q = ""; ! } ! $sql = "SELECT * FROM ".$this->settings["sql_table"]."$q ORDER BY ".$this->settings["field_user"]." LIMIT $start, $pagesize"; $res = sql_query($sql); $users = Array(); *************** *** 298,302 **** return $users; } ! /** * Check what type of access the user has. --- 322,348 ---- return $users; } ! //}}} ! ! /** ! * Get number of users in the database. ! * <code> $nr_users = $instance->get_nr_users(); </code> ! * @param string $search Searchstring to limit results. ! * @return integer Number of users in the database. ! * @access public ! */ ! //{{{ ! public function get_nr_users($search = "") { ! if ($search) { ! $q = " WHERE ".$this->settings["field_user"]." LIKE '%$search%' OR ".$this->settings["field_dir"]." LIKE '%$search%'"; ! } else { ! $q = ""; ! } ! $sql = "SELECT COUNT(*) FROM ".$this->settings["sql_table"]."$q"; ! $res = sql_query($sql); ! $count = sql_result($res,0); ! return $count; ! } ! //}}} ! /** * Check what type of access the user has. *************** *** 308,311 **** --- 354,358 ---- * @access public */ + //{{{ public function check_access ($homedir, $uid, $gid) { if (file_exists($homedir)) { *************** *** 334,338 **** return $rights; } } ! ?> \ No newline at end of file --- 381,386 ---- return $rights; } + //}}} } ! ?> Index: index.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/index.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index.php 3 Oct 2004 16:05:47 -0000 1.1 --- index.php 16 Oct 2004 10:18:06 -0000 1.2 *************** *** 305,310 **** //how many users do we have ! $all_users = $a->get_all_users(); ! $usernr = count($all_users); foreach ($all_users as $user) { if ($a->settings["check_access"]) { --- 305,310 ---- //how many users do we have ! $all_users = $a->get_all_users($search, $start); ! $usernr = $a->get_nr_users($search); foreach ($all_users as $user) { if ($a->settings["check_access"]) { *************** *** 331,335 **** <? } ! if ($start && $start+$a->settings["page_size"]<$usernr) { ?> <tr> --- 331,335 ---- <? } ! if ($start || $start+$a->settings["page_size"]<$usernr) { ?> <tr> *************** *** 351,353 **** } ! ?> \ No newline at end of file --- 351,353 ---- } ! ?> |