From f81bb8935a2169c2b4af6b2b63974a633cbc521f Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Thu, 21 Jul 2011 17:57:47 +0200 Subject: [PATCH] bacula-web: New getClients() function in bweb class - getClients() return an array with (clientid and name) - Fixed function visibility declarations - Removed useless code --- gui/bacula-web/includes/bweb.inc.php | 34 +++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index 2cbca62105..6804c7deb3 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -87,7 +87,7 @@ class Bweb $this->tpl->compile_dir = "./templates_c"; } - function init_gettext() + private function init_gettext() { global $smarty_gettext_path; @@ -110,7 +110,7 @@ class Bweb } } - function GetDbSize() + public function GetDbSize() { $db_size = 0; $query = ''; @@ -161,7 +161,7 @@ class Bweb } // Return an array of volumes ordered by poolid and volume name - function GetVolumeList() + public function GetVolumeList() { $pools = ''; $volumes = ''; @@ -353,6 +353,34 @@ class Bweb return $backupjobs; } + // Return an array with clients list + public function getClients() + { + $query = ''; + $result = ''; + $clients = array(); + + switch( $this->db_link->getDriver() ) + { + case 'sqlite': + case 'mysql': + case 'pgsql': + $query = "SELECT Client.ClientId, Client.Name FROM Client;"; + break; + } + try { + $result = $this->db_link->runQuery($query); + + foreach( $result->fetchAll() as $client ) + $clients[ $client['clientid'] ] = $client['name']; + + }catch(PDOException $e) { + CDBError::raiseError($e); + } + + return $clients; + } + public function countVolumes( $pool_id = 'ALL' ) { $result = null; -- 2.39.5