From a563d594aeb6f9d6553bfb9ed10aff5ffdd20d10 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 15 Apr 2015 09:02:14 -0400
Subject: [PATCH] - ported some patches
---
interface/web/dashboard/dashlets/modules.php | 17 +++++++-
interface/web/tools/lib/module.conf.php | 1
interface/web/client/lib/module.conf.php | 1
interface/web/dns/lib/module.conf.php | 1
interface/web/nav.php | 18 ++++++++
interface/web/sites/lib/module.conf.php | 1
interface/web/dashboard/dashboard.php | 2
interface/web/monitor/lib/module.conf.php | 1
interface/web/dashboard/lib/module.conf.php | 1
interface/web/sites/templates/web_vhost_domain_edit.htm | 19 +++++++++
interface/lib/classes/auth.inc.php | 29 ++++++++++++--
interface/web/mail/lib/module.conf.php | 1
interface/web/admin/templates/server_list.htm | 4 +-
interface/web/admin/system_config_edit.php | 2
interface/web/admin/lib/module.conf.php | 1
interface/web/dashboard/lib/custom_menu.inc.php | 2
16 files changed, 88 insertions(+), 13 deletions(-)
diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php
index 562cf40..56e53ee 100644
--- a/interface/lib/classes/auth.inc.php
+++ b/interface/lib/classes/auth.inc.php
@@ -129,11 +129,32 @@
public function check_module_permissions($module) {
// Check if the current user has the permissions to access this module
+ $module = trim(preg_replace('@\s+@', '', $module));
$user_modules = explode(',',$_SESSION["s"]["user"]["modules"]);
- if(!in_array($module,$user_modules)) {
- // echo "LOGIN_REDIRECT:/index.php";
- header("Location: /index.php");
- exit;
+ if(strpos($module, ',') !== false){
+ $can_use_module = false;
+ $tmp_modules = explode(',', $module);
+ if(is_array($tmp_modules) && !empty($tmp_modules)){
+ foreach($tmp_modules as $tmp_module){
+ if($tmp_module != ''){
+ if(in_array($tmp_module,$user_modules)) {
+ $can_use_module = true;
+ break;
+ }
+ }
+ }
+ }
+ if(!$can_use_module){
+ // echo "LOGIN_REDIRECT:/index.php";
+ header("Location: /index.php");
+ exit;
+ }
+ } else {
+ if(!in_array($module,$user_modules)) {
+ // echo "LOGIN_REDIRECT:/index.php";
+ header("Location: /index.php");
+ exit;
+ }
}
}
diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php
index 7f4d19d..727f7a2 100644
--- a/interface/web/admin/lib/module.conf.php
+++ b/interface/web/admin/lib/module.conf.php
@@ -7,6 +7,7 @@
$module['template'] = 'module.tpl.htm';
$module['startpage'] = 'admin/server_list.php';
$module['tab_width'] = '60';
+$module['order'] = '90';
$items[] = array( 'title' => 'CP Users',
diff --git a/interface/web/admin/system_config_edit.php b/interface/web/admin/system_config_edit.php
index c07810c..f48f11b 100644
--- a/interface/web/admin/system_config_edit.php
+++ b/interface/web/admin/system_config_edit.php
@@ -89,7 +89,7 @@
$available_dashlets_txt = '';
$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets');
while ($file = @readdir($handle)) {
- if ($file != '.' && $file != '..' && !is_dir($file)) {
+ if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) {
$available_dashlets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.substr($file, 0, -4).']<pre class="addPlaceholderContent" style="display:none;">['.substr($file, 0, -4).'],</pre></a> ';
}
}
diff --git a/interface/web/admin/templates/server_list.htm b/interface/web/admin/templates/server_list.htm
index dd05473..893872e 100644
--- a/interface/web/admin/templates/server_list.htm
+++ b/interface/web/admin/templates/server_list.htm
@@ -51,13 +51,13 @@
</tmpl_loop>
<tmpl_unless name="records">
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
- <td colspan="8">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
+ <td colspan="7">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
</tr>
</tmpl_unless>
</tbody>
<tfoot>
<tr>
- <td colspan="8"><tmpl_var name="paging"></td>
+ <td colspan="7"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
diff --git a/interface/web/client/lib/module.conf.php b/interface/web/client/lib/module.conf.php
index e4bddd7..7d6f1b3 100644
--- a/interface/web/client/lib/module.conf.php
+++ b/interface/web/client/lib/module.conf.php
@@ -5,6 +5,7 @@
$module["template"] = "module.tpl.htm";
$module["startpage"] = "client/client_list.php";
$module["tab_width"] = '';
+$module['order'] = '20';
$items[] = array( 'title' => "Edit Client",
diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php
index c806e10..51068b1 100644
--- a/interface/web/dashboard/dashboard.php
+++ b/interface/web/dashboard/dashboard.php
@@ -146,7 +146,7 @@
$dashlet_list = array();
$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets');
while ($file = @readdir($handle)) {
- if ($file != '.' && $file != '..' && !is_dir($file)) {
+ if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) {
$dashlet_name = substr($file, 0, -4);
$dashlet_class = 'dashlet_'.$dashlet_name;
include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file;
diff --git a/interface/web/dashboard/dashlets/modules.php b/interface/web/dashboard/dashlets/modules.php
index 1b1d2ef..da1eb0b 100644
--- a/interface/web/dashboard/dashlets/modules.php
+++ b/interface/web/dashboard/dashlets/modules.php
@@ -28,19 +28,32 @@
include_once '../' . $mt.'/lib/module.conf.php';
/* We don't want to show the dashboard */
if ($mt != 'dashboard') {
+ if($mt == 'dns'){
+ $dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1");
+ if($dns_servers['cnt'] == 0) continue;
+ }
+ if($mt == 'mail'){
+ $mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1");
+ if($mail_servers['cnt'] == 0) continue;
+ }
+ if($mt == 'sites'){
+ $web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1");
+ if($web_servers['cnt'] == 0) continue;
+ }
+
$module_title = $app->lng($module['title']);
if(function_exists('mb_strlen')) {
if(mb_strlen($module_title, "UTF-8") > 8) $module_title = mb_substr($module_title, 0, 7, "UTF-8").'..';
} else {
if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..';
}
- $mod[] = array( 'modules_title' => $module_title,
+ $mod[$module['order']] = array( 'modules_title' => $module_title,
'modules_startpage' => $module['startpage'],
'modules_name' => $module['name']);
}
}
}
-
+ ksort($mod);
$tpl->setloop('modules', $mod);
}
diff --git a/interface/web/dashboard/lib/custom_menu.inc.php b/interface/web/dashboard/lib/custom_menu.inc.php
index b71bd16..176805e 100644
--- a/interface/web/dashboard/lib/custom_menu.inc.php
+++ b/interface/web/dashboard/lib/custom_menu.inc.php
@@ -71,7 +71,7 @@
$rows[] = array('title' => $item->get_title(),
'link' => $item->get_link(),
'content' => $item->get_content(),
- 'date' => $item->get_date('Y-m-d')
+ 'date' => $item->get_date($app->lng('conf_format_dateshort'))
);
}
$n++;
diff --git a/interface/web/dashboard/lib/module.conf.php b/interface/web/dashboard/lib/module.conf.php
index 67f769e..4471f9b 100644
--- a/interface/web/dashboard/lib/module.conf.php
+++ b/interface/web/dashboard/lib/module.conf.php
@@ -32,6 +32,7 @@
$module['template'] = 'dashboard.tpl.htm';
$module['startpage'] = 'dashboard/dashboard.php';
$module['tab_width'] = '';
+$module['order'] = '1';
//$items = array();
//
diff --git a/interface/web/dns/lib/module.conf.php b/interface/web/dns/lib/module.conf.php
index 83027c6..75b17a9 100644
--- a/interface/web/dns/lib/module.conf.php
+++ b/interface/web/dns/lib/module.conf.php
@@ -5,6 +5,7 @@
$module["template"] = "module.tpl.htm";
$module["startpage"] = "dns/dns_soa_list.php";
$module["tab_width"] = '';
+$module['order'] = '50';
$items[] = array( 'title' => "Add DNS Zone",
diff --git a/interface/web/mail/lib/module.conf.php b/interface/web/mail/lib/module.conf.php
index b6df07e..ca7d177 100644
--- a/interface/web/mail/lib/module.conf.php
+++ b/interface/web/mail/lib/module.conf.php
@@ -7,6 +7,7 @@
$module['template'] = 'module.tpl.htm';
$module['startpage'] = 'mail/mail_domain_list.php';
$module['tab_width'] = '';
+$module['order'] = '40';
//**** Email accounts menu
diff --git a/interface/web/monitor/lib/module.conf.php b/interface/web/monitor/lib/module.conf.php
index 6f31204..964d3c8 100644
--- a/interface/web/monitor/lib/module.conf.php
+++ b/interface/web/monitor/lib/module.conf.php
@@ -8,6 +8,7 @@
$module["template"] = "module.tpl.htm";
$module["tab_width"] = '';
$module["startpage"] = "monitor/show_sys_state.php?state=system";
+$module['order'] = '60';
unset($items);
$items[] = array( 'title' => "Show Overview",
diff --git a/interface/web/nav.php b/interface/web/nav.php
index 4d8617c..6475daa 100644
--- a/interface/web/nav.php
+++ b/interface/web/nav.php
@@ -45,25 +45,41 @@
/*
* If the dashboard is in the list of modules it always has to be the first!
*/
+ /*
asort($modules);
if (in_array('dashboard', $modules)) {
$key = array_search('dashboard', $modules);
unset($modules[$key]);
$modules = array_merge(array('dashboard'), $modules);
}
+ */
if(is_array($modules)) {
foreach($modules as $mt) {
if(is_file($mt.'/lib/module.conf.php')) {
if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.');
+ if($mt == 'dns'){
+ $dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1");
+ if($dns_servers['cnt'] == 0) continue;
+ }
+ if($mt == 'mail'){
+ $mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1");
+ if($mail_servers['cnt'] == 0) continue;
+ }
+ if($mt == 'sites'){
+ $web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1");
+ if($web_servers['cnt'] == 0) continue;
+ }
+
include_once $mt.'/lib/module.conf.php';
$language = (isset($_SESSION['s']['user']['language']))?$_SESSION['s']['user']['language']:$conf['language'];
$app->load_language_file('web/'.$mt.'/lib/'.$language.'.lng');
$active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0;
- $topnav[] = array( 'title' => $app->lng($module['title']),
+ $topnav[$module['order']] = array( 'title' => $app->lng($module['title']),
'active' => $active,
'module' => $module['name']);
}
}
+ ksort($topnav);
}
} else {
//* Loading Login Module
diff --git a/interface/web/sites/lib/module.conf.php b/interface/web/sites/lib/module.conf.php
index 8e253fd..979aa63 100644
--- a/interface/web/sites/lib/module.conf.php
+++ b/interface/web/sites/lib/module.conf.php
@@ -7,6 +7,7 @@
$module["template"] = "module.tpl.htm";
$module["startpage"] = "sites/web_vhost_domain_list.php";
$module["tab_width"] = '';
+$module['order'] = '30';
// Websites menu
$items=array();
diff --git a/interface/web/sites/templates/web_vhost_domain_edit.htm b/interface/web/sites/templates/web_vhost_domain_edit.htm
index e313b9f..e0a8276 100644
--- a/interface/web/sites/templates/web_vhost_domain_edit.htm
+++ b/interface/web/sites/templates/web_vhost_domain_edit.htm
@@ -274,6 +274,8 @@
jQuery('#parent_domain_id').change(function() {
reloadServerId(false);
});
+ // new Vhostsubdomains/Vhostaliasdomains
+ if(serverId == '') jQuery('#parent_domain_id').trigger('change');
function reloadServerId(noFormChange) {
var parentWebId = jQuery('#parent_domain_id').val();
@@ -337,16 +339,31 @@
function reloadFastcgiPHPVersions(noFormChange) {
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, php_type : jQuery('#php').val(), type : "getphpfastcgi", client_group_id : clientGroupId}, function(data) {
- var options = '<option value="">Default</option>';
+ //var options = '<option value="">Default</option>';
+ var options = '';
var phpfastcgiselected = '';
$.each(data, function(key, val) {
+ <tmpl_if name="id">
if($('#fastcgi_php_version').val() == key){
phpfastcgiselected = ' selected="selected"';
} else {
phpfastcgiselected = '';
}
+ </tmpl_else>
+ phpfastcgiselected = '';
+ </tmpl_if>
options += '<option value="'+key+'"'+phpfastcgiselected+'>'+val+'</option>';
});
+ <tmpl_if name="id">
+ if($('#fastcgi_php_version').val() == ''){
+ phpfastcgiselected = ' selected="selected"';
+ } else {
+ phpfastcgiselected = '';
+ }
+ </tmpl_else>
+ phpfastcgiselected = '';
+ </tmpl_if>
+ options += '<option value=""'+phpfastcgiselected+'>{tmpl_var name="default_php_txt"}</option>';
$('#fastcgi_php_version').html(options).change();
if(noFormChange) ISPConfig.resetFormChanged();
});
diff --git a/interface/web/tools/lib/module.conf.php b/interface/web/tools/lib/module.conf.php
index 853fd64..617ab0b 100644
--- a/interface/web/tools/lib/module.conf.php
+++ b/interface/web/tools/lib/module.conf.php
@@ -7,6 +7,7 @@
$module['template'] = 'module.tpl.htm';
$module['startpage'] = 'tools/index.php';
$module['tab_width'] = '60';
+$module['order'] = '80';
//**** Change User password
--
Gitblit v1.9.1