]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New getClients() function in bweb class
authorDavide Franco <bacula-dev@dflc.ch>
Thu, 21 Jul 2011 15:57:47 +0000 (17:57 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:26 +0000 (14:49 +0200)
 - getClients() return an array with (clientid and name)
 - Fixed function visibility declarations
 - Removed useless code

gui/bacula-web/includes/bweb.inc.php

index 2cbca62105d0dfe1644890bc6453ac55557d149c..6804c7deb3ff52ba4667fce88e452eb7896e44c1 100644 (file)
@@ -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;