@@ -115,21 +115,55 @@ public function server_ip_delete($session_id, $ip_id)
115115 */
116116
117117
118- public function server_get ($ session_id , $ server_id , $ section ='' ) {
118+ public function server_get ($ session_id , $ server_id = null , $ section ='' ) {
119+ global $ app ;
120+ if (!$ this ->checkPerm ($ session_id , 'server_get ' )) {
121+ $ this ->server ->fault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
122+ return false ;
123+ }
124+ if (!empty ($ session_id )) {
125+ $ app ->uses ('remoting_lib , getconf ' );
126+ if (!empty ($ server_id )) {
127+ $ section_config = $ app ->getconf ->get_server_config ($ server_id , $ section );
128+ return $ section_config ;
129+ } else {
130+ $ servers = array ();
131+ $ sql = "SELECT server_id FROM server WHERE 1 " ;
132+ $ all = $ app ->db ->queryAllRecords ($ sql );
133+ foreach ($ all as $ s ) {
134+ $ servers [$ s ['server_id ' ]] = $ app ->getconf ->get_server_config ($ s ['server_id ' ], $ section );
135+ }
136+ unset($ all );
137+ unset($ s );
138+ return $ servers ;
139+ }
140+ } else {
141+ return false ;
142+ }
143+ }
144+
145+ /**
146+ Gets a list of all servers
147+ @param int session_id
148+ @param int server_name
149+ @author Marius Cramer <m.cramer@pixcept.de> 2014
150+ */
151+ public function server_get_all ($ session_id )
152+ {
119153 global $ app ;
120154 if (!$ this ->checkPerm ($ session_id , 'server_get ' )) {
121155 $ this ->server ->fault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
122156 return false ;
123157 }
124- if (!empty ($ session_id ) && ! empty ( $ server_id ) ) {
125- $ app -> uses ( ' remoting_lib , getconf ' ) ;
126- $ section_config = $ app ->getconf -> get_server_config ( $ server_id , $ section );
127- return $ section_config ;
158+ if (!empty ($ session_id )) {
159+ $ sql = " SELECT server_id, server_name FROM server WHERE 1 " ;
160+ $ servers = $ app ->db -> queryAllRecords ( $ sql );
161+ return $ servers ;
128162 } else {
129163 return false ;
130164 }
131165 }
132-
166+
133167 /**
134168 Gets the server_id by server_name
135169 @param int session_id
0 commit comments