From 108e4bb08b76b05cc0e4762b1c58b209f2483c56 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 14 Aug 2013 13:02:46 -0400
Subject: [PATCH] - Dashlets can now be managed from interface config (left column, right column, position, etc.). Defaults dashlets are used if appropriate fields in interface config are left empty. TODO: formatting of dashlets; they need to adjust themselves to left or right column.

---
 interface/web/dashboard/dashboard.php |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php
index dae00f8..0626758 100644
--- a/interface/web/dashboard/dashboard.php
+++ b/interface/web/dashboard/dashboard.php
@@ -157,8 +157,36 @@
 
 /* Which dashlets in which column */
 /******************************************************************************/
-$leftcol_dashlets = array('modules','invoices','quota','mailquota');
-$rightcol_dashlets = array('limits');
+$default_leftcol_dashlets = array('modules','invoices','quota','mailquota');
+$default_rightcol_dashlets = array('limits');
+
+$app->uses('getconf');
+$dashlets_config = $app->getconf->get_global_config('misc');
+//* 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'])) {
+	$role = 'client';
+//* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
+} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
+	$role = 'reseller';
+//* Admin: If the logged in user is admin
+} else {
+	$role = 'admin';
+}
+$dashlets_config[$role.'_dashlets_left'] = trim($dashlets_config[$role.'_dashlets_left']);
+$dashlets_config[$role.'_dashlets_right'] = trim($dashlets_config[$role.'_dashlets_right']);
+
+if($dashlets_config[$role.'_dashlets_left'] != ''){
+	preg_match_all('@\[(.*?)\]@', $dashlets_config[$role.'_dashlets_left'], $matches);
+	$leftcol_dashlets = $matches[1]; 
+} else {
+	$leftcol_dashlets = $default_leftcol_dashlets;
+}
+if($dashlets_config[$role.'_dashlets_right'] != ''){
+	preg_match_all('@\[(.*?)\]@', $dashlets_config[$role.'_dashlets_right'], $matches);
+	$rightcol_dashlets = $matches[1];
+} else {
+	$rightcol_dashlets = $default_rightcol_dashlets;
+}
 /******************************************************************************/
 
 

--
Gitblit v1.9.1