Bläddra i källkod

added dashboard interface for session administrator - partial CT#566

Cristian Fasanando 15 år sedan
förälder
incheckning
14370b0ee0

+ 1 - 1
index.php

@@ -409,7 +409,7 @@ function display_anonymous_right_menu() {
 				display_create_course_link();
 			}
 			if ($show_course_link) {
-				if (!api_is_drh()) {
+				if (!api_is_drh() && !api_is_session_admin()) {
 					display_edit_course_list_links();
 				} else {
 					display_dashboard_link();

+ 35 - 18
main/admin/dashboard_add_courses_to_user.php

@@ -17,6 +17,7 @@ $cidReset=true;
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
 // create an ajax object
 $xajax = new xajax();
@@ -32,21 +33,26 @@ api_protect_admin_script(true);
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
 
-
 // Database Table Definitions
 $tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
 $tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
 
-// setting the name of the tool
-$tool_name= get_lang('AssignCoursesToHumanResourcesManager');
-
 // initializing variables
 $id_session=intval($_GET['id_session']);
-$hrm_id = intval($_GET['user']);
-$hrm_info = api_get_user_info($hrm_id);
+$user_id = intval($_GET['user']);
+$user_info = api_get_user_info($user_id);
 $user_anonymous  = api_get_anonymous_id();
 $current_user_id = api_get_user_id();
 
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignCoursesToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignCoursesToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignCoursesToHumanResourcesManager');
+}
+
 $add_type = 'multiple';
 if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
@@ -57,7 +63,7 @@ if (!api_is_platform_admin()) {
 }
 
 function search_courses($needle,$type) {
-	global $tbl_course, $tbl_course_rel_user, $hrm_id;
+	global $tbl_course, $tbl_course_rel_user, $user_id;
 
 	$xajax_response = new XajaxResponse();
 	$return = '';
@@ -66,7 +72,7 @@ function search_courses($needle,$type) {
 		$charset = api_get_setting('platform_charset');
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 
-		$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id);
+		$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
 		$assigned_courses_code = array_keys($assigned_courses_to_hrm);
 		foreach ($assigned_courses_code as &$value) {
 			$value = "'".$value."'";
@@ -152,24 +158,25 @@ $UserList = array();
 $msg = '';
 if (intval($_POST['formSent']) == 1) {
 	$courses_list = $_POST['CoursesList'];
-	$affected_rows = CourseManager::suscribe_courses_to_hr_manager($hrm_id,$courses_list);
+	$affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list);
 	if ($affected_rows)	{
 		$msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully');
 	}
 }
 
-// display the dokeos header
+// display header
 Display::display_header($tool_name);
-//echo '<div class="row"><div class="form_header">'.get_lang('AssignedCoursesTo').'&nbsp;'.api_get_person_name($hrm_info['firstname'], $hrm_info['lastname']).'</div></div><br />';
+
+// actions
 echo '<div class="actions" style="height:22px;">
 <span style="float: right;margin:0px;padding:0px;">
-<a href="dashboard_add_users_to_user.php?user='.$hrm_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</a>
-<a href="dashboard_add_sessions_to_user.php?user='.$hrm_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>
-<span style="vertical-align:middle">'.sprintf(get_lang('AssignCoursesToX'), api_get_person_name($hrm_info['firstname'], $hrm_info['lastname'])).'</span></div>';
+<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</a>
+<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>
+<span style="vertical-align:middle">'.sprintf(get_lang('AssignCoursesToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span></div>';
 
 // *******************
 
-$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id);
+$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
 $assigned_courses_code = array_keys($assigned_courses_to_hrm);
 foreach ($assigned_courses_code as &$value) {
 	$value = "'".$value."'";
@@ -191,7 +198,7 @@ $sql 	= " SELECT c.code, c.title FROM $tbl_course c
 $result	= Database::query($sql);
 
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <?php
 if(!empty($msg)) {
@@ -207,7 +214,17 @@ if(!empty($msg)) {
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('CoursesListInPlatform') ?> :</b></td>
   <td width="10%">&nbsp;</td>
-  <td align="center" width="45%"><b><?php echo get_lang('AssignedCoursesListToHumanResourceManager') ?> :</b></td>
+  <td align="center" width="45%"><b>
+  	<?php   	
+	  	if (UserManager::is_admin($user_id)) {
+			echo get_lang('AssignedCoursesListToPlatformAdministrator');
+		} else if ($user_info['status'] == SESSIONADMIN) {
+			echo get_lang('AssignedCoursesListToSessionsAdministrator');		
+		} else {
+			echo get_lang('AssignedCoursesListToHumanResourcesManager');
+		}  	
+  	?> 
+  	:</b></td>
 </tr>
 
 <?php if($add_type == 'multiple') { ?>
@@ -252,7 +269,7 @@ if(!empty($msg)) {
   ?>
 	<br /><br /><br /><br /><br /><br />
 	<?php
-		echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('AssignCoursesToHumanResourcesManager').'</button>';
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
 	?>
   </td>
   <td width="45%" align="center">

+ 43 - 20
main/admin/dashboard_add_sessions_to_user.php

@@ -17,6 +17,7 @@ $cidReset=true;
 require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
 // create an ajax object
 $xajax = new xajax();
@@ -36,27 +37,33 @@ $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList
 $tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
 
-// setting the name of the tool
-$tool_name= get_lang('AssignSessionsToHumanResourcesManager');
-
 // initializing variables
 $id_session=intval($_GET['id_session']);
-$hrm_id = intval($_GET['user']);
-$hrm_info = api_get_user_info($hrm_id);
+$user_id = intval($_GET['user']);
+$user_info = api_get_user_info($user_id);
 $user_anonymous  = api_get_anonymous_id();
 $current_user_id = api_get_user_id();
 
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignSessionsToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignSessionsToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignSessionsToHumanResourcesManager');
+}
+
 $add_type = 'multiple';
 if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
-if (!api_is_platform_admin()) {
+if (!api_is_platform_admin() && !api_is_session_admin()) {
 	api_not_allowed(true);
 }
 
 function search_sessions($needle,$type) {
-	global $tbl_session, $hrm_id;
+	global $tbl_session, $user_id;
 
 	$xajax_response = new XajaxResponse();	
 	$return = '';
@@ -64,7 +71,7 @@ function search_sessions($needle,$type) {
 		// xajax send utf8 datas... datas in db can be non-utf8 datas
 		$charset = api_get_setting('platform_charset');
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
-		$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($hrm_id);
+		$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
 		$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
 
 		$without_assigned_sessions = '';
@@ -148,25 +155,31 @@ $UserList = array();
 $msg = '';
 if (intval($_POST['formSent']) == 1) {
 	$sessions_list = $_POST['SessionsList'];
-	$affected_rows = SessionManager::suscribe_sessions_to_hr_manager($hrm_id,$sessions_list);
+	$affected_rows = SessionManager::suscribe_sessions_to_hr_manager($user_id,$sessions_list);
 	if ($affected_rows)	{
 		$msg = get_lang('AssignedSessionsHaveBeenUpdatedSuccessfully');
 	}
 }
 
-// display the dokeos header
+// display header
 Display::display_header($tool_name);
-//echo '<div class="row"><div class="form_header">'.get_lang('AssignSessionsTo').'&nbsp;'.api_get_person_name($hrm_info['firstname'], $hrm_info['lastname']).'</div></div><br />';
 
-echo '<div class="actions" style="height:22px;">
-<span style="float: right;margin:0px;padding:0px;">
-<a href="dashboard_add_users_to_user.php?user='.$hrm_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</a>
-<a href="dashboard_add_courses_to_user.php?user='.$hrm_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a></span>
-<span style="vertical-align:middle">'.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($hrm_info['firstname'], $hrm_info['lastname'])).'</span></div>';
+// actions
+echo '<div class="actions" style="height:22px;">';
+if ($user_info['status'] != SESSIONADMIN) {
+	echo 	'<span style="float: right;margin:0px;padding:0px;">
+				<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').'</a>
+				<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
+			</span>
+			<span style="vertical-align:middle">'.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span>';
+} else {
+	echo '<span>'.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span>';
+}
+echo '</div>';
 
 // *******************
 
-$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($hrm_id);
+$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
 $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
 $without_assigned_sessions = '';
 if (count($assigned_sessions_id) > 0) {
@@ -183,7 +196,7 @@ $sql 	= " SELECT s.id, s.name FROM $tbl_session s
 			WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
 $result	= Database::query($sql);
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <?php
 if(!empty($msg)) {
@@ -199,7 +212,17 @@ if(!empty($msg)) {
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('SessionsListInPlatform') ?> :</b></td>
   <td width="10%">&nbsp;</td>
-  <td align="center" width="45%"><b><?php echo get_lang('AssignedSessionsListToHumanResourcesManager') ?> :</b></td>
+  <td align="center" width="45%"><b>
+  <?php 
+  	if (UserManager::is_admin($user_id)) {
+		echo get_lang('AssignedSessionsListToPlatformAdministrator');
+	} else if ($user_info['status'] == SESSIONADMIN) {
+		echo get_lang('AssignedSessionsListToSessionsAdministrator');		
+	} else {
+		echo get_lang('AssignedSessionsListToHumanResourcesManager');
+	}   
+  ?> 
+  : </b></td>
 </tr>
 
 <?php if($add_type == 'multiple') { ?>
@@ -244,7 +267,7 @@ if(!empty($msg)) {
   ?>
 	<br /><br /><br /><br /><br /><br />
 	<?php
-		echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('AssignSessionsToHumanResourcesManager').'</button>';
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
 	?>
   </td>
   <td width="45%" align="center">

+ 35 - 18
main/admin/dashboard_add_users_to_user.php

@@ -35,16 +35,22 @@ $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList
 // Database Table Definitions
 $tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
 
-// setting the name of the tool
-$tool_name= get_lang('AssignUsersToHumanResourcesManager');
-
 // initializing variables
 $id_session=intval($_GET['id_session']);
-$hrm_id = intval($_GET['user']);
-$hrm_info = api_get_user_info($hrm_id);
+$user_id = intval($_GET['user']);
+$user_info = api_get_user_info($user_id);
 $user_anonymous  = api_get_anonymous_id();
 $current_user_id = api_get_user_id();
 
+// setting the name of the tool
+if (UserManager::is_admin($user_id)) {
+	$tool_name= get_lang('AssignUsersToPlatformAdministrator');
+} else if ($user_info['status'] == SESSIONADMIN) {
+	$tool_name= get_lang('AssignUsersToSessionsAdministrator');
+} else {
+	$tool_name= get_lang('AssignUsersToHumanResourcesManager');
+}
+
 $add_type = 'multiple';
 if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
@@ -55,7 +61,7 @@ if (!api_is_platform_admin()) {
 }
 
 function search_users($needle,$type) {
-	global $tbl_user, $user_anonymous, $current_user_id, $hrm_id;
+	global $tbl_user, $user_anonymous, $current_user_id, $user_id;
 
 	$xajax_response = new XajaxResponse();
 	$return = '';
@@ -64,7 +70,7 @@ function search_users($needle,$type) {
 		$charset = api_get_setting('platform_charset');
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 
-		$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($hrm_id);
+		$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
 		$assigned_users_id = array_keys($assigned_users_to_hrm);
 		$without_assigned_users = '';
 		if (count($assigned_users_id) > 0) {
@@ -72,7 +78,7 @@ function search_users($needle,$type) {
 		}
 
 		$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-				WHERE  ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND status<>".DRH." AND user_id NOT IN ($user_anonymous, $current_user_id, $hrm_id) $without_assigned_users";
+				WHERE  ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND status<>".DRH." AND user_id NOT IN ($user_anonymous, $current_user_id, $user_id) $without_assigned_users";
 		$rs	= Database::query($sql);
 
 		$return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
@@ -148,24 +154,25 @@ $UserList = array();
 $msg = '';
 if (intval($_POST['formSent']) == 1) {
 	$user_list = $_POST['UsersList'];
-	$affected_rows = UserManager::suscribe_users_to_hr_manager($hrm_id,$user_list);
+	$affected_rows = UserManager::suscribe_users_to_hr_manager($user_id,$user_list);
 	if ($affected_rows)	{
 		$msg = get_lang('AssignedUsersHaveBeenUpdatedSuccessfully');
 	}
 }
 
-// display the dokeos header
+// display header
 Display::display_header($tool_name);
 
+// actions
 echo '<div class="actions" style="height:22px;">
 <span style="float: right;margin:0px;padding:0px;">
-<a href="dashboard_add_courses_to_user.php?user='.$hrm_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
-<a href="dashboard_add_sessions_to_user.php?user='.$hrm_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>
-<span style="vertical-align:middle">'.sprintf(get_lang('AssignUsersToX'), api_get_person_name($hrm_info['firstname'], $hrm_info['lastname'])).'</span></div>';	
+<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
+<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>
+<span style="vertical-align:middle">'.sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])).'</span></div>';	
 
 // *******************
 
-$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($hrm_id);
+$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
 $assigned_users_id = array_keys($assigned_users_to_hrm);
 $without_assigned_users = '';
 if (count($assigned_users_id) > 0) {
@@ -179,11 +186,11 @@ if (isset($_POST['firstLetterUser'])) {
 }
 
 $sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
-		WHERE  $without_assigned_users user_id NOT IN ($user_anonymous, $current_user_id, $hrm_id) AND status<>".DRH." $search_user ";
+		WHERE  $without_assigned_users user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND status<>".DRH." $search_user ";
 $result	= Database::query($sql);
 
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <?php
 if(!empty($msg)) {
@@ -199,7 +206,17 @@ if(!empty($msg)) {
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b></td>
   <td width="10%">&nbsp;</td>
-  <td align="center" width="45%"><b><?php echo get_lang('AssignedUsersListToHumanResourcesManager') ?> :</b></td>
+  <td align="center" width="45%"><b>
+  <?php 
+	if (UserManager::is_admin($user_id)) {
+		echo get_lang('AssignedUsersListToPlatformAdministrator');
+	} else if ($user_info['status'] == SESSIONADMIN) {
+		echo get_lang('AssignedUsersListToSessionsAdministrator');		
+	} else {
+		echo get_lang('AssignedUsersListToHumanResourcesManager');
+	}
+  ?>
+   :</b></td>
 </tr>
 
 <?php if($add_type == 'multiple') { ?>
@@ -245,7 +262,7 @@ if(!empty($msg)) {
   ?>
 	<br /><br /><br /><br /><br /><br />
 	<?php
-		echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('AssignUsersToHumanResourcesManager').'</button>';
+		echo '<button class="save" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';
 	?>
   </td>
   <td width="45%" align="center">

+ 14 - 5
main/admin/user_list.php

@@ -507,11 +507,20 @@ function modify_filter($user_id,$url_params,$row)
 	} else {
 		$result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
 	}
-
-	if ($row['7'] == $statusname[DRH]) {
-		$result .= '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers')).'</a>&nbsp;&nbsp;';
-		$result .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses')).'</a>&nbsp;&nbsp;';
-		$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';	
+	
+	// actions for assigning sessions, courses or users
+	if (api_is_session_admin()) {
+		if ($row[0] == api_get_user_id()) {			
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
+		}
+	} else {
+		if ($row['7'] == $statusname[DRH] || UserManager::is_admin($row[0])) {
+			$result .= '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers')).'</a>&nbsp;&nbsp;';
+			$result .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses')).'</a>&nbsp;&nbsp;';
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';	
+		} else if ($row['7'] == $statusname[SESSIONADMIN]) {
+			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
+		}
 	}
 
 	return $result;

+ 7 - 0
main/dashboard/dashboard_controller.php

@@ -54,6 +54,13 @@ class DashboardController { // extends Controller {
 				$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';	
 				require_once $dashboard_plugin_path.$filename_controller;
 				$obj = new $controller_class($user_id);
+				
+				// check if user is allowed to see the block
+				if (method_exists($obj, 'is_block_visible_for_user')) {					
+					$is_block_visible_for_user = $obj->is_block_visible_for_user($user_id);					
+					if (!$is_block_visible_for_user) continue;
+				}
+				
 				$data_block[$path] = $obj->get_block();
 				// set user block column 
 				$data_block[$path]['column'] = $user_block_data[$block['id']]['column'];				

+ 2 - 2
main/gradebook/lib/be/category.class.php

@@ -1035,7 +1035,7 @@ class Category implements GradebookItem
 			}
 		} else {// all students
 			// course admin
-			if ((api_is_allowed_to_create_course() || api_is_drh()) && !api_is_platform_admin()) {
+			if ((api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) && !api_is_platform_admin()) {
 				// root
 				if ($this->id == 0) {
 					$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
@@ -1093,7 +1093,7 @@ class Category implements GradebookItem
 						api_is_allowed_to_create_course() ? null : 1);
  		}
 		// all students -> only for course/platform admin
-		elseif (api_is_allowed_to_create_course() || api_is_drh()) {
+		elseif (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
 			$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, null);
 		}
 

+ 3 - 3
main/inc/banner.inc.php

@@ -206,13 +206,13 @@ if ($_user['user_id'] && !api_is_anonymous()) {
 
 	// Reporting
 	if (api_get_setting('show_tabs', 'reporting') == 'true') {
-		if (api_is_allowed_to_create_course() || $_user['status'] == DRH) {
+		if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
 			$navigation['session_my_space'] = $possible_tabs['session_my_space'];
 		} else {
 			$navigation['session_my_space'] = $possible_tabs['session_my_progress'];
 		}
 	} else {
-		if (api_is_allowed_to_create_course() || $_user['status'] == DRH) {
+		if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
 			$menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
 		} else {
 			$menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
@@ -230,7 +230,7 @@ if ($_user['user_id'] && !api_is_anonymous()) {
 
 	// Dashboard
 	if (api_get_setting('show_tabs', 'dashboard') == 'true') {
-		if (api_is_platform_admin() || $_user['status'] == DRH) {
+		if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
 			$navigation['dashboard'] = $possible_tabs['dashboard'];
 		}
 	} else{

+ 2 - 2
main/inc/lib/banner.lib.php

@@ -53,7 +53,7 @@ function get_tabs() {
 	}
 
 	// Reporting
-	if(api_is_allowed_to_create_course() || $_user['status']==DRH) {
+	if(api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
 		// Link to my space
 		$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
 		$navigation['session_my_space']['title'] = get_lang('MySpace');
@@ -70,7 +70,7 @@ function get_tabs() {
 	}
 	
 	// Dashboard
-	if (api_is_platform_admin() || $_user['status']==DRH) {
+	if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
 			$navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
 			$navigation['dashboard']['title'] = get_lang('Dashboard');
 	}

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

@@ -360,6 +360,20 @@ class DashboardManager
 
 			// We display all enabled plugins and the checkboxes
 			foreach ($enabled_dashboard_plugins as $block) {
+				
+				$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_block = new $controller_class($user_id);
+				
+				// check if user is allowed to see the block
+				if (method_exists($obj_block, 'is_block_visible_for_user')) {					
+					$is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);					
+					if (!$is_block_visible_for_user) continue;
+				}
+
 				echo '<tr>';
 					// checkboxes
 					self::display_user_dashboard_list_checkboxes($user_id, $block['id']);

+ 1 - 0
main/inc/lib/main_api.lib.php

@@ -32,6 +32,7 @@ $_status_list[SESSIONADMIN] = 'session_admin';
 $_status_list[DRH] = 'drh';
 $_status_list[ANONYMOUS] = 'anonymous';
 
+
 //COURSE VISIBILITY CONSTANTS
 /** only visible for course admin */
 define('COURSE_VISIBILITY_CLOSED', 0);

+ 15 - 14
main/mySpace/course.php

@@ -60,7 +60,7 @@ if (api_get_setting('add_users_by_coach') == 'true') {
 Display :: display_header($nameTools);
 
 $a_courses = array();
-if (api_is_drh()) {
+if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
 
 	$title = '';
 	if (empty($id_session)) {		
@@ -80,17 +80,18 @@ if (api_is_drh()) {
 	}
 			
 	$a_courses = array_keys($courses);
-
-	$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
-	$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';
 	
-	if (empty($_GET['user_id']) && empty($id_session)) {
-		$menu_items[] = get_lang('Courses');
-	} else {
-		$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
+	if (!api_is_session_admin()) {
+		$menu_items[] = '<a href="index.php?view=drh_students&amp;display=yourstudents">'.get_lang('Students').'</a>';
+		$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';		
+		if (empty($_GET['user_id']) && empty($id_session)) {
+			$menu_items[] = get_lang('Courses');
+		} else {
+			$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
+		}
+		$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
 	}
-	$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
-		
+	
 	echo '<div class="actions-title" style ="font-size:10pt;">';
 	$nb_menu_items = count($menu_items);
 	if ($nb_menu_items > 1) {
@@ -132,16 +133,16 @@ if ($show_import_icon) {
 	echo "</div><br />";
 }
 
-if (!api_is_drh()) {	
-	if (api_is_platform_admin()) {
+if (!api_is_drh() && !api_is_session_admin() && !api_is_platform_admin()) {	
+	/*if (api_is_platform_admin()) {
 		if (empty($id_session)) {			
 			$courses = CourseManager::get_real_course_list();			
 		} else {
 			$courses = Tracking::get_courses_list_from_session($id_session);
 		}
-	} else {
+	} else {*/
 		$courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $id_session);
-	}	
+	//}	
 	$a_courses = array_keys($courses);
 } 
 

+ 24 - 14
main/mySpace/index.php

@@ -104,6 +104,12 @@ function rsort_sessions($a, $b) {
 $is_coach = api_is_coach();
 $is_platform_admin = api_is_platform_admin();
 $is_drh = api_is_drh();
+$is_session_admin = api_is_session_admin();
+
+if ($is_session_admin) {
+	header('location:session.php');
+	exit;
+}
 
 // get views
 $views = array('admin', 'teacher', 'coach', 'drh');
@@ -118,7 +124,7 @@ global $_configuration;
 
 // interbreadcrumbs
 if (api_is_allowed_to_create_course()) {
-		
+
 	$session_id = intval($_GET['session_id']);		
 	if (!empty($session_id)) {
 		$courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $session_id);
@@ -131,14 +137,18 @@ if (api_is_allowed_to_create_course()) {
 	$sessions = Tracking::get_sessions_coached_by_user($_user['user_id']);
 	$nb_sessions = count($sessions);
 
-	if ($nb_teacher_courses) {
+	if ($nb_teacher_courses || $nb_sessions) {
 		if (!$is_coach && !$is_platform_admin) {
 			$view = 'teacher';
 		}
 		
 		if ($view == 'teacher' && empty($session_id)) {		
 			$menu_items[] = get_lang('TeacherInterface');
-			$title = get_lang('YourCourseList');			
+			
+			if ($nb_teacher_courses) {
+				$title = get_lang('YourCourseList');
+			}
+						
 		} else {			
 			if (!empty($session_id)) {								
 				$session_name = api_get_session_name($session_id);
@@ -161,19 +171,21 @@ if ($is_coach) {
 	}
 }
 
-if ($is_platform_admin) {
-	if ((!$is_coach || !$is_drh) && $nb_teacher_courses == 0) {
+if ($is_platform_admin &&  $_GET['display'] != 'yourstudents') {
+
+	if ($nb_teacher_courses == 0 && $nb_sessions == 0) {
 		$view = 'admin';
 	}
 	if ($view == 'admin') {
 		$menu_items[] = get_lang('AdminInterface');
 		$title = get_lang('CoachList');
+		//$menu_items[] = $title;
 	} else {
 		$menu_items[] = '<a href="'.api_get_self().'?view=admin">'.get_lang('AdminInterface').'</a>';
 	}
 }
 
-if ($is_drh) {
+if ($is_drh || $_GET['display'] == 'yourstudents') {
 	$view = 'drh';	
 	$menu_items[] = get_lang('Students');
 	$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
@@ -202,7 +214,7 @@ if ($view == 'admin') {
 echo '</div>';
 echo '<h4>'.$title.'</h4>';
 
-if ($is_drh && $view == 'drh') {
+if (($is_drh && $view == 'drh') || $_GET['display'] == 'yourstudents') {
 	// get data for human resources manager
 	$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
 	$courses_of_the_platform = CourseManager :: get_real_course_list();	
@@ -300,7 +312,7 @@ if ($view == 'coach' || $view == 'drh') {
 		echo '
 		 <div class="report_section">
 			<h4>
-				<a href="student.php"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nb_students.')'.'</a>
+				<a href="student.php?display=yourstudents"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nb_students.')'.'</a>
 			</h4>
 			<table class="data_table">
 				<tr>
@@ -360,7 +372,7 @@ if ($view == 'coach' || $view == 'drh') {
 					</td>
 				</tr>
 			</table><br />					
-			<a href="student.php">'.get_lang('SeeStudentList').'</a>
+			<a href="student.php?display=yourstudents">'.get_lang('SeeStudentList').'</a>
 		 </div>';
 	}
 }
@@ -543,13 +555,11 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
 		$table -> setColAttributes(1, array('align' => 'center'));
 		$table -> setColAttributes(2, array('align' => 'center'));
 		$table -> setColAttributes(3, array('align' => 'center'));
-		$table -> display();
-		
-	}
-	
+		$table -> display();		
+	}	
 }
 
-if ($is_platform_admin && $view == 'admin') {
+if ($is_platform_admin && $view == 'admin' && $_GET['display'] != 'yourstudents') {
 	echo '<a href="'.api_get_self().'?view=admin&amp;display=coaches">'.get_lang('DisplayCoaches').'</a> | ';
 	echo '<a href="'.api_get_self().'?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';
 	if ($_GET['display'] == 'useroverview') {

+ 10 - 10
main/mySpace/session.php

@@ -10,7 +10,7 @@ $nameTools= 'Sessions';
 $language_file = array ('registration', 'index', 'trad4all', 'tracking', 'admin');
 $cidReset = true;
 
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
@@ -35,7 +35,6 @@ if (isset($_GET['export']) && $_GET['export'] == 'csv') {
 	$export_csv = true;
 }
 
-
 /*
 ===============================================================================
 	FUNCTION
@@ -65,7 +64,6 @@ function rsort_sessions($a, $b) {
 	}
 }
 
-
 /*
 ===============================================================================
 	MAIN CODE
@@ -78,13 +76,15 @@ if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
 	$id_coach = $_user['user_id'];
 }
 		
-if (api_is_drh()) {
+if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
 
 	$a_sessions = SessionManager::get_sessions_followed_by_drh($_user['user_id']);
 	
-	$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
-	$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
-	$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
+	if (!api_is_session_admin()) {
+		$menu_items[] = '<a href="index.php?view=drh_students&amp;display=yourstudents">'.get_lang('Students').'</a>';
+		$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
+		$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
+	}	
 	$menu_items[] = get_lang('Sessions');
 		
 	echo '<div class="actions-title" style ="font-size:10pt;">';
@@ -105,11 +105,11 @@ if (api_is_drh()) {
 	echo '<h4>'.get_lang('YourSessionsList').'</h4>';
 
 } else {		
-	if (api_is_platform_admin()) {
+	/*if (api_is_platform_admin()) {
 		$a_sessions = SessionManager::get_sessions_list();
-	} else {
+	} else {*/
 		$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
-	}	
+	//}	
 }
 
 $nb_sessions = count($a_sessions);

+ 7 - 8
main/mySpace/student.php

@@ -8,13 +8,12 @@
 $language_file = array ('registration', 'index', 'tracking', 'admin');
 $cidReset = true;
 
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
-
 $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
 if ($export_csv) {
 	ob_start();
@@ -104,16 +103,16 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
 	}
 	$sort_by_first_name = api_sort_by_first_name();
 	
-	if (api_is_drh()) {
-		
+	if (api_is_drh() || $_GET['display'] == 'yourstudents') {
+
 		$title = get_lang('YourStudents');
 		if (!isset($_GET['id_session'])) {
-			
+
 			if (isset($_GET['user_id'])) {
 				$user_id = intval($_GET['user_id']);
-				$user_info = api_get_user_info($user_id);				
+				$user_info = api_get_user_info($user_id);
 				$title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students');
-				$courses_by_teacher  = CourseManager::get_course_list_of_user_as_course_admin($user_id);								
+				$courses_by_teacher  = CourseManager::get_course_list_of_user_as_course_admin($user_id);				
 				$students_by_course = array();
 				if (!empty($courses_by_teacher)) {
 					foreach ($courses_by_teacher as $course) {
@@ -127,7 +126,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
 				}
 				$students = array_unique($students);				
 			} else {
-				$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));									
+				$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
 			}
 			
 			$courses_of_the_platform = CourseManager :: get_real_course_list();			

+ 6 - 6
main/mySpace/teachers.php

@@ -24,12 +24,12 @@ $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'))
 Display :: display_header($nameTools);
 
 $formateurs = array();
-if (api_is_drh()) {
+if (api_is_drh() || api_is_platform_admin()) {
 
 	// followed teachers by drh
 	$formateurs = UserManager::get_users_followed_by_drh($_user['user_id'], COURSEMANAGER);
 	 
-	$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
+	$menu_items[] = '<a href="index.php?view=drh_students&amp;display=yourstudents">'.get_lang('Students').'</a>';
 	$menu_items[] = get_lang('Trainers');
 	$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
 	$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
@@ -76,7 +76,7 @@ if (isset($_POST['export'])) {
 }
 $sort_by_first_name = api_sort_by_first_name();
 
-if (!api_is_drh()) {
+if (!api_is_drh() && !api_is_platform_admin()) {
 	$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
 	if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) {
 		$teacher_id = intval($_GET["teacher_id"]);
@@ -101,7 +101,7 @@ $a_last_week = get_last_week();
 $last_week 	 = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
 
 if ($is_western_name_order) {
-	echo '<table class="data_table"><tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th width="100px">'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
+	echo '<table class="data_table"><tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
 } else {
 	echo '<table class="data_table"><tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
 }
@@ -157,9 +157,9 @@ if (count($formateurs) > 0) {
 		$data[$user_id]["email"] = $email;
 
 		if ($is_western_name_order) {
-			echo '<tr class="'.$css_class.'"><td>'.$firstname.'</td><td>'.$lastname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
+			echo '<tr class="'.$css_class.'"><td>'.$firstname.'</td><td>'.$lastname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'&amp;display=yourstudents"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
 		} else {
-			echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td><td>'.$firstname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
+			echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td><td>'.$firstname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'&amp;display=yourstudents"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
 		}
 	}
 } else {

+ 2 - 1
main/tracking/courseLog.php

@@ -109,13 +109,14 @@ $tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 
 // breadcrumbs
 if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
-    $interbreadcrumb[] = array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
+  	$interbreadcrumb[] = array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
     $interbreadcrumb[] = array('url' => '../admin/session_list.php','name' => get_lang('SessionList'));
     $interbreadcrumb[] = array('url' => '../admin/resume_session.php?id_session='.$_SESSION['id_session'], 'name' => get_lang('SessionOverview'));
 }
 
 $view = (isset($_REQUEST['view']) ? $_REQUEST['view'] : '');
 
+
 $nameTools = get_lang('Tracking');
 
 // display the header

+ 29 - 9
plugin/dashboard/block_course/block_course.class.php

@@ -10,6 +10,7 @@
  * required files for getting data
  */
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 
@@ -22,20 +23,39 @@ class BlockCourse extends Block {
 
 	private $user_id;
 	private $courses;
-	private $path;
+	private $path;	
+	private $permission = array(DRH);
 
 	/**
 	 * Constructor
 	 */
-    public function __construct ($user_id) {
-    	$this->user_id = $user_id;    	
-    	if (api_is_platform_admin()) {
-    		$this->courses = CourseManager::get_real_course_list();
-    	} else if (api_is_drh()) {
-    		$this->courses = CourseManager::get_courses_followed_by_drh($user_id);	
-    	}
-    	$this->path = 'block_course';
+    public function __construct ($user_id) {    	
+    	$this->user_id 		= $user_id;
+    	$this->path 		= 'block_course';				
+		if ($this->is_block_visible_for_user($user_id)) {
+			/*if (api_is_platform_admin()) {
+				$this->courses = CourseManager::get_real_course_list();
+			} else  {*/
+				$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
+			//}
+		}
+    }
+    
+	/**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
+    
 
     /**
      * This method return content html containing information about courses and its position for showing it inside dashboard interface

+ 24 - 5
plugin/dashboard/block_session/block_session.class.php

@@ -10,6 +10,7 @@
  * required files for getting data
  */
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
@@ -24,18 +25,36 @@ class BlockSession extends Block {
     private $user_id;
 	private $sessions;
 	private $path;
+	private $permission = array(DRH, SESSIONADMIN);
 
 	/**
 	 * Constructor
 	 */
     public function __construct ($user_id) {
     	$this->user_id 	= $user_id;
-    	if (api_is_platform_admin()) {
-    		$this->sessions = SessionManager::get_sessions_list();
-    	} else if (api_is_drh()) {
-    		$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);	
-    	}    	
     	$this->path = 'block_session';
+    	if ($this->is_block_visible_for_user($user_id)) {
+    		/*if (api_is_platform_admin()) {
+	    		$this->sessions = SessionManager::get_sessions_list();
+	    	} else {*/
+	    		$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);	
+	    	//}
+    	}
+    }
+
+	/**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
 
     /**

+ 29 - 11
plugin/dashboard/block_student/block_student.class.php

@@ -29,18 +29,36 @@ class BlockStudent extends Block {
     private $user_id;
 	private $students;
 	private $path;
+	private $permission = array(DRH);
 
 	/**
 	 * Constructor
 	 */	
     public function __construct ($user_id) {    	
-    	$this->user_id  = $user_id;    	
-    	if (api_is_platform_admin()) {
-    		$this->students = UserManager::get_user_list(array('status' => STUDENT));
-    	} else if (api_is_drh()) {
-    		$this->students =  UserManager::get_users_followed_by_drh($user_id, STUDENT);
-    	}
-    	$this->path 	= 'block_student';    	  	
+    	$this->user_id  = $user_id;    
+    	$this->path 	= 'block_student';
+    	if ($this->is_block_visible_for_user($user_id)) {
+    		/*if (api_is_platform_admin()) {
+	    		$this->students = UserManager::get_user_list(array('status' => STUDENT));
+	    	} else {*/
+	    		$this->students =  UserManager::get_users_followed_by_drh($user_id, STUDENT);
+	    	//}	
+    	}	
+    }
+    
+    /**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
     
     /**
@@ -55,11 +73,11 @@ class BlockStudent extends Block {
     	$column = 1;
     	$data   = array();
 
-		if (api_is_platform_admin()) {
+		/*if (api_is_platform_admin()) {
 			$student_content_html = $this->get_students_content_html_for_platform_admin();
-		} else if (api_is_drh()) {
+		} else if (api_is_drh()) {*/
 			$student_content_html = $this->get_students_content_html_for_drh();
-		}
+		//}
 		
 		$html = '        		
 			            <li class="widget color-blue" id="intro">
@@ -226,7 +244,7 @@ class BlockStudent extends Block {
   		$content .= $students_table;
  		
  		if (count($students) > 0) {
-			$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=useroverview">'.get_lang('SeeMore').'</a></div>';
+			$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=yourstudents">'.get_lang('SeeMore').'</a></div>';
 		}
 		$content .= '</div>';		
   		return $content;	

+ 28 - 16
plugin/dashboard/block_student_graph/block_student_graph.class.php

@@ -32,18 +32,36 @@ class BlockStudentGraph extends Block {
     private $user_id;
 	private $students;
 	private $path;
+	private $permission = array(DRH);
 
 	/**
 	 * Constructor
 	 */	
     public function __construct ($user_id) {    	
-    	$this->user_id  = $user_id;    	
-    	if (api_is_platform_admin()) {
-    		$this->students = UserManager::get_user_list(array('status' => STUDENT));
-    	} else if (api_is_drh()) {
-    		$this->students =  UserManager::get_users_followed_by_drh($user_id, STUDENT);
-    	}
-    	$this->path 	= 'block_student_graph';    	  	
+    	$this->user_id  = $user_id;
+    	$this->path 	= 'block_student_graph';   
+    	if ($this->is_block_visible_for_user($user_id)) {
+    		/*if (api_is_platform_admin()) {
+	    		$this->students = UserManager::get_user_list(array('status' => STUDENT));
+	    	} else if (api_is_drh()) {*/
+	    		$this->students =  UserManager::get_users_followed_by_drh($user_id, STUDENT);
+	    	//}	
+    	} 	    	    	  	
+    }
+    
+    /**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
     
     /**
@@ -56,15 +74,9 @@ class BlockStudentGraph extends Block {
     	global $charset;
     	    	
     	$column = 1;
-    	$data   = array();
+    	$data   = array();		
+		$students_attendance_graph = $this->get_students_attendance_graph();
 
-		/*
-		if (api_is_platform_admin()) {
-			$student_content_html = $this->get_students_content_html_for_platform_admin();
-		} else if (api_is_drh()) {*/
-			$students_attendance_graph = $this->get_students_attendance_graph();
-		//}
-		
 		$html = '        		
 			            <li class="widget color-orange" id="intro">
 			                <div class="widget-head">
@@ -89,7 +101,7 @@ class BlockStudentGraph extends Block {
  	 * @return string  img html
  	 */
     public function get_students_attendance_graph() {
- 			
+	
  		$students = $this->students;
  		$attendance = new Attendance();
  		

+ 27 - 9
plugin/dashboard/block_teacher/block_teacher.class.php

@@ -23,18 +23,36 @@ class BlockTeacher extends Block {
     private $user_id;
     private $teachers;
     private $path;
+    private $permission = array(DRH);
 
 	/**
 	 * Controller
 	 */
     public function __construct ($user_id) {    	
     	$this->user_id  = $user_id;
-    	if (api_is_platform_admin()) {
-    		$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
-    	} else if (api_is_drh()) {
-    		$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
-    	}     	    	
-    	$this->path 	= 'block_teacher';  	
+    	$this->path 	= 'block_teacher';
+    	if ($this->is_block_visible_for_user($user_id)) {
+    		/*if (api_is_platform_admin()) {
+	    		$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
+	    	} else {*/
+	    		$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
+	    	//}	
+    	}
+    }
+    
+    /**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
     
     /**
@@ -49,11 +67,11 @@ class BlockTeacher extends Block {
     	$column = 1;
     	$data   = array();
 		
-		if (api_is_platform_admin()) {
+		/*if (api_is_platform_admin()) {
 			$teacher_content_html = $this->get_teachers_content_html_for_platform_admin();
-		} else if (api_is_drh()) {
+		} else if (api_is_drh()) {*/
 			$teacher_content_html = $this->get_teachers_content_html_for_drh();
-		}
+		//}
 		
 		$html = '        		
 			            <li class="widget color-blue" id="intro">

+ 29 - 9
plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@@ -28,18 +28,36 @@ class BlockTeacherGraph extends Block {
     private $user_id;
     private $teachers;
     private $path;
+    private $permission = array(DRH);
 
 	/**
 	 * Controller
 	 */
     public function __construct ($user_id) {    	
     	$this->user_id  = $user_id;
-    	if (api_is_platform_admin()) {
-    		$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
-    	} else if (api_is_drh()) {
-    		$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
-    	}     	    	
-    	$this->path 	= 'block_teacher_graph';  	
+    	$this->path 	= 'block_teacher_graph';
+    	if ($this->is_block_visible_for_user($user_id)) {
+    		if (api_is_platform_admin()) {
+	    		$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
+	    	} else {
+	    		$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
+	    	}	
+    	}
+    }
+    
+    /**
+	 * This method check if a user is allowed to see the block inside dashboard interface
+	 * @param	int		User id
+	 * @return	bool	Is block visible for user
+	 */    
+    public function is_block_visible_for_user($user_id) {	
+    	$user_info = api_get_user_info($user_id);
+		$user_status = $user_info['status'];
+		$is_block_visible_for_user = false;
+    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
+    		$is_block_visible_for_user = true;
+    	}    	
+    	return $is_block_visible_for_user;    	
     }
     
     /**
@@ -128,11 +146,13 @@ class BlockTeacherGraph extends Block {
 			}
 	
 			$last_week 	 = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
-			foreach ($a_last_week as &$weekday) {
-				$weekday = date('d/m',$weekday);
+			
+			$days_on_week = array();			
+			foreach ($a_last_week as $weekday) {
+				$days_on_week[] = date('d/m',$weekday);
 			}
 					
-			$data_set->AddPoint($a_last_week,"Days");						
+			$data_set->AddPoint($days_on_week,"Days");						
 			$data_set->SetXAxisName($last_week);
 			$data_set->SetYAxisName(get_lang('Minutes'));