Commit bd665926 authored by Sébastien JEAN's avatar Sébastien JEAN
Browse files

adding multi-server management for clients

parent 78fc9a64
......@@ -117,6 +117,18 @@ class custom_datasource {
case 'default_vserverserver':
$field = 'vserver_server';
break;
case 'mail_servers':
$field = 'mail_server';
break;
case 'web_servers':
$field = 'web_server';
break;
case 'dns_servers':
$field = 'dns_server';
break;
case 'db_servers':
$field = 'db_server';
break;
default:
$field = 'web_server';
break;
......
......@@ -95,6 +95,46 @@ class validate_client {
}
function check_used_servers($field_name, $field_value, $validator)
{
global $app;
if (is_array($field_value))
{
$client_id = intval($_POST['id']);
$used_servers = null;
switch ($field_name)
{
case 'web_servers':
$used_servers = $app->db->queryAllRecords('SELECT domain_id FROM web_domain INNER JOIN sys_user ON web_domain.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');');
break;
case 'dns_servers':
$used_servers = $app->db->queryAllRecords('SELECT id FROM dns_rr INNER JOIN sys_user ON dns_rr.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');');
break;
case 'db_servers':
$used_servers = $app->db->queryAllRecords('SELECT database_id FROM web_database INNER JOIN sys_user ON web_database.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');');
break;
case 'mail_servers':
$used_servers = $app->db->queryAllRecords('SELECT domain_id FROM mail_domain INNER JOIN sys_user ON mail_domain.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');');
break;
}
if ($used_servers === null || count($used_servers))
{
$errmsg = $validator['errmsg'];
if(isset($app->tform->wordbook[$errmsg])) {
return $app->tform->wordbook[$errmsg]."<br>\r\n";
} else {
return $errmsg."<br>\r\n";
}
}
}
}
......
......@@ -225,7 +225,7 @@ class page_action extends tform_actions {
$tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
$default_dbserver = $app->functions->intval($tmp['server_id']);
$sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id;
$sql = "UPDATE client SET mail_servers = $default_mailserver, web_servers = $default_webserver, dns_servers = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, db_servers = $default_dbserver WHERE client_id = ".$this->id;
$app->db->query($sql);
if(isset($this->dataRecord['template_master'])) {
......
......@@ -511,6 +511,25 @@ $form["tabs"]['limits'] = array (
'value' => '',
'name' => 'default_mailserver'
),
'mail_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_mail_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'mail_servers_used'),
),
'value' => '',
'name' => 'mail_servers'
),
'limit_maildomain' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -718,6 +737,25 @@ $form["tabs"]['limits'] = array (
'value' => '',
'name' => 'default_webserver'
),
'web_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_web_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'web_servers_used'),
),
'value' => '',
'name' => 'web_servers'
),
'limit_web_domain' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -903,6 +941,25 @@ $form["tabs"]['limits'] = array (
'value' => '',
'name' => 'default_dnsserver'
),
'dns_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_dns_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'dns_servers_used'),
),
'value' => '',
'name' => 'dns_servers'
),
'limit_dns_zone' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -981,6 +1038,25 @@ $form["tabs"]['limits'] = array (
'value' => '',
'name' => 'default_dbserver'
),
'db_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_db_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'db_servers_used'),
),
'value' => '',
'name' => 'db_servers'
),
'limit_database' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......
......@@ -508,6 +508,24 @@ $form["tabs"]['limits'] = array (
),
'value' => ''
),
'mail_servers' => array (
'datatype' => 'INTEGER',
'formtype' => 'MULTIPLE',
'default' => '1',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_mail_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'mail_servers_used'),
),
'value' => ''
),
'limit_maildomain' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -715,6 +733,25 @@ $form["tabs"]['limits'] = array (
),
'value' => ''
),
'web_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_web_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'web_servers_used'),
),
'value' => ''
),
'limit_web_domain' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -898,6 +935,24 @@ $form["tabs"]['limits'] = array (
),
'value' => ''
),
'dns_servers' => array (
'datatype' => 'INTEGER',
'formtype' => 'MULTIPLE',
'default' => '1',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_dns_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'dns_servers_used'),
),
'value' => ''
),
'limit_dns_zone' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -979,6 +1034,24 @@ $form["tabs"]['limits'] = array (
),
'value' => ''
),
'db_servers' => array (
'datatype' => 'INTEGER',
'formtype' => 'MULTIPLE',
'default' => '1',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_db_server_error'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'db_servers_used'),
),
'value' => ''
),
'limit_database' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......
......@@ -152,4 +152,20 @@ $wb['canceled_txt'] = 'Canceled (disables client login)';
$wb['gender_txt'] = 'Title';
$wb['gender_m_txt'] = 'Mr.';
$wb['gender_f_txt'] = 'Ms.';
$wb["web_servers_txt"] = 'Webservers';
$wb["web_servers_placeholder"] = 'Select Webservers';
$wb['no_web_server_error'] = 'At least one webserver must be selected.';
$wb['web_servers_used'] = 'The server you are trying to remove from this client is used as a webserver. Be sure that this server is not used by this client before to remove it.';
$wb["dns_servers_txt"] = 'DNS Server';
$wb["dns_servers_placeholder"] = 'Select DNS Servers';
$wb['no_dns_server_error'] = 'At least one DNS server must be selected.';
$wb['dns_servers_used'] = 'The server you are trying to remove from this client is used as a DNS server. Be sure that this server is not used by this client before to remove it.';
$wb["db_servers_txt"] = 'Database Server';
$wb["db_servers_placeholder"] = 'Select Database Servers';
$wb['no_db_server_error'] = 'At least one Database server must be selected.';
$wb['db_servers_used'] = 'The server you are trying to remove from this client is used as a Database server. Be sure that this server is not used by this client before to remove it.';
$wb["mail_servers_txt"] = 'Mailservers';
$wb["mail_servers_placeholder"] = 'Select Mailservers';
$wb['no_mail_server_error'] = 'At least one Mailserver must be selected.';
$wb['mail_servers_used'] = 'The server you are trying to remove from this client is used as a Mailserver. Be sure that this server is not used by this client before to remove it.';
?>
......@@ -150,4 +150,20 @@ $wb['canceled_txt'] = 'Canceled';
$wb['gender_m_txt'] = 'Mr.';
$wb['gender_f_txt'] = 'Ms.';
$wb['gender_txt'] = 'Title';
$wb["web_servers_txt"] = 'Webservers';
$wb["web_servers_placeholder"] = 'Select Webservers';
$wb['no_web_server_error'] = 'At least one webserver must be selected.';
$wb['web_servers_used'] = 'The server you are trying to remove from this client is used as a webserver. Be sure that this server is not used by this client before to remove it.';
$wb["dns_servers_txt"] = 'DNS Server';
$wb["dns_servers_placeholder"] = 'Select DNS Servers';
$wb['no_dns_server_error'] = 'At least one DNS server must be selected.';
$wb['dns_servers_used'] = 'The server you are trying to remove from this client is used as a DNS server. Be sure that this server is not used by this client before to remove it.';
$wb["db_servers_txt"] = 'Database Server';
$wb["db_servers_placeholder"] = 'Select Database Servers';
$wb['no_db_server_error'] = 'At least one Database server must be selected.';
$wb['db_servers_used'] = 'The server you are trying to remove from this client is used as a Database server. Be sure that this server is not used by this client before to remove it.';
$wb["mail_servers_txt"] = 'Mailservers';
$wb["mail_servers_placeholder"] = 'Select Mailservers';
$wb['no_mail_server_error'] = 'At least one Mailserver must be selected.';
$wb['mail_servers_used'] = 'The server you are trying to remove from this client is used as a Mailserver. Be sure that this server is not used by this client before to remove it.';
?>
......@@ -149,4 +149,20 @@ $wb['canceled_txt'] = 'Canceled (disables client login)';
$wb['gender_txt'] = 'Title';
$wb['gender_m_txt'] = 'Mr.';
$wb['gender_f_txt'] = 'Ms.';
$wb["web_servers_txt"] = 'Serveurs Web';
$wb["web_servers_placeholder"] = 'Choisissez des serveurs Web';
$wb['no_web_server_error'] = 'Au moins un serveur web doit être sélectionné.';
$wb['web_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur web. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["dns_servers_txt"] = 'Serveurs DNS';
$wb["dns_servers_placeholder"] = 'Choisissez des serveurs DNS';
$wb['no_dns_server_error'] = 'Au moins un serveur DNS doit être sélectionné.';
$wb['dns_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur DNS. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["db_servers_txt"] = 'Serveur de bases de données';
$wb["db_servers_placeholder"] = 'Choisissez des serveurs de bases de données';
$wb['no_db_server_error'] = 'Au moins un serveur de bases de données doit être sélectionné.';
$wb['db_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur de bases de données. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["mail_servers_txt"] = 'Serveurs mail';
$wb["mail_servers_placeholder"] = 'Choisissez des serveurs mail';
$wb['no_mail_server_error'] = 'Au moins un serveur mail doit être sélectionné.';
$wb['mail_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur mail. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
?>
......@@ -148,4 +148,20 @@ $wb['canceled_txt'] = 'Canceled';
$wb['gender_m_txt'] = 'Mr.';
$wb['gender_f_txt'] = 'Ms.';
$wb['gender_txt'] = 'Title';
$wb["web_servers_txt"] = 'Serveurs Web';
$wb["web_servers_placeholder"] = 'Choisissez des serveurs Web';
$wb['no_web_server_error'] = 'Au moins un serveur web doit être sélectionné.';
$wb['web_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur web. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["dns_servers_txt"] = 'Serveurs DNS';
$wb["dns_servers_placeholder"] = 'Choisissez des serveurs DNS';
$wb['no_dns_server_error'] = 'Au moins un serveur DNS doit être sélectionné.';
$wb['dns_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur DNS. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["db_servers_txt"] = 'Serveur de bases de données';
$wb["db_servers_placeholder"] = 'Choisissez des serveurs de bases de données';
$wb['no_db_server_error'] = 'Au moins un serveur de bases de données doit être sélectionné.';
$wb['db_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur de bases de données. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
$wb["mail_servers_txt"] = 'Serveurs mail';
$wb["mail_servers_placeholder"] = 'Choisissez des serveurs mail';
$wb['no_mail_server_error'] = 'Au moins un serveur mail doit être sélectionné.';
$wb['mail_servers_used'] = 'Le serveur que vous tentez de retirer à ce client est utilisé comme serveur mail. Veillez à ce que le serveur ne soit plus utilisé par ce client avant de le retirer.';
?>
......@@ -44,9 +44,9 @@
<div class="subsectiontoggle"><span class="showing"></span>{tmpl_var name='web_limits_txt'}<em class="showing"></em></div>
<div>
<div class="ctrlHolder">
<label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
<select name="default_webserver" id="default_webserver" class="selectInput">
{tmpl_var name='default_webserver'}
<label for="web_servers">{tmpl_var name='web_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='web_servers_placeholder'}" multiple name="web_servers[]" id="web_servers" class="selectInput chosen-select">
{tmpl_var name='web_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -151,9 +151,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='email_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
<select name="default_mailserver" id="default_mailserver" class="selectInput">
{tmpl_var name='default_mailserver'}
<label for="mail_servers">{tmpl_var name='mail_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='mail_servers_placeholder'}" multiple name="mail_servers[]" id="mail_servers" class="selectInput chosen-select">
{tmpl_var name='mail_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -216,9 +216,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='database_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
<select name="default_dbserver" id="default_dbserver" class="selectInput">
{tmpl_var name='default_dbserver'}
<label for="db_servers">{tmpl_var name='db_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='db_servers_placeholder'}" multiple name="db_servers[]" id="db_servers" class="selectInput chosen-select">
{tmpl_var name='db_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -246,9 +246,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='dns_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
<select name="default_dnsserver" id="default_dnsserver" class="selectInput">
{tmpl_var name='default_dnsserver'}
<label for="dns_servers">{tmpl_var name='dns_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='dns_servers_placeholder'}" multiple name="dns_servers[]" id="dns_servers" class="selectInput chosen-select">
{tmpl_var name='dns_servers'}
</select>
</div>
<div class="ctrlHolder">
......
......@@ -33,9 +33,9 @@
<div class="subsectiontoggle"><span class="showing"></span>{tmpl_var name='web_limits_txt'}<em class="showing"></em></div>
<div>
<div class="ctrlHolder">
<label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
<select name="default_webserver" id="default_webserver" class="selectInput">
{tmpl_var name='default_webserver'}
<label for="web_servers">{tmpl_var name='web_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='web_servers_placeholder'}" multiple name="web_servers[]" id="web_servers" class="selectInput chosen-select">
{tmpl_var name='web_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -140,9 +140,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='email_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
<select name="default_mailserver" id="default_mailserver" class="selectInput">
{tmpl_var name='default_mailserver'}
<label for="mail_servers">{tmpl_var name='mail_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='mail_servers_placeholder'}" multiple name="mail_servers[]" id="mail_servers" class="selectInput chosen-select">
{tmpl_var name='mail_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -205,9 +205,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='database_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
<select name="default_dbserver" id="default_dbserver" class="selectInput">
{tmpl_var name='default_dbserver'}
<label for="db_servers">{tmpl_var name='db_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='db_servers_placeholder'}" multiple name="db_servers[]" id="db_servers" class="selectInput chosen-select">
{tmpl_var name='db_servers'}
</select>
</div>
<div class="ctrlHolder">
......@@ -235,9 +235,9 @@
<div class="subsectiontoggle"><span></span>{tmpl_var name='dns_limits_txt'}<em></em></div>
<div style="display:none;">
<div class="ctrlHolder">
<label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
<select name="default_dnsserver" id="default_dnsserver" class="selectInput">
{tmpl_var name='default_dnsserver'}
<label for="dns_servers">{tmpl_var name='dns_servers_txt'}</label>
<select data-placeholder="{tmpl_var name='dns_servers_placeholder'}" multiple name="dns_servers[]" id="dns_servers" class="selectInput chosen-select">
{tmpl_var name='dns_servers'}
</select>
</div>
<div class="ctrlHolder">
......
......@@ -49,12 +49,17 @@ $sys_groupid = (isset($_POST['client_group_id']))?$app->functions->intval($_POST
$domain = (isset($_POST['domain'])&&!empty($_POST['domain']))?$_POST['domain']:NULL;
// get the correct server_id
if($_SESSION['s']['user']['typ'] == 'admin') {
$server_id = (isset($_POST['server_id']))?$app->functions->intval($_POST['server_id']):1;
} else {
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
$server_id = $client["default_dnsserver"];
if (isset($_POST['server_id'])) {
$server_id = $app->functions->intval($_POST['server_id']);
$post_server_id = true;
}
else if (isset($_POST['server_id_value'])) {
$server_id = $app->functions->intval($_POST['server_id_value']);
$post_server_id = true;
}
else {
$server_id = 1;
$post_server_id = false;
}
......@@ -120,6 +125,34 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO
$app->tpl->setVar("client_group_id",$client_select);
}
if($_SESSION["s"]["user"]["typ"] != 'admin')
{
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client_dns = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
$client_dns['dns_servers_ids'] = explode(',', $client_dns['dns_servers']);
$only_one_server = count($client_dns['dns_servers_ids']) === 1;
$app->tpl->setVar('only_one_server', $only_one_server);
if ($only_one_server) {
$app->tpl->setVar('server_id_value', $client_dns['dns_servers_ids'][0]);
}
$sql = "SELECT server_id, server_name FROM server WHERE server_id IN (" . $client_dns['dns_servers'] . ");";
$dns_servers = $app->db->queryAllRecords($sql);
$options_dns_servers = "";
foreach ($dns_servers as $dns_server) {
$options_dns_servers .= "<option value='$dns_server[server_id]'>$dns_server[server_name]</option>";
}
$app->tpl->setVar("server_id", $options_dns_servers);
unset($options_dns_servers);
}
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_import.lng';
include($lng_file);
$app->tpl->setVar($wb);
......
......@@ -115,6 +115,34 @@ class page_action extends tform_actions {
$app->tpl->setVar("client_group_id",$client_select);
}
if($_SESSION["s"]["user"]["typ"] != 'admin')
{
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client_dns = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
$client_dns['dns_servers_ids'] = explode(',', $client_dns['dns_servers']);
$only_one_server = count($client_dns['dns_servers_ids']) === 1;
$app->tpl->setVar('only_one_server', $only_one_server);
if ($only_one_server) {
$app->tpl->setVar('server_id_value', $client_dns['dns_servers_ids'][0]);
}
$sql = "SELECT server_id, server_name FROM server WHERE server_id IN (" . $client_dns['dns_servers'] . ");";
$dns_servers = $app->db->queryAllRecords($sql);
$options_dns_servers = "";
foreach ($dns_servers as $dns_server) {
$options_dns_servers .= "<option value='$dns_server[server_id]'>$dns_server[server_name]</option>";
}
$app->tpl->setVar("client_server_id", $options_dns_servers);
unset($options_dns_servers);
}
if($this->id > 0) {
//* we are editing a existing record
......@@ -133,19 +161,17 @@ class page_action extends tform_actions {
if($_SESSION["s"]["user"]["typ"] != 'admin') {
// Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client = $app->db->queryOneRecord("SELECT limit_dns_zone, default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
$client = $app->db->queryOneRecord("SELECT limit_dns_zone, dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
$client['dns_servers_ids'] = explode(',', $client['dns_servers']);
// Check if chosen server is in authorized servers for this client
if (!(is_array($client['dns_servers_ids']) && in_array($this->dataRecord["server_id"], $client['dns_servers_ids'])) && $_SESSION["s"]["user"]["typ"] != 'admin') {
$app->error($app->tform->wordbook['error_not_allowed_server_id']);
}
// When the record is updated
if($this->id > 0) {