Преглед изворни кода

Feature #347 - In some previously missed places: Removing the parameters __FILE__ and __LINE__ in the Database::query() calls.

Ivan Tcholakov пре 15 година
родитељ
комит
65a77f5091

+ 25 - 25
main/admin/dashboard_add_courses_to_user.php

@@ -3,8 +3,8 @@
 
 
 /**
 /**
 ==============================================================================
 ==============================================================================
-*	Interface for assigning courses to Human Resources Manager 
-*	@package chamilo.admin 	
+*	Interface for assigning courses to Human Resources Manager
+*	@package chamilo.admin
 ==============================================================================
 ==============================================================================
 */
 */
 
 
@@ -52,8 +52,8 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 }
 
 
-if (!api_is_platform_admin()) {	
-	api_not_allowed(true);	
+if (!api_is_platform_admin()) {
+	api_not_allowed(true);
 }
 }
 
 
 function search_courses($needle,$type) {
 function search_courses($needle,$type) {
@@ -67,23 +67,23 @@ function search_courses($needle,$type) {
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 
 
 		$assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
 		$assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
-		$assigned_courses_code = array_keys($assigned_courses_to_hrm);		
+		$assigned_courses_code = array_keys($assigned_courses_to_hrm);
 		foreach ($assigned_courses_code as &$value) {
 		foreach ($assigned_courses_code as &$value) {
 			$value = "'".$value."'";
 			$value = "'".$value."'";
 		}
 		}
-		$without_assigned_courses = '';	
+		$without_assigned_courses = '';
 		if (count($assigned_courses_code) > 0) {
 		if (count($assigned_courses_code) > 0) {
 			$without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
 			$without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
 		}
 		}
-		
+
 		$sql = "SELECT c.code, c.title FROM $tbl_course c
 		$sql = "SELECT c.code, c.title FROM $tbl_course c
 				WHERE  c.code LIKE '$needle%' $without_assigned_courses ";
 				WHERE  c.code LIKE '$needle%' $without_assigned_courses ";
-		$rs	= Database::query($sql,__FILE__,__LINE__);
-		
+		$rs	= Database::query($sql);
+
 		$course_list = array();
 		$course_list = array();
 		$return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
 		$return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
 		while($course = Database :: fetch_array($rs)) {
 		while($course = Database :: fetch_array($rs)) {
-			$course_list[] = $course['id'];						
+			$course_list[] = $course['id'];
 			$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'],ENT_QUOTES).'">'.$course['title'].' ('.$course['code'].')</option>';
 			$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'],ENT_QUOTES).'">'.$course['title'].' ('.$course['code'].')</option>';
 		}
 		}
 		$return .= '</select>';
 		$return .= '</select>';
@@ -96,7 +96,7 @@ function search_courses($needle,$type) {
 $xajax -> processRequests();
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 $htmlHeadXtra[] = '
-<script type="text/javascript">	
+<script type="text/javascript">
 <!--
 <!--
 function moveItem(origin , destination) {
 function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
@@ -134,7 +134,7 @@ function valide() {
 	var options = document.getElementById("destination").options;
 	var options = document.getElementById("destination").options;
 	for (i = 0 ; i<options.length ; i++) {
 	for (i = 0 ; i<options.length ; i++) {
 		options[i].selected = true;
 		options[i].selected = true;
-	}		
+	}
 	document.forms.formulaire.submit();
 	document.forms.formulaire.submit();
 }
 }
 function remove_item(origin) {
 function remove_item(origin) {
@@ -145,7 +145,7 @@ function remove_item(origin) {
 		}
 		}
 	}
 	}
 }
 }
--->	
+-->
 </script>';
 </script>';
 
 
 $formSent=0;
 $formSent=0;
@@ -153,12 +153,12 @@ $errorMsg = $firstLetterCourse = '';
 $UserList = array();
 $UserList = array();
 
 
 $msg = '';
 $msg = '';
-if (intval($_POST['formSent']) == 1) {		
+if (intval($_POST['formSent']) == 1) {
 	$courses_list = $_POST['CoursesList'];
 	$courses_list = $_POST['CoursesList'];
 	$affected_rows = CourseManager::suscribe_courses_to_hr_manager($hrm_id,$courses_list);
 	$affected_rows = CourseManager::suscribe_courses_to_hr_manager($hrm_id,$courses_list);
 	if ($affected_rows)	{
 	if ($affected_rows)	{
 		$msg = get_lang('AssignedCoursesHasBeenUpdatedSuccesslly');
 		$msg = get_lang('AssignedCoursesHasBeenUpdatedSuccesslly');
-	}	
+	}
 }
 }
 
 
 // display the dokeos header
 // display the dokeos header
@@ -168,12 +168,12 @@ echo '<div class="row"><div class="form_header">'.get_lang('AssignedCoursesTo').
 // *******************
 // *******************
 
 
 $assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
 $assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
-$assigned_courses_code = array_keys($assigned_courses_to_hrm);		
+$assigned_courses_code = array_keys($assigned_courses_to_hrm);
 foreach ($assigned_courses_code as &$value) {
 foreach ($assigned_courses_code as &$value) {
 	$value = "'".$value."'";
 	$value = "'".$value."'";
 }
 }
 
 
-$without_assigned_courses = '';	
+$without_assigned_courses = '';
 if (count($assigned_courses_code) > 0) {
 if (count($assigned_courses_code) > 0) {
 	$without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
 	$without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")";
 }
 }
@@ -186,7 +186,7 @@ if (isset($_POST['firstLetterCourse'])) {
 
 
 $sql 	= " SELECT c.code, c.title FROM $tbl_course c
 $sql 	= " SELECT c.code, c.title FROM $tbl_course c
 			WHERE  c.code LIKE '$needle' $without_assigned_courses ";
 			WHERE  c.code LIKE '$needle' $without_assigned_courses ";
-$result	= Database::query($sql,__FILE__,__LINE__);
+$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 $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
@@ -199,8 +199,8 @@ if(!empty($msg)) {
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <tr>
 <tr>
 	<td align="left"></td>
 	<td align="left"></td>
-	<td align="left"></td>	
-	<td width="" align="center"> &nbsp;	</td>	
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
 </tr>
 </tr>
 <tr>
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('CoursesListInPlatform') ?> :</b></td>
   <td width="45%" align="center"><b><?php echo get_lang('CoursesListInPlatform') ?> :</b></td>
@@ -214,7 +214,7 @@ if(!empty($msg)) {
      <select name="firstLetterCourse" onchange = "xajax_search_courses(this.value,'multiple')">
      <select name="firstLetterCourse" onchange = "xajax_search_courses(this.value,'multiple')">
       <option value="%">--</option>
       <option value="%">--</option>
       <?php
       <?php
-      echo Display :: get_alphabet_options($_POST['firstLetterCourse']);      
+      echo Display :: get_alphabet_options($_POST['firstLetterCourse']);
       ?>
       ?>
      </select>
      </select>
 </td>
 </td>
@@ -225,13 +225,13 @@ if(!empty($msg)) {
 	<div id="ajax_list_courses_multiple">
 	<div id="ajax_list_courses_multiple">
 	<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">
 	<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">
 	<?php
 	<?php
-	while ($enreg = Database::fetch_array($result)) {		
+	while ($enreg = Database::fetch_array($result)) {
 	?>
 	?>
 		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"';?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
 		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"';?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
 	<?php } ?>
 	<?php } ?>
 	</select></div>
 	</select></div>
   </td>
   </td>
-  
+
   <td width="10%" valign="middle" align="center">
   <td width="10%" valign="middle" align="center">
   <?php
   <?php
   if ($ajax_search) {
   if ($ajax_search) {
@@ -257,10 +257,10 @@ if(!empty($msg)) {
   <select id='destination' name="CoursesList[]" multiple="multiple" size="20" style="width:320px;">
   <select id='destination' name="CoursesList[]" multiple="multiple" size="20" style="width:320px;">
 	<?php
 	<?php
 	if (is_array($assigned_courses_to_hrm)) {
 	if (is_array($assigned_courses_to_hrm)) {
-		foreach($assigned_courses_to_hrm as $enreg) {			
+		foreach($assigned_courses_to_hrm as $enreg) {
 	?>
 	?>
 		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"'; ?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
 		<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'],ENT_QUOTES).'"'; ?>><?php echo $enreg['title'].' ('.$enreg['code'].')'; ?></option>
-	<?php } 
+	<?php }
 	}?>
 	}?>
   </select></td>
   </select></td>
 </tr>
 </tr>

+ 31 - 31
main/admin/dashboard_add_sessions_to_user.php

@@ -3,8 +3,8 @@
 
 
 /**
 /**
 ==============================================================================
 ==============================================================================
-*	Interface for assigning sessions to Human Resources Manager 
-*	@package chamilo.admin 	
+*	Interface for assigning sessions to Human Resources Manager
+*	@package chamilo.admin
 ==============================================================================
 ==============================================================================
 */
 */
 
 
@@ -52,8 +52,8 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 }
 
 
-if (!api_is_platform_admin()) {	
-	api_not_allowed(true);	
+if (!api_is_platform_admin()) {
+	api_not_allowed(true);
 }
 }
 
 
 function search_sessions($needle,$type) {
 function search_sessions($needle,$type) {
@@ -68,25 +68,25 @@ function search_sessions($needle,$type) {
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 		$needle = api_convert_encoding($needle, $charset, 'utf-8');
 
 
 		$assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
 		$assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
-		
-		$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);		
-				
-		$without_assigned_sessions = '';	
+
+		$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
+
+		$without_assigned_sessions = '';
 		if (count($assigned_sessions_id) > 0) {
 		if (count($assigned_sessions_id) > 0) {
 			$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
 			$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
 		}
 		}
-		
+
 		$sql = "SELECT s.id, s.name FROM $tbl_session s
 		$sql = "SELECT s.id, s.name FROM $tbl_session s
 				WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
 				WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
-				
-		 	
-				
-		$rs	= Database::query($sql,__FILE__,__LINE__);
-		
+
+
+
+		$rs	= Database::query($sql);
+
 		$course_list = array();
 		$course_list = array();
 		$return .= '<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">';
 		$return .= '<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">';
 		while($session = Database :: fetch_array($rs)) {
 		while($session = Database :: fetch_array($rs)) {
-			$session_list[] = $session['id'];						
+			$session_list[] = $session['id'];
 			$return .= '<option value="'.$session['id'].'" title="'.htmlspecialchars($session['name'],ENT_QUOTES).'">'.$session['name'].'</option>';
 			$return .= '<option value="'.$session['id'].'" title="'.htmlspecialchars($session['name'],ENT_QUOTES).'">'.$session['name'].'</option>';
 		}
 		}
 		$return .= '</select>';
 		$return .= '</select>';
@@ -99,7 +99,7 @@ function search_sessions($needle,$type) {
 $xajax -> processRequests();
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 $htmlHeadXtra[] = '
-<script type="text/javascript">	
+<script type="text/javascript">
 <!--
 <!--
 function moveItem(origin , destination) {
 function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
@@ -137,7 +137,7 @@ function valide() {
 	var options = document.getElementById("destination").options;
 	var options = document.getElementById("destination").options;
 	for (i = 0 ; i<options.length ; i++) {
 	for (i = 0 ; i<options.length ; i++) {
 		options[i].selected = true;
 		options[i].selected = true;
-	}		
+	}
 	document.forms.formulaire.submit();
 	document.forms.formulaire.submit();
 }
 }
 function remove_item(origin) {
 function remove_item(origin) {
@@ -148,7 +148,7 @@ function remove_item(origin) {
 		}
 		}
 	}
 	}
 }
 }
--->	
+-->
 </script>';
 </script>';
 
 
 $formSent=0;
 $formSent=0;
@@ -156,12 +156,12 @@ $errorMsg = $firstLetterSession = '';
 $UserList = array();
 $UserList = array();
 
 
 $msg = '';
 $msg = '';
-if (intval($_POST['formSent']) == 1) {		
-	$sessions_list = $_POST['SessionsList'];	
+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($hrm_id,$sessions_list);
 	if ($affected_rows)	{
 	if ($affected_rows)	{
 		$msg = get_lang('AssignedSessionsHasBeenUpdatedSuccesslly');
 		$msg = get_lang('AssignedSessionsHasBeenUpdatedSuccesslly');
-	}	
+	}
 }
 }
 
 
 // display the dokeos header
 // display the dokeos header
@@ -171,8 +171,8 @@ echo '<div class="row"><div class="form_header">'.get_lang('AssignedSessionsTo')
 // *******************
 // *******************
 
 
 $assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
 $assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
-$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);		
-$without_assigned_sessions = '';	
+$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
+$without_assigned_sessions = '';
 if (count($assigned_sessions_id) > 0) {
 if (count($assigned_sessions_id) > 0) {
 	$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
 	$without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")";
 }
 }
@@ -185,7 +185,7 @@ if (isset($_POST['firstLetterSession'])) {
 
 
 $sql 	= " SELECT s.id, s.name FROM $tbl_session s
 $sql 	= " SELECT s.id, s.name FROM $tbl_session s
 			WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
 			WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
-$result	= Database::query($sql,__FILE__,__LINE__);
+$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 $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
 <input type="hidden" name="formSent" value="1" />
 <input type="hidden" name="formSent" value="1" />
@@ -197,8 +197,8 @@ if(!empty($msg)) {
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <tr>
 <tr>
 	<td align="left"></td>
 	<td align="left"></td>
-	<td align="left"></td>	
-	<td width="" align="center"> &nbsp;	</td>	
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
 </tr>
 </tr>
 <tr>
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('SessionsListInPlatform') ?> :</b></td>
   <td width="45%" align="center"><b><?php echo get_lang('SessionsListInPlatform') ?> :</b></td>
@@ -212,7 +212,7 @@ if(!empty($msg)) {
      <select name="firstLetterSession" onchange = "xajax_search_sessions(this.value,'multiple')">
      <select name="firstLetterSession" onchange = "xajax_search_sessions(this.value,'multiple')">
       <option value="%">--</option>
       <option value="%">--</option>
       <?php
       <?php
-      echo Display :: get_alphabet_options($_POST['firstLetterSession']);      
+      echo Display :: get_alphabet_options($_POST['firstLetterSession']);
       ?>
       ?>
      </select>
      </select>
 </td>
 </td>
@@ -223,13 +223,13 @@ if(!empty($msg)) {
 	<div id="ajax_list_sessions_multiple">
 	<div id="ajax_list_sessions_multiple">
 	<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">
 	<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">
 	<?php
 	<?php
-	while ($enreg = Database::fetch_array($result)) {		
+	while ($enreg = Database::fetch_array($result)) {
 	?>
 	?>
 		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"';?>><?php echo $enreg['name']; ?></option>
 		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"';?>><?php echo $enreg['name']; ?></option>
 	<?php } ?>
 	<?php } ?>
 	</select></div>
 	</select></div>
   </td>
   </td>
-  
+
   <td width="10%" valign="middle" align="center">
   <td width="10%" valign="middle" align="center">
   <?php
   <?php
   if ($ajax_search) {
   if ($ajax_search) {
@@ -255,10 +255,10 @@ if(!empty($msg)) {
   <select id='destination' name="SessionsList[]" multiple="multiple" size="20" style="width:320px;">
   <select id='destination' name="SessionsList[]" multiple="multiple" size="20" style="width:320px;">
 	<?php
 	<?php
 	if (is_array($assigned_sessions_to_hrm)) {
 	if (is_array($assigned_sessions_to_hrm)) {
-		foreach($assigned_sessions_to_hrm as $enreg) {			
+		foreach($assigned_sessions_to_hrm as $enreg) {
 	?>
 	?>
 		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; ?>><?php echo $enreg['name'] ?></option>
 		<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; ?>><?php echo $enreg['name'] ?></option>
-	<?php } 
+	<?php }
 	}?>
 	}?>
   </select></td>
   </select></td>
 </tr>
 </tr>

+ 18 - 18
main/admin/dashboard_add_users_to_user.php

@@ -3,8 +3,8 @@
 
 
 /**
 /**
 ==============================================================================
 ==============================================================================
-*	Interface for assigning users to Human Resources Manager 
-*	@package chamilo.admin 	
+*	Interface for assigning users to Human Resources Manager
+*	@package chamilo.admin
 ==============================================================================
 ==============================================================================
 */
 */
 
 
@@ -51,8 +51,8 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 }
 
 
-if (!api_is_platform_admin()) {	
-	api_not_allowed(true);	
+if (!api_is_platform_admin()) {
+	api_not_allowed(true);
 }
 }
 
 
 function search_users($needle,$type) {
 function search_users($needle,$type) {
@@ -71,16 +71,16 @@ function search_users($needle,$type) {
 		if (count($assigned_users_id) > 0) {
 		if (count($assigned_users_id) > 0) {
 			$without_assigned_users = " AND user_id NOT IN(".implode(',',$assigned_users_id).")";
 			$without_assigned_users = " AND user_id NOT IN(".implode(',',$assigned_users_id).")";
 		}
 		}
-		
+
 		$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
 		$sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
 				WHERE  ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'  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 user_id NOT IN ($user_anonymous, $current_user_id, $hrm_id) $without_assigned_users";
-		$rs	= Database::query($sql,__FILE__,__LINE__);
+		$rs	= Database::query($sql);
 
 
 		$user_list = array();
 		$user_list = array();
 		$return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
 		$return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
 		while($user = Database :: fetch_array($rs)) {
 		while($user = Database :: fetch_array($rs)) {
 			$user_list[] = $user['id'];
 			$user_list[] = $user['id'];
-			$person_name = api_get_person_name($user['firstname'], $user['lastname']);			
+			$person_name = api_get_person_name($user['firstname'], $user['lastname']);
 			$return .= '<option value="'.$user['user_id'].'" title="'.htmlspecialchars($person_name,ENT_QUOTES).'">'.$person_name.' ('.$user['username'].')</option>';
 			$return .= '<option value="'.$user['user_id'].'" title="'.htmlspecialchars($person_name,ENT_QUOTES).'">'.$person_name.' ('.$user['username'].')</option>';
 		}
 		}
 		$return .= '</select>';
 		$return .= '</select>';
@@ -93,7 +93,7 @@ function search_users($needle,$type) {
 $xajax -> processRequests();
 $xajax -> processRequests();
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 $htmlHeadXtra[] = '
-<script type="text/javascript">	
+<script type="text/javascript">
 <!--
 <!--
 function moveItem(origin , destination) {
 function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
@@ -131,7 +131,7 @@ function valide() {
 	var options = document.getElementById("destination").options;
 	var options = document.getElementById("destination").options;
 	for (i = 0 ; i<options.length ; i++) {
 	for (i = 0 ; i<options.length ; i++) {
 		options[i].selected = true;
 		options[i].selected = true;
-	}		
+	}
 	document.forms.formulaire.submit();
 	document.forms.formulaire.submit();
 }
 }
 function remove_item(origin) {
 function remove_item(origin) {
@@ -142,7 +142,7 @@ function remove_item(origin) {
 		}
 		}
 	}
 	}
 }
 }
--->	
+-->
 </script>';
 </script>';
 
 
 $formSent=0;
 $formSent=0;
@@ -150,7 +150,7 @@ $errorMsg = $firstLetterUser = '';
 $UserList = array();
 $UserList = array();
 
 
 $msg = '';
 $msg = '';
-if (intval($_POST['formSent']) == 1) {	
+if (intval($_POST['formSent']) == 1) {
 	$user_list = $_POST['UsersList'];
 	$user_list = $_POST['UsersList'];
 	$affected_rows = UserManager::suscribe_users_to_hr_manager($hrm_id,$user_list);
 	$affected_rows = UserManager::suscribe_users_to_hr_manager($hrm_id,$user_list);
 	if ($affected_rows)	{
 	if ($affected_rows)	{
@@ -170,7 +170,7 @@ $assigned_users_id = array_keys($assigned_users_to_hrm);
 $without_assigned_users = '';
 $without_assigned_users = '';
 if (count($assigned_users_id) > 0) {
 if (count($assigned_users_id) > 0) {
 	$without_assigned_users = " user_id NOT IN(".implode(',',$assigned_users_id).") AND ";
 	$without_assigned_users = " user_id NOT IN(".implode(',',$assigned_users_id).") AND ";
-} 
+}
 
 
 $search_user = '';
 $search_user = '';
 if (isset($_POST['firstLetterUser'])) {
 if (isset($_POST['firstLetterUser'])) {
@@ -180,7 +180,7 @@ if (isset($_POST['firstLetterUser'])) {
 
 
 $sql = "SELECT user_id, username, lastname, firstname FROM $tbl_user user
 $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) $search_user ";
 		WHERE  $without_assigned_users user_id NOT IN ($user_anonymous, $current_user_id, $hrm_id) $search_user ";
-$result	= Database::query($sql,__FILE__,__LINE__);
+$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 $hrm_id ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
@@ -193,8 +193,8 @@ if(!empty($msg)) {
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">
 <tr>
 <tr>
 	<td align="left"></td>
 	<td align="left"></td>
-	<td align="left"></td>	
-	<td width="" align="center"> &nbsp;	</td>	
+	<td align="left"></td>
+	<td width="" align="center"> &nbsp;	</td>
 </tr>
 </tr>
 <tr>
 <tr>
   <td width="45%" align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b></td>
   <td width="45%" align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b></td>
@@ -208,7 +208,7 @@ if(!empty($msg)) {
      <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')">
      <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')">
       <option value="%">--</option>
       <option value="%">--</option>
       <?php
       <?php
-      echo Display :: get_alphabet_options($_POST['firstLetterUser']);      
+      echo Display :: get_alphabet_options($_POST['firstLetterUser']);
       ?>
       ?>
      </select>
      </select>
 </td>
 </td>
@@ -226,7 +226,7 @@ if(!empty($msg)) {
 	<?php } ?>
 	<?php } ?>
 	</select></div>
 	</select></div>
   </td>
   </td>
-  
+
   <td width="10%" valign="middle" align="center">
   <td width="10%" valign="middle" align="center">
   <?php
   <?php
   if ($ajax_search) {
   if ($ajax_search) {
@@ -256,7 +256,7 @@ if(!empty($msg)) {
 			$person_name = api_get_person_name($enreg['firstname'], $enreg['lastname']);
 			$person_name = api_get_person_name($enreg['firstname'], $enreg['lastname']);
 	?>
 	?>
 		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"'; ?>><?php echo $person_name.' ('.$enreg['username'].')'; ?></option>
 		<option value="<?php echo $enreg['user_id']; ?>" <?php echo 'title="'.htmlspecialchars($person_name,ENT_QUOTES).'"'; ?>><?php echo $person_name.' ('.$enreg['username'].')'; ?></option>
-	<?php } 
+	<?php }
 	}?>
 	}?>
   </select></td>
   </select></td>
 </tr>
 </tr>

+ 31 - 31
main/inc/lib/course.lib.php

@@ -2143,87 +2143,87 @@ class CourseManager {
 		return $row[0];
 		return $row[0];
 	}
 	}
 
 
-/**
+	/**
 	  * Subscribes courses to human resource manager (Dashboard feature)
 	  * Subscribes courses to human resource manager (Dashboard feature)
 	  *	@param	int 		Human Resource Manager id
 	  *	@param	int 		Human Resource Manager id
 	  * @param	array		Courses code
 	  * @param	array		Courses code
-	  * @param	int			Relation type 
+	  * @param	int			Relation type
 	  **/
 	  **/
 	public static function suscribe_courses_to_hr_manager($hr_manager_id,$courses_list) {
 	public static function suscribe_courses_to_hr_manager($hr_manager_id,$courses_list) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
 		$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
 
 
-		$hr_manager_id = intval($hr_manager_id);		
-		$affected_rows = 0;			
-		
-		//Deleting assigned courses to hrm_id			
+		$hr_manager_id = intval($hr_manager_id);
+		$affected_rows = 0;
+
+		//Deleting assigned courses to hrm_id
 	   	$sql = "SELECT course_code FROM $tbl_course_rel_user WHERE user_id = $hr_manager_id AND relation_type = 1";
 	   	$sql = "SELECT course_code FROM $tbl_course_rel_user WHERE user_id = $hr_manager_id AND relation_type = 1";
-		$result = Database::query($sql,__FILE__,__LINE__);
-		
+		$result = Database::query($sql);
+
 		if (Database::num_rows($result) > 0) {
 		if (Database::num_rows($result) > 0) {
 			$sql = "DELETE FROM $tbl_course_rel_user WHERE user_id = $hr_manager_id AND relation_type = 1 ";
 			$sql = "DELETE FROM $tbl_course_rel_user WHERE user_id = $hr_manager_id AND relation_type = 1 ";
-			Database::query($sql,__FILE__,__LINE__);					
+			Database::query($sql);
 		}
 		}
-		
+
 		// inserting new courses list
 		// inserting new courses list
 		if (is_array($courses_list)) {
 		if (is_array($courses_list)) {
 			foreach ($courses_list as $course_code) {
 			foreach ($courses_list as $course_code) {
 				$course_code = Database::escape_string($course_code);
 				$course_code = Database::escape_string($course_code);
 				$insert_sql = "INSERT IGNORE INTO $tbl_course_rel_user(course_code, user_id, relation_type) VALUES('$course_code', $hr_manager_id, '1')";
 				$insert_sql = "INSERT IGNORE INTO $tbl_course_rel_user(course_code, user_id, relation_type) VALUES('$course_code', $hr_manager_id, '1')";
-				Database::query($insert_sql,__FILE__,__LINE__);
+				Database::query($insert_sql);
 				$affected_rows = Database::affected_rows();
 				$affected_rows = Database::affected_rows();
-			}			
+			}
 		}
 		}
 		return $affected_rows;
 		return $affected_rows;
-		
+
 	}
 	}
-	
+
 	/**
 	/**
 	 * get assigned courses to human resources manager
 	 * get assigned courses to human resources manager
 	 * @param int 		human resources manager id
 	 * @param int 		human resources manager id
-	 * @return array	assigned courses  
+	 * @return array	assigned courses
 	 */
 	 */
 	public static function get_assigned_courses_to_hr_manager($hr_manager_id) {
 	public static function get_assigned_courses_to_hr_manager($hr_manager_id) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course 			= 	Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
 		$tbl_course_rel_user 	= 	Database::get_main_table(TABLE_MAIN_COURSE_USER);
-		
-		$hr_manager_id = intval($hr_manager_id);		
-		
+
+		$hr_manager_id = intval($hr_manager_id);
+
 		$assigned_courses_to_hrm = array();
 		$assigned_courses_to_hrm = array();
-		
-		/* @todo relation_type field should be changed by status = 4(DRH) */		
+
+		/* @todo relation_type field should be changed by status = 4(DRH) */
 		$sql = "SELECT * FROM $tbl_course c
 		$sql = "SELECT * FROM $tbl_course c
 				 INNER JOIN $tbl_course_rel_user cru ON cru.course_code = c.code AND cru.user_id = '$hr_manager_id' AND relation_type = '1'";
 				 INNER JOIN $tbl_course_rel_user cru ON cru.course_code = c.code AND cru.user_id = '$hr_manager_id' AND relation_type = '1'";
-				 
+
 		$rs_assigned_courses = Database::query($sql);
 		$rs_assigned_courses = Database::query($sql);
 		if (Database::num_rows($rs_assigned_courses) > 0) {
 		if (Database::num_rows($rs_assigned_courses) > 0) {
 			while ($row_assigned_courses = Database::fetch_array($rs_assigned_courses))	{
 			while ($row_assigned_courses = Database::fetch_array($rs_assigned_courses))	{
-				$assigned_courses_to_hrm[$row_assigned_courses['code']] = $row_assigned_courses; 
+				$assigned_courses_to_hrm[$row_assigned_courses['code']] = $row_assigned_courses;
 			}
 			}
-		}		
-		return $assigned_courses_to_hrm;			
+		}
+		return $assigned_courses_to_hrm;
 	}
 	}
-	
+
 	/**
 	/**
 	 * check if a course is special (autoregister)
 	 * check if a course is special (autoregister)
 	 * @param string course code
 	 * @param string course code
 	 */
 	 */
 	public static function is_special_course($course_code){
 	public static function is_special_course($course_code){
 		$tbl_course_field_value		= Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
 		$tbl_course_field_value		= Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
-		$tbl_course_field 			= Database::get_main_table(TABLE_MAIN_COURSE_FIELD);		
-		$is_special = false;	
+		$tbl_course_field 			= Database::get_main_table(TABLE_MAIN_COURSE_FIELD);
+		$is_special = false;
 		$sql = "SELECT course_code FROM $tbl_course_field_value tcfv INNER JOIN $tbl_course_field tcf ON " .
 		$sql = "SELECT course_code FROM $tbl_course_field_value tcfv INNER JOIN $tbl_course_field tcf ON " .
 				" tcfv.field_id =  tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 AND course_code='$course_code'";
 				" tcfv.field_id =  tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 AND course_code='$course_code'";
 		$result = Database::query($sql);
 		$result = Database::query($sql);
 		$num_rows = Database::num_rows($result);
 		$num_rows = Database::num_rows($result);
 		if ($num_rows > 0){
 		if ($num_rows > 0){
 			$is_special = true;
 			$is_special = true;
-			
-		}		
+
+		}
 		return $is_special;
 		return $is_special;
 
 
 	}
 	}

+ 7 - 7
main/inc/lib/course_description.lib.php

@@ -72,30 +72,30 @@ class CourseDescription
 	}
 	}
 
 
 	/**
 	/**
-     * Get all data by description and session id, 
+     * Get all data by description and session id,
      * first you must set session_id property with the object CourseDescription
      * first you must set session_id property with the object CourseDescription
      * @param 	int	description type
      * @param 	int	description type
      * @param   string  course code (optional)
      * @param   string  course code (optional)
      * @return array
      * @return array
      */
      */
 	public function get_data_by_description_type($description_type, $course_code = '') {
 	public function get_data_by_description_type($description_type, $course_code = '') {
-		
+
 		$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
 		$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
-		
+
 		if (!empty($course_code)) {
 		if (!empty($course_code)) {
 			$course_info = api_get_course_info($course_code);
 			$course_info = api_get_course_info($course_code);
 			$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION, $course_info['dbName']);
 			$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION, $course_info['dbName']);
 		}
 		}
 
 
 		$sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' AND session_id='".$this->session_id."'";
 		$sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' AND session_id='".$this->session_id."'";
-		$rs = Database::query($sql, __FILE__, __LINE__);				
-		$data = array();		
+		$rs = Database::query($sql);
+		$data = array();
 		if ($description = Database::fetch_array($rs)) {
 		if ($description = Database::fetch_array($rs)) {
 			$data['description_title']	 = $description['title'];
 			$data['description_title']	 = $description['title'];
 			$data['description_content'] = $description['content'];
 			$data['description_content'] = $description['content'];
 			$data['progress'] 			 = $description['progress'];
 			$data['progress'] 			 = $description['progress'];
-		}						
-		return $data;		
+		}
+		return $data;
 	}
 	}
 
 
 	/**
 	/**

+ 140 - 140
main/inc/lib/dashboard.lib.php

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

+ 115 - 115
main/inc/lib/sessionmanager.lib.php

@@ -22,7 +22,7 @@ class SessionManager {
     	$t = Database::get_main_table(TABLE_MAIN_SESSION);
     	$t = Database::get_main_table(TABLE_MAIN_SESSION);
         if ($id != strval(intval($id))) { return array(); }
         if ($id != strval(intval($id))) { return array(); }
         $s = "SELECT * FROM $t WHERE id = $id";
         $s = "SELECT * FROM $t WHERE id = $id";
-        $r = Database::query($s,__FILE__,__LINE__);
+        $r = Database::query($s);
         if (Database::num_rows($r) != 1) { return array(); }
         if (Database::num_rows($r) != 1) { return array(); }
         return Database::fetch_array($r,'ASSOC');
         return Database::fetch_array($r,'ASSOC');
     }
     }
@@ -60,7 +60,7 @@ class SessionManager {
 		$tbl_session	= Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session	= Database::get_main_table(TABLE_MAIN_SESSION);
 
 
 		$sql = 'SELECT user_id FROM '.$tbl_user.' WHERE username="'.Database::escape_string($coach_username).'"';
 		$sql = 'SELECT user_id FROM '.$tbl_user.' WHERE username="'.Database::escape_string($coach_username).'"';
-		$rs = Database::query($sql, __FILE__, __LINE__);
+		$rs = Database::query($sql);
 		$id_coach = Database::result($rs,0,'user_id');
 		$id_coach = Database::result($rs,0,'user_id');
 
 
 		if (empty($nolimit)) {
 		if (empty($nolimit)) {
@@ -94,7 +94,7 @@ class SessionManager {
 			} else {
 			} else {
 				$sql_insert = "INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id,visibility)
 				$sql_insert = "INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id,visibility)
 							   VALUES('".Database::escape_string($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.", ".$id_session_category.", ".$id_visibility.")";
 							   VALUES('".Database::escape_string($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.", ".$id_session_category.", ".$id_visibility.")";
-				Database::query($sql_insert ,__FILE__,__LINE__);
+				Database::query($sql_insert);
 				$id_session=Database::insert_id();
 				$id_session=Database::insert_id();
 
 
 				// add event to system log
 				// add event to system log
@@ -189,11 +189,11 @@ class SessionManager {
 						session_category_id = ".$id_session_category." ,
 						session_category_id = ".$id_session_category." ,
 						visibility= ".$id_visibility."
 						visibility= ".$id_visibility."
 					  WHERE id='$id'";
 					  WHERE id='$id'";
-				Database::query($sql,__FILE__,__LINE__);
+				Database::query($sql);
 				/*$sqlu = "UPDATE $tbl_session_rel_course " .
 				/*$sqlu = "UPDATE $tbl_session_rel_course " .
 						  " SET id_coach='$id_coach'" .
 						  " SET id_coach='$id_coach'" .
 						  " WHERE id_session='$id'";
 						  " WHERE id_session='$id'";
-				Database::query($sqlu,__FILE__,__LINE__);*/
+				Database::query($sqlu);*/
 				return $id;
 				return $id;
 			}
 			}
 		}
 		}
@@ -221,15 +221,15 @@ class SessionManager {
 
 
 		if (!api_is_platform_admin() && !$from_ws) {
 		if (!api_is_platform_admin() && !$from_ws) {
 			$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_checked;
 			$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_checked;
-			$rs = Database::query($sql,__FILE__,__LINE__);
+			$rs = Database::query($sql);
 			if (Database::result($rs,0,0)!=$_user['user_id']) {
 			if (Database::result($rs,0,0)!=$_user['user_id']) {
 				api_not_allowed(true);
 				api_not_allowed(true);
 			}
 			}
 		}
 		}
-		Database::query("DELETE FROM $tbl_session WHERE id IN($id_checked)",__FILE__,__LINE__);
-		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session IN($id_checked)",__FILE__,__LINE__);
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session IN($id_checked)",__FILE__,__LINE__);
-		Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session IN($id_checked)",__FILE__,__LINE__);
+		Database::query("DELETE FROM $tbl_session WHERE id IN($id_checked)");
+		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session IN($id_checked)");
+		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session IN($id_checked)");
+		Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session IN($id_checked)");
 
 
 		// delete extra session fields
 		// delete extra session fields
 		$t_sf 		= Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
 		$t_sf 		= Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
@@ -237,7 +237,7 @@ class SessionManager {
 
 
 		// Delete extra fields from session where field variable is "SECCION"
 		// Delete extra fields from session where field variable is "SECCION"
 		$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf  WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'SECCION' ";
 		$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf  WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'SECCION' ";
-		$rs_field = Database::query($sql,__FILE__,__LINE__);
+		$rs_field = Database::query($sql);
 
 
 		$field_id = 0;
 		$field_id = 0;
 		if (Database::num_rows($rs_field) == 1) {
 		if (Database::num_rows($rs_field) == 1) {
@@ -245,20 +245,20 @@ class SessionManager {
 			$field_id = $row_field[0];
 			$field_id = $row_field[0];
 
 
 			$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
 			$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
-			$rs_delete_sfv = Database::query($sql_delete_sfv,__FILE__,__LINE__);
+			$rs_delete_sfv = Database::query($sql_delete_sfv);
 		}
 		}
 
 
 		$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
 		$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
-		$rs_field_id = Database::query($sql,__FILE__,__LINE__);
+		$rs_field_id = Database::query($sql);
 
 
 		if (Database::num_rows($rs_field_id) == 0) {
 		if (Database::num_rows($rs_field_id) == 0) {
 			$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
 			$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
-			$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
+			$rs_delete_sf = Database::query($sql_delete_sf);
 		}
 		}
 
 
 		/*
 		/*
 		$sql = "SELECT distinct field_id FROM $t_sfv  WHERE session_id = '$id_checked'";
 		$sql = "SELECT distinct field_id FROM $t_sfv  WHERE session_id = '$id_checked'";
-		$res_field_ids = @Database::query($sql,__FILE__,__LINE__);
+		$res_field_ids = @Database::query($sql);
 
 
 		if (Database::num_rows($res_field_ids) > 0) {
 		if (Database::num_rows($res_field_ids) > 0) {
 			while($row_field_id = Database::fetch_row($res_field_ids)){
 			while($row_field_id = Database::fetch_row($res_field_ids)){
@@ -269,10 +269,10 @@ class SessionManager {
 		//delete from table_session_field_value from a given session id
 		//delete from table_session_field_value from a given session id
 
 
 		$sql_session_field_value = "DELETE FROM $t_sfv WHERE session_id = '$id_checked'";
 		$sql_session_field_value = "DELETE FROM $t_sfv WHERE session_id = '$id_checked'";
-		@Database::query($sql_session_field_value,__FILE__,__LINE__);
+		@Database::query($sql_session_field_value);
 
 
 		$sql = "SELECT distinct field_id FROM $t_sfv";
 		$sql = "SELECT distinct field_id FROM $t_sfv";
-		$res_field_all_ids = @Database::query($sql,__FILE__,__LINE__);
+		$res_field_all_ids = @Database::query($sql);
 
 
 		if (Database::num_rows($res_field_all_ids) > 0) {
 		if (Database::num_rows($res_field_all_ids) > 0) {
 			while($row_field_all_id = Database::fetch_row($res_field_all_ids)){
 			while($row_field_all_id = Database::fetch_row($res_field_all_ids)){
@@ -287,7 +287,7 @@ class SessionManager {
 					continue;
 					continue;
 				} else {
 				} else {
 					$sql_session_field = "DELETE FROM $t_sf WHERE id = '$field_id'";
 					$sql_session_field = "DELETE FROM $t_sf WHERE id = '$field_id'";
-					Database::query($sql_session_field,__FILE__,__LINE__);
+					Database::query($sql_session_field);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -318,14 +318,14 @@ class SessionManager {
 		$tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 		$tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 	   	$tbl_session_rel_user 				= Database::get_main_table(TABLE_MAIN_SESSION_USER);
 	   	$tbl_session_rel_user 				= Database::get_main_table(TABLE_MAIN_SESSION_USER);
 	   	$tbl_session						= Database::get_main_table(TABLE_MAIN_SESSION);
 	   	$tbl_session						= Database::get_main_table(TABLE_MAIN_SESSION);
-		
+
 		$session_info 		= api_get_session_info($id_session);
 		$session_info 		= api_get_session_info($id_session);
 		$session_name 		= $session_info['name'];
 		$session_name 		= $session_info['name'];
-		
+
 		//from function parameter
 		//from function parameter
-		$session_visibility = $visibility;		
+		$session_visibility = $visibility;
 	   	if (empty($session_visibility)) {
 	   	if (empty($session_visibility)) {
-	   		$session_visibility = $session_info['name']; 
+	   		$session_visibility = $session_info['name'];
 	   		$session_visivility	= $session_info['visibility']; //loaded from DB
 	   		$session_visivility	= $session_info['visibility']; //loaded from DB
 	   		//default status loaded if empty
 	   		//default status loaded if empty
 			if (empty($session_visivility))
 			if (empty($session_visivility))
@@ -335,35 +335,35 @@ class SessionManager {
 		$session_name = $session_info['name'];
 		$session_name = $session_info['name'];
 
 
 	   	$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session'";
 	   	$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session'";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 		$existingUsers = array();
 		$existingUsers = array();
 		while($row = Database::fetch_array($result)){
 		while($row = Database::fetch_array($result)){
 			$existingUsers[] = $row['id_user'];
 			$existingUsers[] = $row['id_user'];
 		}
 		}
 		$sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'";
 		$sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'";
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 		$course_list=array();
 		$course_list=array();
 
 
 		while($row=Database::fetch_array($result)) {
 		while($row=Database::fetch_array($result)) {
 			$course_list[]=$row['course_code'];
 			$course_list[]=$row['course_code'];
 		}
 		}
-		
-		
+
+
 		if ($send_email == true) {
 		if ($send_email == true) {
 		    global $_configuration;
 		    global $_configuration;
 			//sending emails only
 			//sending emails only
-			if(is_array($user_list) && count($user_list)>0) {			
-				foreach($user_list as $enreg_user) {				
+			if(is_array($user_list) && count($user_list)>0) {
+				foreach($user_list as $enreg_user) {
 				    if (!in_array($enreg_user,$existingUsers )) {
 				    if (!in_array($enreg_user,$existingUsers )) {
-					    //send email                             
+					    //send email
 					    $emailbody 	= '';
 					    $emailbody 	= '';
 					    $emailheaders = '';
 					    $emailheaders = '';
-					    
-					    $user_info 	= UserManager::get_user_info_by_id($enreg_user);				
+
+					    $user_info 	= UserManager::get_user_info_by_id($enreg_user);
 					    $firstname 	= $user_info['firstname'];
 					    $firstname 	= $user_info['firstname'];
 					    $lastname 	= $user_info['lastname'];
 					    $lastname 	= $user_info['lastname'];
 					    $email 		= $user_info['email'];
 					    $email 		= $user_info['email'];
-						
+
 					    $emailto = '"'.$firstname.' '.$lastname.'" <'.$email.'>';
 					    $emailto = '"'.$firstname.' '.$lastname.'" <'.$email.'>';
 					    $emailsubject = '['.get_setting('siteName').'] '.get_lang('YourReg').' '.get_setting('siteName');
 					    $emailsubject = '['.get_setting('siteName').'] '.get_lang('YourReg').' '.get_setting('siteName');
 					    $emailheaders = 'From: '.get_setting('administratorName').' '.get_setting('administratorSurname').' <'.get_setting('emailAdministrator').">\n";
 					    $emailheaders = 'From: '.get_setting('administratorName').' '.get_setting('administratorSurname').' <'.get_setting('emailAdministrator').">\n";
@@ -372,18 +372,18 @@ class SessionManager {
 					    if ($_configuration['multiple_access_urls']==true) {
 					    if ($_configuration['multiple_access_urls']==true) {
 				            $access_url_id = api_get_current_access_url_id();
 				            $access_url_id = api_get_current_access_url_id();
 				            if ($access_url_id != -1 ){
 				            if ($access_url_id != -1 ){
-				            	$url 		= api_get_access_url($access_url_id);				            	
-				            	$emailbody	= get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreRegisterToSession')." : ". $session_name  ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');			            	
+				            	$url 		= api_get_access_url($access_url_id);
+				            	$emailbody	= get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreRegisterToSession')." : ". $session_name  ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
 				            }
 				            }
 					    } else {
 					    } else {
 					    	$emailbody	= get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreRegisterToSession')." : ". $session_name ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
 					    	$emailbody	= get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreRegisterToSession')." : ". $session_name ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
 					    }
 					    }
-					    
+
 					    @api_send_mail($emailto, $emailsubject, $emailbody, $emailheaders);
 					    @api_send_mail($emailto, $emailsubject, $emailbody, $emailheaders);
-					    
+
 					}
 					}
 				}
 				}
-			}		
+			}
 		}
 		}
 
 
 		foreach ($course_list as $enreg_course) {
 		foreach ($course_list as $enreg_course) {
@@ -395,7 +395,7 @@ class SessionManager {
 				foreach ($existingUsers as $existing_user) {
 				foreach ($existingUsers as $existing_user) {
 					if(!in_array($existing_user, $user_list)) {
 					if(!in_array($existing_user, $user_list)) {
 						$sql = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course' AND id_user='$existing_user' AND status != 2 ";
 						$sql = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course' AND id_user='$existing_user' AND status != 2 ";
-						Database::query($sql,__FILE__,__LINE__);
+						Database::query($sql);
 						if(Database::affected_rows()) {
 						if(Database::affected_rows()) {
 							$nbr_users--;
 							$nbr_users--;
 						}
 						}
@@ -407,7 +407,7 @@ class SessionManager {
 				if(!in_array($enreg_user, $existingUsers)) {
 				if(!in_array($enreg_user, $existingUsers)) {
 	                $enreg_user = Database::escape_string($enreg_user);
 	                $enreg_user = Database::escape_string($enreg_user);
 					$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user,visibility) VALUES('$id_session','$enreg_course','$enreg_user','$session_visivility')";
 					$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user,visibility) VALUES('$id_session','$enreg_course','$enreg_user','$session_visivility')";
-					Database::query($insert_sql,__FILE__,__LINE__);
+					Database::query($insert_sql);
 					if(Database::affected_rows()) {
 					if(Database::affected_rows()) {
 						$nbr_users++;
 						$nbr_users++;
 					}
 					}
@@ -415,15 +415,15 @@ class SessionManager {
 			}
 			}
 			// count users in this session-course relation
 			// count users in this session-course relation
 			$sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'";
 			$sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'";
-			$rs = Database::query($sql, __FILE__, __LINE__);
+			$rs = Database::query($sql);
 			list($nbr_users) = Database::fetch_array($rs);
 			list($nbr_users) = Database::fetch_array($rs);
 			// update the session-course relation to add the users total
 			// update the session-course relation to add the users total
 			$update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
 			$update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
-			Database::query($update_sql,__FILE__,__LINE__);
+			Database::query($update_sql);
 		}
 		}
 		// delete users from the session
 		// delete users from the session
 		if ($empty_users===true){
 		if ($empty_users===true){
-			Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session = $id_session",__FILE__,__LINE__);
+			Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session = $id_session");
 		}
 		}
 			// insert missing users into session
 			// insert missing users into session
 		$nbr_users = 0;
 		$nbr_users = 0;
@@ -431,19 +431,19 @@ class SessionManager {
 	        $enreg_user = Database::escape_string($enreg_user);
 	        $enreg_user = Database::escape_string($enreg_user);
 			$nbr_users++;
 			$nbr_users++;
 			$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$enreg_user')";
 			$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$enreg_user')";
-			Database::query($insert_sql,__FILE__,__LINE__);
+			Database::query($insert_sql);
 		}
 		}
 		// update number of users in the session
 		// update number of users in the session
 		$nbr_users = count($user_list);
 		$nbr_users = count($user_list);
 		$update_sql = "UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ";
 		$update_sql = "UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ";
-		Database::query($update_sql,__FILE__,__LINE__);
+		Database::query($update_sql);
 	}
 	}
-	
+
 	 /**
 	 /**
 	  * Subscribes sessions to user (Dashboard feature)
 	  * Subscribes sessions to user (Dashboard feature)
 	  *	@param	int 		User id
 	  *	@param	int 		User id
 	  * @param	int			Session id
 	  * @param	int			Session id
-	  * @param	int			Relation type 
+	  * @param	int			Relation type
 	  **/
 	  **/
 	public static function suscribe_sessions_to_user($user_id,$session_list, $relation_stype) {
 	public static function suscribe_sessions_to_user($user_id,$session_list, $relation_stype) {
 
 
@@ -451,32 +451,32 @@ class SessionManager {
 	   	foreach($session_list as $session_id){
 	   	foreach($session_list as $session_id){
 	   		if ($session_id!= strval(intval($session_id))) return false;
 	   		if ($session_id!= strval(intval($session_id))) return false;
 	   	}
 	   	}
-	   	
+
 	   	$tbl_session_rel_course		= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 	   	$tbl_session_rel_course		= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 	   	$tbl_session_rel_user 		= Database::get_main_table(TABLE_MAIN_SESSION_USER);
 	   	$tbl_session_rel_user 		= Database::get_main_table(TABLE_MAIN_SESSION_USER);
 	   	$tbl_session				= Database::get_main_table(TABLE_MAIN_SESSION);
 	   	$tbl_session				= Database::get_main_table(TABLE_MAIN_SESSION);
-			
+
 	   	$sql = "SELECT id_session FROM $tbl_session_rel_user WHERE id_user = $user_id AND relation_type = 1 ";
 	   	$sql = "SELECT id_session FROM $tbl_session_rel_user WHERE id_user = $user_id AND relation_type = 1 ";
-		$result = Database::query($sql,__FILE__,__LINE__);
+		$result = Database::query($sql);
 		$existing_sessions = array();
 		$existing_sessions = array();
 		while($row = Database::fetch_array($result)){
 		while($row = Database::fetch_array($result)){
 			$existing_sessions[] = $row['id_session'];
 			$existing_sessions[] = $row['id_session'];
 		}
 		}
-		
-		//Deleting existing session_rel_user 
-		foreach ($existing_sessions as $existing_session) {				
+
+		//Deleting existing session_rel_user
+		foreach ($existing_sessions as $existing_session) {
 			$sql = "DELETE FROM $tbl_session_rel_user WHERE id_session=$existing_session  AND id_user = $user_id AND relation_type = 1 ";
 			$sql = "DELETE FROM $tbl_session_rel_user WHERE id_session=$existing_session  AND id_user = $user_id AND relation_type = 1 ";
-			Database::query($sql,__FILE__,__LINE__);					
+			Database::query($sql);
 		}
 		}
 
 
 		foreach ($session_list as $session_id) {
 		foreach ($session_list as $session_id) {
-			// for each session		
+			// for each session
             $enreg_user = Database::escape_string($enreg_user);
             $enreg_user = Database::escape_string($enreg_user);
 			$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session,id_user,relation_type) VALUES('$session_id','$user_id','1')";
 			$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session,id_user,relation_type) VALUES('$session_id','$user_id','1')";
-			Database::query($insert_sql,__FILE__,__LINE__);
+			Database::query($insert_sql);
 		}
 		}
 	}
 	}
-	
+
 	 /** Subscribes courses to the given session and optionally (default) unsubscribes previous users
 	 /** Subscribes courses to the given session and optionally (default) unsubscribes previous users
 	 * @author Carlos Vargas <carlos.vargas@dokeos.com>,from existing code
 	 * @author Carlos Vargas <carlos.vargas@dokeos.com>,from existing code
      * @param	int		Session ID
      * @param	int		Session ID
@@ -508,7 +508,7 @@ class SessionManager {
 		$sql="SELECT id_user
 		$sql="SELECT id_user
 			FROM $tbl_session_rel_user
 			FROM $tbl_session_rel_user
 			WHERE id_session = $id_session";
 			WHERE id_session = $id_session";
-		$result=Database::query($sql,__FILE__,__LINE__);
+		$result=Database::query($sql);
 		$user_list=Database::store_result($result);
 		$user_list=Database::store_result($result);
 
 
 		// remove existing courses from the session
 		// remove existing courses from the session
@@ -536,7 +536,7 @@ class SessionManager {
 			if (!$exists) {
 			if (!$exists) {
 				//if the course isn't subscribed yet
 				//if the course isn't subscribed yet
 				$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course (id_session,course_code) VALUES ('$id_session','$enreg_course')";
 				$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course (id_session,course_code) VALUES ('$id_session','$enreg_course')";
-				Database::query($sql_insert_rel_course ,__FILE__,__LINE__);
+				Database::query($sql_insert_rel_course);
 				//We add the current course in the existing courses array, to avoid adding another time the current course
 				//We add the current course in the existing courses array, to avoid adding another time the current course
 				$existingCourses[]=array('course_code'=>$enreg_course);
 				$existingCourses[]=array('course_code'=>$enreg_course);
 				$nbr_courses++;
 				$nbr_courses++;
@@ -546,15 +546,15 @@ class SessionManager {
 				foreach ($user_list as $enreg_user) {
 				foreach ($user_list as $enreg_user) {
 					$enreg_user_id = Database::escape_string($enreg_user['id_user']);
 					$enreg_user_id = Database::escape_string($enreg_user['id_user']);
 					$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session,course_code,id_user) VALUES ('$id_session','$enreg_course','$enreg_user_id')";
 					$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session,course_code,id_user) VALUES ('$id_session','$enreg_course','$enreg_user_id')";
-					Database::query($sql_insert,__FILE__,__LINE__);
+					Database::query($sql_insert);
 					if (Database::affected_rows()) {
 					if (Database::affected_rows()) {
 						$nbr_users++;
 						$nbr_users++;
 					}
 					}
 				}
 				}
-				Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'",__FILE__,__LINE__);
+				Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'");
 			}
 			}
 		}
 		}
-		Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'",__FILE__,__LINE__);
+		Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'");
      }
      }
 
 
   /**
   /**
@@ -572,7 +572,7 @@ class SessionManager {
 		$fieldtype = (int)$fieldtype;
 		$fieldtype = (int)$fieldtype;
 		$time = time();
 		$time = time();
 		$sql_field = "SELECT id FROM $t_sf WHERE field_variable = '$fieldvarname'";
 		$sql_field = "SELECT id FROM $t_sf WHERE field_variable = '$fieldvarname'";
-		$res_field = Database::query($sql_field,__FILE__,__LINE__);
+		$res_field = Database::query($sql_field);
 
 
 		$r_field = Database::fetch_row($res_field);
 		$r_field = Database::fetch_row($res_field);
 
 
@@ -581,7 +581,7 @@ class SessionManager {
 		} else {
 		} else {
 			// save new fieldlabel into course_field table
 			// save new fieldlabel into course_field table
 			$sql = "SELECT MAX(field_order) FROM $t_sf";
 			$sql = "SELECT MAX(field_order) FROM $t_sf";
-			$res = Database::query($sql,__FILE__,__LINE__);
+			$res = Database::query($sql);
 
 
 			$order = 0;
 			$order = 0;
 			if (Database::num_rows($res)>0) {
 			if (Database::num_rows($res)>0) {
@@ -595,7 +595,7 @@ class SessionManager {
 						                field_display_text = '$fieldtitle',
 						                field_display_text = '$fieldtitle',
 						                field_order = '$order',
 						                field_order = '$order',
 						                tms = FROM_UNIXTIME($time)";
 						                tms = FROM_UNIXTIME($time)";
-			$result = Database::query($sql,__FILE__,__LINE__);
+			$result = Database::query($sql);
 
 
 			$field_id=Database::insert_id();
 			$field_id=Database::insert_id();
 		}
 		}
@@ -633,7 +633,7 @@ class SessionManager {
 		}
 		}
 
 
 		$sqlsf = "SELECT * FROM $t_sf WHERE field_variable='$fname'";
 		$sqlsf = "SELECT * FROM $t_sf WHERE field_variable='$fname'";
-		$ressf = Database::query($sqlsf,__FILE__,__LINE__);
+		$ressf = Database::query($sqlsf);
 		if(Database::num_rows($ressf)==1)
 		if(Database::num_rows($ressf)==1)
 		{ //ok, the field exists
 		{ //ok, the field exists
 			//	Check if enumerated field, if the option is available
 			//	Check if enumerated field, if the option is available
@@ -641,7 +641,7 @@ class SessionManager {
 
 
 			$tms = time();
 			$tms = time();
 			$sqlsfv = "SELECT * FROM $t_sfv WHERE session_id = '$session_id' AND field_id = '".$rowsf['id']."' ORDER BY id";
 			$sqlsfv = "SELECT * FROM $t_sfv WHERE session_id = '$session_id' AND field_id = '".$rowsf['id']."' ORDER BY id";
-			$ressfv = Database::query($sqlsfv,__FILE__,__LINE__);
+			$ressfv = Database::query($sqlsfv);
 			$n = Database::num_rows($ressfv);
 			$n = Database::num_rows($ressfv);
 			if ($n>1) {
 			if ($n>1) {
 				//problem, we already have to values for this field and user combination - keep last one
 				//problem, we already have to values for this field and user combination - keep last one
@@ -650,14 +650,14 @@ class SessionManager {
 					if($n > 1)
 					if($n > 1)
 					{
 					{
 						$sqld = "DELETE FROM $t_sfv WHERE id = ".$rowsfv['id'];
 						$sqld = "DELETE FROM $t_sfv WHERE id = ".$rowsfv['id'];
-						$resd = Database::query($sqld,__FILE__,__LINE__);
+						$resd = Database::query($sqld);
 						$n--;
 						$n--;
 					}
 					}
 					$rowsfv = Database::fetch_array($ressfv);
 					$rowsfv = Database::fetch_array($ressfv);
 					if($rowsfv['field_value'] != $fvalues)
 					if($rowsfv['field_value'] != $fvalues)
 					{
 					{
 						$sqlu = "UPDATE $t_sfv SET field_value = '$fvalues', tms = FROM_UNIXTIME($tms) WHERE id = ".$rowsfv['id'];
 						$sqlu = "UPDATE $t_sfv SET field_value = '$fvalues', tms = FROM_UNIXTIME($tms) WHERE id = ".$rowsfv['id'];
-						$resu = Database::query($sqlu,__FILE__,__LINE__);
+						$resu = Database::query($sqlu);
 						return($resu?true:false);
 						return($resu?true:false);
 					}
 					}
 					return true;
 					return true;
@@ -669,7 +669,7 @@ class SessionManager {
 				{
 				{
 					$sqlu = "UPDATE $t_sfv SET field_value = '$fvalues', tms = FROM_UNIXTIME($tms) WHERE id = ".$rowsfv['id'];
 					$sqlu = "UPDATE $t_sfv SET field_value = '$fvalues', tms = FROM_UNIXTIME($tms) WHERE id = ".$rowsfv['id'];
 					//error_log('UM::update_extra_field_value: '.$sqlu);
 					//error_log('UM::update_extra_field_value: '.$sqlu);
-					$resu = Database::query($sqlu,__FILE__,__LINE__);
+					$resu = Database::query($sqlu);
 					return($resu?true:false);
 					return($resu?true:false);
 				}
 				}
 				return true;
 				return true;
@@ -677,7 +677,7 @@ class SessionManager {
 				$sqli = "INSERT INTO $t_sfv (session_id,field_id,field_value,tms) " .
 				$sqli = "INSERT INTO $t_sfv (session_id,field_id,field_value,tms) " .
 					"VALUES ('$session_id',".$rowsf['id'].",'$fvalues',FROM_UNIXTIME($tms))";
 					"VALUES ('$session_id',".$rowsf['id'].",'$fvalues',FROM_UNIXTIME($tms))";
 				//error_log('UM::update_extra_field_value: '.$sqli);
 				//error_log('UM::update_extra_field_value: '.$sqli);
-				$resi = Database::query($sqli,__FILE__,__LINE__);
+				$resi = Database::query($sqli);
 				return($resi?true:false);
 				return($resi?true:false);
 			}
 			}
 		} else {
 		} else {
@@ -695,7 +695,7 @@ class SessionManager {
 		$tbl_session_course	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 		$tbl_session_course	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 		$return_value = false;
 		$return_value = false;
 		$sql= "SELECT course_code FROM $tbl_session_course WHERE id_session = ".Database::escape_string($session_id)." AND course_code = '".Database::escape_string($course_id)."'";
 		$sql= "SELECT course_code FROM $tbl_session_course WHERE id_session = ".Database::escape_string($session_id)." AND course_code = '".Database::escape_string($course_id)."'";
-		$result = Database::query($sql,  __FILE__, __LINE__);
+		$result = Database::query($sql);
 		$num = Database::num_rows($result);
 		$num = Database::num_rows($result);
 		if ($num>0) {
 		if ($num>0) {
 			$return_value = true;
 			$return_value = true;
@@ -711,7 +711,7 @@ class SessionManager {
 	public static function get_session_by_name ($session_name) {
 	public static function get_session_by_name ($session_name) {
 		$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
 		$sql = 'SELECT id, id_coach, date_start, date_end FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name).'"';
 		$sql = 'SELECT id, id_coach, date_start, date_end FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name).'"';
-		$result = Database::query($sql,  __FILE__, __LINE__);
+		$result = Database::query($sql);
 		$num = Database::num_rows($result);
 		$num = Database::num_rows($result);
 		if ($num>0){
 		if ($num>0){
 			return Database::fetch_array($result);
 			return Database::fetch_array($result);
@@ -759,7 +759,7 @@ class SessionManager {
 			return $msg;
 			return $msg;
 		} else {
 		} else {
 			$sql = "INSERT INTO $tbl_session_category(name, date_start, date_end) VALUES('".Database::escape_string($name)."','$date_start','$date_end')";
 			$sql = "INSERT INTO $tbl_session_category(name, date_start, date_end) VALUES('".Database::escape_string($name)."','$date_start','$date_end')";
-			Database::query($sql ,__FILE__,__LINE__);
+			Database::query($sql);
 			$id_session=Database::insert_id();
 			$id_session=Database::insert_id();
 			// add event to system log
 			// add event to system log
 			$time = time();
 			$time = time();
@@ -811,7 +811,7 @@ class SessionManager {
 		} else {
 		} else {
 			$sql = "UPDATE $tbl_session_category SET name = '".Database::escape_string($name)."', date_start = '$date_start', date_end = '$date_end'
 			$sql = "UPDATE $tbl_session_category SET name = '".Database::escape_string($name)."', date_start = '$date_start', date_end = '$date_end'
 					WHERE id= '".$id."' ";
 					WHERE id= '".$id."' ";
-			$result = Database::query($sql, __FILE__,__LINE__);
+			$result = Database::query($sql);
 			return ($result? true:false);
 			return ($result? true:false);
 		}
 		}
 	}
 	}
@@ -834,7 +834,7 @@ class SessionManager {
 			$id_checked=intval($id_checked);
 			$id_checked=intval($id_checked);
 		}
 		}
 		$sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
 		$sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
-		$result = @Database::query($sql,__FILE__,__LINE__);
+		$result = @Database::query($sql);
 		while ($rows = Database::fetch_array($result)) {
 		while ($rows = Database::fetch_array($result)) {
 			$session_id = $rows['id'];
 			$session_id = $rows['id'];
 			if($delete_session == true){
 			if($delete_session == true){
@@ -846,7 +846,7 @@ class SessionManager {
 			}
 			}
 		}
 		}
 		$sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")";
 		$sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")";
-		$rs = @Database::query($sql,__FILE__,__LINE__);
+		$rs = @Database::query($sql);
 		$result = Database::affected_rows();
 		$result = Database::affected_rows();
 
 
 		// add event to system log
 		// add event to system log
@@ -860,22 +860,22 @@ class SessionManager {
 		$t_sfv 		= Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
 		$t_sfv 		= Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
 
 
 		$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf  WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'PERIODO' ";
 		$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf  WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'PERIODO' ";
-		$rs_field = Database::query($sql,__FILE__,__LINE__);
+		$rs_field = Database::query($sql);
 
 
 		$field_id = 0;
 		$field_id = 0;
 		if (Database::num_rows($rs_field) > 0) {
 		if (Database::num_rows($rs_field) > 0) {
 			$row_field = Database::fetch_row($rs_field);
 			$row_field = Database::fetch_row($rs_field);
 			$field_id = $row_field[0];
 			$field_id = $row_field[0];
 			$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
 			$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
-			$rs_delete_sfv = Database::query($sql_delete_sfv,__FILE__,__LINE__);
+			$rs_delete_sfv = Database::query($sql_delete_sfv);
 		}
 		}
 
 
 		$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
 		$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
-		$rs_field_id = Database::query($sql,__FILE__,__LINE__);
+		$rs_field_id = Database::query($sql);
 
 
 		if (Database::num_rows($rs_field_id) == 0) {
 		if (Database::num_rows($rs_field_id) == 0) {
 			$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
 			$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
-			$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
+			$rs_delete_sf = Database::query($sql_delete_sf);
 		}
 		}
 
 
 		return true;
 		return true;
@@ -912,7 +912,7 @@ class SessionManager {
 		if (count($order_by)>0) {
 		if (count($order_by)>0) {
 			$sql_query .= ' ORDER BY '.Database::escape_string(implode(',',$order_by));
 			$sql_query .= ' ORDER BY '.Database::escape_string(implode(',',$order_by));
 		}
 		}
-		$sql_result = Database::query($sql_query,__FILE__,__LINE__);
+		$sql_result = Database::query($sql_query);
 		while ($result = Database::fetch_array($sql_result)) {
 		while ($result = Database::fetch_array($sql_result)) {
 			$return_array[] = $result;
 			$return_array[] = $result;
 		}
 		}
@@ -927,7 +927,7 @@ class SessionManager {
 		$id = intval($id);
 		$id = intval($id);
 		$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 		$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 		$sql = 'SELECT id, name, date_start, date_end FROM '.$tbl_session_category.' WHERE id="'.$id.'"';
 		$sql = 'SELECT id, name, date_start, date_end FROM '.$tbl_session_category.' WHERE id="'.$id.'"';
-		$result = Database::query($sql,  __FILE__, __LINE__);
+		$result = Database::query($sql);
 		$num = Database::num_rows($result);
 		$num = Database::num_rows($result);
 		if ($num>0){
 		if ($num>0){
 			return Database::fetch_array($result);
 			return Database::fetch_array($result);
@@ -969,7 +969,7 @@ class SessionManager {
 		// check if user is a teacher
 		// check if user is a teacher
 		$sql= "SELECT * FROM $tbl_user WHERE status='1' AND user_id = '$user_id'";
 		$sql= "SELECT * FROM $tbl_user WHERE status='1' AND user_id = '$user_id'";
 
 
-		$rs_check_user = Database::query($sql,__FILE__,__LINE__);
+		$rs_check_user = Database::query($sql);
 
 
 		if (Database::num_rows($rs_check_user) > 0) {
 		if (Database::num_rows($rs_check_user) > 0) {
 
 
@@ -977,18 +977,18 @@ class SessionManager {
 
 
 				// check if user_id exits int session_rel_user
 				// check if user_id exits int session_rel_user
 				$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = '$session_id' AND id_user = '$user_id'";
 				$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = '$session_id' AND id_user = '$user_id'";
-				$res = Database::query($sql,__FILE__,__LINE__);
+				$res = Database::query($sql);
 
 
 				if (Database::num_rows($res) > 0) {
 				if (Database::num_rows($res) > 0) {
 					// The user don't be a coach now
 					// The user don't be a coach now
 					$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 0 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
 					$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 0 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
-					$rs_update = Database::query($sql,__FILE__,__LINE__);
+					$rs_update = Database::query($sql);
 					if (Database::affected_rows() > 0) return true;
 					if (Database::affected_rows() > 0) return true;
 					else return false;
 					else return false;
 				} else {
 				} else {
 					// The user don't be a coach now
 					// The user don't be a coach now
 					$sql = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
 					$sql = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
-					$rs_delete = Database::query($sql,__FILE__,__LINE__);
+					$rs_delete = Database::query($sql);
 					if (Database::affected_rows() > 0) return true;
 					if (Database::affected_rows() > 0) return true;
 					else return false;
 					else return false;
 				}
 				}
@@ -997,17 +997,17 @@ class SessionManager {
 				// Assign user like a coach to course
 				// Assign user like a coach to course
 				// First check if the user is registered in the course
 				// First check if the user is registered in the course
 				$sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id'";
 				$sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id'";
-				$rs_check = Database::query($sql,__FILE__,__LINE__);
+				$rs_check = Database::query($sql);
 
 
 				//Then update or insert
 				//Then update or insert
 				if (Database::num_rows($rs_check) > 0) {
 				if (Database::num_rows($rs_check) > 0) {
 					$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 2 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
 					$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 2 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
-					$rs_update = Database::query($sql,__FILE__,__LINE__);
+					$rs_update = Database::query($sql);
 					if (Database::affected_rows() > 0) return true;
 					if (Database::affected_rows() > 0) return true;
 					else return false;
 					else return false;
 				} else {
 				} else {
 					$sql = " INSERT INTO $tbl_session_rel_course_rel_user(id_session, course_code, id_user, status) VALUES('$session_id', '$course_code', '$user_id', 2)";
 					$sql = " INSERT INTO $tbl_session_rel_course_rel_user(id_session, course_code, id_user, status) VALUES('$session_id', '$course_code', '$user_id', 2)";
-					$rs_insert = Database::query($sql,__FILE__,__LINE__);
+					$rs_insert = Database::query($sql);
 					if (Database::affected_rows() > 0) return true;
 					if (Database::affected_rows() > 0) return true;
 					else return false;
 					else return false;
 				}
 				}
@@ -1016,68 +1016,68 @@ class SessionManager {
 			return false;
 			return false;
 		}
 		}
 	}
 	}
-	
+
 	/**
 	/**
 	  * Subscribes sessions to human resource manager (Dashboard feature)
 	  * Subscribes sessions to human resource manager (Dashboard feature)
 	  *	@param	int 		Human Resource Manager id
 	  *	@param	int 		Human Resource Manager id
 	  * @param	array 		Sessions id
 	  * @param	array 		Sessions id
-	  * @param	int			Relation type 
+	  * @param	int			Relation type
 	  **/
 	  **/
 	public static function suscribe_sessions_to_hr_manager($hr_manager_id,$sessions_list) {
 	public static function suscribe_sessions_to_hr_manager($hr_manager_id,$sessions_list) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
 		$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
-		
-		$hr_manager_id = intval($hr_manager_id);		
-		$affected_rows = 0;			
-		
-		//Deleting assigned sessions to hrm_id			
+
+		$hr_manager_id = intval($hr_manager_id);
+		$affected_rows = 0;
+
+		//Deleting assigned sessions to hrm_id
 	   	$sql = "SELECT id_session FROM $tbl_session_rel_user WHERE id_user = $hr_manager_id AND relation_type = '1'";
 	   	$sql = "SELECT id_session FROM $tbl_session_rel_user WHERE id_user = $hr_manager_id AND relation_type = '1'";
-		$result = Database::query($sql,__FILE__,__LINE__);
-		
+		$result = Database::query($sql);
+
 		if (Database::num_rows($result) > 0) {
 		if (Database::num_rows($result) > 0) {
 			$sql = "DELETE FROM $tbl_session_rel_user WHERE id_user = $hr_manager_id AND relation_type = '1' ";
 			$sql = "DELETE FROM $tbl_session_rel_user WHERE id_user = $hr_manager_id AND relation_type = '1' ";
-			Database::query($sql,__FILE__,__LINE__);					
+			Database::query($sql);
 		}
 		}
-		
+
 		// inserting new sessions list
 		// inserting new sessions list
 		if (is_array($sessions_list)) {
 		if (is_array($sessions_list)) {
 			foreach ($sessions_list as $session_id) {
 			foreach ($sessions_list as $session_id) {
 				$session_id = intval($session_id);
 				$session_id = intval($session_id);
 				$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user, relation_type) VALUES($session_id, $hr_manager_id, '1')";
 				$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user, relation_type) VALUES($session_id, $hr_manager_id, '1')";
-				Database::query($insert_sql,__FILE__,__LINE__);
+				Database::query($insert_sql);
 				$affected_rows = Database::affected_rows();
 				$affected_rows = Database::affected_rows();
-			}			
+			}
 		}
 		}
 		return $affected_rows;
 		return $affected_rows;
-		
+
 	}
 	}
-	
+
 	/**
 	/**
 	 * Get assigned sessions to human resources manager
 	 * Get assigned sessions to human resources manager
 	 * @param int	Human resources manager id
 	 * @param int	Human resources manager id
 	 * @return array assigned sessions
 	 * @return array assigned sessions
 	 */
 	 */
 	public static function get_assigned_sessions_to_hr_manager($hr_manager_id) {
 	public static function get_assigned_sessions_to_hr_manager($hr_manager_id) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
 		$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
-		
-		$hr_manager_id = intval($hr_manager_id);				
+
+		$hr_manager_id = intval($hr_manager_id);
 		$assigned_sessions_to_hrm = array();
 		$assigned_sessions_to_hrm = array();
-				
+
 		$sql = "SELECT * FROM $tbl_session s
 		$sql = "SELECT * FROM $tbl_session s
 				 INNER JOIN $tbl_session_rel_user sru ON sru.id_session = s.id AND sru.id_user = '$hr_manager_id' AND sru.relation_type = '1'";
 				 INNER JOIN $tbl_session_rel_user sru ON sru.id_session = s.id AND sru.id_user = '$hr_manager_id' AND sru.relation_type = '1'";
-				 
-		$rs_assigned_sessions = Database::query($sql, __FILE__, __LINE__);
+
+		$rs_assigned_sessions = Database::query($sql);
 		if (Database::num_rows($rs_assigned_sessions) > 0) {
 		if (Database::num_rows($rs_assigned_sessions) > 0) {
 			while ($row_assigned_sessions = Database::fetch_array($rs_assigned_sessions))	{
 			while ($row_assigned_sessions = Database::fetch_array($rs_assigned_sessions))	{
-				$assigned_sessions_to_hrm[$row_assigned_sessions['id']] = $row_assigned_sessions; 
+				$assigned_sessions_to_hrm[$row_assigned_sessions['id']] = $row_assigned_sessions;
 			}
 			}
-		}		
-		return $assigned_sessions_to_hrm;			
+		}
+		return $assigned_sessions_to_hrm;
 	}
 	}
-	
+
 }
 }

+ 6 - 6
main/inc/lib/tracking.lib.php

@@ -273,7 +273,7 @@ class Tracking {
 			// table definition
 			// table definition
 			$tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW, $a_course['db_name']);
 			$tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW, $a_course['db_name']);
 			$tbl_course_lp = Database :: get_course_table(TABLE_LP_MAIN, $a_course['db_name']);
 			$tbl_course_lp = Database :: get_course_table(TABLE_LP_MAIN, $a_course['db_name']);
-			// count the number of learning paths 
+			// count the number of learning paths
 			$count_lp = Database::fetch_row(Database::query("SELECT count(id) FROM $tbl_course_lp"));
 			$count_lp = Database::fetch_row(Database::query("SELECT count(id) FROM $tbl_course_lp"));
 			$avg_progress = 0;
 			$avg_progress = 0;
 			//if there is at least one learning path and one student
 			//if there is at least one learning path and one student
@@ -287,9 +287,9 @@ class Tracking {
                 // sum the progresses for each user and each learning path
                 // sum the progresses for each user and each learning path
                 // if we have 5 students and 3 learning paths, get the sum of
                 // if we have 5 students and 3 learning paths, get the sum of
                 // 15 progresses
                 // 15 progresses
-                $sql_progress = "SELECT SUM(progress) FROM $tbl_course_lp_view AS lp_view ". 
-                                "WHERE $condition_user lp_view.lp_id IN (SELECT id FROM $tbl_course_lp)";                                
-                $result_item  = Database::query($sql_progress, __FILE__, __LINE__);
+                $sql_progress = "SELECT SUM(progress) FROM $tbl_course_lp_view AS lp_view ".
+                                "WHERE $condition_user lp_view.lp_id IN (SELECT id FROM $tbl_course_lp)";
+                $result_item  = Database::query($sql_progress);
                 // total sum recovered in $rowItem
                 // total sum recovered in $rowItem
                 $row_item = Database::fetch_row($result_item);
                 $row_item = Database::fetch_row($result_item);
                 // average progress = total sum divided by the number of LP*student
                 // average progress = total sum divided by the number of LP*student
@@ -297,8 +297,8 @@ class Tracking {
                 $number_items = $count_lp[0];
                 $number_items = $count_lp[0];
                 if (is_array($student_id)) {
                 if (is_array($student_id)) {
                     $number_items = $count_lp[0] * count($student_id);
                     $number_items = $count_lp[0] * count($student_id);
-                }                               
-                $avg_progress = round($row_item[0] / $number_items, 1); 
+                }
+                $avg_progress = round($row_item[0] / $number_items, 1);
 				return $avg_progress;
 				return $avg_progress;
 			}
 			}
 		}
 		}

+ 22 - 22
main/inc/lib/usermanager.lib.php

@@ -2871,8 +2871,8 @@ class UserManager
 			}
 			}
 		}
 		}
 	}
 	}
-	
-	
+
+
 	/**
 	/**
 	 * get assigned users to human resource manager
 	 * get assigned users to human resource manager
 	 * @param int  	hr_manager id
 	 * @param int  	hr_manager id
@@ -2880,54 +2880,54 @@ class UserManager
 	 * @return array assigned users
 	 * @return array assigned users
 	 */
 	 */
 	public static function get_assigned_users_to_hr_manager($hr_manager_id, $status = 0) {
 	public static function get_assigned_users_to_hr_manager($hr_manager_id, $status = 0) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
 		$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
 		$tbl_user_rel_user 	= 	Database::get_main_table(TABLE_MAIN_USER_REL_USER);
 		$tbl_user_rel_user 	= 	Database::get_main_table(TABLE_MAIN_USER_REL_USER);
-		
-		$hr_manager_id = intval($hr_manager_id);		
+
+		$hr_manager_id = intval($hr_manager_id);
 		$assigned_users_to_hrm = array();
 		$assigned_users_to_hrm = array();
-		
+
 		$condition_status = '';
 		$condition_status = '';
 		if (!empty($status)) {
 		if (!empty($status)) {
-			$status = intval($status);			
+			$status = intval($status);
 			$condition_status = ' WHERE u.status = '.$status;
 			$condition_status = ' WHERE u.status = '.$status;
 		}
 		}
-		
+
 		$sql = "SELECT u.user_id, u.username, u.lastname, u.firstname FROM $tbl_user u
 		$sql = "SELECT u.user_id, u.username, u.lastname, u.firstname FROM $tbl_user u
 				 INNER JOIN $tbl_user_rel_user uru ON uru.user_id = u.user_id AND friend_user_id = '$hr_manager_id' AND relation_type = '1'";
 				 INNER JOIN $tbl_user_rel_user uru ON uru.user_id = u.user_id AND friend_user_id = '$hr_manager_id' AND relation_type = '1'";
 		$rs_assigned_users = Database::query($sql);
 		$rs_assigned_users = Database::query($sql);
 		if (Database::num_rows($rs_assigned_users) > 0) {
 		if (Database::num_rows($rs_assigned_users) > 0) {
 			while ($row_assigned_users = Database::fetch_array($rs_assigned_users))	{
 			while ($row_assigned_users = Database::fetch_array($rs_assigned_users))	{
-				$assigned_users_to_hrm[$row_assigned_users['user_id']] = $row_assigned_users; 
+				$assigned_users_to_hrm[$row_assigned_users['user_id']] = $row_assigned_users;
 			}
 			}
-		}		
+		}
 		return $assigned_users_to_hrm;
 		return $assigned_users_to_hrm;
 	}
 	}
-	
+
 	/**
 	/**
 	  * Subscribes users to human resource manager (Dashboard feature)
 	  * Subscribes users to human resource manager (Dashboard feature)
 	  *	@param	int 		User id
 	  *	@param	int 		User id
 	  * @param	array		Users id
 	  * @param	array		Users id
-	  * @param	int			Relation type 
+	  * @param	int			Relation type
 	  **/
 	  **/
 	public static function suscribe_users_to_hr_manager($hr_manager_id,$user_list) {
 	public static function suscribe_users_to_hr_manager($hr_manager_id,$user_list) {
-		
+
 		// Database Table Definitions
 		// Database Table Definitions
 		$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
 		$tbl_user 			= 	Database::get_main_table(TABLE_MAIN_USER);
 		$tbl_user_rel_user 	= 	Database::get_main_table(TABLE_MAIN_USER_REL_USER);
 		$tbl_user_rel_user 	= 	Database::get_main_table(TABLE_MAIN_USER_REL_USER);
 
 
 		$hr_manager_id = intval($hr_manager_id);
 		$hr_manager_id = intval($hr_manager_id);
-		$affected_rows = 0;			
-		//Deleting assigned users to hrm_id			
+		$affected_rows = 0;
+		//Deleting assigned users to hrm_id
 	   	$sql = "SELECT user_id FROM $tbl_user_rel_user WHERE friend_user_id = $hr_manager_id AND relation_type = 1";
 	   	$sql = "SELECT user_id FROM $tbl_user_rel_user WHERE friend_user_id = $hr_manager_id AND relation_type = 1";
-		$result = Database::query($sql,__FILE__,__LINE__);
-		
+		$result = Database::query($sql);
+
 		if (Database::num_rows($result) > 0) {
 		if (Database::num_rows($result) > 0) {
 			$sql = "DELETE FROM $tbl_user_rel_user WHERE friend_user_id = $hr_manager_id AND relation_type = 1 ";
 			$sql = "DELETE FROM $tbl_user_rel_user WHERE friend_user_id = $hr_manager_id AND relation_type = 1 ";
-			Database::query($sql);					
+			Database::query($sql);
 		}
 		}
-		
+
 		// inserting new user list
 		// inserting new user list
 		if (is_array($user_list)) {
 		if (is_array($user_list)) {
 			foreach ($user_list as $user_id) {
 			foreach ($user_list as $user_id) {
@@ -2935,12 +2935,12 @@ class UserManager
 				$insert_sql = "INSERT IGNORE INTO $tbl_user_rel_user(user_id, friend_user_id, relation_type) VALUES('$user_id', $hr_manager_id, '1')";
 				$insert_sql = "INSERT IGNORE INTO $tbl_user_rel_user(user_id, friend_user_id, relation_type) VALUES('$user_id', $hr_manager_id, '1')";
 				Database::query($insert_sql);
 				Database::query($insert_sql);
 				$affected_rows = Database::affected_rows();
 				$affected_rows = Database::affected_rows();
-			}			
+			}
 		}
 		}
 		return $affected_rows;
 		return $affected_rows;
-		
+
 	}
 	}
-	
+
 
 
 
 
 }
 }

+ 54 - 54
plugin/dashboard/block_course/block_course.class.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 /**
 /**
- * This file is part of course block plugin for dashboard, 
+ * This file is part of course block plugin for dashboard,
  * it should be required inside dashboard controller for showing it into dashboard interface from plattform
  * it should be required inside dashboard controller for showing it into dashboard interface from plattform
  * @package chamilo.dashboard
  * @package chamilo.dashboard
  * @author Christian Fasanando
  * @author Christian Fasanando
@@ -14,12 +14,12 @@ require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 
 
 /**
 /**
- * This class is used like controller for this course block plugin, 
+ * This class is used like controller for this course block plugin,
  * the class name must be registered inside path.info file (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it
  * the class name must be registered inside path.info file (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it
  * @package chamilo.dashboard
  * @package chamilo.dashboard
  */
  */
 class BlockCourse extends Block {
 class BlockCourse extends Block {
-	
+
 	private $user_id;
 	private $user_id;
 	private $courses;
 	private $courses;
 	private $path;
 	private $path;
@@ -27,27 +27,27 @@ class BlockCourse extends Block {
 	/**
 	/**
 	 * Constructor
 	 * Constructor
 	 */
 	 */
-    public function __construct ($user_id) {    	
-    	$this->user_id = $user_id; 
+    public function __construct ($user_id) {
+    	$this->user_id = $user_id;
     	$this->courses = CourseManager::get_assigned_courses_to_hr_manager($user_id);
     	$this->courses = CourseManager::get_assigned_courses_to_hr_manager($user_id);
     	$this->path = 'block_course';
     	$this->path = 'block_course';
     }
     }
-    
+
     /**
     /**
      * This method return content html containing information about courses and its position for showing it inside dashboard interface
      * This method return content html containing information about courses and its position for showing it inside dashboard interface
-     * it's important to use the name 'get_block' for beeing used from dashboard controller 
+     * it's important to use the name 'get_block' for beeing used from dashboard controller
      * @return array   column and content html
      * @return array   column and content html
      */
      */
     public function get_block() {
     public function get_block() {
-    	
+
     	global $charset;
     	global $charset;
-    	    	
+
     	$column = 2;
     	$column = 2;
     	$data   = array();
     	$data   = array();
-		$content = '';	
+		$content = '';
 		$data_table = '';
 		$data_table = '';
-		$content = $this->get_content_html();		
-		$html = '        		
+		$content = $this->get_content_html();
+		$html = '
 		            <li class="widget color-green" id="intro">
 		            <li class="widget color-green" id="intro">
 		                <div class="widget-head">
 		                <div class="widget-head">
 		                    <h3>Courses Informations</h3>
 		                    <h3>Courses Informations</h3>
@@ -56,23 +56,23 @@ class BlockCourse extends Block {
 		                <div class="widget-content">
 		                <div class="widget-content">
 		                   '.$content.'
 		                   '.$content.'
 		                </div>
 		                </div>
-		            </li>            			    
-				';     	
+		            </li>
+				';
     	$data['column'] = $column;
     	$data['column'] = $column;
     	$data['content_html'] = $html;
     	$data['content_html'] = $html;
 
 
-    	return $data;    	    	
+    	return $data;
     }
     }
- 
+
  	/**
  	/**
  	 * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
  	 * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
  	 * @return string  content html
  	 * @return string  content html
  	 */
  	 */
  	public function get_content_html() {
  	public function get_content_html() {
- 		
+
  		$course_data = $this->get_course_information_data();
  		$course_data = $this->get_course_information_data();
  		$content = '';
  		$content = '';
- 		if (!empty($course_data)) { 	
+ 		if (!empty($course_data)) {
 	    	$data_table = '<table class="data_table" width:"95%">';
 	    	$data_table = '<table class="data_table" width:"95%">';
 	    	$data_table .= '<tr>
 	    	$data_table .= '<tr>
 	    						<th>'.get_lang('CourseTitle').'</th>
 	    						<th>'.get_lang('CourseTitle').'</th>
@@ -82,8 +82,8 @@ class BlockCourse extends Block {
 	    						<th width="10%">'.get_lang('AvgCourseScore').'</th>
 	    						<th width="10%">'.get_lang('AvgCourseScore').'</th>
 	    						<th width="10%">'.get_lang('AvgExercisesScore').'</th>
 	    						<th width="10%">'.get_lang('AvgExercisesScore').'</th>
 	    						<th width="10%">'.get_lang('ThematicAdvance').'</th>
 	    						<th width="10%">'.get_lang('ThematicAdvance').'</th>
-	    					</tr>';	    						
-	    	$i = 1;		    	
+	    					</tr>';
+	    	$i = 1;
 	    	foreach ($course_data as $course) {
 	    	foreach ($course_data as $course) {
 	    		if ($i%2 == 0) $class_tr = 'row_odd';
 	    		if ($i%2 == 0) $class_tr = 'row_odd';
 	    		else $class_tr = 'row_even';
 	    		else $class_tr = 'row_even';
@@ -98,90 +98,90 @@ class BlockCourse extends Block {
 		} else {
 		} else {
 			$data_table .= get_lang('ThereAreNoInformationsAboutYoursCourses');
 			$data_table .= get_lang('ThereAreNoInformationsAboutYoursCourses');
 		}
 		}
-		
+
 		$content .= '<div style="margin:15px;"><h3>'.get_lang('YourCourseList').'</h3>';
 		$content .= '<div style="margin:15px;"><h3>'.get_lang('YourCourseList').'</h3>';
 		$content .= $data_table;
 		$content .= $data_table;
 		if (!empty($course_data)) {
 		if (!empty($course_data)) {
 			$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
 			$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
 		}
 		}
 		$content .= '</div>';
 		$content .= '</div>';
- 		
+
  		return $content;
  		return $content;
  	}
  	}
- 
+
     /**
     /**
-	 * Get number of courses  
+	 * Get number of courses
 	 * @return int
 	 * @return int
 	 */
 	 */
 	function get_number_of_courses() {
 	function get_number_of_courses() {
 		return count($this->courses);
 		return count($this->courses);
 	}
 	}
-	
+
 	/**
 	/**
-	 * Get course information data  
+	 * Get course information data
 	 * @return array
 	 * @return array
 	 */
 	 */
 	function get_course_information_data() {
 	function get_course_information_data() {
 		$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
 		$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
 		$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-		
-		$a_course_students  = array();	
-		$course_data = array();	
+
+		$a_course_students  = array();
+		$course_data = array();
 		$courses = $this->courses;
 		$courses = $this->courses;
-			
+
 		foreach ($courses as $row_course) {
 		foreach ($courses as $row_course) {
-	
-			$course_code = $row_course['code'];			
-			$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;		
-						
+
+			$course_code = $row_course['code'];
+			$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
+
 			// students directly subscribed to the course
 			// students directly subscribed to the course
-			$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";					
-			$rs = Database::query($sql, __FILE__, __LINE__);
-			$users = array();		
-			while ($row = Database::fetch_array($rs)) {		
-				$users[] = $row['user_id']; 							
-			}		
+			$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
+			$rs = Database::query($sql);
+			$users = array();
+			while ($row = Database::fetch_array($rs)) {
+				$users[] = $row['user_id'];
+			}
 			if (count($users) > 0) {
 			if (count($users) > 0) {
-				$nb_students_in_course = count($users);			
-				$avg_time_spent_in_course  = Tracking::get_time_spent_on_the_course($users, $course_code);			
-				$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code);		
+				$nb_students_in_course = count($users);
+				$avg_time_spent_in_course  = Tracking::get_time_spent_on_the_course($users, $course_code);
+				$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code);
 				$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code);
 				$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code);
 				$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code);
 				$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code);
-							
+
 				$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
 				$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
 				$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
 				$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
 				$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
 				$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
-				$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);		
+				$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);
 			} else {
 			} else {
 				$avg_time_spent_in_course = null;
 				$avg_time_spent_in_course = null;
 				$avg_progress_in_course = null;
 				$avg_progress_in_course = null;
 				$avg_score_in_course = null;
 				$avg_score_in_course = null;
 				$avg_score_in_exercise = null;
 				$avg_score_in_exercise = null;
 			}
 			}
-			
+
 			$tematic_advance_progress = 0;
 			$tematic_advance_progress = 0;
 			$course_description = new CourseDescription();
 			$course_description = new CourseDescription();
 			$course_description->set_session_id(0);
 			$course_description->set_session_id(0);
 			$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
 			$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
-			
+
 			if (!empty($tematic_advance)) {
 			if (!empty($tematic_advance)) {
 				$tematic_advance_progress = $tematic_advance['progress'];
 				$tematic_advance_progress = $tematic_advance['progress'];
 			}
 			}
-						
-			$table_row = array();		
+
+			$table_row = array();
 			$table_row[] = $row_course['title'];
 			$table_row[] = $row_course['title'];
 			$table_row[] = $nb_students_in_course;
 			$table_row[] = $nb_students_in_course;
 			$table_row[] = $avg_time_spent_in_course;
 			$table_row[] = $avg_time_spent_in_course;
 			$table_row[] = is_null($avg_progress_in_course) ? '' : $avg_progress_in_course.'%';
 			$table_row[] = is_null($avg_progress_in_course) ? '' : $avg_progress_in_course.'%';
 			$table_row[] = is_null($avg_score_in_course) ? '' : $avg_score_in_course.'%';
 			$table_row[] = is_null($avg_score_in_course) ? '' : $avg_score_in_course.'%';
 			$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
 			$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
-			$table_row[] = $tematic_advance_progress.'%';						
-			$course_data[] = $table_row;				
+			$table_row[] = $tematic_advance_progress.'%';
+			$course_data[] = $table_row;
 		}
 		}
-		
+
 		return $course_data;
 		return $course_data;
 	}
 	}
-    
-    
+
+
 }
 }
 ?>
 ?>

+ 44 - 44
plugin/dashboard/block_session/block_session.class.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 /**
 /**
- * This file is part of session block plugin for dashboard, 
+ * This file is part of session block plugin for dashboard,
  * it should be required inside dashboard controller for showing it into dashboard interface from plattform
  * it should be required inside dashboard controller for showing it into dashboard interface from plattform
  * @package chamilo.dashboard
  * @package chamilo.dashboard
  * @author Christian Fasanando
  * @author Christian Fasanando
@@ -15,7 +15,7 @@ require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 
 
 /**
 /**
- * This class is used like controller for this session block plugin, 
+ * This class is used like controller for this session block plugin,
  * the class name must be registered inside path.info file (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it
  * the class name must be registered inside path.info file (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it
  * @package chamilo.dashboard
  * @package chamilo.dashboard
  */
  */
@@ -28,64 +28,64 @@ class BlockSession extends Block {
 	/**
 	/**
 	 * Constructor
 	 * Constructor
 	 */
 	 */
-    public function __construct ($user_id) {    	
+    public function __construct ($user_id) {
     	$this->user_id 	= $user_id;
     	$this->user_id 	= $user_id;
     	$this->sessions = SessionManager::get_assigned_sessions_to_hr_manager($user_id);
     	$this->sessions = SessionManager::get_assigned_sessions_to_hr_manager($user_id);
-    	$this->path 	= 'block_session';   	
+    	$this->path 	= 'block_session';
     }
     }
-    
+
     /**
     /**
      * This method return content html containing information about sessions and its position for showing it inside dashboard interface
      * This method return content html containing information about sessions and its position for showing it inside dashboard interface
-     * it's important to use the name 'get_block' for beeing used from dashboard controller 
+     * it's important to use the name 'get_block' for beeing used from dashboard controller
      * @return array   column and content html
      * @return array   column and content html
      */
      */
     public function get_block() {
     public function get_block() {
 
 
 		global $charset;
 		global $charset;
-		
+
     	$column = 2;
     	$column = 2;
     	$data   = array();
     	$data   = array();
 
 
 		$content = $this->get_content_html();
 		$content = $this->get_content_html();
 
 
-		$content_html = '        		
+		$content_html = '
 			            <li class="widget color-red" id="intro">
 			            <li class="widget color-red" id="intro">
 			                <div class="widget-head">
 			                <div class="widget-head">
 			                    <h3>'.get_lang('SessionsInformation').'</h3>
 			                    <h3>'.get_lang('SessionsInformation').'</h3>
 			                    <div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
 			                    <div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
 			                </div>
 			                </div>
-			
+
 			                <div class="widget-content">
 			                <div class="widget-content">
 							'.$content.'
 							'.$content.'
 			                </div>
 			                </div>
-			            </li>            			    
-				'; 
-    	
+			            </li>
+				';
+
     	$data['column'] = $column;
     	$data['column'] = $column;
     	$data['content_html'] = $content_html;
     	$data['content_html'] = $content_html;
-    	    		
-    	return $data;     	    	
+
+    	return $data;
     }
     }
-    
+
     /**
     /**
  	 * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
  	 * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
  	 * @return string  content html
  	 * @return string  content html
  	 */
  	 */
     public function get_content_html() {
     public function get_content_html() {
- 		
- 		$content = ''; 		 						
+
+ 		$content = '';
 		$sessions = $this->sessions;
 		$sessions = $this->sessions;
-		
+
 		$content = '<div style="margin:10px;">';
 		$content = '<div style="margin:10px;">';
 		$content .= '<h3><font color="#000">'.get_lang('YourTrainingsSessionList').'</font></h3>';
 		$content .= '<h3><font color="#000">'.get_lang('YourTrainingsSessionList').'</font></h3>';
-		
+
 		if (count($sessions) > 0) {
 		if (count($sessions) > 0) {
 			foreach ($sessions as $session) {
 			foreach ($sessions as $session) {
-				
+
 				$session_id = intval($session['id']);
 				$session_id = intval($session['id']);
 				$content .= '<div style="margin-top:10px;"><strong>'.$session['name'].'</strong> - '.get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'].'</div>';
 				$content .= '<div style="margin-top:10px;"><strong>'.$session['name'].'</strong> - '.get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'].'</div>';
 				$courses = Tracking ::get_courses_list_from_session($session_id);
 				$courses = Tracking ::get_courses_list_from_session($session_id);
-	
+
 				$courses_table = '';
 				$courses_table = '';
 				if (count($courses)) {
 				if (count($courses)) {
 					$courses_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"95%">';
 					$courses_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"95%">';
@@ -96,75 +96,75 @@ class BlockSession extends Block {
 										<th width="10%">'.get_lang('Score').'</th>
 										<th width="10%">'.get_lang('Score').'</th>
 										<th width="10%">'.get_lang('TematicAdvance').'</th>
 										<th width="10%">'.get_lang('TematicAdvance').'</th>
 									</tr>';
 									</tr>';
-					$i = 1;					
+					$i = 1;
 					foreach ($courses as $course) {
 					foreach ($courses as $course) {
-											
+
 						$course_code = Database::escape_string($course['course_code']);
 						$course_code = Database::escape_string($course['course_code']);
 						$course_info = CourseManager :: get_course_information($course_code);
 						$course_info = CourseManager :: get_course_information($course_code);
-						
+
 						$tbl_session_course_user 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 						$tbl_session_course_user 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-						
+
 						// students directly subscribed to the course
 						// students directly subscribed to the course
-						$sql = "SELECT id_user  FROM $tbl_session_course_user srcu WHERE  srcu. course_code='$course_code'";					
-						$rs = Database::query($sql, __FILE__, __LINE__);
-						$users = array();		
-						while ($row = Database::fetch_array($rs)) {		
-							$users[] = $row['id_user']; 							
-						}	
-		
+						$sql = "SELECT id_user  FROM $tbl_session_course_user srcu WHERE  srcu. course_code='$course_code'";
+						$rs = Database::query($sql);
+						$users = array();
+						while ($row = Database::fetch_array($rs)) {
+							$users[] = $row['id_user'];
+						}
+
 						$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($users, $course_code));
 						$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($users, $course_code));
 						$progress = Tracking :: get_avg_student_progress($users, $course_code);
 						$progress = Tracking :: get_avg_student_progress($users, $course_code);
 						$score = Tracking :: get_avg_student_score($users, $course_code);
 						$score = Tracking :: get_avg_student_score($users, $course_code);
 						$progress = empty($progress) ? '0%' : $progress.'%';
 						$progress = empty($progress) ? '0%' : $progress.'%';
 						$score = empty($score) ? '0%' : $score.'%';
 						$score = empty($score) ? '0%' : $score.'%';
-												
+
 						$tematic_advance_progress = 0;
 						$tematic_advance_progress = 0;
 						$course_description = new CourseDescription();
 						$course_description = new CourseDescription();
 						$course_description->set_session_id($session_id);
 						$course_description->set_session_id($session_id);
 						$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
 						$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
-						
+
 						if (!empty($tematic_advance)) {
 						if (!empty($tematic_advance)) {
 							$tematic_advance_progress = $tematic_advance['progress'];
 							$tematic_advance_progress = $tematic_advance['progress'];
 						}
 						}
 
 
 						if ($i%2 == 0) $class_tr = 'row_odd';
 						if ($i%2 == 0) $class_tr = 'row_odd';
 			    		else $class_tr = 'row_even';
 			    		else $class_tr = 'row_even';
-						
+
 						$courses_table .= '<tr class="'.$class_tr.'">
 						$courses_table .= '<tr class="'.$class_tr.'">
 												<td align="right">'.$course_info['title'].'</td>
 												<td align="right">'.$course_info['title'].'</td>
 												<td align="right">'.$time_spent_on_course.'</td>
 												<td align="right">'.$time_spent_on_course.'</td>
 												<td align="right">'.$progress.'</td>
 												<td align="right">'.$progress.'</td>
 												<td align="right">'.$score.'</td>
 												<td align="right">'.$score.'</td>
 												<td align="right">'.$tematic_advance_progress.'%</td>
 												<td align="right">'.$tematic_advance_progress.'%</td>
-										   </tr>';	
-						$i++;							
+										   </tr>';
+						$i++;
 					}
 					}
 					$courses_table .= '</table></div>';
 					$courses_table .= '</table></div>';
 				} else {
 				} else {
 					$courses_table .= '<div style="margin:10px;">'.get_lang('ThereAreNoCoursesInformationsInsideThisSession').'</div>';
 					$courses_table .= '<div style="margin:10px;">'.get_lang('ThereAreNoCoursesInformationsInsideThisSession').'</div>';
-				}				
+				}
 				$content .= $courses_table;
 				$content .= $courses_table;
 			}
 			}
 		} else {
 		} else {
 			$content .= '<div style="margin:20px;">'.get_lang('ThereAreNoInformationsAboutYoursSessions').'</div>';
 			$content .= '<div style="margin:20px;">'.get_lang('ThereAreNoInformationsAboutYoursSessions').'</div>';
-		}		
-		
+		}
+
 		if (count($sessions) > 0) {
 		if (count($sessions) > 0) {
 			$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
 			$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
 		}
 		}
-				
+
 		$content .= '</div>';
 		$content .= '</div>';
 
 
  		return $content;
  		return $content;
  	}
  	}
- 
+
     /**
     /**
-	 * Get number of sessions  
+	 * Get number of sessions
 	 * @return int
 	 * @return int
 	 */
 	 */
 	function get_number_of_sessions() {
 	function get_number_of_sessions() {
 		return count($this->sessions);
 		return count($this->sessions);
 	}
 	}
-	    
+
 }
 }
 ?>
 ?>