Skip to content

Commit 35a68db

Browse files
author
florian030
committed
2 parents 5bd2aa2 + 41add69 commit 35a68db

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

interface/lib/classes/remote.d/server.inc.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

interface/lib/classes/tform_base.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ protected function _getDatasourceData($field, $record, $api = false) {
270270
unset($tmp_recordid);
271271

272272
$querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring);
273-
$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', "self::table_auth_sql", $querystring);
273+
$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', array($this, 'table_auth_sql'), $querystring);
274274

275275
// Getting the records
276276
$tmp_records = $app->db->queryAllRecords($querystring);
@@ -312,6 +312,9 @@ protected function _getDatasourceData($field, $record, $api = false) {
312312

313313
}
314314

315+
function table_auth_sql($matches){
316+
return $this->getAuthSQL('r', $matches[1]);
317+
}
315318

316319
/**
317320
* Get the key => value array of a form filled from a datasource definitiom

0 commit comments

Comments
 (0)