@@ -479,17 +479,50 @@ protected function getSession($session_id)
479479 }
480480 }
481481
482- // needed from inside the remoting plugins
483- public function server_get ($ session_id , $ server_id , $ section ='' ) {
482+ public function server_get ($ session_id , $ server_id = null , $ section ='' ) {
484483 global $ app ;
485484 if (!$ this ->checkPerm ($ session_id , 'server_get ' )) {
486- throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
485+ $ this ->server ->fault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
486+ return false ;
487+ }
488+ if (!empty ($ session_id )) {
489+ if (!empty ($ server_id )) {
490+ $ app ->uses ('remoting_lib , getconf ' );
491+ $ section_config = $ app ->getconf ->get_server_config ($ server_id , $ section );
492+ return $ section_config ;
493+ } else {
494+ $ servers = array ();
495+ $ sql = "SELECT server_id FROM server WHERE 1 " ;
496+ $ all = $ app ->db ->queryAllRecords ($ sql );
497+ foreach ($ all as $ s ) {
498+ $ servers [$ s ['server_id ' ]] = $ app ->getconf ->get_server_config ($ s ['server_id ' ], $ section );
499+ }
500+ unset($ all );
501+ unset($ s );
502+ return $ servers ;
503+ }
504+ } else {
487505 return false ;
488506 }
489- if (!empty ($ session_id ) && !empty ($ server_id )) {
490- $ app ->uses ('remoting_lib , getconf ' );
491- $ section_config = $ app ->getconf ->get_server_config ($ server_id , $ section );
492- return $ section_config ;
507+ }
508+
509+ /**
510+ Gets a list of all servers
511+ @param int session_id
512+ @param int server_name
513+ @author Marius Cramer <m.cramer@pixcept.de> 2014
514+ */
515+ public function server_get_all ($ session_id )
516+ {
517+ global $ app ;
518+ if (!$ this ->checkPerm ($ session_id , 'server_get ' )) {
519+ $ this ->server ->fault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
520+ return false ;
521+ }
522+ if (!empty ($ session_id )) {
523+ $ sql = "SELECT server_id, server_name FROM server WHERE 1 " ;
524+ $ servers = $ app ->db ->queryAllRecords ($ sql );
525+ return $ servers ;
493526 } else {
494527 return false ;
495528 }
0 commit comments