Skip to content

Commit 0494b46

Browse files
author
Marius Burkard
committed
- added remote function for getting system config
1 parent 4733cfe commit 0494b46

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

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

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,55 @@ public function update_record_permissions($tablename, $index_field, $index_value
106106
/**
107107
Set a value in the system configuration
108108
@param int session id
109-
@param int server id
110-
@param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
109+
@param string section of the config field in the table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
111110
@param string key of the option that you want to set
112111
@param string option value that you want to set
113112
*/
114-
115-
116113
public function system_config_set($session_id, $section, $key, $value) {
117-
global $app;
118-
if(!$this->checkPerm($session_id, 'system_config_set')) {
119-
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
120-
return false;
121-
}
122-
if ($section != '' && $key != '') {
123-
$app->uses('remoting_lib,getconf,ini_parser');
124-
$system_config_array = $app->getconf->get_global_config();
125-
$system_config_array[$section][$key] = $value;
126-
$system_config_str = $app->ini_parser->get_ini_string($system_config_array);
127-
$app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1);
128-
} else {
129-
throw new SoapFault('invalid_function_parameter', 'Invalid function parameter.');
130-
return false;
131-
}
114+
global $app;
115+
if(!$this->checkPerm($session_id, 'system_config_set')) {
116+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
117+
return false;
118+
}
119+
if ($section != '' && $key != '') {
120+
$app->uses('remoting_lib,getconf,ini_parser');
121+
$system_config_array = $app->getconf->get_global_config();
122+
$system_config_array[$section][$key] = $value;
123+
$system_config_str = $app->ini_parser->get_ini_string($system_config_array);
124+
$app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1);
125+
} else {
126+
throw new SoapFault('invalid_function_parameter', 'Invalid function parameter.');
127+
return false;
128+
}
132129
}
133130

131+
/**
132+
Get the values of the system configuration
133+
@param int session id
134+
@param string section of the config field in the table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
135+
@param string key of the option that you want to set
136+
@param string option value that you want to set
137+
*/
138+
public function system_config_get($session_id, $section, $key) {
139+
global $app;
140+
if(!$this->checkPerm($session_id, 'system_config_get')) {
141+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
142+
return false;
143+
}
144+
if ($section != '') {
145+
$app->uses('remoting_lib,getconf,ini_parser');
146+
$system_config_array = $app->getconf->get_global_config();
147+
if($key != '') {
148+
if(isset($system_config_array[$section][$key])) return $system_config_array[$section][$key];
149+
else return false;
150+
} else {
151+
if(isset($system_config_array[$section])) return $system_config_array[$section];
152+
else return false;
153+
} else {
154+
throw new SoapFault('invalid_function_parameter', 'Invalid function parameter.');
155+
return false;
156+
}
157+
}
134158

135159
}
136160

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$function_list['server_get,server_config_set,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_get,server_ip_add,server_ip_update,server_ip_delete,system_config_set'] = 'Server functions';
3+
$function_list['server_get,server_config_set,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_get,server_ip_add,server_ip_update,server_ip_delete,system_config_set,system_config_get'] = 'Server functions';
44
$function_list['admin_record_permissions'] = 'Record permission changes';
55

66
?>

0 commit comments

Comments
 (0)