From 8fe80611d30c018f93c95502ec13a67c8b346b17 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Wed, 5 Sep 2001 11:16:58 +0000 Subject: [PATCH] Added return of total to get_list by ref, needs tweaking --- phpgwapi/inc/class.interserver.inc.php | 36 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/phpgwapi/inc/class.interserver.inc.php b/phpgwapi/inc/class.interserver.inc.php index 285828a7fc..a318350e33 100644 --- a/phpgwapi/inc/class.interserver.inc.php +++ b/phpgwapi/inc/class.interserver.inc.php @@ -468,9 +468,30 @@ return False; } - function get_list($start='',$sort='',$order='',$query='',$offset='') + function get_list($start='',$sort='',$order='',$query='',$offset='',&$total) { - $sql = "SELECT * FROM $this->table"; + if (!$sort) + { + $sort = 'DESC'; + } + if ($query) + { + $whereclause = "WHERE server_name LIKE '%$query%'" + . "OR server_url LIKE '%$query%'" + . "OR server_mode LIKE '%$query%'" + . "OR admin_name LIKE '%$query%'" + . "OR admin_email LIKE '%$query%'"; + } + if ($order) + { + $orderclause = 'ORDER BY ' . $order . ' ' . $sort; + } + else + { + $orderclause = 'ORDER BY server_name ASC'; + } + + $sql = "SELECT * FROM $this->table $whereclause $orderclause"; $this->db->query($sql,__LINE__,__FILE__); while ($this->db->next_record()) @@ -485,11 +506,12 @@ $this->servers[$this->db->f('server_name')]['admin_name'] = $this->db->f('admin_name'); $this->servers[$this->db->f('server_name')]['admin_email'] = $this->db->f('admin_email'); } - $this->total = $this->db->num_rows() + 1; + $this->total = $this->db->num_rows(); + $total = $this->total; return $this->servers; } - function formatted_list($server_id=0,$java=False) + function formatted_list($server_id=0,$java=False,$local=False) { if ($java) { @@ -501,9 +523,11 @@ { $select .= ' selected'; } - $select .= '>' . lang('Please Select') . ''."\n"; + $selectlang = $local ? lang('Local') : lang('Please Select'); + $select .= '>' . $selectlang . ''."\n"; - $slist = $this->get_list(); + $x = ''; + $slist = $this->get_list('','','','','',$x); while (list($key,$val) = each($slist)) { $foundservers = True;