Commit a25fa66c authored by Till Brehm's avatar Till Brehm

Added remote functions config_value_get, config_value_add,...

Added remote functions config_value_get, config_value_add, config_value_update, config_value_replace and config_value_delete to access the sys_config key / value store in ISPConfig from remote api.
parent e15923ab
......@@ -156,6 +156,122 @@ class remoting_admin extends remoting {
return false;
}
}
// config_value_* functions ---------------------------------------------------------------------------------------
//* Get config_value details
public function config_value_get($session_id, $group, $name)
{
global $app;
if(!$this->checkPerm($session_id, 'config_value_get')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// validate fields
if($group == '' || $name == '') {
throw new SoapFault('field_empty_error', 'Group and name parameter may not be empty.');
return false;
}
return $app->db->queryOneRecord('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ?', $group, $name);
}
//* Add a config_value record
public function config_value_add($session_id, $group, $name, $value)
{
global $app;
if(!$this->checkPerm($session_id, 'config_value_add')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// validate fields
if($group == '' || $name == '' || $value == '') {
throw new SoapFault('field_empty_error', 'Group, name, and value parameter may not be empty.');
return false;
}
if(is_array($app->db->queryOneRecord('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ?', $group, $name))) {
throw new SoapFault('record_unique_error', 'Group plus name field combination is not unique.');
return false;
}
return $app->db->query('INSERT INTO sys_config (`group`,`name`,`value`) VALUES (?,?,?)',$group,$name,$value);
}
//* Update config_value record
public function config_value_update($session_id, $group, $name, $value)
{
global $app;
if(!$this->checkPerm($session_id, 'config_value_update')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// validate fields
if($group == '' || $name == '' || $value == '') {
throw new SoapFault('field_empty_error', 'Group, name, and value parameter may not be empty.');
return false;
}
if(!is_array($app->db->queryOneRecord('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ?', $group, $name))) {
throw new SoapFault('record_nonexist_error', 'There is no record with this group plus name field combination.');
return false;
}
return $app->db->query('UPDATE sys_config SET `value` = ? WHERE `group` = ? AND `name` = ?',$value,$group,$name);
}
//* Replace config_value record
public function config_value_replace($session_id, $group, $name, $value)
{
global $app;
if(!$this->checkPerm($session_id, 'config_value_replace')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// validate fields
if($group == '' || $name == '' || $value == '') {
throw new SoapFault('field_empty_error', 'Group, name, and value parameter may not be empty.');
return false;
}
if(is_array($app->db->queryOneRecord('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ?', $group, $name))) {
return $app->db->query('UPDATE sys_config SET `value` = ? WHERE `group` = ? AND `name` = ?',$value,$group,$name);
} else {
return $app->db->query('INSERT INTO sys_config (`group`,`name`,`value`) VALUES (?,?,?)',$group,$name,$value);
}
}
//* Delete config_value record
public function config_value_delete($session_id, $group, $name)
{
global $app;
if(!$this->checkPerm($session_id, 'config_value_delete')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// validate fields
if($group == '' || $name == '') {
throw new SoapFault('field_empty_error', 'Group and name parameter may not be empty.');
return false;
}
if(!is_array($app->db->queryOneRecord('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ?', $group, $name))) {
throw new SoapFault('record_nonexist_error', 'There is no record with this group plus name field combination.');
return false;
}
return $app->db->query('DELETE FROM sys_config WHERE `group` = ? AND `name` = ?',$group,$name);
}
}
......
<?php
$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';
$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,config_value_get,config_value_add,config_value_update,config_value_replace,config_value_delete'] = 'Server functions';
$function_list['admin_record_permissions'] = 'Record permission changes';
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment