Commit 36c8a26c authored by Michael Fürmann's avatar Michael Fürmann

Clients limit update

parent fbe2d6b2
......@@ -122,6 +122,10 @@ class validate_client {
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;
case 'xmpp_servers':
$used_servers = $app->db->queryAllRecords('SELECT domain_id FROM xmpp_domain INNER JOIN sys_user ON xmpp_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))
......
......@@ -782,9 +782,8 @@ $form["tabs"]['limits'] = array (
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'no_xmpp_server_error'),
1 => array ( 'type' => 'CUSTOM',
'validators' => array (
0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'xmpp_servers_used'),
......@@ -832,17 +831,6 @@ $form["tabs"]['limits'] = array (
'default' => 'n',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_auth_options' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOXARRAY',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'xmpp_auth_options_notempty'),
),
'default' => '',
'separator' => ',',
'valuelimit' => 'client:xmpp_auth_options',
'value' => array('plain' => 'Plain', 'hashed' => 'Hashed', 'isp' => 'By Mail Account')
),
'limit_xmpp_vjud' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
......
......@@ -178,10 +178,8 @@ $wb['no_xmpp_server_error'] = 'At least one XMPP Server must be selected.';
$wb['xmpp_servers_used'] = 'The server you are trying to remove from this client is used as a XMPP Server. Be sure that this server is not used by this client before you remove it.';
$wb['limit_xmpp_domain_error_notint'] = 'The XMPP domain limit must be a number.';
$wb['limit_xmpp_user_error_notint'] = 'The XMPP user limit must be a number.';
$wb['xmpp_auth_options_notempty'] = 'At least one XMPP auth method must be selected.';
$wb['limit_xmpp_domain_txt'] = 'Max. number of XMPP domains';
$wb['limit_xmpp_user_txt'] = 'Max. number of XMPP accounts';
$wb['xmpp_auth_options_txt'] = 'Available Auth options';
$wb['limit_xmpp_muc_txt'] = 'Multiuser chat available';
$wb['limit_xmpp_pastebin_txt'] = 'Pastebin for MUC available';
$wb['limit_xmpp_httparchive_txt'] = 'HTTP archive for MUC available';
......
......@@ -58,4 +58,5 @@ $wb['save_certificate_txt'] = 'Save certificate';
$wb['create_certificate_txt'] = 'Create certificate';
$wb['delete_certificate_txt'] = 'Delete certificate';
$wb['ssl_error_isemail'] = 'Please enter a valid email adress for generation of the SSL certificate';
$wb["limit_xmppdomain_txt"] = 'The max. number of XMPP domains for your account is reached.';
?>
......@@ -151,7 +151,7 @@ if($app->auth->get_client_limit($userid, 'fetchmail') != 0)
//**** XMPP Menu
$items = array();
if($app->auth->get_client_limit($userid, 'xmppdomain') != 0)
if($app->auth->get_client_limit($userid, 'xmpp_domain') != 0)
{
$items[] = array( 'title' => 'XMPP Domain',
'target' => 'content',
......@@ -159,7 +159,7 @@ if($app->auth->get_client_limit($userid, 'xmppdomain') != 0)
'html_id' => 'xmpp_domain_list');
}
if($app->auth->get_client_limit($userid, 'xmppaccount') != 0)
if($app->auth->get_client_limit($userid, 'xmpp_user') != 0)
{
$items[] = array( 'title' => 'XMPP Account',
'target' => 'content',
......
......@@ -4,43 +4,50 @@
<p><tmpl_var name="list_desc_txt"></p>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_anon_host_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_anon_host'}
<tmpl_if name="limit_xmpp_anon" value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_anon_host_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_anon_host'}
</div>
</div>
</div>
</tmpl_if>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_pubsub_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_pubsub'}
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_vjud_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_vjud'}
<tmpl_if name="limit_xmpp_vjud" value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_vjud_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_vjud'}
</div>
</div>
</div>
<div class="form-group">
<label for="vjud_opt_mode" class="col-sm-3 control-label">{tmpl_var name='vjud_opt_mode_txt'}</label>
<div class="col-sm-3"><select name="vjud_opt_mode" id="vjud_opt_mode" class="form-control">
{tmpl_var name='vjud_opt_mode'}
</select></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_proxy_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_proxy'}
<div class="form-group">
<label for="vjud_opt_mode" class="col-sm-3 control-label">{tmpl_var name='vjud_opt_mode_txt'}</label>
<div class="col-sm-3"><select name="vjud_opt_mode" id="vjud_opt_mode" class="form-control">
{tmpl_var name='vjud_opt_mode'}
</select></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_status_host_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_status_host'}
</tmpl_if>
<tmpl_if name="limit_xmpp_proxy" value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_proxy_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_proxy'}
</div>
</div>
</div>
</tmpl_if>
<tmpl_if name="limit_xmpp_status" value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_status_host_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_status_host'}
</div>
</div>
</tmpl_if>
......
......@@ -33,47 +33,51 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_pastebin_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_pastebin'}
</div>
</div>
<div id="toggle-use-pastebin" class="collapse">
<tmpl_if name='limit_xmpp_pastebin' value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='pastebin_expire_after_txt'}</label>
<div class="col-sm-3">
<input type="number" name="pastebin_expire_after" id="pastebin_expire_after" value="{tmpl_var name='pastebin_expire_after'}" class="form-control" />
<label class="col-sm-3 control-label">{tmpl_var name='use_pastebin_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_pastebin'}
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='pastebin_trigger_txt'}</label>
<div class="col-sm-3">
<input type="text" name="pastebin_trigger" id="pastebin_trigger" value="{tmpl_var name='pastebin_trigger'}" class="form-control" />
<div id="toggle-use-pastebin" class="collapse">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='pastebin_expire_after_txt'}</label>
<div class="col-sm-3">
<input type="number" name="pastebin_expire_after" id="pastebin_expire_after" value="{tmpl_var name='pastebin_expire_after'}" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='pastebin_trigger_txt'}</label>
<div class="col-sm-3">
<input type="text" name="pastebin_trigger" id="pastebin_trigger" value="{tmpl_var name='pastebin_trigger'}" class="form-control" />
</div>
</div>
</div>
</div>
</tmpl_if>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='use_http_archive_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='use_http_archive'}
</div>
</div>
<div id="toggle-use-archive" class="collapse">
<tmpl_if name='limit_xmpp_httparchive' value="y">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='http_archive_show_join_txt'}</label>
<label class="col-sm-3 control-label">{tmpl_var name='use_http_archive_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='http_archive_show_join'}
{tmpl_var name='use_http_archive'}
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='http_archive_show_status_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='http_archive_show_status'}
<div id="toggle-use-archive" class="collapse">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='http_archive_show_join_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='http_archive_show_join'}
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='http_archive_show_status_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='http_archive_show_status'}
</div>
</div>
</div>
</div>
</tmpl_if>
</div>
......
......@@ -72,18 +72,18 @@ class page_action extends tform_actions {
// we will check only users, not admins
if($_SESSION["s"]["user"]["typ"] == 'user') {
if(!$app->tform->checkClientLimit('limit_xmppdomain')) {
if(!$app->tform->checkClientLimit('limit_xmpp_domain')) {
$app->error($app->tform->wordbook["limit_xmppdomain_txt"]);
}
if(!$app->tform->checkResellerLimit('limit_xmppdomain')) {
if(!$app->tform->checkResellerLimit('limit_xmpp_domain')) {
$app->error('Reseller: '.$app->tform->wordbook["limit_xmppdomain_txt"]);
}
} else {
$settings = $app->getconf->get_global_config('xmpp');
$app->tform->formDef['tabs']['domain']['fields']['server_id']['default'] = intval($settings['default_xmppserver']);
}
}
$app->tform->formDef['tabs']['domain']['fields']['server_id']['default'] = intval($settings['default_xmppserver']);
parent::onShowNew();
parent::onShowNew();
}
function onShowEnd() {
......@@ -92,6 +92,17 @@ class page_action extends tform_actions {
$app->uses('ini_parser,getconf');
$settings = $app->getconf->get_global_config('domains');
$read_limits = array('limit_xmpp_pastebin', 'limit_xmpp_httparchive', 'limit_xmpp_anon', 'limit_xmpp_vjud', 'limit_xmpp_proxy', 'limit_xmpp_status');
if($_SESSION["s"]["user"]["typ"] != 'admin') {
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$client = $app->db->queryOneRecord("SELECT client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
// add limits to template to be able to hide settings
foreach($read_limits as $limit) $app->tpl->setVar($limit, $client[$limit]);
}else{
foreach($read_limits as $limit) $app->tpl->setVar($limit, 'y');
}
if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] != 'y') {
// Getting Clients of the user
$sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name";
......@@ -112,12 +123,7 @@ class page_action extends tform_actions {
// Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_xmppserver, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id order by client.contact_name");
// Set the xmppserver to the default server of the client
$tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_xmppserver]");
$app->tpl->setVar("server_id", "<option value='$client[default_xmppserver]'>$tmp[server_name]</option>");
unset($tmp);
$client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id order by client.contact_name");
if ($settings['use_domain_module'] != 'y') {
// Fill the client select field
......@@ -233,7 +239,7 @@ class page_action extends tform_actions {
if($_SESSION["s"]["user"]["typ"] != 'admin') {
// Get the limits of the client
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$client = $app->db->queryOneRecord("SELECT limit_xmppdomain, default_xmppserver 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_xmpp_domain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
// When the record is updated
if($this->id > 0) {
// restore the server ID if the user is not admin and record is edited
......@@ -249,9 +255,9 @@ class page_action extends tform_actions {
$app->error($app->tform->wordbook['error_not_allowed_server_id']);
}
if($client["limit_xmppdomain"] >= 0) {
if($client["limit_xmpp_domain"] >= 0) {
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM xmpp_domain WHERE sys_groupid = $client_group_id");
if($tmp["number"] >= $client["limit_xmppdomain"]) {
if($tmp["number"] >= $client["limit_xmpp_domain"]) {
$app->error($app->tform->wordbook["limit_xmppdomain_txt"]);
}
}
......@@ -355,7 +361,7 @@ class page_action extends tform_actions {
//* If the user is neither admin nor reseller
} else {
//* We do not allow users to change a domain which has been created by the admin
$rec = $app->db->queryOneRecord("SELECT sys_perm_group, domainfrom xmpp_domain WHERE domain_id = ".$this->id);
$rec = $app->db->queryOneRecord("SELECT sys_perm_group, domain from xmpp_domain WHERE domain_id = ".$this->id);
if(isset($this->dataRecord["domain"]) && $rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id, 'u')) {
//* Add a error message and switch back to old server
$app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.');
......
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