Juan Carlos Raña 15 years ago
parent
commit
207a21db4f
50 changed files with 1226 additions and 1175 deletions
  1. 3 3
      main/admin/calendar.lib.php
  2. 3 3
      main/admin/calendar.php
  3. 3 3
      main/admin/calendar_ical_export.php
  4. 3 3
      main/admin/calendar_view.php
  5. 21 4
      main/admin/course_information.php
  6. 5 5
      main/admin/session_add.php
  7. 4 4
      main/admin/session_import.php
  8. 296 296
      main/admin/session_list.php
  9. 5 5
      main/admin/user_add.php
  10. 4 4
      main/admin/user_edit.php
  11. 42 27
      main/admin/user_import.php
  12. 43 44
      main/announcements/announcements.inc.php
  13. 6 6
      main/announcements/announcements.php
  14. 3 3
      main/auth/lost_password.lib.php
  15. 14 36
      main/auth/my_progress.php
  16. 4 4
      main/blog/blog.php
  17. 3 3
      main/blog/calendar.php
  18. 45 46
      main/calendar/agenda.inc.php
  19. 3 3
      main/calendar/agenda.php
  20. 22 14
      main/calendar/calendar.php
  21. 3 3
      main/calendar/ical_export.php
  22. 3 3
      main/calendar/myagenda.php
  23. 1 1
      main/calendar/tbl_change.js
  24. 2 2
      main/chat/chat_message.php
  25. 1 1
      main/chat/chat_whoisonline.php
  26. 23 22
      main/course_info/infocours.php
  27. 3 3
      main/course_info/postpone.php
  28. 1 1
      main/create_course/add_course.php
  29. 4 4
      main/document/document.inc.php
  30. 14 14
      main/document/document.php
  31. 1 1
      main/dropbox/dropbox_class.inc.php
  32. 10 10
      main/dropbox/dropbox_functions.inc.php
  33. 2 2
      main/dropbox/dropbox_init.inc.php
  34. 4 4
      main/dropbox/dropbox_submit.php
  35. 1 0
      main/dropbox/index.php
  36. 2 25
      main/exercice/exercice.php
  37. 20 4
      main/exercice/exercise_show.php
  38. 11 9
      main/inc/lib/formvalidator/Element/calendar_popup.php
  39. 5 4
      main/inc/lib/internationalization.lib.php
  40. 6 31
      main/mySpace/index.php
  41. 13 26
      main/mySpace/lp_tracking.php
  42. 519 425
      main/mySpace/myStudents.php
  43. 16 47
      main/newscorm/lp_stats.php
  44. 3 3
      main/reservation/rcalendar.php
  45. 13 3
      main/tracking/courseLog.php
  46. 3 3
      main/tracking/course_access_details.php
  47. 4 4
      main/tracking/logins_details.php
  48. 4 4
      main/tracking/toolaccess_details.php
  49. 1 0
      main/tracking/userLog.php
  50. 1 0
      main/tracking/userlogCSV.php

+ 3 - 3
main/admin/calendar.lib.php

@@ -15,11 +15,11 @@
 */
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 /*
 ==============================================================================

+ 3 - 3
main/admin/calendar.php

@@ -159,11 +159,11 @@ else
 // Variable definitions
 $dateNow 			= format_locale_date($dateTimeFormatLong);
 // Defining the shorts for the days. We use camelcase because these are arrays of language variables
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days. We use camelcase because these are arrays of language variables
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months. We use camelcase because these are arrays of language variables
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 // Database table definitions
 $TABLEAGENDA 			= Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);

+ 3 - 3
main/admin/calendar_ical_export.php

@@ -32,11 +32,11 @@ $nameTools = get_lang('MyAgenda');
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
 {

+ 3 - 3
main/admin/calendar_view.php

@@ -36,11 +36,11 @@ if(isset($_GET['id_session']))
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array(get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort")); 
+$DaysShort = api_get_week_days_short(); 
 // Defining the days of the week to allow translation of the days
-$DaysLong = array(get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong")); 
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array(get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong")); 
+$MonthsLong = api_get_months_long();
 
 ?>
 <html>

+ 21 - 4
main/admin/course_information.php

@@ -103,6 +103,7 @@ $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 $sql = "SELECT *,cu.status as course_status FROM $table_course_user cu, $table_user u WHERE cu.user_id = u.user_id AND cu.course_code = '".$code."'";
 $res = api_sql_query($sql,__FILE__,__LINE__);
+$is_western_name_order = api_is_western_name_order();
 if (mysql_num_rows($res) > 0)
 {
 	$users = array ();
@@ -110,8 +111,16 @@ if (mysql_num_rows($res) > 0)
 	{
 		$user = array ();
 		$user[] = $obj->official_code;
-		$user[] = $obj->firstname;
-		$user[] = $obj->lastname;
+		if ($is_western_name_order)
+		{
+			$user[] = $obj->firstname;
+			$user[] = $obj->lastname;
+		}
+		else
+		{
+			$user[] = $obj->lastname;
+			$user[] = $obj->firstname;
+		}
 		$user[] = Display :: encrypted_mailto_link($obj->email, $obj->email);
 		$user[] = $obj->course_status == 5 ? get_lang('Student') : get_lang('Teacher');
 		$user[] = '<a href="user_information.php?user_id='.$obj->user_id.'">'.Display::return_icon('synthese_view.gif',get_lang('UserInfo')).'</a>';
@@ -121,8 +130,16 @@ if (mysql_num_rows($res) > 0)
 	$table->set_additional_parameters(array ('code' => $code));
 	$table->set_other_tables(array('usage_table','class_table'));
 	$table->set_header(0,get_lang('OfficialCode'), true);
-	$table->set_header(1,get_lang('FirstName'), true);
-	$table->set_header(2,get_lang('LastName'), true);
+	if ($is_western_name_order)
+	{
+		$table->set_header(1,get_lang('FirstName'), true);
+		$table->set_header(2,get_lang('LastName'), true);
+	}
+	else
+	{
+		$table->set_header(1,get_lang('LastName'), true);
+		$table->set_header(2,get_lang('FirstName'), true);
+	}
 	$table->set_header(3,get_lang('Email'), true);
 	$table->set_header(4,get_lang('Status'), true);
 	$table->set_header(5,'', false);

+ 5 - 5
main/admin/session_add.php

@@ -162,8 +162,9 @@ $sql = 'SELECT COUNT(1) FROM '.$tbl_user.' WHERE status=1';
 $rs = api_sql_query($sql, __FILE__, __LINE__);
 $count_users = Database::result($rs, 0, 0);
 
-if (intval($count_users)<50) {	
-	$sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1' ORDER BY lastname,firstname,username";	
+if (intval($count_users)<50) {
+	$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
+	$sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;	
 	global $_configuration;	
 	if ($_configuration['multiple_access_urls']==true) {		
 		$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);	
@@ -171,8 +172,7 @@ if (intval($count_users)<50) {
 		if ($access_url_id != -1){					
 			$sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user
 			INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
-			WHERE access_url_id = '.$access_url_id.'  AND status=1
-			ORDER BY lastname, firstname, username';			
+			WHERE access_url_id = '.$access_url_id.'  AND status=1'.$order_clause;			
 		}
 	}	
 	
@@ -182,7 +182,7 @@ if (intval($count_users)<50) {
 	<select name="coach_username" value="true" style="width:250px;">
 		<option value="0"><?php get_lang('None'); ?></option>
 		<?php foreach($Coaches as $enreg): ?>
-		<option value="<?php echo $enreg['username']; ?>" <?php if($sent && $enreg['user_id'] == $id_coach) echo 'selected="selected"'; ?>><?php echo $enreg['firstname'].' '.$enreg['lastname'].' ('.$enreg['username'].')'; ?></option>
+		<option value="<?php echo $enreg['username']; ?>" <?php if($sent && $enreg['user_id'] == $id_coach) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
 		<?php endforeach; ?>
 	</select>
 	<?php

+ 4 - 4
main/admin/session_import.php

@@ -117,10 +117,10 @@ if ($_POST['formSent']) {
 							}
 							// send an email to users
 							if($sendMail) {														
-								$recipient_name = $firstname.' '.$lastname;
+								$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
 								$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');			
-								$emailbody="[NOTE:] ".get_lang('ThisIsAutomaticEmailNoReply').".\n\n".get_lang('langDear')." $firstname $lastname,\n\n".get_lang('langYouAreReg')." ".api_get_setting('siteName') ." ".get_lang('langSettings')." $username\n". get_lang('langPass')." : $password\n\n".get_lang('langAddress') ." ". get_lang('langIs') ." ". $serverAddress ."\n\n".get_lang('YouWillSoonReceiveMailFromCoach')."\n\n". get_lang('langProblem'). "\n\n". get_lang('langFormula');						
-								$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+								$emailbody="[NOTE:] ".get_lang('ThisIsAutomaticEmailNoReply').".\n\n".get_lang('langDear')." ".api_get_person_name($firstname, $lastname).",\n\n".get_lang('langYouAreReg')." ".api_get_setting('siteName') ." ".get_lang('langSettings')." $username\n". get_lang('langPass')." : $password\n\n".get_lang('langAddress') ." ". get_lang('langIs') ." ". $serverAddress ."\n\n".get_lang('YouWillSoonReceiveMailFromCoach')."\n\n". get_lang('langProblem'). "\n\n". get_lang('langFormula');						
+								$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 							    $email_admin = api_get_setting('emailAdministrator');							
 								@api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name,$email_admin);
 							}
@@ -203,7 +203,7 @@ if ($_POST['formSent']) {
 											expiration_date = NULL,
 											last_edit = now(),
 											last_visit = NULL,
-											tutor_name = '".$lastname." ".$firstname."',
+											tutor_name = '".api_get_person_name($firstname, $lastname, null, null, $language)."',
 											visual_code = '".$currentCourseCode."'";
 	
 								api_sql_query($sql, __FILE__, __LINE__);

+ 296 - 296
main/admin/session_list.php

@@ -1,300 +1,300 @@
-<?php
-/* For licensing terms, see /dokeos_license.txt */
-$language_file='admin';
-$cidReset=true;
-
-include('../inc/global.inc.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
-
-api_protect_admin_script(true);
-
-$htmlHeadXtra[] = '<script language="javascript">
-		
-				function selectAll(idCheck,numRows,action) {
-					
-					for(i=0;i<numRows;i++) {
-						idcheck = document.getElementById(idCheck+"_"+i);
-						if (action == "true"){
-							idcheck.checked = true;
-						} else {
-							idcheck.checked = false;
-						}		
-					}		
-							
-				}
-				
-				</script>
-		';
-
-$tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
-$tbl_session_rel_course=Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-$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_user = Database::get_main_table(TABLE_MAIN_USER);
-
-$page=intval($_GET['page']);
-$action=$_REQUEST['action'];
-$sort=in_array($_GET['sort'],array('name','nbr_courses','date_start','date_end'))?$_GET['sort']:'name';
-$idChecked = $_REQUEST['idChecked'];
-
-if ($action == 'delete') {
-	SessionManager::delete_session($idChecked);
-	header('Location: '.api_get_self().'?sort='.$sort);
-	exit();
-}
-
-$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
-
-if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
-	
-	$interbreadcrumb[] = array ("url" => 'session_list.php', "name" => get_lang('SessionList'));
-	$tool_name = get_lang('SearchASession');
-	Display :: display_header($tool_name);
-	
-	$form = new FormValidator('advanced_search','get');
-	$form->addElement('header', '', $tool_name);
-	$active_group = array();
-	$active_group[] = $form->createElement('checkbox','active','',get_lang('Active'));
-	$active_group[] = $form->createElement('checkbox','inactive','',get_lang('Inactive'));
-	$form->addGroup($active_group,'',get_lang('ActiveSession'),'<br/>',false);
-	
+<?php
+/* For licensing terms, see /dokeos_license.txt */
+$language_file='admin';
+$cidReset=true;
+
+include('../inc/global.inc.php');
+require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
+require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
+
+api_protect_admin_script(true);
+
+$htmlHeadXtra[] = '<script language="javascript">
+
+				function selectAll(idCheck,numRows,action) {
+
+					for(i=0;i<numRows;i++) {
+						idcheck = document.getElementById(idCheck+"_"+i);
+						if (action == "true"){
+							idcheck.checked = true;
+						} else {
+							idcheck.checked = false;
+						}
+					}
+
+				}
+
+				</script>
+		';
+
+$tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_session_rel_course=Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
+$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_user = Database::get_main_table(TABLE_MAIN_USER);
+
+$page=intval($_GET['page']);
+$action=$_REQUEST['action'];
+$sort=in_array($_GET['sort'],array('name','nbr_courses','date_start','date_end'))?$_GET['sort']:'name';
+$idChecked = $_REQUEST['idChecked'];
+
+if ($action == 'delete') {
+	SessionManager::delete_session($idChecked);
+	header('Location: '.api_get_self().'?sort='.$sort);
+	exit();
+}
+
+$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
+
+if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
+
+	$interbreadcrumb[] = array ("url" => 'session_list.php', "name" => get_lang('SessionList'));
+	$tool_name = get_lang('SearchASession');
+	Display :: display_header($tool_name);
+
+	$form = new FormValidator('advanced_search','get');
+	$form->addElement('header', '', $tool_name);
+	$active_group = array();
+	$active_group[] = $form->createElement('checkbox','active','',get_lang('Active'));
+	$active_group[] = $form->createElement('checkbox','inactive','',get_lang('Inactive'));
+	$form->addGroup($active_group,'',get_lang('ActiveSession'),'<br/>',false);
+
 	$form->addElement('style_submit_button', 'submit',get_lang('Search'),'class="search"');
-	$defaults['active'] = 1;
-	$defaults['inactive'] = 1;
-	$form->setDefaults($defaults);
-	$form->display();
-	
-} else {
-	
-	$limit = 20;
-	$from = $page * $limit;
-	
-	//if user is crfp admin only list its sessions
-	if(!api_is_platform_admin()) {
-		$where = 'WHERE session_admin_id='.intval($_user['user_id']);
-		$where .= (empty($_REQUEST['keyword']) ? " " : " AND name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
-	}
-	else {
-		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
-	}
-	
-	if(trim($where) == ''){
-		$and=" WHERE id_coach=user_id";
-	} else {
-		$and=" AND id_coach=user_id";
-	}
-	
-	if (isset($_REQUEST['active']) && !isset($_REQUEST['inactive']) ){
-		$and .= ' AND ( (session.date_start <= CURDATE() AND session.date_end >= CURDATE()) OR session.date_start="0000-00-00" ) ';
-		$cond_url = '&amp;active='.Security::remove_XSS($_REQUEST['active']);
-	}
-	if (!isset($_REQUEST['active']) && isset($_REQUEST['inactive']) ){
-		$and .= ' AND ( (session.date_start > CURDATE() OR session.date_end < CURDATE()) AND session.date_start<>"0000-00-00" ) ';
-		$cond_url = '&amp;inactive='.Security::remove_XSS($_REQUEST['inactive']);
-	}
-	
-	$query= "SELECT id,name,nbr_courses,date_start,date_end, firstname, lastname
-			FROM $tbl_session, $tbl_user
-			$where
-			$and
-			ORDER BY $sort
-			LIMIT $from,".($limit+1);
-			
-	//query which allows me to get a record without taking into account the page
-	$query_rows= "SELECT count(*) as total_rows
-				FROM $tbl_session, $tbl_user
-				$where
-				$and
-				ORDER BY $sort";
-				
-	
-	//filtering the session list by access_url
-	if ($_configuration['multiple_access_urls']==true){
-		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);	
-		$access_url_id = api_get_current_access_url_id();
-		if ($access_url_id != -1) {
-			$and.= " AND access_url_id = $access_url_id AND $table_access_url_rel_session.session_id = $tbl_session.id";
-			$query= "SELECT id,name,nbr_courses,date_start,date_end, firstname, lastname 
-				FROM $tbl_session, $tbl_user, $table_access_url_rel_session
-				$where
-				$and
-				ORDER BY $sort 
-				LIMIT $from,".($limit+1);
-				
-			$query_rows= "SELECT count(*) as total_rows
-				FROM $tbl_session, $tbl_user,$table_access_url_rel_session
-				$where
-				$and
-				ORDER BY $sort";
-		}
-	}
-	
-
-
-	$result_rows = api_sql_query($query_rows,__FILE__,__LINE__);
-	$recorset = Database::fetch_array($result_rows);
-	$num = $recorset['total_rows'];
-	
-	$result = api_sql_query($query,__FILE__,__LINE__);
-	$Sessions = api_store_result($result);
-	$nbr_results = sizeof($Sessions);
-	$tool_name = get_lang('SessionList');	
-	Display::display_header($tool_name);	
-	//api_display_tool_title($tool_name);
-    
-    if (!empty($_GET['warn'])) {
-        Display::display_warning_message(urldecode($_GET['warn']),false);
-    }
-    if(isset($_GET['action'])) {
-        Display::display_normal_message(stripslashes($_GET['message']),false);
-    }
-    ?>	
-	<div class="actions">		
-	<?php
-		
-	echo '<div style="float:right;">
-		<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSession').'</a>									
-	 </div>';	  
-	?>  
-	<form method="POST" action="session_list.php">
-		<input type="text" name="keyword" value="<?php echo Security::remove_XSS($_GET['keyword']); ?>"/>
-		<button class="search" type="submit" name="name" value="<?php echo get_lang('Search') ?>"><?php echo get_lang('Search') ?></button>
-		<a href="session_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a>
-		</form>
-	<form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
-	 </div><br />
-	
-	<div align="left">	
-	<?php
-	if(count($Sessions)==0 && isset($_POST['keyword'])) {
-		echo get_lang('NoSearchResults');
-		echo '	</div>';
-	} else {
-		if ($num > $limit) {
-			if ($page) {
-			?>
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>	
-			<?php
-			} else {
-				echo get_lang('Previous');
-			}
-			?>	
-			|
-			<?php
-			if($nbr_results > $limit) {
-				?>	
-				<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>	
-				<?php
-			} else {
-				echo get_lang('Next');
-			}
-		}
-		?>	
-	</div>
-		<br />
-		<table class="data_table" width="100%">
-		<tr>
-		  <th>&nbsp;</th>
-		  <th><a href="<?php echo api_get_self(); ?>?sort=name"><?php echo get_lang('NameOfTheSession'); ?></a></th>
-		  <th><a href="<?php echo api_get_self(); ?>?sort=nbr_courses"><?php echo get_lang('NumberOfCourses'); ?></a></th>
-		  <th><a href="<?php echo api_get_self(); ?>?sort=date_start"><?php echo get_lang('StartDate'); ?></a></th>
-		  <th><a href="<?php echo api_get_self(); ?>?sort=date_end"><?php echo get_lang('EndDate'); ?></a></th>
-		  <th><a href="<?php echo api_get_self(); ?>?sort=coach_name"><?php echo get_lang('Coach'); ?></a></th>
-		  <th><?php echo get_lang('Actions'); ?></th>
-		</tr>
-	
-		<?php
-		$i=0;
-		$x=0;
-		foreach ($Sessions as $key=>$enreg) {
-			if($key == $limit) {
-				break;
-			}
-			$sql = 'SELECT COUNT(course_code) FROM '.$tbl_session_rel_course.' WHERE id_session='.intval($enreg['id']);
-	
-		  	$rs = api_sql_query($sql, __FILE__, __LINE__);
-		  	list($nb_courses) = Database::fetch_array($rs);
-	
-		?>
-	
-		<tr class="<?php echo $i?'row_odd':'row_even'; ?>">
-		  <td><input type="checkbox" id="idChecked_<?php echo $x; ?>" name="idChecked[]" value="<?php echo $enreg['id']; ?>"></td>		  
-		  <td><a href="resume_session.php?id_session=<?php echo $enreg['id']; ?>"><?php echo api_htmlentities($enreg['name'],ENT_QUOTES,$charset); ?></a></td>
-		  <td><a href="session_course_list.php?id_session=<?php echo $enreg['id']; ?>"><?php echo $nb_courses; ?> cours</a></td>
-		  <td><?php echo api_htmlentities($enreg['date_start'],ENT_QUOTES,$charset); ?></td>
-		  <td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
-		  <td><?php echo api_htmlentities($enreg['firstname'],ENT_QUOTES,$charset).' '.api_htmlentities($enreg['lastname'],ENT_QUOTES,$charset); ?></td>
-		  <td>
-			<a href="add_users_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('add_user_big.gif', get_lang('SubscribeUsersToSession')); ?></a>
-			<a href="add_courses_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('synthese_view.gif', get_lang('SubscribeCoursesToSession')); ?></a>
-			<a href="session_edit.php?page=session_list.php&id=<?php echo $enreg['id']; ?>"><?php Display::display_icon('edit.gif', get_lang('Edit')); ?></a>
-			<a href="<?php echo api_get_self(); ?>?sort=<?php echo $sort; ?>&action=delete&idChecked=<?php echo $enreg['id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.gif', get_lang('Delete')); ?></a>
-		  </td>
-		</tr>
-	
-		<?php
-			$i=$i ? 0 : 1;
-			$x++;
-		}
-	
-		unset($Sessions);
-	
-		?>
-	
-		</table>
-	
-		<br />
-	
-		<div align="left">
-	
-		<?php
-		
-		if ($num > $limit) {
-		if ($page)
-			{
-			?>
-		
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
-		
-			<?php
-			}
-			else
-			{
-				echo get_lang('Previous');
-			}
-			?>
-		
-			|
-		
-			<?php
-			if($nbr_results > $limit)
-			{
-			?>
-		
-			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
-		
-			<?php
-			}
-			else
-			{
-				echo get_lang('Next');
-			}
-		}
-		?>
-	
-		</div>
-	
-		<br />
+	$defaults['active'] = 1;
+	$defaults['inactive'] = 1;
+	$form->setDefaults($defaults);
+	$form->display();
+
+} else {
+	
+	$limit=20;
+	$from=$page * $limit;
+	
+	//if user is crfp admin only list its sessions
+	if(!api_is_platform_admin()) {
+		$where = 'WHERE session_admin_id='.intval($_user['user_id']);
+		$where .= (empty($_REQUEST['keyword']) ? " " : " AND name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
+	}
+	else {
+		$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
+	}
+	
+	if(trim($where) == ''){
+		$and=" WHERE id_coach=user_id";
+	} else {
+		$and=" AND id_coach=user_id";
+	}
+	
+	if(isset($_REQUEST['active']) && !isset($_REQUEST['inactive']) ){
+		$and .= ' AND ( (session.date_start <= CURDATE() AND session.date_end >= CURDATE()) OR session.date_start="0000-00-00" ) ';
+		$cond_url = '&amp;active='.Security::remove_XSS($_REQUEST['active']);
+	}
+	if(!isset($_REQUEST['active']) && isset($_REQUEST['inactive']) ){
+		$and .= ' AND ( (session.date_start > CURDATE() OR session.date_end < CURDATE()) AND session.date_start<>"0000-00-00" ) ';
+		$cond_url = '&amp;inactive='.Security::remove_XSS($_REQUEST['inactive']);
+	}
+	
+	$query= "SELECT id,name,nbr_courses,date_start,date_end, firstname, lastname 
+			FROM $tbl_session, $tbl_user
+			$where
+			$and
+			ORDER BY $sort 
+			LIMIT $from,".($limit+1);
+			
+	//query which allows me to get a record without taking into account the page
+	$query_rows= "SELECT count(*) as total_rows
+				FROM $tbl_session, $tbl_user
+				$where
+				$and
+				ORDER BY $sort";
+				
+
+	//filtering the session list by access_url
+	if ($_configuration['multiple_access_urls']==true){
+		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);	
+		$access_url_id = api_get_current_access_url_id();
+		if ($access_url_id != -1) {
+			$and.= " AND access_url_id = $access_url_id AND $table_access_url_rel_session.session_id = $tbl_session.id";
+			$query= "SELECT id,name,nbr_courses,date_start,date_end, firstname, lastname 
+				FROM $tbl_session, $tbl_user, $table_access_url_rel_session
+				$where
+				$and
+				ORDER BY $sort 
+				LIMIT $from,".($limit+1);
+				
+			$query_rows= "SELECT count(*) as total_rows
+				FROM $tbl_session, $tbl_user,$table_access_url_rel_session
+				$where
+				$and
+				ORDER BY $sort";
+		}
+	}
+	
+
+	
+	$result_rows = api_sql_query($query_rows,__FILE__,__LINE__);
+	$recorset = Database::fetch_array($result_rows);
+	$num = $recorset['total_rows'];
+	
+	$result=api_sql_query($query,__FILE__,__LINE__);	
+	$Sessions=api_store_result($result);	
+	$nbr_results=sizeof($Sessions);	
+	$tool_name = get_lang('SessionList');	
+	Display::display_header($tool_name);	
+	//api_display_tool_title($tool_name);
+
+    if (!empty($_GET['warn'])) {
+        Display::display_warning_message(urldecode($_GET['warn']),false);
+    }
+    if(isset($_GET['action'])) {
+        Display::display_normal_message(stripslashes($_GET['message']),false);
+    }
+	?>	
+	<div class="actions">		
+	<?php
+
+	echo '<div style="float:right;">
+		<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSession').'</a>									
+	  </div>'; 
+	?>
+	<form method="POST" action="session_list.php">
+		<input type="text" name="keyword" value="<?php echo Security::remove_XSS($_GET['keyword']); ?>"/>
+		<button class="search" type="submit" name="name" value="<?php echo get_lang('Search') ?>"><?php echo get_lang('Search') ?></button>
+		<a href="session_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a>
+		</form>
+	<form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
+	 </div><br />
+	
+	<div align="left">
+	<?php
+	if(count($Sessions)==0 && isset($_POST['keyword'])) {
+		echo get_lang('NoSearchResults');
+		echo '	</div>';
+	} else {
+		if($num>$limit){
+			if($page) {
+			?>	
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>	
+			<?php
+			} else {
+				echo get_lang('Previous');
+			}
+			?>	
+			|	
+			<?php
+			if($nbr_results > $limit) {
+				?>	
+				<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>	
+				<?php
+			} else {
+				echo get_lang('Next');
+			}
+		}
+		?>
+	</div>	
+		<br />
+		<table class="data_table" width="100%">
+		<tr>
+		  <th>&nbsp;</th>
+		  <th><a href="<?php echo api_get_self(); ?>?sort=name"><?php echo get_lang('NameOfTheSession'); ?></a></th>
+		  <th><a href="<?php echo api_get_self(); ?>?sort=nbr_courses"><?php echo get_lang('NumberOfCourses'); ?></a></th>
+		  <th><a href="<?php echo api_get_self(); ?>?sort=date_start"><?php echo get_lang('StartDate'); ?></a></th>
+		  <th><a href="<?php echo api_get_self(); ?>?sort=date_end"><?php echo get_lang('EndDate'); ?></a></th>
+		  <th><a href="<?php echo api_get_self(); ?>?sort=coach_name"><?php echo get_lang('Coach'); ?></a></th>
+		  <th><?php echo get_lang('Actions'); ?></th>
+		</tr>
+	
+		<?php
+		$i=0;
+		$x=0;
+		foreach ($Sessions as $key=>$enreg) {
+			if($key == $limit) {
+				break;
+			}
+			$sql = 'SELECT COUNT(course_code) FROM '.$tbl_session_rel_course.' WHERE id_session='.intval($enreg['id']);
+	
+		  	$rs = api_sql_query($sql, __FILE__, __LINE__);
+		  	list($nb_courses) = Database::fetch_array($rs);
+	
+		?>
+	
+		<tr class="<?php echo $i?'row_odd':'row_even'; ?>">
+		  <td><input type="checkbox" id="idChecked_<?php echo $x; ?>" name="idChecked[]" value="<?php echo $enreg['id']; ?>"></td>
+	      <td><a href="resume_session.php?id_session=<?php echo $enreg['id']; ?>"><?php echo api_htmlentities($enreg['name'],ENT_QUOTES,$charset); ?></a></td>
+	      <td><a href="session_course_list.php?id_session=<?php echo $enreg['id']; ?>"><?php echo $nb_courses; ?> cours</a></td>
+	      <td><?php echo api_htmlentities($enreg['date_start'],ENT_QUOTES,$charset); ?></td>
+	      <td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
+	      <td><?php echo api_htmlentities(api_get_person_name($enreg['firstname'], $enreg['lastname']),ENT_QUOTES,$charset); ?></td>
+		  <td>
+			<a href="add_users_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('add_user_big.gif', get_lang('SubscribeUsersToSession')); ?></a>
+			<a href="add_courses_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('synthese_view.gif', get_lang('SubscribeCoursesToSession')); ?></a>
+			<a href="session_edit.php?page=session_list.php&id=<?php echo $enreg['id']; ?>"><?php Display::display_icon('edit.gif', get_lang('Edit')); ?></a>
+			<a href="<?php echo api_get_self(); ?>?sort=<?php echo $sort; ?>&action=delete&idChecked=<?php echo $enreg['id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.gif', get_lang('Delete')); ?></a>
+		  </td>
+		</tr>
+	
+		<?php
+			$i=$i ? 0 : 1;
+			$x++;
+		}
+	
+		unset($Sessions);
+	
+		?>
+	
+		</table>
+	
+		<br />
+	
+		<div align="left">
+	
+		<?php
+
+		if($num>$limit) {
+		if($page)
+			{
+			?>
+		
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
+		
+			<?php
+			}
+			else
+			{
+				echo get_lang('Previous');
+			}
+			?>
+		
+			|
+		
+			<?php
+			if($nbr_results > $limit)
+			{
+			?>
+		
+			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
+		
+			<?php
+			}
+			else
+			{
+				echo get_lang('Next');
+			}
+		}
+		?>
+	
+		</div>
+	
+		<br />
 		<a href="javascript: void(0);" onclick="javascript: selectAll('idChecked',<?php echo $x; ?>,'true');return false;"><?php echo get_lang('SelectAll') ?></a>&nbsp;-&nbsp;
 		<a href="javascript: void(0);" onclick="javascript: selectAll('idChecked',<?php echo $x; ?>,'false');return false;"><?php echo get_lang('UnSelectAll') ?></a>
-		<select name="action">
-		<option value="delete"><?php echo get_lang('DeleteSelectedSessions'); ?></option>
-		</select>
-		<button class="save" type="submit" name="name" value="<?php echo get_lang('Ok') ?>"><?php echo get_lang('Ok') ?></button>
-		<?php } ?>
-	</table>
-<?php
-}
-Display::display_footer();
+		<select name="action">
+		<option value="delete"><?php echo get_lang('DeleteSelectedSessions'); ?></option>
+		</select>
+		<button class="save" type="submit" name="name" value="<?php echo get_lang('Ok') ?>"><?php echo get_lang('Ok') ?></button>
+		<?php } ?>
+	</table>
+<?php
+}
+Display::display_footer();
 ?>

+ 5 - 5
main/admin/user_add.php

@@ -380,7 +380,7 @@ if( $form->validate())
 					chmod($picture_path,$perm);
 				}
 			}
-			$picture_infos=getimagesize($_FILES['picture']['tmp_name']);
+			$picture_infos=@getimagesize($_FILES['picture']['tmp_name']);
 			$type=$picture_infos[2];
 			$small_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 22); //small picture
 			$medium_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 85); //medium picture
@@ -425,21 +425,21 @@ if( $form->validate())
 		}
 		if (!empty ($email) && $send_mail)
 		{
-			$recipient_name = $firstname.' '.$lastname;
+			$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
 			$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');			
 									
-			$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+			$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 		    $email_admin = api_get_setting('emailAdministrator');
 		    
 		    if ($_configuration['multiple_access_urls']==true) {
 				$access_url_id = api_get_current_access_url_id();				
 				if ($access_url_id != -1 ){
 					$url = api_get_access_url($access_url_id);					
-					$emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+					$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 				}		
 			}
 			else {
-				$emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+				$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 			}
 					
 		    	

+ 4 - 4
main/admin/user_edit.php

@@ -461,20 +461,20 @@ if( $form->validate())
 	
 	if (!empty ($email) && $send_mail)
 	{
-		$recipient_name = $firstname.' '.$lastname;
+		$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
 		$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');												
-		$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+		$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 	    $email_admin = api_get_setting('emailAdministrator');
 	    
 	    if ($_configuration['multiple_access_urls']==true) {
 			$access_url_id = api_get_current_access_url_id();				
 			if ($access_url_id != -1 ){
 				$url = api_get_access_url($access_url_id);					
-				$emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+				$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 			}		
 		}
 		else {
-			$emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
+			$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 		}
 			
 					

+ 42 - 27
main/admin/user_import.php

@@ -166,10 +166,10 @@ function save_data($users) {
 			}
 		
     		if ($sendMail) {			
-    			$recipient_name = $user['FirstName'].' '.$user['LastName'];
+    			$recipient_name = api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS);
     			$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');			
-    			$emailbody = get_lang('Dear').$user['FirstName'].' '.$user['LastName'].",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('Settings')." $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path('WEB_PATH')." \n\n".get_lang('Problem')."\n\n".get_lang('Formula').",\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator')."";						
-    			$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+    			$emailbody = get_lang('Dear').api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('Settings')." $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path('WEB_PATH')." \n\n".get_lang('Problem')."\n\n".get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator')."";						
+    			$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
     		    $email_admin = api_get_setting('emailAdministrator');			
     			@api_mail($recipient_name, $user['Email'], $emailsubject, $emailbody, $sender_name,$email_admin);
     		}
@@ -283,11 +283,14 @@ $extra_fields = Usermanager::get_extra_fields(0, 0, 5, 'ASC',false);
 $user_id_error=array();
 if ($_POST['formSent'] AND $_FILES['import_file']['size'] !== 0) {
 	$file_type = $_POST['file_type'];
-	if (strcmp($file_type,'csv')===0){ //&& strcmp($_FILES['import_file']['type'],'text/'.$file_type.'')===0) {
+	Security::clear_token();
+    $tok = Security::get_token(); 
+	
+	if (strcmp($file_type,'csv')===0){ //&& strcmp($_FILES['import_file']['type'],'text/'.$file_type.'')===0) {		
 		$users = parse_csv_data($_FILES['import_file']['tmp_name']);
 		$errors = validate_data($users);
 		$error_kind_file=false;
-	} elseif (strcmp($file_type,'xml')===0){// && strcmp($_FILES['import_file']['type'],'text/'.$file_type.'')===0) {
+	} elseif (strcmp($file_type,'xml')===0){// && strcmp($_FILES['import_file']['type'],'text/'.$file_type.'')===0) {		
 		$users = parse_xml_data($_FILES['import_file']['tmp_name']);
 		$errors = validate_data($users);
 		$error_kind_file=false;
@@ -304,13 +307,22 @@ if ($_POST['formSent'] AND $_FILES['import_file']['size'] !== 0) {
 	}
 	if  (is_array($users)) {
 		foreach ($users as $my_user) {
-		if (!in_array($my_user['UserName'],$user_id_error)) {
-			$users_to_insert[]=$my_user;
-				}
+			if (!in_array($my_user['UserName'],$user_id_error)) {
+				$users_to_insert[]=$my_user;
 			}
 		}
-        $inserted_in_course = array();
-	save_data($users_to_insert);
+	}
+	
+    $inserted_in_course = array();
+
+	if (strcmp($_FILES['import_file']['type'],'text/'.$file_type.'') === 0) {
+		save_data($users_to_insert);	
+	} else {
+		$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
+		header('Location: '.api_get_self().'?warn='.urlencode($error_message).'&amp;file_type='.$file_type.'&amp;sec_token='.$tok);
+		exit ();
+	}
+
 	if ( count($errors)>0 ) {
 		$see_message_import=get_lang('FileImportedJustUsersThatAreNotRegistered');
 	} else {
@@ -318,29 +330,29 @@ if ($_POST['formSent'] AND $_FILES['import_file']['size'] !== 0) {
 	}
         $msg2 = '';
 	if (count($inserted_in_course)>1) {
-        	$msg2 .="<br>".get_lang('UsersSubscribedToSeveralCoursesBecauseOfVirtualCourses').':';
-            foreach ($inserted_in_course as $course) {
-            	$msg2 .= ' '.$course.',';
-            }
-            $msg2 = substr($msg2,0,-1);
-	    $msg2 .= "</br>";
+        $msg2 .="<br>".get_lang('UsersSubscribedToSeveralCoursesBecauseOfVirtualCourses').':';
+        foreach ($inserted_in_course as $course) {
+        	$msg2 .= ' '.$course.',';
         }
+        $msg2 = substr($msg2,0,-1);
+	    $msg2 .= "</br>";
+    }
+    
 	if (count($errors) != 0) {
-	$error_message = '<ul>';
-	foreach ($errors as $index => $error_user) {
-	$error_message .= '<li><b>'.$error_user['error'].'</b>: ';
-	$error_message .= $error_user['UserName'].'&nbsp;('.$error_user['FirstName'].' '.$error_user['LastName'].')';
-		$error_message .= '</li>';
+		$error_message = '<ul>';
+		foreach ($errors as $index => $error_user) {
+			$error_message .= '<li><b>'.$error_user['error'].'</b>: ';
+			$error_message .= $error_user['UserName'].'&nbsp;('.$error_user['FirstName'].' '.$error_user['LastName'].')';
+			$error_message .= '</li>';
 		}
 		$error_message .= '</ul>';
 	}
+      
+	header('Location: user_list.php?action=show_message&message='.urlencode($see_message_import).'&warn='.urlencode($error_message).'&sec_token='.$tok);
+	exit ();
+	
+}
 
- 
-        Security::clear_token();
-        $tok = Security::get_token();       
-		header('Location: user_list.php?action=show_message&message='.urlencode($see_message_import).'&warn='.urlencode($error_message).'&sec_token='.$tok);
-		exit ();
-	}
 Display :: display_header($tool_name);
 //api_display_tool_title($tool_name);
 
@@ -350,6 +362,9 @@ if($_FILES['import_file']['size'] == 0 AND $_POST) {
 
 if ($error_kind_file===true) {
 	Display :: display_error_message(get_lang('YouMustImportAFileAccordingToSelectedOption'));
+} else if (isset($_GET['warn'])) {
+	$error_message = Security::remove_XSS($_GET['warn']);
+	Display :: display_error_message($error_message);
 }
 $form = new FormValidator('user_import');
 $form->addElement('header', '', $tool_name);

+ 43 - 44
main/announcements/announcements.inc.php

@@ -72,12 +72,15 @@ function display_announcement($announcement_id)
 	$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
 	$result = Database::fetch_array($sql_result);
 	
-	$title		 = $result['title'];
-	$content	 = $result['content'];
-	$content     = make_clickable($content);
-	$content     = text_filter($content);
-	$last_post_datetime = $result['insert_date'];// post time format  datetime de mysql
-	list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
+	if ($result !== false) // A sanity check.
+	{
+		$title		 = $result['title'];
+		$content	 = $result['content'];
+		$content     = make_clickable($content);
+		$content     = text_filter($content);
+		$last_post_datetime = $result['insert_date'];// post time format  datetime de mysql
+		list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
+	}
 	
 	echo "<table height=\"100\" width=\"100%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">\n";
 	echo "<tr class=\"data\"><td>" . $title . "</td></tr>\n";
@@ -112,13 +115,13 @@ function show_to_form($to_already_selected)
 	// the buttons for adding or removing groups/users
 	echo "\n\t\t<td valign=\"middle\">\n";
 	echo "\t\t<input	type=\"button\"	",
-				"onClick=\"move(this.form.elements[0],this.form.elements[3])\" ",// 7 & 4 : fonts
+				"onClick=\"javascript: move(this.form.elements[0],this.form.elements[3])\" ",// 7 & 4 : fonts
 				"value=\"   >>   \">",
 
 				"\n\t\t<p>&nbsp;</p>",
 
 				"\n\t\t<input	type=\"button\"",
-				"onClick=\"move(this.form.elements[3],this.form.elements[0])\" ",
+				"onClick=\"javascript: move(this.form.elements[3],this.form.elements[0])\" ",
 				"value=\"   <<   \">";
 	echo "\t\t</td>\n";
 	echo "\n\t\t<td>\n";
@@ -167,7 +170,7 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t
 			if (!(in_array("USER:".$this_user["user_id"],$to_already_selected))) // $to_already_selected is the array containing the users (and groups) that are already selected
 			{
 				echo	"\t\t<option value=\"USER:",$this_user["user_id"],"\">",
-					"",$this_user['lastName']," ",$this_user['firstName'],
+					"", api_get_person_name($this_user['firstName'], $this_user['lastName']),
 					"</option>\n";
 			}	
 		}
@@ -212,46 +215,42 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
 			}
 			else
 			{
-				
 				foreach($ref_array_users as $key=>$value){
-	
 					if($value['user_id']==$id){
-						echo "\t\t<option value=\"".$groupuser."\">".$value['lastName']." ".$value['firstName']."</option>";
+						echo "\t\t<option value=\"".$groupuser."\">".api_get_person_name($value['firstName'], $value['lastName'])."</option>";
 						break;
 					}
-					
 				}
 			}
 		}
 	} else {
-			if($to_already_selected=='everyone'){						
-				// adding the groups to the select form
-				if (is_array($ref_array_groups))
+		if ($to_already_selected=='everyone') {						
+			// adding the groups to the select form
+			if (is_array($ref_array_groups))
+			{
+				foreach($ref_array_groups as $this_group)
 				{
-					foreach($ref_array_groups as $this_group)
-					{
-						//api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
-						if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'],$to_already_selected)) // $to_already_selected is the array containing the groups (and users) that are already selected
-							{
-							echo	"\t\t<option value=\"GROUP:".$this_group['id']."\">",
-								"G: ",$this_group['name']," &ndash; " . $this_group['userNb'] . " " . get_lang('Users') .
-								"</option>\n";
-						}
-					}					
-				}
-			
-				// adding the individual users to the select form
-				foreach($ref_array_users as $this_user)
-				{					
-					if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
+					//api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
+					if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'],$to_already_selected)) // $to_already_selected is the array containing the groups (and users) that are already selected
 					{
-						echo	"\t\t<option value=\"USER:",$this_user['user_id'],"\">",
-							"",$this_user['lastName']," ",$this_user['firstName'],
+						echo	"\t\t<option value=\"GROUP:".$this_group['id']."\">",
+							"G: ",$this_group['name']," &ndash; " . $this_group['userNb'] . " " . get_lang('Users') .
 							"</option>\n";
 					}
+				}					
+			}
+			// adding the individual users to the select form
+			foreach($ref_array_users as $this_user)
+			{					
+				if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
+				{
+					echo	"\t\t<option value=\"USER:",$this_user['user_id'],"\">",
+						"", api_get_person_name($this_user['lastName'], $this_user['firstName']),
+						"</option>\n";
 				}
-			}			
+			}
 		}
+	}
 	echo "</select>\n";
 }
 
@@ -269,8 +268,8 @@ function show_to_form_group($group_id)
 	
 	echo "\t\t<select name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>\n";
 	$group_users = GroupManager::get_subscribed_users($group_id);
-	foreach($group_users as $user){
-		echo '<option value="'.$user['user_id'].'">'.$user['lastname'].' '.$user['firstname'].'</option>';
+	foreach ($group_users as $user){
+		echo '<option value="'.$user['user_id'].'">'.api_get_person_name($user['firstname'], $user['lastname']).'</option>';
 	}
 	echo '</select>';
 	
@@ -592,8 +591,8 @@ function sent_to_form($sent_to_array)
 			{
 				foreach ($sent_to_array['users'] as $user_id)
 				{
-					$user_info=api_get_user_info($user_id);
-					$output.="\t<option value=\"\">".$user_info['lastName']." ".$user_info['firstName']."</option>\n";
+					$user_info = api_get_user_info($user_id);
+					$output.="\t<option value=\"\">".api_get_person_name($user_info['firstName'], $user_info['lastName'])."</option>\n";
 				}
 			}
 		}
@@ -605,8 +604,8 @@ function sent_to_form($sent_to_array)
 	{
 		if (isset($sent_to_array['users']) and is_array($sent_to_array['users']))
 		{
-			$user_info=api_get_user_info($sent_to_array['users'][0]);
-			echo $user_info['lastName']." ".$user_info['firstName'];
+			$user_info = api_get_user_info($sent_to_array['users'][0]);
+			echo api_get_person_name($user_info['firstName'], $user_info['lastName']);
 		}
 		if (isset($sent_to_array['groups']) and is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
 		{
@@ -919,8 +918,8 @@ function send_announcement_email($user_list, $course_code, $_course, $mail_title
 		$mail_subject = get_lang('professorMessage').' - '.$_course['official_code'].' - '.$mail_title;
 
 		$mail_body = '['.$_course['official_code'].'] - ['.$_course['name']."]\n";
-		$mail_body .= $this_user['lastname'].' '.$this_user['firstname'].' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, $charset)))." \n\n-- \n";
-		$mail_body .= $_user['firstName'].' '.$_user['lastName'].' ';
+		$mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, $charset)))." \n\n-- \n";
+		$mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS).' ';
 		$mail_body .= '<'.$_user['mail'].">\n";
 		$mail_body .= $_course['official_code'].' '.$_course['name'];
 		
@@ -929,7 +928,7 @@ function send_announcement_email($user_list, $course_code, $_course, $mail_title
 		if(empty($charset)){$charset='ISO-8859-1';}
 		$encoding = 'Content-Type: text/plain; charset='. $charset;
 		
-		$newmail = api_mail($this_user['lastname'].' '.$this_user['firstname'], $this_user['email'], $mail_subject, $mail_body, $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'], $_SESSION['_user']['mail'], $encoding);
+		$newmail = api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail'], $encoding);
 	}
 }
 

+ 6 - 6
main/announcements/announcements.php

@@ -580,7 +580,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 							$subject=stripslashes($emailTitle);
 							$message=stripslashes($newContentsix);
 						
-						    $sender_name = $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'];
+						    $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
 						    $email = $_SESSION['_user']['mail'];
 							$headers="From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
 							//@mail($to,$subject,$message,$headers);
@@ -699,7 +699,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								$newContentsix=str_replace("#uid#",$myrow["user_id"],$newContentfive);
 	                			$message=stripslashes($newContentsix);
 	
-							    $sender_name = $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'];
+							    $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
 							    $email = $_SESSION['_user']['mail'];
 	
 	
@@ -708,14 +708,14 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
 	                        } else {
 	                            // intro of the email: receiver name and subject
-								$mail_body = $myrow["lastname"]." ".$myrow["firstname"]."<br />\n".stripslashes($emailTitle)."<br />";
+								$mail_body = api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS)."<br />\n".stripslashes($emailTitle)."<br />";
 								// make a change for absolute url
 	        					$newContent = str_replace('src=\"../../','src=\"'.api_get_path(WEB_PATH).'', $newContent);
 	                            // main part of the email
 	                            $mail_body .= trim(stripslashes($newContent));
 	                            // signature of email: sender name and course URL after -- line
 	                            $mail_body .= "<br />-- <br />";
-	                            $mail_body .= $_user['firstName'].' '.$_user['lastName']." \n";
+	                            $mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)." \n";
 	                            $mail_body .= "<br /> \n<a href=\"".api_get_path(WEB_COURSE_PATH).$_course['id']."\">";
 	                            $mail_body .= $_course['official_code'].' '.$_course['name'] . "</a>";
 	
@@ -730,7 +730,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 								$headers['charset'] = $charset;
 		                        $mailid=$myrow["email"];
 	 
-								$newmail = api_mail_html($myrow["lastname"].' '.$myrow["firstname"], $myrow["email"], stripslashes($emailSubject), $mail_body, $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'], $_SESSION['_user']['mail'],$headers);
+								$newmail = api_mail_html(api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS), $myrow["email"], stripslashes($emailSubject), $mail_body, api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail'],$headers);
 	                        }
 	                        
 							$sql_date="SELECT * FROM $db_name WHERE survey_id='$surveyid'";
@@ -1359,7 +1359,7 @@ if ($display_announcement_list && !$surveyid) {
 			$sent_to_form=sent_to_form($sent_to);
 			$user_info=api_get_user_info($myrow['insert_user_id']);
 			
-			echo '&nbsp;&nbsp;&nbsp;'.get_lang('By').' : &nbsp;'.$user_info['lastName'].'&nbsp;'.$user_info['firstName'];			
+				echo '&nbsp;&nbsp;&nbsp;'.get_lang('By').' : &nbsp;'.str_replace(' ', '&nbsp;', api_get_person_name($user_info['firstName'], $user_info['lastName']));
 			echo "\t\t\t\t\t</th>\n","\t\t\t\t</tr>\n";			
 			echo "\t\t\t\t<tr class='row_odd'>\n\t\t\t\t\t<td class=\"announcements_datum\" colspan=\"3\">";
 			echo get_lang('AnnouncementPublishedOn')," : ",api_ucfirst(format_locale_date($dateFormatLong,strtotime($last_post_date)));

+ 3 - 3
main/auth/lost_password.lib.php

@@ -10,7 +10,7 @@
 function get_email_headers()
 {
 	global $charset;
-	$emailHeaders = "From: \"".addslashes(api_get_setting('administratorSurname')." ".api_get_setting('administratorName'))."\" <".api_get_setting('emailAdministrator').">\n";
+	$emailHeaders = "From: \"".addslashes(api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS))."\" <".api_get_setting('emailAdministrator').">\n";
 	$emailHeaders .= "Reply-To: ".api_get_setting('emailAdministrator')."\n";
 	$emailHeaders .= "Return-Path: ".api_get_setting('emailAdministrator')."\n";
 	$emailHeaders .= "X-Sender: ".api_get_setting('emailAdministrator')."\n";	
@@ -85,7 +85,7 @@ function send_password_to_user($user)
 	$emailBody = get_lang('YourAccountParam')." ".$portal_url."\n\n$userAccountList";
 	// SEND MESSAGE
 	$emailTo = $user[0]["email"];			
-	$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+	$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
     $email_admin = api_get_setting('emailAdministrator');			
 				
 	if (@api_mail('', $emailTo, $emailSubject, $emailBody, $sender_name,$email_admin)==1) {
@@ -116,7 +116,7 @@ function handle_encrypted_password($user)
 	$emailBody .= "-----------------------------------------------\n".$userAccountList."\n-----------------------------------------------\n\n";
 	$emailBody .=get_lang('PasswordEncryptedForSecurity');
 	$emailBody .="\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
-	$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
+	$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
     $email_admin = api_get_setting('emailAdministrator');
 			
 	if (@api_mail('', $emailTo, $emailSubject, $emailBody, $sender_name,$email_admin)==1)

+ 14 - 36
main/auth/my_progress.php

@@ -1,10 +1,13 @@
 <?php
+/* For licensing terms, see /dokeos_license.txt */
 // name of the language file that needs to be included
 $language_file = array('registration','tracking','exercice','admin');
 
 $cidReset = true;
+$this_section = 'session_my_space';
 
 require ('../inc/global.inc.php');
+
 require_once (api_get_path(LIBRARY_PATH).'tracking.lib.php');
 require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
 require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
@@ -12,8 +15,6 @@ require_once ('../newscorm/learnpath.class.php');
 
 $nameTools=get_lang('MyProgress');
 
-$this_section = 'session_my_progress';
-
 api_block_anonymous_users();
 
 Display :: display_header($nameTools);
@@ -35,28 +36,25 @@ $tbl_course_quiz 			= Database :: get_course_table(TABLE_QUIZ_TEST);
 
 
 // get course list
-$sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.$_user['user_id'];
+$sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.intval($_user['user_id']);
 $rs = api_sql_query($sql, __FILE__, __LINE__);
 $Courses = array();
-while($row = Database :: fetch_array($rs))
-{
+while($row = Database :: fetch_array($rs)) {
 	$Courses[$row['course_code']] = CourseManager::get_course_information($row['course_code']);
 }
 
 // get the list of sessions where the user is subscribed as student
 $sql = 'SELECT DISTINCT course_code FROM '.Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' WHERE id_user='.intval($_user['user_id']);
 $rs = api_sql_query($sql, __FILE__, __LINE__);
-while($row = Database :: fetch_array($rs))
-{
+while($row = Database :: fetch_array($rs)) {
 	$Courses[$row['course_code']] = CourseManager::get_course_information($row['course_code']);
 }
+
 echo '<div class="actions-title" >';
 echo $nameTools;
 echo '</div>';
 $now=date('Y-m-d');
-
 ?>
-
 <table class="data_table" width="100%">
 <tr class="tableName">
 	<td colspan="6">
@@ -82,10 +80,8 @@ $totalScore = 0;
 $totalItem = 0;
 $totalProgress = 0;
 
-foreach($Courses as $enreg)
-{
+foreach($Courses as $enreg) {
 	$weighting = 0;
-
 	$lastConnexion = Tracking :: get_last_connection_date_on_the_course($_user['user_id'],$enreg['code']);
 	$progress = Tracking :: get_avg_student_progress($_user['user_id'], $enreg['code']);
 	$total_time_login=Tracking :: get_time_spent_on_the_course($_user['user_id'], $enreg['code']);
@@ -97,15 +93,12 @@ foreach($Courses as $enreg)
   	<td>
 		<?php echo api_html_entity_decode($enreg['title'],ENT_QUOTES,$charset); ?>
   	</td>
-
   	<td align='center'>
 		<?php echo $time; ?>
   	</td>
-
   	<td align='center'>
   		<?php echo $progress.'%'; ?>
   	</td>
-
   	<td align='center'>
 		<?php 
 		if (!is_null($pourcentageScore)) {
@@ -115,27 +108,19 @@ foreach($Courses as $enreg)
 		}
 		?>
   	</td>
-
   	<td align='center' >
 		<?php echo $lastConnexion ?>
   	</td>
-
   	<td align='center'>
 		<a href="<?php echo api_get_self(); ?>?course=<?php echo $enreg['code']; ?>"> <?php Display::display_icon('2rightarrow.gif', get_lang('Details')); ?> </a>
   	</td>
 </tr>
-
 <?php
-
-
-
 	$i=$i ? 0 : 1;
 }
 ?>
 </table>
-
-<br/><br/>
-
+<br /><br />
 <?php
 /*
  * **********************************************************************************************
@@ -144,14 +129,12 @@ foreach($Courses as $enreg)
  *
  * **********************************************************************************************
  */
-	if(isset($_GET['course']))
-	{
+	if(isset($_GET['course'])) {
 		$course = Database::escape_string($_GET['course']);
 		$a_infosCours = CourseManager::get_course_information($course);
 		
 		//get coach and session_name if there is one and if session_mode is activated
-		if(api_get_setting('use_session_mode')=='true')
-		{
+		if(api_get_setting('use_session_mode')=='true') {
 			$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
 			$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
 			$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -190,12 +173,12 @@ foreach($Courses as $enreg)
 				if($session_course_coach_id!=0)
 				{
 					$coach_infos = UserManager :: get_user_info_by_id($session_course_coach_id);
-					$a_infosCours['tutor_name'] = $coach_infos['firstname'].' '.$coach_infos['lastname'];
+					$a_infosCours['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
 				}
 				else if($session_coach_id!=0)
 				{
 					$coach_infos = UserManager :: get_user_info_by_id($session_coach_id);
-					$a_infosCours['tutor_name'] = $coach_infos['firstname'].' '.$coach_infos['lastname'];
+					$a_infosCours['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
 				}
 			}
 		} // end if(api_get_setting('use_session_mode')=='true')
@@ -217,15 +200,10 @@ foreach($Courses as $enreg)
 			  <th class="head" style="color:#000"><?php echo get_lang('LastConnexion'); ?></th>
 			</tr>
 			<?php
-				$sqlLearnpath = "	SELECT lp.name,lp.id
-									FROM ".$a_infosCours['db_name'].".".$tbl_course_lp." AS lp
-								";
-
+				$sqlLearnpath = "SELECT lp.name,lp.id FROM ".$a_infosCours['db_name'].".".$tbl_course_lp." AS lp";
 				$resultLearnpath = api_sql_query($sqlLearnpath);
-
 				if(Database::num_rows($resultLearnpath)>0) {
 					while($a_learnpath = Database::fetch_array($resultLearnpath)) {
-
 						$progress = learnpath :: get_db_progress($a_learnpath['id'],$_user['user_id'], '%',$a_infosCours['db_name']);
 
 						// calculates last connection time

+ 4 - 4
main/blog/blog.php

@@ -1,5 +1,5 @@
 <?php //$Id: announcements.php 16702 2008-11-10 13:02:30Z elixir_inter $
-/*     
+/*
 ==============================================================================
 	Dokeos - elearning and course management software
 
@@ -64,9 +64,9 @@ require_once ($lib_path.'/fckeditor/fckeditor.php');
 $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
 
 $nameTools = get_lang('Blogs');
-$DaysShort = array (get_lang('SundayShort'), get_lang('MondayShort'), get_lang('TuesdayShort'), get_lang('WednesdayShort'), get_lang('ThursdayShort'), get_lang('FridayShort'), get_lang('SaturdayShort'));
-$DaysLong = array (get_lang('SundayLong'), get_lang('MondayLong'), get_lang('TuesdayLong'), get_lang('WednesdayLong'), get_lang('ThursdayLong'), get_lang('FridayLong'), get_lang('SaturdayLong'));
-$MonthsLong = array (get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong'));
+$DaysShort = api_get_week_days_short();
+$DaysLong = api_get_week_days_long();
+$MonthsLong = api_get_months_long();
 
 $current_page = $_GET['action'];
 

+ 3 - 3
main/blog/calendar.php

@@ -7,11 +7,11 @@ include('../inc/global.inc.php');
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array(get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort")); 
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array(get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong")); 
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array(get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong")); 
+$MonthsLong = api_get_months_long();
 
 ?>
 <html>

+ 45 - 46
main/calendar/agenda.inc.php

@@ -23,11 +23,11 @@
 */
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 /*
 ==============================================================================
@@ -398,15 +398,15 @@ function display_monthcalendar($month, $year)
 
 	for ($ii=1;$ii<8; $ii++)
 	{
-	echo "<td class=\"weekdays\" width=\"14%\">",$DaysShort[$ii%7],"</td>\n";
-  }
+		echo "<td class=\"weekdays\" width=\"14%\">",$DaysShort[$ii%7],"</td>\n";
+	}
 
 	echo "</tr>\n";
 	$curday = -1;
 	$today = getdate();
 	while ($curday <=$numberofdays[$month])
   	{
-	echo "<tr>\n";	
+		echo "<tr>\n";	
     	for ($ii=0; $ii<7; $ii++)
 	  	{
 	  		if (($curday == -1)&&($ii==$startdayofweek))
@@ -750,11 +750,11 @@ function get_course_users()
 	if (!isset($courseadmin_filter))
 		{$courseadmin_filter='';}
 	
+	$order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
 	$sql = "SELECT u.user_id uid, u.lastname lastName, u.firstname firstName
 			FROM $tbl_user as u, $tbl_courseUser as cu
 			WHERE cu.course_code = '".$_cid."'
-				AND cu.user_id = u.user_id $courseadmin_filter
-			ORDER BY u.lastname, u.firstname";
+			AND cu.user_id = u.user_id $courseadmin_filter".$order_clause;
 	$result = api_sql_query($sql,__FILE__,__LINE__);
 	while($user=Database::fetch_array($result)){
 		$users[$user[0]] = $user;
@@ -865,7 +865,7 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t
 			if (!is_array($to_already_selected) || !in_array("USER:".$this_user['uid'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
 			{
 				echo	"\t\t<option value=\"USER:",$this_user['uid'],"\">",
-					"",$this_user['lastName']," ",$this_user['firstName'],
+					"",api_get_person_name($this_user['firstName'], $this_user['lastName']),
 					"</option>\n";
 			}
 		}			
@@ -910,8 +910,8 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
 			}			
 			else
 			{								
-				$select_options_user[] = "\t\t<option value=\"".$groupuser."\">".$ref_array_users[$id]['lastName']." ".$ref_array_users[$id]['firstName']."</option>";
-				//echo "\t\t<option value=\"".$groupuser."\">".$ref_array_users[$id]['lastName']." ".$ref_array_users[$id]['firstName']."</option>";
+				$select_options_user[] = "\t\t<option value=\"".$groupuser."\">".api_get_person_name($ref_array_users[$id]['firstName'], $ref_array_users[$id]['lastName'])."</option>";
+				//echo "\t\t<option value=\"".$groupuser."\">".api_get_person_name($ref_array_users[$id]['firstName'], $ref_array_users[$id]['lastName'])."</option>";
 			}			
 		}
 		$select_options_group[] = "<option value=\"\">--------------------------------------------</option>";
@@ -943,7 +943,7 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
 					if (!is_array($to_already_selected) || !in_array("USER:".$this_user['uid'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
 					{
 						echo	"\t\t<option value=\"USER:",$this_user['uid'],"\">",
-							"",$this_user['lastName']," ",$this_user['firstName'],
+							"",api_get_person_name($this_user['firstName'], $this_user['lastName']),
 							"</option>\n";
 					}
 				}
@@ -1152,28 +1152,28 @@ function sent_to($tool, $id)
 	$sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'";
 	$result=api_sql_query($sql,__FILE__,__LINE__);
 	while ($row=Database::fetch_array($result))
-		{
+	{
 		// if to_group_id is null then it is sent to a specific user
 		// if to_group_id = 0 then it is sent to everybody
 		if (!is_null($row['to_group_id']) )
-			{
+		{
 			$sent_to_group[]=$row['to_group_id'];
 			//echo $row['to_group_id'];
-			}
+		}
 		// if to_user_id <> 0 then it is sent to a specific user
 		if ($row['to_user_id']<>0)
-			{
+		{
 			$sent_to_user[]=$row['to_user_id'];
-			}
 		}
+	}
 	if (isset($sent_to_group))
-		{
+	{
 		$sent_to['groups']=$sent_to_group;
-		}
+	}
 	if (isset($sent_to_user))
-		{
+	{
 		$sent_to['users']=$sent_to_user;
-		}
+	}
 	return $sent_to;
 }
 
@@ -1198,19 +1198,19 @@ function sent_to_form($sent_to_array)
 	// we count the number of users and the number of groups
 	if (isset($sent_to_array['users']))
 	{
-	$number_users=count($sent_to_array['users']);
+		$number_users=count($sent_to_array['users']);
 	}
 	else
 	{
-	$number_users=0;
+		$number_users=0;
 	}
 	if (isset($sent_to_array['groups']))
 	{
-	$number_groups=count($sent_to_array['groups']);
+		$number_groups=count($sent_to_array['groups']);
 	}
 	else
 	{
-	$number_groups=0;
+		$number_groups=0;
 	}
 	$total_numbers=$number_users+$number_groups;
 
@@ -1234,7 +1234,7 @@ function sent_to_form($sent_to_array)
 			foreach ($sent_to_array['users'] as $user_id)
 				{
 				$user_info=api_get_user_info($user_id);
-				$output.="\t<option value=\"\">".$user_info['firstName']." ".$user_info['lastName']."</option>\n";
+				$output.="\t<option value=\"\">".api_get_person_name($user_info['firstName'], $user_info['lastName'])."</option>\n";
 				}
 			}
 	}
@@ -1244,21 +1244,21 @@ function sent_to_form($sent_to_array)
 	}
 	else // there is only one user/group
 	{
-	if (is_array($sent_to_array['users']))
+		if (is_array($sent_to_array['users']))
 		{
-		$user_info=api_get_user_info($sent_to_array['users'][0]);
-		echo $user_info['firstName']." ".$user_info['lastName'];
+			$user_info=api_get_user_info($sent_to_array['users'][0]);
+			echo api_get_person_name($user_info['firstName'], $user_info['lastName']);
 		}
-	if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
+		if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
 		{
-		$group_id=$sent_to_array['groups'][0];
-		echo $group_names[$group_id]['name'];
+			$group_id=$sent_to_array['groups'][0];
+			echo $group_names[$group_id]['name'];
 		}
-	if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0)
+		if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0)
 		{
-		echo get_lang("Everybody");
+			echo get_lang("Everybody");
 		}
-	//.$sent_to_array['groups'][0];
+		//.$sent_to_array['groups'][0];
 	}
 
 	echo $output;
@@ -1273,15 +1273,15 @@ function show_group_filter_form()
 {
 	$group_list=get_course_groups();
 	
-	echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
+	echo "<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";
 	echo "<option value=\"agenda.php?group=none\">show all groups</option>";
 	foreach($group_list as $this_group)
-		{
+	{
 		// echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
 		echo "<option value=\"agenda.php?group=".$this_group['id']."\" ";
 		echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
 		echo ">".$this_group['name']."</option>";
-		}
+	}
 	echo "</select>";
 }
 
@@ -1295,14 +1295,14 @@ function show_user_filter_form()
 {
 	$user_list=get_course_users();
 	
-	echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
+	echo "<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";
 	echo "<option value=\"agenda.php?user=none\">show all users</option>";
 	foreach($user_list as $this_user)
 		{
-		// echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
+		// echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".api_get_person_name($this_user['firstName'], $this_user['lastName'])."</option>";
 		echo "<option value=\"agenda.php?user=".$this_user['uid']."\" ";
 		echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
-		echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";
+		echo ">".api_get_person_name($this_user['firstName'], $this_user['lastName'])."</option>";
 		}
 	echo "</select>";
 }
@@ -1315,7 +1315,7 @@ function show_user_filter_form()
 */
 function show_user_group_filter_form()
 {
-	echo "\n<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
+	echo "\n<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";
 	
 	// Groups
 	$option = "\n\t<optgroup label=\"".get_lang("Groups")."\">";
@@ -1357,7 +1357,7 @@ function show_user_group_filter_form()
 	foreach($user_list as $this_user) {
 		echo "\n\t\t<option value=\"agenda.php?user=".$this_user['uid']."\" ";
 		echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
-		echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";		
+		echo ">".api_get_person_name($this_user['firstName'], $this_user['lastName'])."</option>";
 	}		
 	echo "\n\t</optgroup>";
 	echo "</select>";
@@ -1400,7 +1400,6 @@ function load_edit_users($tool, $id)
 }
 
 
-
 /**
 * This functions swithes the visibility a course resource using the visible field in 'last_tooledit' values: 0 = invisible
 * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
@@ -2434,7 +2433,7 @@ function display_one_agenda_item($agenda_id)
 	    //echo '<a class="ical_export" href="'.$mylink.'&amp;class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> ';
 	    //echo '<a class="ical_export" href="'.$mylink.'&amp;class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> ';
 	    //echo '<a class="ical_export" href="'.$mylink.'&amp;class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> ';
-	    echo '<a href="#" onclick="javascript:win_print=window.open(\'print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">'.Display::return_icon('print.gif', get_lang('Print')).'</a>&nbsp;';
+	    echo '<a href="javascript: void(0);" onclick="javascript:win_print=window.open(\'print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">'.Display::return_icon('print.gif', get_lang('Print')).'</a>&nbsp;';
 		echo "</td></tr>";
 	    if($repeat) {
 	    	echo '<tr>';
@@ -2614,7 +2613,7 @@ function show_add_form($id = '')
 	{
 		echo '	<div class="row">
 					<div class="label">
-						<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.Display::return_icon('group.gif', get_lang('SentTo'), array ('align' => 'absmiddle')).' '.get_lang('SentTo').'</a>
+						<a href="javascript: void(0);" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.Display::return_icon('group.gif', get_lang('SentTo'), array ('align' => 'absmiddle')).' '.get_lang('SentTo').'</a>
 					</div>
 					<div class="formw">';
 		if ((isset($_GET['id'])  && $to=='everyone') || !isset($_GET['id']))

+ 3 - 3
main/calendar/agenda.php

@@ -201,11 +201,11 @@ event_access_tool(TOOL_CALENDAR_EVENT);
 // Variable definitions
 $dateNow 			= format_locale_date($dateTimeFormatLong);
 // Defining the shorts for the days. We use camelcase because these are arrays of language variables
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days. We use camelcase because these are arrays of language variables
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months. We use camelcase because these are arrays of language variables
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 // Database table definitions
 $TABLEAGENDA 			= Database::get_course_table(TABLE_AGENDA);

+ 22 - 14
main/calendar/calendar.php

@@ -22,10 +22,8 @@
 ==============================================================================
 */
 
-// name of the language file that needs to be included
 $language_file = 'agenda';
-// including the claroline global 
-require_once '../inc/global.inc.php';
+require_once dirname(__FILE__).'/../inc/global.inc.php';
 
 //session
 if(isset($_GET['id_session']))
@@ -33,17 +31,27 @@ if(isset($_GET['id_session']))
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array(get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort")); 
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array(get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong")); 
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array(get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong")); 
-
+$MonthsLong = api_get_months_long();
+@ $iso_lang = Database :: get_language_isocode($language_interface);
+if (empty ($iso_lang) )
+{
+	//if there was no valid iso-code, use the english one
+	$iso_lang = 'en';
+}
 ?>
-<html>
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $iso_lang; ?>" lang="<?php echo $iso_lang; ?>">
 <head>
 <title>Calendar</title>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>">
 <style type="text/css">
+/*<![CDATA[*/
 @import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo api_get_setting('stylesheets'); ?>/default.css";
 .data_table th
 {
@@ -77,8 +85,8 @@ table.calendar td
 	background-color: #ffff00;
 }
 </style>
-<script language="JavaScript" type="text/javascript">
-<!--
+<script type="text/javascript">
+/* <![CDATA[ */
     /* added 2004-06-10 by Michael Keck
      *       we need this for Backwards-Compatibility and resolving problems
      *       with non DOM browsers, which may have problems with css 2 (like NC 4)
@@ -107,11 +115,11 @@ table.calendar td
             }
         } // end if... else if...
     } // end if
-//-->
+/* ]]> */
 </script>
 <script type="text/javascript" src="tbl_change.js"></script>
 <script type="text/javascript">
-<!--
+/* <![CDATA[ */
 var month_names = new Array(
 <?php
 foreach($MonthsLong as $index => $month)
@@ -128,10 +136,10 @@ foreach($DaysShort as $index => $day)
 }
 ?>
 "");
-//-->
+/* ]]> */
 </script>
 </head>
-<body onLoad="initCalendar();">
+<body onLoad="javascript: initCalendar();">
 <div id="calendar_data"></div>
 <div id="clock_data"></div>
 </body>

+ 3 - 3
main/calendar/ical_export.php

@@ -29,11 +29,11 @@ $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
 {

+ 3 - 3
main/calendar/myagenda.php

@@ -103,11 +103,11 @@ $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 /*==============================================================================
   			TREATING THE URL PARAMETERS

+ 1 - 1
main/calendar/tbl_change.js

@@ -13,7 +13,7 @@ var clock_set = 0;
  * @param   string      field name
  */
 function openCalendar(form, field) {
-    window.open("./calendar.php", "calendar", "width=260,height=220,status=yes");
+    window.open("./calendar.php", "calendar", "width=260,height=250,status=yes");
 	day = eval("document." + form + "." + field + "day.options["+ "document." + form + "." + field + "day.selectedIndex].value");
     month = eval("document." + form + "." + field + "month.options["+ "document." + form + "." + field + "month.selectedIndex].value");
    	month = month-1;

+ 2 - 2
main/chat/chat_message.php

@@ -248,13 +248,13 @@ if (!empty($course) && !empty($_user['user_id']))
 				if($isMaster)
 				{
 					$photo= '<img src="'.api_get_path(WEB_IMG_PATH).'teachers.gif" alt="'.get_lang('Teacher').'"  width="11" height="11" align="top"  title="'.get_lang('Teacher').'"  />';				
-					fputs($fp,'<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <span id="chat_login_name"><b>'.$firstname.' '.$lastname.'</b></span> : <i>'.$message.'</i><br>'."\n");	 		
+					fputs($fp,'<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <span id="chat_login_name"><b>'.api_get_person_name($firstname, $lastname).'</b></span> : <i>'.$message.'</i><br>'."\n");	 		
 					
 				}
 				else
 				{
 					$photo= '<img src="'.api_get_path(WEB_IMG_PATH).'students.gif" alt="'.get_lang('Student').'"  width="11" height="11" align="top"  title="'.get_lang('Student').'"  />';
-					 fputs($fp,'<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <b>'.$firstname.' '.$lastname.'</b> : <i>'.$message.'</i><br>'."\n");
+					 fputs($fp,'<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <b>'.api_get_person_name($firstname, $lastname).'</b> : <i>'.$message.'</i><br>'."\n");
 				}
 		
 				fclose($fp);

+ 1 - 1
main/chat/chat_whoisonline.php

@@ -114,7 +114,7 @@ if (!empty($course))
 	?>    
     <tr>    
 	  <td width="1%" valign="top"><img src="<?php echo $file_url;?>" border="0" width="22" alt="" /></td>
-	  <td width="99%"><?php if($status == 1) echo Display::return_icon('teachers.gif', get_lang('Teacher'),array('height' => '11')).' '; else echo Display::return_icon('students.gif', get_lang('Student'), array('height' => '11'));?><a <?php if($status == 1) echo 'class="master"';// ?> name="user_<?php echo $enreg['user_id']; ?>" href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&showPic=<?php if($showPic == $enreg['user_id']) echo '0'; else echo $enreg['user_id']; ?>#user_<?php echo $enreg['user_id']; ?>"><?php echo api_ucfirst($enreg['firstname']).' '.api_ucfirst($enreg['lastname']); ?></a></td>
+	  <td width="99%"><?php if($status == 1) echo Display::return_icon('teachers.gif', get_lang('Teacher'),array('height' => '11')).' '; else echo Display::return_icon('students.gif', get_lang('Student'), array('height' => '11'));?><a <?php if($status == 1) echo 'class="master"';// ?> name="user_<?php echo $enreg['user_id']; ?>" href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&showPic=<?php if($showPic == $enreg['user_id']) echo '0'; else echo $enreg['user_id']; ?>#user_<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></a></td>
 	</tr>
 	<?php
 	

+ 23 - 22
main/course_info/infocours.php

@@ -116,25 +116,26 @@ $s_tutor=mysql_result($q_tutor,0,"tutor_name");
 $s_sql_course_titular="SELECT DISTINCT username, lastname, firstname FROM $tbl_user as user, $tbl_course_user as course_rel_user WHERE (course_rel_user.status='1') AND user.user_id=course_rel_user.user_id AND course_code='".$course_code."'";
 $q_result_titulars=api_sql_query($s_sql_course_titular, __FILE__, __LINE__);
 
+$target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
 if(mysql_num_rows($q_result_titulars)==0){
-	$sql="SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id ORDER BY lastname ASC";
+	$sql="SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id ORDER BY ".$target_name." ASC";
 	$q_result_titulars=api_sql_query($sql, __FILE__, __LINE__);
 }
 
 $a_profs[0] = '-- '.get_lang('NoManager').' --';
-while($a_titulars=mysql_fetch_array($q_result_titulars)){
-		$s_username=$a_titulars["username"];
-		$s_lastname=$a_titulars["lastname"];
-		$s_firstname=$a_titulars["firstname"];
+while ($a_titulars = mysql_fetch_array($q_result_titulars)) {
+	$s_username = $a_titulars['username'];
+	$s_lastname = $a_titulars['lastname'];
+	$s_firstname = $a_titulars['firstname'];
 
-		if($s_firstname.' '.$s_lastname==$s_tutor){
-			$s_selected_tutor=$s_firstname.' '.$s_lastname;
-		}
-		$s_disabled_select_titular="";
-		if(!$is_courseAdmin){
-            $s_disabled_select_titular="disabled=disabled";
-		}
-		$a_profs[$s_firstname.' '.$s_lastname]="$s_lastname $s_firstname ($s_username)";
+	if (api_get_person_name($s_firstname, $s_lastname) == $s_tutor) {
+		$s_selected_tutor = api_get_person_name($s_firstname, $s_lastname);
+	}
+	$s_disabled_select_titular = '';
+	if (!$is_courseAdmin) {
+		$s_disabled_select_titular = 'disabled=disabled';
+	}
+	$a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname).' ('.$s_username.')';
 }
 
 while ($cat = mysql_fetch_array($res))
@@ -152,7 +153,7 @@ $form = new FormValidator('update_course');
 // COURSE SETTINGS
 $form->addElement('html','<div class="sectiontitle"><a href="#header" style="float:right;">'.Display::return_icon('top.gif',get_lang('Top')).'</a><a name="coursesettings" id="coursesettings"></a>'.Display::return_icon('settings.gif',get_lang('CourseSettings')).' '.get_lang('CourseSettings').'</div>');
 $visual_code=$form->addElement('text','visual_code', get_lang('Code'));
-$visual_code->freeze();
+	$visual_code->freeze();
 $form->applyFilter('visual_code', 'strtoupper');
 //$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
 $prof = &$form->addElement('select', 'tutor_name', get_lang('Professors'), $a_profs);
@@ -253,11 +254,11 @@ $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class=
 if (api_get_setting('allow_course_theme') == 'true')
 {	
 	$form->addElement('html','<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif',get_lang('Top')).'</a><a name="theme" id="theme"></a>'.Display::return_icon('theme.gif',get_lang('Theming')).' '.get_lang('Theming').'</div><div style="clear:both;"></div>');
-	
+
 	//Allow Learning path 
 	$form->addElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
 	$form->addElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
-	$form -> addElement('html',$linebreak);	
+	$form -> addElement('html',$linebreak);
 	
 	$form->addElement('select_theme', 'course_theme', get_lang('Theme'));
 	$form->applyFilter('course_theme', 'trim');
@@ -265,9 +266,9 @@ if (api_get_setting('allow_course_theme') == 'true')
 }
 
 if (is_settings_editable())
-{
+	{
 	$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
-}
+	}
 else
 {
 	// is it allowed to edit the course settings?
@@ -321,7 +322,7 @@ if ($form->validate() && is_settings_editable()) {
 	$update_values = $form->exportValues();
 	foreach ($update_values as $index => $value) {
 		$update_values[$index] = Database::escape_string($value);
-	}	
+	}
 	$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
 	$sql = "UPDATE $table_course SET title 			= '".Security::remove_XSS($update_values['title'])."',
 										 visual_code 	= '".$update_values['visual_code']."',
@@ -366,7 +367,7 @@ if ($form->validate() && is_settings_editable()) {
 	if($update_values['allow_user_image_forum'] != $values['allow_user_image_forum']){
 		$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_image_forum']." WHERE variable = 'allow_user_image_forum' ";
 		api_sql_query($sql,__FILE__,__LINE__);
-	}	
+	}
 	if($update_values['allow_open_chat_window'] != $values['allow_open_chat_window']){
 		$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_open_chat_window']." WHERE variable = 'allow_open_chat_window' ";
 		api_sql_query($sql,__FILE__,__LINE__);
@@ -397,9 +398,9 @@ Display :: display_header($nameTools, MODULE_HELP_NAME);
 
 //api_display_tool_title($nameTools);
 if (isset ($_GET['action']) && $_GET['action'] == 'show_message')
-{
+	{
 	Display :: display_normal_message(get_lang('ModifDone'));
-}
+	}
 
 // actions bar
 echo '<div class="actions">';

+ 3 - 3
main/course_info/postpone.php

@@ -92,14 +92,14 @@ $currentCourseExpirationDate	= $currentCourseExtentionData["expiration_date"];
 <h3>
 	<?php echo $nameTools ?>
 </h3>
-<?php echo get_lang('SubTitle'); ?>
+<?php //echo get_lang('SubTitle'); ?>
 
 
-this script  would be  called  by  
+This script  would be  called  by  
 	professor, 
 	or administrator, 
 	or other  script 
-to give more time to a course before expiration
+to give more time to a course before expiration.
 
 <?php
 Display::display_footer();

+ 1 - 1
main/create_course/add_course.php

@@ -93,7 +93,7 @@ if (isset($_user["language"]) && $_user["language"]!="") {
 	$values['course_language'] = api_get_setting('platformLanguage');
 }
 
-$values['tutor_name'] = $_user['firstName']." ".$_user['lastName'];
+$values['tutor_name'] = api_get_person_name($_user['firstName'], $_user['lastName'], null, null, $values['course_language']);
 $form->setDefaults($values);
 // Validate the form
 if ($form->validate()) {

+ 4 - 4
main/document/document.inc.php

@@ -102,7 +102,7 @@ function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRend
 				elseif(strstr($folder_titles[$folder], 'sf_user_'))
 				{			
 						$userinfo=Database::get_user_info_from_id(substr($folder_titles[$folder],8));
-						$folder_titles[$folder]=$userinfo['lastname'].', '.$userinfo['firstname'];				
+					$folder_titles[$folder]=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);				
 				}				
 				
 				$label = str_repeat('&nbsp;&nbsp;&nbsp;',count($path_parts)-2).' &mdash; '.$folder_titles[$folder];
@@ -189,7 +189,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
 			$url=$www.$path;
 		}
 		//files that we want opened in a new window
-		if($ext=='txt') //add here
+		if($ext=='txt' || $ext=='log' || $ext=='css' || $ext=='js') //add here
 		{
 			$target='_blank';
 		}
@@ -211,7 +211,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
 	elseif(strstr($tooltip_title, 'sf_user_'))
 	{
 		$userinfo=Database::get_user_info_from_id(substr($tooltip_title,8));
-		$tooltip_title_alt=$userinfo['lastname'].', '.$userinfo['firstname'];
+		$tooltip_title_alt=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
 	}
 	else
 	{
@@ -271,7 +271,7 @@ function build_document_icon_tag($type, $path)
 			{
 				$icon = '../upload/users/'.substr($basename,8).'/'.$image_path['file'];
 			}
-			$basename = $userinfo['lastname'].', '.$userinfo['firstname'];			
+			$basename = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);			
 		}
 		else
 		{	

+ 14 - 14
main/document/document.php

@@ -318,7 +318,7 @@ for ($i=0; $i<$array_len;$i++)
 	elseif(strstr($dir_array[$i], 'sf_user_'))
 	{
 		$userinfo=Database::get_user_info_from_id(substr($dir_array[$i], 8));		
-		$dir_array[$i]=$userinfo['lastname'].', '.$userinfo['firstname'];
+		$dir_array[$i]=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
 	}
 
 	$url_dir='document.php?&curdirpath='.$dir_acum.$dir_array[$i]; 
@@ -370,7 +370,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
 	  ======================================*/
 	$my_get_move=Security::remove_XSS($_GET['move']); 
 	if (isset($_GET['move']) && $_GET['move']!='')
-	{	
+	{ 	
 		if (!$is_allowed_to_edit)
 		{
 			if(DocumentManager::check_readonly($_course,$_user['user_id'],$my_get_move))
@@ -606,7 +606,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
 		$template_text .= '<button type="submit" class="add" name="create_template">'.get_lang('CreateTemplate').'</button>';
 		$template_text .= '</form>';
 		//show the form
-		Display::display_normal_message($template_text,false);
+		Display::display_normal_message($template_text,false);		
 		
 	} elseif(isset($_GET['add_as_template']) && isset($_POST['create_template'])) {		
 		
@@ -636,26 +636,26 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
 				
 				// upload dir
 				$upload_dir = api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/';
-				
+
 				// resize image to max default and end upload
 				require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
 				$temp = new image($_FILES['template_image']['tmp_name']);
-				$picture_infos=getimagesize($_FILES['template_image']['tmp_name']);
-				
+				$picture_infos = @getimagesize($_FILES['template_image']['tmp_name']);
+
 				$max_width_for_picture = 100;
-				
+
 				if ($picture_infos[0]>$max_width_for_picture) {		
 					$thumbwidth = $max_width_for_picture;
 					if (empty($thumbwidth) or $thumbwidth==0) {
 					  $thumbwidth=$max_width_for_picture;
 					}
 					$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
-					
+
 					$temp->resize($thumbwidth,$new_height,0);
 				}
-				
+
 				$type=$picture_infos[2];
-						  
+
 				switch (!empty($type)) {
 					case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name);							 
 							 break;
@@ -668,7 +668,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
 	   }	
 		
 		DocumentManager::set_document_as_template($title, $description, $document_id_for_template, $course_code, $user_id, $new_file_name);		
-		Display::display_confirmation_message(get_lang('DocumentSetAsTemplate'));
+		Display::display_confirmation_message(get_lang('DocumentSetAsTemplate'));		
 	}
 		
 	if(isset($_GET['remove_as_template'])) {		
@@ -741,12 +741,12 @@ if(isset($docs_and_folders) && is_array($docs_and_folders))
 			$document_name=$id['title'];
 		} else {
 		   $document_name=basename($id['path']);
-			//Juan Carlos Ra�a get lastname and firstname when folder is in shared_folder
+			//Juan Carlos Raña: Get firstname and lastname when folder is in shared_folder.
 			//TODO: check if is also necessary (above else)
 			if(strstr($document_name, 'sf_user_'))
 			{
 				$userinfo=Database::get_user_info_from_id(substr($document_name, 8));
-				$document_name=$userinfo['lastname'].', '.$userinfo['firstname'];
+				$document_name=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
 			}
 			elseif(strstr($document_name, 'shared_folder'))
 			{
@@ -764,7 +764,7 @@ if(isset($docs_and_folders) && is_array($docs_and_folders))
 		if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') {
 			if (!empty($id['insert_user_id'])) {
 				$user_info=UserManager::get_user_info_by_id($id['insert_user_id']);		
-				$user_name=$user_info['firstname'].' '.$user_info['lastname'];
+				$user_name=api_get_person_name($user_info['firstname'], $user_info['lastname']);
 				$user_link='<div class="document_owner">'.get_lang('Owner').': '.display_user_link_document($id['insert_user_id'],$user_name).'</div>';
 			}
 		}

+ 1 - 1
main/dropbox/dropbox_class.inc.php

@@ -104,7 +104,7 @@ class Dropbox_Work {
 		$this->filesize = $filesize;
 		$this->title = $title;
 		$this->description = $description;
-		$this->author 			= $_user['firstName'].' '.$_user['lastName'];
+		$this->author = api_get_person_name($_user['firstName'], $_user['lastName']);
 		$this->last_upload_date = date("Y-m-d H:i:s",time());
 
 		// Check if object exists already. If it does, the old object is used

+ 10 - 10
main/dropbox/dropbox_functions.inc.php

@@ -584,9 +584,9 @@ function display_add_form()
 		}
 	}
 
-	foreach ($complete_user_list_for_dropbox as $k => $e)
-	    $complete_user_list_for_dropbox[$k] = $e +
-	        array('lastcommafirst' => $e['lastname'] . ', ' . $e['firstname']);
+	foreach ($complete_user_list_for_dropbox as $k => $e) {
+	    $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
+	}
 
 	$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
 
@@ -685,7 +685,7 @@ function getUserNameFromId ( $id)  // RH: Mailing: return 'Mailing ' + id
 	    return dropbox_lang("mailingAsUsername", "noDLTT") . $mailingId;
     }
     $id = intval($id);
-    $sql = "SELECT CONCAT(lastname,' ', firstname) AS name
+    $sql = "SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ', lastname)" : "CONCAT(lastname,' ', firstname)")." AS name
 			FROM " . dropbox_cnf("tbl_user") . "
 			WHERE user_id='$id'";
     $result = Database::query($sql,__FILE__,__LINE__);
@@ -829,7 +829,7 @@ function dropbox_lang($variable, $notrans = 'DLTT')
 /**
 * Function that finds a given config setting
 *
-* @author Ren� Haentjens, Ghent University
+* @author René Haentjens, Ghent University
 */
 function dropbox_cnf($variable)
 {
@@ -1020,10 +1020,10 @@ function store_add_dropbox()
 		{
 			include_once(api_get_path(LIBRARY_PATH) . 'usermanager.lib.php');
 			$recipent_temp=UserManager :: get_user_info_by_id($recipient_id);
-			api_mail($recipent_temp['lastname'].' '.$recipent_temp['firstname'],$recipent_temp['email'],
+			api_mail(api_get_person_name($recipent_temp['firstname'].' '.$recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'],
 				get_lang('NewDropboxFileUploaded'),
-				get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".$_user['firstName']." ".$_user['lastName']."\n".  get_lang('Email') ." : ".$_user['mail'], $_user['firstName']." ".$_user['lastName'],$_user['mail']);
-				//get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'),api_get_setting('administratorName')." ".api_get_setting('administratorSurname'),api_get_setting('emailAdministrator'));
+				get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)."\n".  get_lang('Email') ." : ".$_user['mail'], api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_user['mail']);
+				//get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName')." ".api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator'));
 		}
 	}
 	
@@ -1057,7 +1057,7 @@ function display_user_link($user_id, $name='')
 			$sql="SELECT * FROM $table_user WHERE user_id='".Database::escape_string($user_id)."'";
 			$result=Database::query($sql,__FILE__,__LINE__);
 			$row=Database::fetch_array($result);
-			return "<a href=\"../user/userInfo.php?uInfo=".$row['user_id']."\">".$row['firstname']." ".$row['lastname']."</a>";
+			return "<a href=\"../user/userInfo.php?uInfo=".$row['user_id']."\">".api_get_person_name($row['firstname'], $row['lastname'])."</a>";
 		}
 		else
 		{
@@ -1300,7 +1300,7 @@ function zip_download_alternative($files)
 	
 	// Step 1: create the overview file and add it to the zip
 	$overview_file_content=generate_html_overview($files, array('filename'), array('title'));
-	$overview_file=$temp_zip_dir.'overview'.$_user['firstname'].$_user['lastname'].'.html';
+	$overview_file=$temp_zip_dir.'overview'.replace_dangerous_char(api_is_western_name_order() ? $_user['firstname'].$_user['lastname'] : $_user['lastname'].$_user['firstname'], 'strict').'.html';
 	$handle=fopen($overview_file,'w');
 	fwrite($handle,$overview_file_content);
 	// todo: find a different solution for this because even 2 seconds is no guarantee.

+ 2 - 2
main/dropbox/dropbox_init.inc.php

@@ -115,7 +115,7 @@ if ($_GET['action']=='add')
 -----------------------------------------------------------
 */
 
-$javascript = "<script>
+$javascript = "<script type=\"text/javascript\">
 	function confirmsend ()
 	{
 		if (confirm(\"".dropbox_lang("mailingConfirmSend", "noDLTT")."\")){
@@ -216,7 +216,7 @@ $javascript .="
 $htmlHeadXtra[] = $javascript;
 
 $htmlHeadXtra[] =
-"<script>
+"<script type=\"text/javascript\">
 function confirmation (name)
 {
 	if (confirm(\" ". get_lang("AreYouSureToDelete") ." \"+ name + \" ?\"))

+ 4 - 4
main/dropbox/dropbox_submit.php

@@ -68,7 +68,7 @@ if ( isset( $_POST["submitWork"]))
 
     /**
      * --------------------------------------
-     * �����FORM SUBMIT : VALIDATE POSTED DATA
+     * FORM SUBMIT : VALIDATE POSTED DATA
      * --------------------------------------
      */
     // the author or description field is empty
@@ -142,7 +142,7 @@ if ( isset( $_POST["submitWork"]))
 
     /**
      * --------------------------------------
-     * ����FORM SUBMIT : UPLOAD NEW FILE
+     * FORM SUBMIT : UPLOAD NEW FILE
      * --------------------------------------
      */
     if ( !$error)
@@ -458,7 +458,7 @@ if ( isset( $_GET['mailingIndex']))  // examine or send
 		            {
 						$errormsg .= dropbox_lang("mailingFileIsFor");
 		            }
-					$errormsg .= htmlspecialchars($thisRecip[1].' '.$thisRecip[2],ENT_QUOTES,$charset);
+					$errormsg .= htmlspecialchars(api_get_person_name($thisRecip[2], $thisRecip[1]), ENT_QUOTES, $charset);
 
 					if ( is_null($thisRecip[3]))
 					{
@@ -489,7 +489,7 @@ if ( isset( $_GET['mailingIndex']))  // examine or send
 		        $remainingUsers = '';
 		        while ( ($res = mysql_fetch_array($result)))
 		        {
-					$remainingUsers .= ', ' . htmlspecialchars($res[0].' '.$res[1],ENT_QUOTES,$charset);
+					$remainingUsers .= ', ' . htmlspecialchars(api_get_person_name($res[1], $res[0]), ENT_QUOTES, $charset);
 		        }
 		        $errormsg .= '<br />' . dropbox_lang("mailingNothingFor") . api_substr($remainingUsers, 1) . '.<br />';
 	        }

+ 1 - 0
main/dropbox/index.php

@@ -521,6 +521,7 @@ if (!$_GET['view'] OR $_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs'
 			foreach ($dropbox_file->recipients as $recipient) {
 				$receivers_celldata=display_user_link($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
 			}
+			$receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
 			$dropbox_file_data[]=$receivers_celldata;
 			$dropbox_file_data[]=date_to_str_ago($dropbox_file->last_upload_date).'<br><span class="dropbox_date">'.$dropbox_file->last_upload_date.'</span>';
 

+ 2 - 25
main/exercice/exercice.php

@@ -1,29 +1,6 @@
 <?php
 // $Id: exercice.php 22201 2009-07-17 19:57:03Z cfasanando $
-
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
 
 /**
 *	Exercise list: This script shows the list of exercises for administrators and students.
@@ -403,7 +380,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
 		}
 		if ($origin == 'tracking_course' && !empty($_POST['lp_item_id'])) {
 			//Redirect to the course detail in lp		
-			header('location: ../mySpace/lp_tracking.php?course=' . Security :: remove_XSS($_GET['course']) . '&origin=' . $origin . '&lp_id=' . Security :: remove_XSS($_POST['lp_item_id']) . '&student_id=' . Security :: remove_XSS($_GET['student']));
+			header('location: ../mySpace/lp_tracking.php?course=' . Security :: remove_XSS($_GET['course']) . '&origin=' . $origin . '&lp_id=' . Security :: remove_XSS($_POST['lp_item_id']) . '&student_id=' . Security :: remove_XSS($_GET['student']).'&from='.Security::remove_XSS($_GET['from']));
 		} else {
 			//Redirect to the reporting		
 			header('location: ../mySpace/myStudents.php?origin=' . $origin . '&student=' . Security :: remove_XSS($_GET['student']) . '&details=true&course=' . Security :: remove_XSS($_GET['course']));

+ 20 - 4
main/exercice/exercise_show.php

@@ -101,13 +101,27 @@ if (!empty($gradebook) && $gradebook=='view') {
 			'name' => get_lang('Gradebook')
 		);
 }
-
+$fromlink = '';
 if($origin=='user_course') {
 	$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
 	$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student'])."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
 } else if($origin=='tracking_course') {
-	$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
- 	$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
+	
+	//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
+ 	//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
+ 	$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
+	$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));	
+	$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
+	$interbreadcrumb[] = array ("url" => "../mySpace/lp_tracking.php?action=stats&course=".$cidReq."&student_id=".Security::remove_XSS($_GET['student'])."&lp_id=".$_GET['my_lp_id']."&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("LearningPathDetails"));
+
+	$from_myspace = false;
+	if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
+		$fromlink = '&from=myspace';
+		$this_section = "session_my_space";
+	} else {
+		$this_section = SECTION_COURSES;
+	}
+
 } else if($origin=='student_progress') {
 	$interbreadcrumb[] = array ("url" => "../auth/my_progress.php?id_session".Security::remove_XSS($_GET['id_session'])."&course=".$_cid, "name" => get_lang('MyProgress'));
 	unset($_cid);
@@ -116,6 +130,7 @@ if($origin=='user_course') {
 	$this_section=SECTION_COURSES;
 }
 
+
 if ($origin != 'learnpath') {
 	Display::display_header($nameTools,"Exercise");
 } else {
@@ -1030,7 +1045,8 @@ if (is_array($arrid) && is_array($arrmarks)) {
 
 if ($is_allowedToEdit) {		
 	if (in_array($origin, array('tracking_course','user_course'))) {
-		echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.urlencode($test).'&emailid='.$emailId.'&origin='.$origin.'&student='.$_GET['student'].'&details=true&course='.$_GET['cidReq'].'" method="post">';
+		
+		echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.urlencode($test).'&emailid='.$emailId.'&origin='.$origin.'&student='.$_GET['student'].'&details=true&course='.$_GET['cidReq'].$fromlink.'" method="post">';
 		echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
 		if (isset($_GET['myid']) && isset($_GET['my_lp_id']) && isset($_GET['student'])) {			
 			?>

+ 11 - 9
main/inc/lib/formvalidator/Element/calendar_popup.php

@@ -21,19 +21,21 @@
 	Mail: info@dokeos.com
 ==============================================================================
 */
-// including the relevant language file
-// name of the language file that needs to be included 
+
 $language_file = 'agenda';
-// including the claroline global 
-require ('../../../global.inc.php');
+require_once dirname(__FILE__).'/../../../global.inc.php';
+
+//session
+if(isset($_GET['id_session']))
+	$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']);
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array(get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort")); 
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array(get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong")); 
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array(get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong")); 
+$MonthsLong = api_get_months_long();
 @ $iso_lang = Database :: get_language_isocode($language_interface);
 if (empty ($iso_lang) )
 {
@@ -48,9 +50,9 @@ if (empty ($iso_lang) )
 <head>
 <title>Calendar</title>
 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>">
-<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>/css/default.css"/>
 <style type="text/css">
 /*<![CDATA[*/
+@import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo api_get_setting('stylesheets'); ?>/default.css";
 table.calendar
 {
 	width: 100%;	
@@ -157,7 +159,7 @@ foreach($DaysShort as $index => $day)
 /* ]]> */
 </script>
 </head>
-<body onload="initCalendar();">
+<body onLoad="javascript: initCalendar();">
 <div id="calendar_data"></div>
 <div id="clock_data"></div>
 </body>

+ 5 - 4
main/inc/lib/internationalization.lib.php

@@ -26,13 +26,14 @@ define('DATE_FORMAT_LONG', 2);		// Aug 25, 09
 define('DATE_TIME_FORMAT_LONG', 3);	// August 25, 2009 at 03:28 PM
 
 // Formatting person's name.
-define('PERSON_NAME_COMMON_CONVENTION', 0);	// Formatting person's name using the pattern as it has been
+define('PERSON_NAME_COMMON_CONVENTION', 0);	// Formatting a person's name using the pattern as it has been
 											// configured in the internationalization database for every language.
 											// This (default) option would be the most used.
 // The followind options may be used in limited number of places for overriding the common convention:
-define('PERSON_NAME_WESTERN_ORDER', 1);		// Formatting person's name in Western order: first_name last_name
-define('PERSON_NAME_EASTERN_ORDER', 2);		// Formatting person's name in Eastern order: last_name first_name
-define('PERSON_NAME_LIBRARY_ORDER', 3);		// Formatting person's name in library order: last_name, first_name
+define('PERSON_NAME_WESTERN_ORDER', 1);		// Formatting a person's name in Western order: first_name last_name
+define('PERSON_NAME_EASTERN_ORDER', 2);		// Formatting a person's name in Eastern order: last_name first_name
+define('PERSON_NAME_LIBRARY_ORDER', 3);		// Contextual: formatting person's name in library order: last_name, first_name
+define('PERSON_NAME_EMAIL_ADDRESS', PERSON_NAME_WESTERN_ORDER);		// Contextual: formatting a person's name assotiated with an email-address. Ivan: I am not sure how seems email servers an clients would interpret name order, so I assign the Western order.
 
 /**
  * ----------------------------------------------------------------------------

+ 6 - 31
main/mySpace/index.php

@@ -1,27 +1,5 @@
 <?php // $Id: index.php 16620 2008-10-25 20:03:54Z yannoo $
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) various contributors
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
-
+/* For licensing terms, see /dokeos_license.txt */
 /**
  * @todo use constant for $this_section
  */
@@ -52,14 +30,10 @@ $nameTools= get_lang("MySpace");
  
 // access control
 api_block_anonymous_users();
-if(!$export_csv)
-{
+if(!$export_csv) {
 	Display :: display_header($nameTools);
-}
-else
-{
-	if ($_GET['view'] == 'admin' AND $_GET['display'] == 'useroverview')
-	{
+} else {
+	if ($_GET['view'] == 'admin' AND $_GET['display'] == 'useroverview') {
 		export_tracking_user_overview();
 		exit;
 	}
@@ -610,7 +584,8 @@ if(api_is_allowed_to_create_course() && $view=='teacher')
 			$table_row[] = $avg_score_in_exercise;
 			$table_row[] = $avg_messages_in_course;
 			$table_row[] = $avg_assignments_in_course;
-			$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
+			//set the "from" value to know if I access the Reporting by the Dokeos tab or the course link 
+			$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&from=myspace"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
 			
 			$csv_content[] = array(
 								api_html_entity_decode($course['title'], ENT_QUOTES, $charset),

+ 13 - 26
main/mySpace/lp_tracking.php

@@ -1,24 +1,5 @@
 <?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008-2009 Dokeos SPRL
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
 
 /*
  * Created on 26 mars 07 by Eric Marguin
@@ -26,8 +7,18 @@
  */
  
 $language_file = array ('registration', 'index', 'tracking', 'exercice', 'scorm', 'learnpath');
-$cidReset = true;
+//$cidReset = true;
+
 include ('../inc/global.inc.php');
+
+$from_myspace = false;
+$from_link = '';
+if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
+	$from_link = '&from=myspace';
+	$this_section = "session_my_space";
+} else {
+	$this_section = SECTION_COURSES;
+}
 include_once(api_get_path(LIBRARY_PATH).'tracking.lib.php');
 include_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
 include_once(api_get_path(LIBRARY_PATH).'course.lib.php');
@@ -37,13 +28,10 @@ include_once('../newscorm/learnpathItem.class.php');
 require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
 
 $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
-if($export_csv)
-{
+if($export_csv) {
 	ob_start();
 }
 $csv_content = array();
-
-
 $user_id = intval($_GET['student_id']);
 
 if (isset($_GET['course'])) {
@@ -164,7 +152,6 @@ echo '<div class ="actions"><div align="left" style="float:left;margin-top:2px;"
 
 $list = learnpath :: get_flat_ordered_items_list($lp_id);
 $origin = 'tracking';
-
 if($export_csv) {	
 	include_once('../newscorm/lp_stats.php');	
 	//Export :: export_table_csv($csv_content, 'reporting_student');

File diff suppressed because it is too large
+ 519 - 425
main/mySpace/myStudents.php


+ 16 - 47
main/newscorm/lp_stats.php

@@ -1,25 +1,5 @@
 <?php
-
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2008 Dokeos SPRL
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
-	Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
 /**
  * This script displays statistics on the current learning path (scorm)
  * 
@@ -34,12 +14,9 @@ require_once ('resourcelinker.inc.php');
 require_once ('../inc/lib/tracking.lib.php');
 require_once ('../inc/lib/course.lib.php');
 
-if(empty($_SESSION['_course']['id']) && isset($_GET['course']))
-{
+if(empty($_SESSION['_course']['id']) && isset($_GET['course'])) {
 	$course_code = Security::remove_XSS($_GET['course']);
-}
-else
-{
+} else {
 	$course_code = $_SESSION['_course']['id'];
 }
 
@@ -55,8 +32,7 @@ if (isset($_GET['student_id'])) {
 //$stats_charset = $_SESSION['oLP']->encoding
 if(!isset($origin))
 	$origin = '';
-if($origin != 'tracking')
-{
+if($origin != 'tracking') {
 	if (!empty ($stats_charset)) {
 		$lp_charset = $stats_charset;
 	} else {
@@ -71,16 +47,13 @@ if($origin != 'tracking')
 	</style>';
 	include_once ('../inc/reduced_header.inc.php');
 	echo '<body>';
-}
-else
-{
+} else {
     //Get learning path's encoding
     $TBL_LP = Database :: get_course_table(TABLE_LP_MAIN);
     $sql = "SELECT default_encoding FROM $TBL_LP " .
                 "WHERE id = '".(int)$_GET['lp_id']."'";
     $res = api_sql_query($sql, __FILE__, __LINE__);
-    if (Database :: num_rows($res) > 0)
-    {
+    if (Database :: num_rows($res) > 0) {
         $row = Database::fetch_array($res);
         $lp_charset = $row['default_encoding'];
     }
@@ -90,21 +63,17 @@ else
 $dokeos_charset = api_get_setting('platform_charset');
 $output = '';
 //if display in fullscreen required
-if (!empty($_GET['fs']) && strcmp($_GET['fs'], 'true') == 0) 
-{
+if (!empty($_GET['fs']) && strcmp($_GET['fs'], 'true') == 0) {
 	$output .= '<table width="100%" align="center">';
-} 
-else 
-{
+} else {
 	$output .= '<table width="100%">';
 }
 
 //check if the user asked for the "extend all" option
 $extend_all_link = '';
 $extend_all = 0;
-
 if ($origin == 'tracking') {
-	$url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($_GET['lp_id']) . '&origin=' . Security::remove_XSS($_GET['origin']);
+	$url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($_GET['lp_id']) . '&origin=' . Security::remove_XSS($_GET['origin']).$from_link;
 } else {
 	$url_suffix = '';
 }
@@ -567,7 +536,7 @@ if (is_array($list) && count($list) > 0){
 						$my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']);
 						$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC ';
 					} else {
-						$my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']).'&origin=' . Security::remove_XSS($_GET['origin']);
+						$my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']).'&origin=' . Security::remove_XSS($_GET['origin'].$from_link);
 						$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND status <> "incomplete"  ORDER BY exe_date DESC ';
 					}
 	
@@ -714,15 +683,15 @@ if (is_array($list) && count($list) > 0){
 							 		if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 										$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></td>';
 									} else {
-										$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
-									}
-							 								
-								} else {
+										$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id .$from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
+									}							 								
+								} else {	
 									if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 										$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></td>';
 									} else {
-										$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
-									}															
+										$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
+									}		
+													
 								}		 				 	        
 							 	$output .= '</tr>';
 								$n++;												

+ 3 - 3
main/reservation/rcalendar.php

@@ -26,9 +26,9 @@
     The rCalendar
     --------------
  */
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$DaysShort = api_get_week_days_short();
+$DaysLong = api_get_week_days_long();
+$MonthsLong = api_get_months_long();
 
 class rCalendar {
 	function rCalendar() {

+ 13 - 3
main/tracking/courseLog.php

@@ -25,7 +25,14 @@ $language_file[] = 'scorm';
 require '../inc/global.inc.php';
 
 // the section (for the tabs)
-$this_section = "session_my_space";
+//$this_section = "session_my_space";
+$from_myspace = false;
+if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
+	$from_myspace = true;
+	$this_section = "session_my_space";
+} else {
+	$this_section = SECTION_COURSES;
+}
 
 
 $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
@@ -558,8 +565,11 @@ if($_GET['studentlist'] == 'false') {
 				$row[8] = strip_tags($row[8]);
 				$csv_content[] = $row;
 			}
-			
-			$row[] = '<center><a href="../mySpace/myStudents.php?student='.$student_id.'&details=true&course='.$course_code.'&origin=tracking_course"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
+			$from = '';
+			if ($from_myspace) {
+				$from ='&from=myspace';
+			}
+			$row[] = '<center><a href="../mySpace/myStudents.php?student='.$student_id.'&details=true&course='.$course_code.'&origin=tracking_course'.$from.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
 			
 			$all_datas[] = $row;		
 	

+ 3 - 3
main/tracking/course_access_details.php

@@ -67,11 +67,11 @@ include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 
 $is_allowedToTrack = $is_courseAdmin;
 

+ 4 - 4
main/tracking/logins_details.php

@@ -78,13 +78,13 @@ include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 // Defining the months of the year to allow translation of the months
-$MonthsShort = array (get_lang("JanuaryShort"), get_lang("FebruaryShort"), get_lang("MarchShort"), get_lang("AprilShort"), get_lang("MayShort"), get_lang("JuneShort"), get_lang("JulyShort"), get_lang("AugustShort"), get_lang("SeptemberShort"), get_lang("OctoberShort"), get_lang("NovemberShort"), get_lang("DecemberShort"));
+$MonthsShort = api_get_months_short();
 
 $is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
 $is_allowedToTrackEverybodyInCourse = $is_courseAdmin; // allowed to track all student in course

+ 4 - 4
main/tracking/toolaccess_details.php

@@ -77,13 +77,13 @@ include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
 
 // the variables for the days and the months
 // Defining the shorts for the days
-$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
+$DaysShort = api_get_week_days_short();
 // Defining the days of the week to allow translation of the days
-$DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
+$DaysLong = api_get_week_days_long();
 // Defining the months of the year to allow translation of the months
-$MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
+$MonthsLong = api_get_months_long();
 // Defining the months of the year to allow translation of the months
-$MonthsShort = array (get_lang("JanuaryShort"), get_lang("FebruaryShort"), get_lang("MarchShort"), get_lang("AprilShort"), get_lang("MayShort"), get_lang("JuneShort"), get_lang("JulyShort"), get_lang("AugustShort"), get_lang("SeptemberShort"), get_lang("OctoberShort"), get_lang("NovemberShort"), get_lang("DecemberShort"));
+$MonthsShort = api_get_months_short();
 
 $tool=$_REQUEST['tool'];
 $period=$_REQUEST['period'];

+ 1 - 0
main/tracking/userLog.php

@@ -159,6 +159,7 @@ $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 
 // the variables for the days and the months
 // Defining the shorts for the days
+// TODO: The function myEnc() should be eliminated. The following arrays should be constructed using the correspondent API-functions in the internationalization library.
 $DaysShort = array (myEnc(get_lang("SundayShort")), myEnc(get_lang("MondayShort")), myEnc(get_lang("TuesdayShort")), myEnc(get_lang("WednesdayShort")), myEnc(get_lang("ThursdayShort")), myEnc(get_lang("FridayShort")), myEnc(get_lang("SaturdayShort")));
 // Defining the days of the week to allow translation of the days
 $DaysLong = array (myEnc(get_lang("SundayLong")), myEnc(get_lang("MondayLong")), myEnc(get_lang("TuesdayLong")), myEnc(get_lang("WednesdayLong")), myEnc(get_lang("ThursdayLong")), myEnc(get_lang("FridayLong")), myEnc(get_lang("SaturdayLong")));

+ 1 - 0
main/tracking/userlogCSV.php

@@ -150,6 +150,7 @@ $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 
 // the variables for the days and the months
 // Defining the shorts for the days
+// TODO: The function myEnc() should be eliminated. The following arrays should be constructed using the correspondent API-functions in the internationalization library.
 $DaysShort = array (myEnc(get_lang("SundayShort")), myEnc(get_lang("MondayShort")), myEnc(get_lang("TuesdayShort")), myEnc(get_lang("WednesdayShort")), myEnc(get_lang("ThursdayShort")), myEnc(get_lang("FridayShort")), myEnc(get_lang("SaturdayShort")));
 // Defining the days of the week to allow translation of the days
 $DaysLong = array (myEnc(get_lang("SundayLong")), myEnc(get_lang("MondayLong")), myEnc(get_lang("TuesdayLong")), myEnc(get_lang("WednesdayLong")), myEnc(get_lang("ThursdayLong")), myEnc(get_lang("FridayLong")), myEnc(get_lang("SaturdayLong")));

Some files were not shown because too many files changed in this diff