Commit 8173c6f2 authored by Falko Timme's avatar Falko Timme

- Added option to fill fields on SSL tab with client data by clicking on a link.

parent dcb1f40c
......@@ -252,7 +252,7 @@ class db extends mysqli
$sQuery = call_user_func_array(array(&$this, '_build_query_string'), $aArgs);
$this->securityScan($sQuery);
$this->_iQueryId = mysqli_query($this->_iConnId, $sQuery);
$this->_iQueryId = @mysqli_query($this->_iConnId, $sQuery);
if (!$this->_iQueryId) {
$this->_sqlerror('Falsche Anfrage / Wrong Query', false, 'SQL-Query = ' . $sQuery);
return false;
......
......@@ -201,6 +201,44 @@ if ($type == 'getdirectivesnippet') {
$json = json_encode($snippets);
}
if($type == 'getclientssldata'){
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", intval($web_id));
$sys_group = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE groupid = ?", intval($web['sys_groupid']));
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", intval($sys_group['client_id']));
if(is_array($client) && !empty($client)){
if($client['telephone'] == '' && $client['mobile'] != '') $client['telephone'] = $client['mobile'];
$fname = '';
$lname = '';
$parts = preg_split("/\s+/", $client['contact_name']);
if(sizeof($parts) == 2){
$fname = $parts[0];
$lname = $parts[1];
}
if(sizeof($parts) > 2){
$fname = $parts[0].' ';
for($i=1;$i<sizeof($parts);$i++){
if($i == (sizeof($parts) - 1)){
$lname .= $parts[$i];
} else {
if(preg_match('@^(von|van|ten|ter|zur|zu|auf|sieber)$@i', $parts[$i])){
$lname .= implode(' ', array_slice($parts, $i));
break;
} else {
$fname .= $parts[$i].' ';
}
}
}
}
$fname = trim($fname);
$lname = trim($lname);
$client['fname'] = $fname;
$client['lname'] = $lname;
if(trim($client['company_name']) == '') $client['company_name'] = $fname.' '.$lname;
}
$json = $app->functions->json_encode($client);
}
//}
header('Content-type: application/json');
......
......@@ -137,4 +137,7 @@ $wb['apache_directive_blocked_error'] = 'Die Apache Direktive wurde durch die Si
$wb['btn_save_txt'] = 'Speichern';
$wb['btn_cancel_txt'] = 'Abbrechen';
$wb['enable_spdy_txt'] = 'Aktiviere SPDY';
$wb['load_client_data_txt'] = 'Kundendaten übernehmen';
$wb['load_my_data_txt'] = 'Meine Kontaktdaten laden';
$wb['reset_client_data_txt'] = 'Daten verwerfen';
?>
......@@ -140,4 +140,7 @@ $wb['subdomain_error_empty'] = 'The subdommain field is empty or contains invali
$wb['btn_save_txt'] = "Save";
$wb['btn_cancel_txt'] = "Cancel";
$wb['enable_spdy_txt'] = 'Enable SPDY';
$wb['load_client_data_txt'] = 'Load client details';
$wb['load_my_data_txt'] = 'Load my contact details';
$wb['reset_client_data_txt'] = 'Reset data';
?>
......@@ -14,6 +14,12 @@
<div class="pnl_formsarea">
<fieldset class="inlineLabels">
<tmpl_if name='show_helper_links'>
<div class="ctrlHolder" id="show_helper_links" style="display:none;">
<label></label>
<a href="javascript:void(0);" id="load_data"><tmpl_if name='is_admin'>{tmpl_var name='load_client_data_txt'}</tmpl_else>{tmpl_var name='load_my_data_txt'}</tmpl_if></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" id="reset_data">{tmpl_var name='reset_client_data_txt'}</a>
</div>
</tmpl_if>
<div class="ctrlHolder">
<label for="ssl_state">{tmpl_var name='ssl_state_txt'}</label>
<input name="ssl_state" id="ssl_state" value="{tmpl_var name='ssl_state'}" size="30" maxlength="255" type="text" class="textInput" />
......@@ -37,7 +43,7 @@
</select>
</div>
<div class="ctrlHolder">
<label for="client_group_id">{tmpl_var name='ssl_domain_txt'}</label>
<label for="ssl_domain">{tmpl_var name='ssl_domain_txt'}</label>
<select name="ssl_domain" id="ssl_domain" class="selectInput">
{tmpl_var name='ssl_domain'}
</select>
......@@ -83,3 +89,29 @@
</div>
</div>
<script language="JavaScript" type="text/javascript">
<tmpl_if name='show_helper_links'>
if($("input[name=id]").val() > 0) $('#show_helper_links:hidden').show();
$('#reset_data').click(function(){
$('#ssl_organisation').add('#ssl_locality').add('#ssl_state').add('#ssl_organisation_unit').val('');
$('#ssl_country').val($("#ssl_country option:first").val());
});
$('#load_data').click(function(){
loadClientData();
});
function loadClientData() {
var web_id = $("input[name=id]").val();
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {'web_id': web_id, 'type': "getclientssldata"}, function(data) {
$('#ssl_organisation').val(data['company_name']);
$('#ssl_locality').val(data['city']);
$('#ssl_country').val(data['country']);
$('#ssl_state').val(data['state']);
$('#ssl_organisation_unit').val('IT');
});
}
</tmpl_if>
</script>
\ No newline at end of file
......@@ -142,6 +142,8 @@ class page_action extends tform_actions {
$read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
if($this->_vhostdomain_type != 'domain') $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
$is_admin = false;
//* Client: If the logged in user is not admin and has no sub clients (no reseller)
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
......@@ -451,6 +453,8 @@ class page_action extends tform_actions {
//* Admin: If the logged in user is admin
} else {
$is_admin = true;
if($this->_vhostdomain_type == 'domain') {
// The user is admin, so we fill in all IP addresses of the server
......@@ -700,6 +704,14 @@ class page_action extends tform_actions {
$app->tpl->setVar('vhostdomain_type', $this->_vhostdomain_type);
$app->tpl->setVar('is_spdy_enabled', ($web_config['enable_spdy'] === 'y'));
$app->tpl->setVar("is_admin", $is_admin);
if($this->id > 0) {
$tmp_web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", intval($this->id));
$tmp_sys_group = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE groupid = ?", intval($tmp_web['sys_groupid']));
if(intval($tmp_sys_group['client_id']) > 0) $tmp_client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", intval($tmp_sys_group['client_id']));
if(is_array($tmp_client) && !empty($tmp_client) && trim($this->dataRecord['ssl_organisation']) == '' && trim($this->dataRecord['ssl_locality']) == '' && trim($this->dataRecord['ssl_state']) == '' && trim($this->dataRecord['ssl_organisation_unit']) == '') $app->tpl->setVar("show_helper_links", true);
}
parent::onShowEnd();
}
......
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