Browse Source

added controller, model and view for dashboard - partial CT#571

Cristian Fasanando 15 years ago
parent
commit
d5d6abaa8a

+ 28 - 1
main/css/academica/default.css

@@ -2959,4 +2959,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/baby_orange/default.css

@@ -2948,4 +2948,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/blue_lagoon/default.css

@@ -3573,4 +3573,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/chamilo/default.css

@@ -3939,4 +3939,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/chamilo_green/default.css

@@ -3942,4 +3942,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/chamilo_red/default.css

@@ -3944,4 +3944,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/cool_blue/default.css

@@ -3450,4 +3450,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/corporate/default.css

@@ -2944,4 +2944,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/cosmic_campus/default.css

@@ -2992,4 +2992,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/delicious_bordeaux/default.css

@@ -3465,4 +3465,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/dokeos_blue/default.css

@@ -3455,4 +3455,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/dokeos_classic/default.css

@@ -3734,4 +3734,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/dokeos_classic_2D/default.css

@@ -3764,4 +3764,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/empire_green/default.css

@@ -3465,4 +3465,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/fruity_orange/default.css

@@ -3466,4 +3466,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/medical/default.css

@@ -3924,4 +3924,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/public_admin/default.css

@@ -3648,4 +3648,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/royal_purple/default.css

@@ -3462,4 +3462,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/silver_line/default.css

@@ -3272,4 +3272,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/sober_brown/default.css

@@ -3644,4 +3644,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/steel_grey/default.css

@@ -3466,4 +3466,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 28 - 1
main/css/tasty_olive/default.css

@@ -3468,4 +3468,31 @@ div.attendance-calendar-add div.row div.formw,div.attendance-calendar-edit div.r
 	background-color:none;
 	padding:2px;
 	font-size:11px;
-}
+}
+
+/* DASHBOARD */
+
+/* Head section */
+#head {
+    background-color: #000;
+    height: 100px;
+}
+#head h1 {
+    line-height: 100px;
+    color: #FFF;
+    text-align: center;    
+    text-indent: -9999em
+}
+/* End Head Section */
+
+/* Columns section */
+#columns .column {
+    float: left;
+    width: 50%;
+		/* Min-height: */
+		min-height: 400px;
+		height: auto !important; 
+		height: 400px;
+}
+
+#columns ul, #columns ol {margin:0; padding:0; list-style:none; border:none;}

+ 34 - 0
main/dashboard/block.class.php

@@ -0,0 +1,34 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * This file contains class used parent class for blocks plugins 
+ * @author Christian Fasanando <christian1827@gmail.com>
+ * @package chamilo.dashboard
+ */
+
+/**
+ * Parent class for controller Blocks from dashboard plugin
+ * @package chamilo.dashboard 
+ */
+ 
+class Block {
+
+	/**
+	 * Contructor
+	 */
+    public function __construct() {}
+    
+    /**
+     * Display small blocks, @todo it will be implemented for next version
+     */
+    public function display_small() {}
+    
+    /**
+     * Display larges blocks, @todo it will be implemented for next version
+     */
+    public function display_large() {}
+    
+}
+
+?>

+ 97 - 0
main/dashboard/dashboard.php

@@ -0,0 +1,97 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* Template (view in MVC pattern) used for displaying blocks for dashboard  
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.dashboard
+*/
+
+// protect script
+api_block_anonymous_users();
+
+// menu actions for dashboard views
+$views = array('blocks', 'list');
+//$dashboard_view = 'blocks';
+if(isset($_GET['view']) && in_array($_GET['view'], $views)){
+	$dashboard_view = $_GET['view'];
+}
+if($dashboard_view == 'list') {
+	$link_blocks_view = '<a href="'.api_get_self().'?view=blocks">'.Display::return_icon('thumbnails.png').get_lang('DashboardBlocks').'</a>';
+	$link_list_view   = Display::return_icon('check.gif').get_lang('DashboardList').' ';
+} else {
+	$link_blocks_view = Display::return_icon('thumbnails.png').get_lang('DashboardBlocks').'&nbsp;&nbsp;&nbsp;';
+	$link_list_view = '<a href="'.api_get_self().'?view=list">'.Display::return_icon('check.gif').get_lang('DashboardList').'</a>';
+}
+
+echo '<div class="actions">';
+echo $link_blocks_view.$link_list_view;
+echo '</div>';
+
+// block dashboard view
+if($dashboard_view == 'blocks') {
+	
+	if (isset($msg)) {		
+		//Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccesslly'));		
+	}
+	
+	if (count($blocks) > 0) {
+		$columns = array();
+		// group content html by number of column
+		if (is_array($blocks) && count($blocks) > 0) {	
+			$tmp_columns = array();	
+			foreach ($blocks as $block) {		
+				$tmp_columns[] = $block['column'];		
+				if (in_array($block['column'], $tmp_columns)) {
+					$columns['column_'.$block['column']][] = $block['content_html'];
+				}						
+			}		
+		}
+		
+		echo '<div id="columns">';
+		if (count($columns) > 0) {
+			$columns_name = array_keys($columns);
+			// blocks for column 1
+			if (in_array('column_1',$columns_name)) {		
+				echo '<ul id="column1" class="column">'; 
+					foreach ($columns['column_1'] as $content) {
+						echo $content; 
+					}
+				echo '</ul>';		
+			} else {
+				echo '<ul id="column1" class="column">';
+				echo '&nbsp;';
+				echo '</ul>';		
+			}
+			// blocks for column 2
+			if (in_array('column_2',$columns_name)) {
+				// blocks for column 1
+				echo '<ul id="column2" class="column">'; 
+					foreach ($columns['column_2'] as $content) {
+						echo $content; 
+					}
+				echo '</ul>';		
+			} else {
+				echo '<ul id="column2" class="column">';
+				echo '&nbsp;';
+				echo '</ul>';		
+			}		
+		}
+		echo '</div>';
+	} else {		
+		echo '<div style="margin-top:20px;">'.get_lang('YouHaveNotEnabledBlocks').'</div>';		
+	}
+
+} else {
+	// block dashboard list
+	if (isset($success)) {		
+		Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccesslly'));		
+	}
+	
+	$user_id = api_get_user_id();
+	DashboardManager::display_user_dashboard_list($user_id);
+	
+}
+
+
+?>

+ 111 - 0
main/dashboard/dashboard_controller.php

@@ -0,0 +1,111 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * This file contains class used like controller, it should be included inside a dispatcher file (e.g: index.php)
+ * @author Christian Fasanando <christian1827@gmail.com>
+ * @package chamilo.dashboard
+ */
+
+/**
+ * Controller script. Prepares the common background variables to give to the scripts corresponding to
+ * the requested action
+ * @package chamilo.dashboard 
+ */
+class DashboardController { // extends Controller {	
+		
+	private $toolname;
+	private $view; 
+	private $user_id;
+	
+	/**
+	 * Constructor
+	 */
+	public function __construct() {		
+		$this->user_id = api_get_user_id();
+		$this->toolname = 'dashboard';	
+		$this->view = new View($this->toolname);			
+	}
+	
+	/**
+	 * Display blocks from dashboard plugin paths
+	 * @param string message (optional)
+	 * render to dashboard.php view
+	 */
+	public function display($msg = false) {
+
+		$data = array();		
+		$user_id = $this->user_id;
+		
+		$dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks();
+		$user_block_data  = DashboardManager::get_user_block_data($user_id);		
+		$user_blocks_id = array_keys($user_block_data);
+
+		foreach ($dashboard_blocks as $block) {
+			
+			// display only user blocks
+			if (!in_array($block['id'], $user_blocks_id)) continue;								 			
+			
+			$path = $block['path'];
+			$controller_class = $block['controller'];
+			$filename_controller = $path.'.class.php';			
+			$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';	
+			require_once $dashboard_plugin_path.$filename_controller;
+			$obj = new $controller_class($user_id);
+			$data_block[$path] = $obj->get_block();
+			// set user block column 
+			$data_block[$path]['column'] = $user_block_data[$block['id']]['column'];				
+		}
+		
+		$data['blocks'] = $data_block; 
+		$data['dashboard_view'] = 'blocks';	
+		
+		if ($msg) {
+			$data['msg'] = $msg;
+		}
+			
+		// render to the view
+		$this->view->set_data($data);
+		$this->view->set_layout('layout'); 
+		$this->view->set_template('dashboard');		       
+		$this->view->render();		
+	}
+	
+	/**
+	 * This method allow store user blocks from dashboard manager
+	 * render to dashboard.php view
+	 */
+	public function store_user_block() {
+		
+		$data = array();
+		$user_id = $this->user_id;
+		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
+			$enabled_blocks = $_POST['enabled_blocks'];
+			$columns = $_POST['columns'];
+			$affected_rows = DashboardManager::store_user_blocks($user_id, $enabled_blocks, $columns);			
+			if ($affected_rows) {
+				$data['success'] = true;
+			}
+		}
+
+		$data['dashboard_view'] = 'list'; 
+				
+		// render to the view
+		$this->view->set_data($data);
+		$this->view->set_layout('layout'); 
+		$this->view->set_template('dashboard');		       
+		$this->view->render();		
+	}
+	
+	/**
+	 * This method is used when you close a block from dashboard block interface
+	 * render to dashboard.php view
+	 */
+	public function close_user_block($path) {				
+		$user_id = $this->user_id;		
+		$result = DashboardManager::close_user_block($user_id, $path);
+		$this->display($result);
+	}
+	
+}
+?>

+ 66 - 0
main/dashboard/index.php

@@ -0,0 +1,66 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action  
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.dashboard
+*/
+
+// name of the language file that needs to be included
+$language_file = array ('registration', 'index', 'tracking', 'userInfo');
+
+// including files 
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'dashboard.lib.php';
+require_once api_get_path(LIBRARY_PATH).'display.lib.php';
+require_once api_get_path(LIBRARY_PATH).'app_view.php';
+require_once 'dashboard_controller.php';
+require_once 'block.class.php';
+
+// protect script
+api_block_anonymous_users();
+
+// defining constants
+
+// current section
+$this_section = SECTION_DASHBOARD;
+
+// get actions
+$actions = array('listing', 'store_user_block', 'disable_block');
+$action = 'listing';
+if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
+	$action = $_GET['action'];
+}
+
+// load styles from dashboard plugins
+$dashboar_plugin_styles = DashboardManager::get_links_for_styles_from_dashboard_plugins();
+$htmlHeadXtra[] = $dashboar_plugin_styles;
+
+// interbreadcrumb
+$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('Dashboard'));
+
+// course description controller object
+$dashboard_controller = new DashboardController();
+
+if (isset($_GET['path'])) {
+	$path = $_GET['path'];
+}
+
+// distpacher actions to controller
+switch ($action) {	
+	case 'listing':	
+						$dashboard_controller->display();
+						break;
+	case 'store_user_block':	
+						$dashboard_controller->store_user_block();
+						break;	
+	case 'disable_block':	
+						$dashboard_controller->close_user_block($path);
+						break;					
+	default		  :	
+						$dashboard_controller->display();
+}
+
+?>

+ 21 - 0
main/dashboard/layout.php

@@ -0,0 +1,21 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* Layout (principal view) used for structuring other views  
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_description
+*/
+
+// protect script
+api_block_anonymous_users();
+
+// Header
+Display :: display_header('');
+
+// Display
+echo $content;
+
+// Footer
+Display :: display_footer();
+?>

BIN
main/img/close.gif


+ 474 - 0
main/inc/lib/dashboard.lib.php

@@ -0,0 +1,474 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * This file contains a class used like library, provides functions for dashboard.
+ * @author Christian Fasanando <christian1827@gmail.com>
+ * @package chamilo.dashboard
+ */
+
+/**
+ * DashboardManager can be used to manage dashboard
+ * @package chamilo.dashboard
+ */
+
+class DashboardManager 
+{
+	/**
+	 * contructor
+	 */
+	private function __construct() {}
+		
+    /**
+	 * This function allows easy activating and inactivating of dashboard plugins
+	 * @return void
+	*/
+	public static function handle_dashboard_plugins() {
+
+		$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+	
+		/* We scan the plugin directory. Each folder is a potential plugin. */
+		$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';	
+		$possibleplugins = self::get_posible_dashboard_plugins_path();
+
+		$table_cols = array('name', 'version', 'description');
+		echo '<h3>'.get_lang('DashboardPlugins').'</h3>';			
+		echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.$_GET['category'].'">';
+		echo '<table class="data_table">';	
+		echo '<tr>';
+		echo '<th width="50px">'.get_lang('Enabled').'</th>';
+		echo '<th width="250px">'.get_lang('Name').'</th>';
+		echo '<th width="100px">'.get_lang('Version').'</th>';		
+		echo '<th>'.get_lang('Description').'</th>';	
+		echo '</tr>';
+		
+		$disabled_block_data = self::get_block_data_without_plugin();
+			
+		// We display all the possible enabled or disabled plugins
+		foreach ($possibleplugins as $testplugin) {
+			$plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info";
+			$plugin_info = array();
+			if (file_exists($plugin_info_file)) {						
+				$plugin_info = parse_info_file($plugin_info_file);
+			}
+			
+			// change index to lower case
+			$plugin_info = array_change_key_case($plugin_info);
+			
+			echo '<tr>';
+				self::display_dashboard_plugin_checkboxes($testplugin);			
+				for ($i = 0 ; $i < count($table_cols); $i++) {
+					if (isset($plugin_info[strtolower($table_cols[$i])])) {
+			    		echo '<td>';
+			    			echo $plugin_info[$table_cols[$i]];
+			    		echo '</td>';
+			    	} else {
+			    		echo '<td>&nbsp;</td>';
+			    	}
+				}					    
+			echo '</tr>';
+		}
+		
+		// display all disabled block data
+		if (count($disabled_block_data) > 0) {
+			foreach ($disabled_block_data as $disabled_block) {
+				echo '<tr style="background-color:#eee">';
+				echo '<td><center><input type="checkbox" name="disabled_block" value="true" disabled /></center>';
+				for ($j = 0 ; $j < count($table_cols); $j++) {
+
+					if (isset($disabled_block[strtolower($table_cols[$j])])) {
+
+						if ($j == 2) {
+							echo '<td>';
+			    				echo '<font color="#aaa">'.$disabled_block[$table_cols[$j]].'</font><br />';
+			    				echo '<font color="red">'.get_lang('ThisPluginHasbeenDeletedFromDashboardPluginDirectory').'</font>';
+			    			echo '</td>';
+						} else {
+							echo '<td>';
+			    				echo '<font color="#aaa">'.$disabled_block[$table_cols[$j]].'</font>';
+			    			echo '</td>';	
+						}
+						
+			    		
+			    	} else {
+			    		echo '<td>&nbsp;</td>';
+			    	}
+				}
+				echo '</tr>';		
+			}
+		}
+				
+		echo '</table>';
+		echo '<br />';
+		echo '<button class="save" type="submit" name="submit_dashboard_plugins" value="'.get_lang('EnableDashboardPlugins').'">'.get_lang('EnableDashboardPlugins').'</button></form>';
+	}
+	
+	/**
+	 * display checkboxes for dashboard plugin list
+	 * @param string  plugin path
+	 * @return void
+	 */
+	public static function display_dashboard_plugin_checkboxes($plugin_path) {
+	
+		$tbl_block = Database::get_main_table(TABLE_MAIN_BLOCK);
+		$plugin_path = Database::escape_string($plugin_path);
+			
+		$sql = "SELECT * FROM $tbl_block WHERE path = '$plugin_path' AND active = 1";
+		$rs  = Database::query($sql, __FILE__, __LINE__);
+		
+		$checked = '';
+		if (Database::num_rows($rs) > 0) {
+			$checked = "checked";
+		}
+		
+		echo "<td align=\"center\">";
+			echo '<input type="checkbox" name="'.$plugin_path.'" value="true" '.$checked.'/>';
+		echo "</td>";
+	}
+	
+	/**
+	 * This function allows easy activating and inactivating of plugins and save them inside db
+	 * @param array dashboard plugin paths
+	 * return int affected rows
+	*/
+	public static function store_dashboard_plugins($plugin_paths)
+	{
+		
+		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);		
+		$affected_rows = 0;
+		
+		// get all plugins path inside plugin directory 		
+		$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
+		$possibleplugins = self::get_posible_dashboard_plugins_path();	
+		
+		$condition_path = '';
+		if (count($possibleplugins) > 0) {
+			$tmp_possibleplugins = $possibleplugins;		
+			foreach ($tmp_possibleplugins as &$plugins) {
+				$plugins = "'".$plugins."'";
+			}
+			$condition_path = ' WHERE path IN('.implode(',',$tmp_possibleplugins).')';			
+				
+			// clean block table for adding paths
+			$sql = "SELECT id FROM $tbl_block $condition_path ";
+			$rs  = Database::query($sql, __FILE__, __LINE__);
+			if (Database::num_rows($rs) > 0) {
+				$sql_del = "DELETE FROM $tbl_block $condition_path ";
+				Database::query($sql_del, __FILE__, __LINE__);	
+			}
+
+			// get selected plugins
+			$selected_plugins = array();
+			if (!empty($plugin_paths)) {		
+				$selected_plugins = array_intersect(array_keys($plugin_paths),$possibleplugins);
+			}
+		
+			if (count($selected_plugins) > 0) {
+				foreach ($selected_plugins as $testplugin) {
+					$plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info";
+					$plugin_info = array();
+					if (file_exists($plugin_info_file)) {						
+						$plugin_info = parse_info_file($plugin_info_file);
+					}
+					
+					// change keys to lower case
+					$plugin_info = array_change_key_case($plugin_info);
+		
+					// setting variables 
+					$plugin_name = $testplugin;
+					$plugin_description = '';
+					$plugin_controller = '';
+					$plugin_path = $testplugin;
+					
+					if (isset($plugin_info['name'])) {
+						$plugin_name = Database::escape_string($plugin_info['name']);
+					}
+					if (isset($plugin_info['description'])) {
+						$plugin_description = Database::escape_string($plugin_info['description']);
+					}
+					if (isset($plugin_info['controller'])) {
+						$plugin_controller = Database::escape_string($plugin_info['controller']);
+					}
+					
+					$sql_ins = "INSERT INTO $tbl_block(name, description, path, controller) VALUES ('$plugin_name', '$plugin_description', '$plugin_path', '$plugin_controller')";
+					Database::query($sql_ins, __FILE__, __LINE__);
+					$affected_rows = Database::affected_rows();
+		
+				}
+			}
+		}	
+		return $affected_rows;	
+	}
+	
+	/**
+	 * Get all plugins path inside dashboard directory
+	 * @return array name plugins directories
+	 */
+	public static function get_posible_dashboard_plugins_path() {
+		
+		// get all plugins path inside plugin directory 
+		/* We scan the plugin directory. Each folder is a potential plugin. */
+		$possibleplugins = array();
+		$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
+		$handle = @opendir($dashboard_pluginpath);
+		while (false !== ($file = readdir($handle)))
+		{
+			if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file))
+			{
+				$possibleplugins[] = $file;
+			}
+		}
+		@closedir($handle);		
+		return $possibleplugins;
+	}
+	
+	/**
+	 * Get all blocks data without plugin directory 
+	 * @return array Block data
+	 */
+	public static function get_block_data_without_plugin() {
+		
+		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);								
+		$possibleplugins = self::get_posible_dashboard_plugins_path();
+		
+		// We check if plugin exists inside directory for updating active field
+		$sql = "SELECT * FROM $tbl_block";
+		$rs = Database::query($sql);		
+		if (Database::num_rows($rs) > 0){			
+			while ($row = Database::fetch_array($rs)) {				
+				$path = $row['path'];
+				if (!in_array($row['path'],$possibleplugins)) {											
+						$active = 0;					 					
+				} else {
+						$active = 1;
+				}
+				
+				// update active
+				$upd = "UPDATE $tbl_block SET active = '$active' WHERE path = '".$row['path']."'";
+				Database::query($upd);
+			}			
+		}
+						
+		// get disabled block data
+		$block_data = array();
+		$sql = "SELECT * FROM $tbl_block WHERE active = 0";
+		$rs_block = Database::query($sql);
+		if (Database::num_rows($rs_block) > 0) {
+			while ($row_block = Database::fetch_array($rs_block)) {				
+				$block_data[] = $row_block;				
+			}
+		}
+		return $block_data;
+
+	}
+	
+	/**
+	 * get data about enabled dashboard block (stored insise block table)
+	 * @param  string	plugin path
+	 * @return array 	data
+	 */	
+	public static function get_enabled_dashboard_blocks($path = '') {				
+		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
+		$condition_path = '';
+		if (!empty($path)) {
+			$path = Database::escape_string($path);
+			$condition_path = ' WHERE path = "'.$path.'" ';	
+		}
+				
+		$sql = "SELECT * FROM $tbl_block $condition_path WHERE active = 1";
+		$rs  = Database::query($sql, __FILE__, __LINE__);
+		$block_data = array();
+		if (Database::num_rows($rs) > 0) {
+			while ($row = Database::fetch_array($rs)) {
+				$block_data[$row['path']] = $row;
+			}
+		}
+		return $block_data;
+	}
+	
+	/**
+	 * display user dashboard list
+	 * @param int  User id
+	 * @return void
+	 */
+	public static function display_user_dashboard_list($user_id) {
+		
+		$enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();		
+		$user_block_data = self::get_user_block_data($user_id);
+		
+		if (count($enabled_dashboard_plugins) > 0) {		
+			echo '<div style="margin-top:20px">';
+			echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />';
+			echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
+			echo '<table class="data_table">';	
+			echo '<tr>';
+			echo '<th width="5%">';
+			echo get_lang('Enabled');
+			echo '</th>';
+			echo '<th width="30%">';
+			echo get_lang('Name');
+			echo '</th>';
+			echo '<th width="40%">';
+			echo get_lang('Description');
+			echo '</th>';
+			echo '<th>';
+			echo get_lang('ColumnPosition');
+			echo '</th>';	
+			echo '</tr>';
+								
+			// We display all enabled plugins and the checkboxes	
+			foreach ($enabled_dashboard_plugins as $block) {
+				echo '<tr>';
+					// checkboxes						
+					self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
+					
+					echo '<td>'.$block['name'].'</td>';
+					echo '<td>'.$block['description'].'</td>';
+					echo '<td><center>
+							<select name="columns['.$block['id'].']">
+							<option value="1" '.($user_block_data[$block['id']]['column']==1?'selected':'').' >1</option>
+							<option value="2" '.($user_block_data[$block['id']]['column']==2?'selected':'').' >2</option>
+							</select></center>	
+						  </td>';								    
+				echo '</tr>';
+			}	
+						
+			echo '</table>';
+			echo '<br />';
+			echo '<button class="save" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'">'.get_lang('EnableDashboardBlock').'</button></form>';
+			echo '</div>';
+		} else {
+			echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>';
+		}
+	}
+	
+	
+	/**
+	 * display checkboxes for user dashboard list
+	 * @param int 	User id
+	 * @param int	Block id	
+	 * @return void
+	 */
+	public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
+	
+		$user_id = intval($user_id);
+		$user_block_data = self::get_user_block_data($user_id);
+		$enabled_blocks_id = array_keys($user_block_data);
+		
+		$checked = '';		
+		if (in_array($block_id, $enabled_blocks_id)) {
+			$checked = "checked";
+		}
+				
+		echo "<td align=\"center\">";
+			echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>';
+		echo "</td>";
+	}
+	
+	/**
+	 * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
+	 * @param int User id
+	 * @param array selected blocks
+	 * @param array columns position
+	 * @return bool 
+	*/
+	public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
+
+		$selected_blocks_id = array_keys($enabled_blocks);
+		
+		// build data for storing inside extra user field		
+		$fname = 'dashboard';
+		$fvalue = array();		
+		foreach ($selected_blocks_id as $block_id) {			
+			$fvalue[] = $block_id.':'.$columns[$block_id];			
+		}
+		
+		$upd_extra_field = UserManager::update_extra_field_value($user_id, $fname, $fvalue);
+		
+		return $upd_extra_field;
+		
+	}
+	
+	/**
+	 * This function get user block data (block id with its number of column) from extra user data
+	 * @param int  		User id
+	 * @return array  	data (block_id,column)
+	 */	
+	public static function get_user_block_data($user_id) {
+		
+		$user_id = intval($user_id);
+		$field_variable = 'dashboard';		
+		$extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);		
+		$extra_user_data = explode(';',$extra_user_data[$field_variable]);		
+		$data = array();
+		foreach ($extra_user_data as $extra) {
+			$split_extra = explode(':',$extra);
+			$block_id = $split_extra[0];
+			$column = $split_extra[1];			
+			$data[$block_id] = array('block_id' => $block_id, 'column' => $column);			
+		}
+		
+		return $data;
+		
+	}
+
+	/**
+	 * This function update extra user blocks data after closing a dashboard block
+	 * @param int 		User id
+	 * @param string	plugin path
+	 * @return bool
+	 */	
+	public static function close_user_block($user_id, $path) {
+		
+		$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
+		$user_block_data = self::get_user_block_data($user_id);
+		
+		foreach ($enabled_dashboard_blocks as $enabled_block) {								
+			unset($user_block_data[$enabled_block['id']]);			
+		}
+		
+		// get columns and blocks id for updating extra user data
+		$columns = array();
+		$user_blocks_id = array();
+		foreach ($user_block_data as $data) {
+			$user_blocks_id[$data['block_id']] = true;
+			$columns[$data['block_id']] = $data['column']; 			
+		}
+		
+		// update extra user blocks data		
+		$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
+		
+		return $upd_extra_field;
+		
+	}
+	
+	/**
+	 * get links for styles from dashboard plugins
+	 * @return string   links
+	 */
+	public static function get_links_for_styles_from_dashboard_plugins() {
+		
+		$possible_paths = self::get_posible_dashboard_plugins_path();		
+		$enabled_blocks = self::get_enabled_dashboard_blocks();
+		$links = '';
+		foreach ($enabled_blocks as $block) {			
+			$path = $block['path'];
+			$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/css/';			
+			if (is_dir($dashboard_plugin_path)) {				
+				$handle = @opendir($dashboard_plugin_path);
+				while (false !== ($file = readdir($handle))) {
+					if ($file <> '.' AND $file <> '..') {
+						$src = api_get_path(WEB_PLUGIN_PATH).'dashboard/'.$path.'/css/'.$file;
+						$links .= '<link rel="stylesheet" href="'.$src.'" type="text/css" />'.PHP_EOL;
+					}
+				}
+				@closedir($handle);				
+			}							
+		}		
+		return $links;		
+	}
+	
+}
+
+
+?>