Browse Source

Merge with 8e9e6fe5f271596d7f63859657c67f10c0374472

Ivan Tcholakov 15 years ago
parent
commit
93260b0f9b

+ 3 - 3
main/newscorm/aicc_api.php

@@ -153,7 +153,7 @@ function LMSGetValue(param) {
 		result='<?php echo $_user['user_id']; ?>';
 	}else if(param == 'cmi.core.student_name'){
 		  <?php
-			$who=addslashes($_user['lastName'].", ".$_user['firstName']);
+			$who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
 		    echo "result='$who';"; 
 		  ?>
 	}else if(param == 'cmi.core.lesson_location'){
@@ -209,7 +209,7 @@ function LMSGetValue(param) {
 			break;
 		case 'cmi.core.student_name'	: 
 		  <?php
-			$who=addslashes($_user['firstName'].",".$_user['lastName']);
+		    $who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
 		    echo "result='$who';"; 
 		  ?>	break;
 		case 'cmi.core.lesson_location'	:
@@ -605,7 +605,7 @@ function update_message_frame(msg_msg)
  * @param	string		This parameter can be a string specifying the next 
  *						item (like 'next', 'previous', 'first' or 'last') or the id to the next item  
  */
-function switch_item(current_item, next_item){ 
+function switch_item(current_item, next_item){
 	/*
 	if(!current_item){
 		logit_lms('In switch - no current_item defined',0);

+ 1 - 1
main/newscorm/aicc_hacp.php

@@ -106,7 +106,7 @@ if(!empty($_REQUEST['command']))
 			$result = $s_ec.$error_code.$crlf.$s_et.$error_text.$crlf.$s_ad.$crlf;
 			$result .= '[Core]'.$crlf;
 			$result .= $tab.'Student_ID='.$_user['user_id'].$crlf;
-			$result .= $tab.'Student_Name='.$_user['lastName'].', '.$_user['firstName'].$_user['user_id'].$crlf;
+			$result .= $tab.'Student_Name='.api_get_person_name($_user['firstName'], $_user['lastName']).$crlf;
 			$result .= $tab.'Lesson_Location='.$oItem->get_lesson_location().$crlf;
 			$result .= $tab.'Credit='.$oItem->get_credit().$crlf;
 			$result .= $tab.'Lesson_Status='.$oItem->get_status().$crlf;

+ 152 - 152
main/newscorm/scorm_api.php

@@ -7,7 +7,7 @@
 	Copyright (c) Denes Nagy (darkden@freemail.hu)
 	
 	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.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
@@ -65,7 +65,7 @@ if(!is_object($oItem)){
 	error_log('New LP - scorm_api - Could not load oItem item',0);
 	exit;
 }
-$autocomplete_when_80pct = 0; 
+$autocomplete_when_80pct = 0;
 
 /*
 ============================================================================== 
@@ -108,18 +108,18 @@ api_1484_11 = API_1484_11;
 //api_1484_11 = new APIobject();  //for scorm 1.3
 
 // Error codes  
-var G_NoError 					= 0;
-var G_GeneralException 			= 101;
+var G_NoError = 0;
+var G_GeneralException = 101;
 var G_ServerBusy 				= 102; // this is not in the Scorm1.2_Runtime document 
-var G_InvalidArgumentError 		= 201;
+var G_InvalidArgumentError = 201;
 var G_ElementCannotHaveChildren = 202;
-var G_ElementIsNotAnArray 		= 203;
-var G_NotInitialized 			= 301;
-var G_NotImplementedError 		= 401;
-var G_InvalidSetValue 			= 402;
-var G_ElementIsReadOnly 		= 403;
-var G_ElementIsWriteOnly 		= 404;
-var G_IncorrectDataType 		= 405;
+var G_ElementIsNotAnArray = 203;
+var G_NotInitialized = 301;
+var G_NotImplementedError = 401;
+var G_InvalidSetValue = 402;
+var G_ElementIsReadOnly = 403;
+var G_ElementIsWriteOnly = 404;
+var G_IncorrectDataType = 405;
 
 // Error messages 
 var G_NoErrorMessage 					= '';
@@ -170,7 +170,7 @@ $(document).ready( function() {
 	info_lms_item[1]='<?php echo $oItem->get_id();?>';
 	
 	$("#current_item_id").attr("value",<?php echo $oItem->get_id();?>);
-	$("#old_item").attr("value",<?php echo $oItem->get_id();?>);
+	$("#old_item").attr("value",<?php echo $oItem->get_id();?>);	
 	
 	//var myiframe=document.getElementById('content_id');
 	//myiframe.Events.AttachEvent("onclick", update_lp_item_id);
@@ -187,7 +187,7 @@ $(document).ready( function() {
  });
 });
  
- 
+
 //Dokeos internal variables
 var saved_lesson_status = 'not attempted';
 var lms_lp_id = <?php echo $oLP->get_id();?>;
@@ -224,49 +224,49 @@ var lms_old_item_id = 0;
 var execute_stats='false';
 
 
-    
+
 /**
  * Function called mandatorily by the SCORM content to start the SCORM communication
  */
 function LMSInitialize() {  //this is the initialize function of all APIobjects
-	
+
 	/* load info for this new item by calling the js_api_refresh command in
 	 * the message frame. The message frame will update the JS variables by 
 	 * itself, in JS, by doing things like top.lesson_status = 'not attempted' 
 	 * and that kind of stuff, so when the content loads in the content frame
 	 * it will have all the correct variables set 
-	 */	 
+	 */
 	G_LastError = G_NoError ;
-	G_LastErrorMessage = 'No error';
+	G_LastErrorMessage = 'No error';	
 	//reinit to list
 	reinit_update_table_list ()
 		
 	lms_initialized=0;
-	// if there are more parameters than ""		
+	// if there are more parameters than ""
 	if (arguments.length>1) {
 		G_LastError 		= G_InvalidArgumentError;
 		G_LastErrorMessage 	= G_InvalidArgumentErrorMessage;
 		logit_scorm('Error '+ G_InvalidArgumentError + G_InvalidArgumentErrorMessage, 0);
-		return('false');		
-	} else {	
+		return('false');
+	} else {
 		logit_scorm('LMSInitialise()',0);
-		lms_initialized=1;
-		return('true');	
-	}	
+	lms_initialized=1;
+	return('true');
+	}
 }
 
 function Initialize() 
 {  //this is the initialize function of all APIobjects
-	return LMSInitialize();
+  return LMSInitialize();
 }
 
 function LMSGetValue(param) 
-{		
+{
 	//logit_scorm("LMSGetValue('"+param+"')",1);
 	G_LastError = G_NoError ;
 	G_LastErrorMessage = 'No error';	
-	var result='';	
-	
+	var result='';
+
 	// the LMSInitialize is missing
 	if (lms_initialized == 0) {
 		 G_LastError 		= G_NotInitialized; 
@@ -274,9 +274,9 @@ function LMSGetValue(param)
 		 logit_scorm('Error '+ G_NotInitialized + ' ' +G_NotInitializedMessage, 0);
 		 return '';
 	}
-	
+
 	//Dokeos does not support this SCO object properties
-	
+
 	if (param == 'cmi.student_preference.text' || 
 		param == 'cmi.student_preference.language' ||
 		param == 'cmi.student_preference.speed' ||
@@ -290,13 +290,13 @@ function LMSGetValue(param)
 		G_lastErrorString = G_NotImplementedErrorMessage;
 		logit_scorm("LMSGetValue  ('"+param+"') Error '"+G_NotImplementedErrorMessage+"'",1);
 		result = '';
-		return result;			
+		return result;
 	}
 
 	// ---- cmi.core._children
-	if(param=='cmi.core._children' || param=='cmi.core_children') {
+	if(param=='cmi.core._children' || param=='cmi.core_children'){
 		result='entry, exit, lesson_status, student_id, student_name, lesson_location, total_time, credit, lesson_mode, score, session_time';
-	} else if(param == 'cmi.core.entry'){
+	}else if(param == 'cmi.core.entry'){
 	// ---- cmi.core.entry
 		if(lms_item_core_exit=='none') {
 			result='ab-initio';
@@ -305,48 +305,48 @@ function LMSGetValue(param)
 		} else {
 			result='';
 		}
-	} else if(param == 'cmi.core.exit'){
-		// ---- cmi.core.exit
+	}else if(param == 'cmi.core.exit'){
+	// ---- cmi.core.exit
 		result='';
 		G_LastError = G_ElementIsWriteOnly;
 	}else if(param == 'cmi.core.session_time'){
 		result='';
-		G_LastError = G_ElementIsWriteOnly;		
+		G_LastError = G_ElementIsWriteOnly;
 	}else if(param == 'cmi.core.lesson_status'){
 	// ---- cmi.core.lesson_status
 	    if(lesson_status != '') {
 	    	result=lesson_status;
-	    } else {	    	
+	    } else {
 	    	//result='not attempted';
 	    }
-	} else if(param == 'cmi.core.student_id'){
+	}else if(param == 'cmi.core.student_id'){
 	// ---- cmi.core.student_id
 		result='<?php echo $_user['user_id']; ?>';
-	} else if(param == 'cmi.core.student_name'){
+	}else if(param == 'cmi.core.student_name'){
 	// ---- cmi.core.student_name
 		  <?php
-			$who=addslashes($_user['lastName'].", ".$_user['firstName']);
+			$who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
 		    echo "result='$who';"; 
 		  ?>
-	} else if(param == 'cmi.core.lesson_location'){
+	}else if(param == 'cmi.core.lesson_location'){
 	// ---- cmi.core.lesson_location
 		result=lesson_location;
-	} else if(param == 'cmi.core.total_time'){
+	}else if(param == 'cmi.core.total_time'){
 	// ---- cmi.core.total_time
 		result=total_time;
-	} else if(param == 'cmi.core.score._children'){
+	}else if(param == 'cmi.core.score._children'){
 	// ---- cmi.core.score._children
 		result='raw,min,max';
-	} else if(param == 'cmi.core.score.raw'){
+	}else if(param == 'cmi.core.score.raw'){
 	// ---- cmi.core.score.raw
 		result=score;
-	} else if(param == 'cmi.core.score.max'){
+	}else if(param == 'cmi.core.score.max'){
 	// ---- cmi.core.score.max
 		result=max;
-	} else if(param == 'cmi.core.score.min'){
+	}else if(param == 'cmi.core.score.min'){
 	// ---- cmi.core.score.min
 		result=min;
-	} else if(param == 'cmi.core.score'){
+	}else if(param == 'cmi.core.score'){
 	// ---- cmi.core.score -- non-standard item, provided as cmi.core.score.raw just in case
 		result=score;
 	}else if(param == 'cmi.core.credit'){
@@ -457,22 +457,22 @@ function LMSGetValue(param)
 			}
 		}
 	}else if(param == 'cmi.student_data._children'){
-		// ---- cmi.student_data._children
+	// ---- cmi.student_data._children
 		result = 'mastery_score,max_time_allowed';
 	}else if(param == 'cmi.student_data.mastery_score'){
-		// ---- cmi.student_data.mastery_score
+	// ---- cmi.student_data.mastery_score
 		result = mastery_score;
 	}else if(param == 'cmi.student_data.max_time_allowed'){
-		// ---- cmi.student_data.max_time_allowed
+	// ---- cmi.student_data.max_time_allowed
 		result = max_time_allowed;
 	}else if(param == 'cmi.interactions._count'){
-		// ---- cmi.interactions._count
+	// ---- cmi.interactions._count
 		result = interactions.length;
 	}else if(param == 'cmi.interactions._children'){
-		// ---- cmi.interactions._children
+	// ---- cmi.interactions._children
 		result = 'id,time,type,correct_responses,weighting,student_response,result,latency';
-	} else {
-		// ---- anything else
+	}else{
+	// ---- anything else
 		// Invalid argument error
 		G_lastError = G_InvalidArgumentError ;
 		G_lastErrorString = G_InvalidArgumentErrorMessage;
@@ -489,7 +489,7 @@ function GetValue(param) {
 }
 
 function LMSSetValue(param, val) {
-	
+
 	logit_scorm("LMSSetValue\n\t('"+param+"','"+val+"')",0);
 	commit = true; //value has changed, need to re-commit
 	G_LastError = G_NoError ;
@@ -521,11 +521,11 @@ function LMSSetValue(param, val) {
 		updatetable_to_list['cmi.completion_status']='true';
 		return_value='true'; //1.3
 	} else if ( param == "cmi.core.session_time" ) {
-		session_time = val;
+		session_time = val;		
 		updatetable_to_list['cmi.core.session_time']='true';		
 		return_value='true';
 	} else if ( param == "cmi.score.scaled") { //1.3
-		if(val<=1 && val>=-1) { 
+		if(val<=1 && val>=-1) {
 			score = val ;
 			updatetable_to_list['cmi.score.scaled']='true';
 			return_value='true';
@@ -550,22 +550,22 @@ function LMSSetValue(param, val) {
 		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.core.credit" ) {
 		G_LastError = G_ElementIsReadOnly;
-	} else if ( param == "cmi.core.entry" ) {               
+	} else if ( param == "cmi.core.entry" ) {
 		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.core.total_time" ) {
-		G_LastError = G_ElementIsReadOnly;			
+		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.core.lesson_mode" ) {
 		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.comments_from_lms" ) {
-		G_LastError = G_ElementIsReadOnly;	
+		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.student_data.time_limit_action" ) {
-		G_LastError = G_ElementIsReadOnly;	
+		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.student_data.mastery_score" ) {
-		G_LastError = G_ElementIsReadOnly;		
+		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.student_data.max_time_allowed" ) {
 		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.student_preference._children" ) {
-		G_LastError = G_ElementIsReadOnly;		
+		G_LastError = G_ElementIsReadOnly;
 	} else if ( param == "cmi.launch_data" ) {
 		G_LastError = G_ElementIsReadOnly;
 	} else {
@@ -576,13 +576,13 @@ function LMSSetValue(param, val) {
 			if(elem_id > interactions.length) //interactions setting should start at 0
 			{
 				/*
-                G_LastError = G_InvalidArgumentError;
+				G_LastError = G_InvalidArgumentError;
                 G_LastErrorString = 'Invalid argument (interactions)';
 				return_value = false;
                 */
                 interactions[0] = ['0','','','','','','',''];
-			}			
-			if(interactions[elem_id] == null) {
+			}
+			if(interactions[elem_id] == null){
 					interactions[elem_id] = ['','','','','','','',''];
 					//id(0), type(1), time(2), weighting(3),correct_responses(4),student_response(5),result(6),latency(7)
 					interactions[elem_id][4] = new Array();
@@ -634,7 +634,7 @@ function LMSSetValue(param, val) {
 							G_lastError = G_NotImplementedError;
 							G_lastErrorString = 'Not implemented yet';
 			}
-		} else if(param.substring(0,15)== 'cmi.objectives.'){
+		}else if(param.substring(0,15)== 'cmi.objectives.'){
 			var myres = '';
 			updatetable_to_list['objectives']='true';
 			if(myres = param.match(/cmi.objectives.(\d+).(id|score|status)(.*)/))
@@ -697,7 +697,7 @@ function LMSSetValue(param, val) {
 					}
 				}
 			}
-		} else {
+		}else{
 			G_lastError = G_NotImplementedError;
 			G_lastErrorString = G_NotImplementedErrorMessage;
 		}
@@ -742,15 +742,15 @@ function reinit_update_table_list () {
 function savedata(origin) { 
 	//origin can be 'commit', 'finish' or 'terminate'	
     if ((lesson_status != 'completed') && (lesson_status != 'passed') && (mastery_score >=0) && (score >= mastery_score)) {
-		lesson_status = 'passed';
+      lesson_status = 'passed';
         updatetable_to_list['cmi.core.lesson_status']='true';
     } else if( (mastery_score < 0) && (lms_lp_type != '2') && ( lesson_status == 'incomplete') && (score >= (0.8*max) ) ) {
-    	//the status cannot be modified automatically by the LMS under SCORM 1.2's rules    	
-    	<?php if ($autocomplete_when_80pct){ ?>
+    	//the status cannot be modified automatically by the LMS under SCORM 1.2's rules
+    <?php if ($autocomplete_when_80pct){ ?>
     	      lesson_status = 'completed';
               updatetable_to_list['cmi.core.lesson_status']='true';
-    	<?php }?>
-    	; 	
+    <?php }?>
+    ;
     } else {
         /*
          * See notes in switch_item for why this has been disabled
@@ -776,7 +776,7 @@ function savedata(origin) {
 
     my_get_value_scorm=new Array();
     my_get_value_scorm=ProcessValueScorm();
-    
+
 	logit_lms('saving data (status='+lesson_status+' - interactions: '+ interactions.length +')',1);
 	
 	old_item_id=info_lms_item[0];
@@ -805,14 +805,14 @@ function savedata_onunload() {
 */
 
 function LMSCommit(val) {
-		logit_scorm('LMSCommit()',0);
-		G_LastError = G_NoError ;
-		G_LastErrorMessage = 'No error';
-		
-		savedata('commit');
+	logit_scorm('LMSCommit()',0);
+	G_LastError = G_NoError ;
+	G_LastErrorMessage = 'No error';	
+
+			savedata('commit');
 		reinit_update_table_list();
 	    //commit = 'false' ; //now changes have been commited, no need to update until next SetValue()
-		return('true');
+	return('true');
 }
 
 function Commit(val) {
@@ -820,13 +820,13 @@ function Commit(val) {
 }
 
 function LMSFinish(val) {
-		G_LastError = G_NoError ;
-		G_LastErrorMessage = 'No error';
-		// why commit==false?	
-		if (( commit == false )) { 	
-			logit_scorm('LMSFinish() (no LMSCommit())',1);
-			 
-		}
+	G_LastError = G_NoError ;
+	G_LastErrorMessage = 'No error';	
+	// why commit==false?
+	if (( commit == false )) { 	
+		logit_scorm('LMSFinish() (no LMSCommit())',1); 
+
+	}
 
 		//if ( commit == true ) {
 			logit_scorm('LMSFinish() called',1);		
@@ -876,8 +876,8 @@ function Terminate()
 		G_LastError 		= G_NotInitialized; 
 		G_LastErrorMessage = G_NotInitializedMessage;
 		logit_scorm('Error '+ G_NotInitialized + G_NotInitializedMessage, 0);
-		return('false');		
-	} else {				
+		return('false');
+	} else {
 		logit_scorm('Terminate()',0);
 		G_LastError = G_NoError ;
 		G_LastErrorMessage = 'No error';	
@@ -956,7 +956,7 @@ function addListeners(){
     /* See notes in switch_item() for why this has been disabled
     if (lms_lp_type==2) {
         addEvent(window,'unload',savedata_onunload,false);    	
-    }
+	}
     */
 	logit_lms('Quitting addListeners()',2);
 }
@@ -976,7 +976,7 @@ function load_item(item_id,url){
 			lms_old_item_id = lms_item_id;
 			var lms_new_item_id = item_id;
 			//load new content page into content frame
-			if(lms_lp_type==1 || lms_item_type=='asset') {
+			if(lms_lp_type==1 || lms_item_type=='asset'){
 				dokeos_save_asset();
 			}
 			cont_f.src = url;
@@ -994,7 +994,7 @@ function load_item(item_id,url){
  * Save a Dokeos learnpath item's time and mark as completed upon
  * leaving it
  */
-function dokeos_save_asset() {
+function dokeos_save_asset(){
 	// only for dokeos lps
 	if (execute_stats=='true') {
 		execute_stats='false';
@@ -1032,13 +1032,13 @@ function dokeos_void_save_asset(myscore,mymax)
  * @param	integer Priority (0 for top priority, 3 for lowest)
  */
 function logit_scorm(message,priority){
-	
+
 	if(scorm_logs>priority){
 		if($("#lp_log_name") && $("#log_content")){
 			$("#log_content").append("SCORM: " + message + "<br/>");
 		}
 	}
-	
+
 }
 
 /**
@@ -1047,7 +1047,7 @@ function logit_scorm(message,priority){
  * @param	integer Priority (0 for top priority, 3 for lowest)
  */
 function logit_lms(message,priority){
-	if(lms_logs>priority){ 
+	if(lms_logs>priority){
 		if ($("#lp_log_name") && $("#log_content")) {
 			$("#log_content").append("LMS: " + message + "<br />");
 		}
@@ -1066,7 +1066,7 @@ function update_toc(update_action,update_id,change_ids)
         }
 		var myelem = $("#toc_"+update_id);		
 		var myelemimg = $("#toc_img_"+update_id);		
-		logit_lms('update_toc("'+update_action+'",'+update_id+')',2);				
+		logit_lms('update_toc("'+update_action+'",'+update_id+')',2);
 		
 		if(update_id != 0)
 		{
@@ -1074,11 +1074,11 @@ function update_toc(update_action,update_id,change_ids)
 			{
 				case 'unhighlight':
 					if (update_id%2==0)
-					{						
+					{
 						myelem.attr('class',"scorm_item_2");
 					}
 					else
-					{					
+					{
 						myelem.attr('class',"scorm_item_1");
 					}
 					break;
@@ -1089,37 +1089,37 @@ function update_toc(update_action,update_id,change_ids)
                     }				 				
 					myelem.attr('class',"scorm_item_highlight");
 					break;
-				case 'not attempted':   					
+				case 'not attempted':
 					if( myelemimg.attr('src') != '../img/notattempted.gif') {
 						myelemimg.attr('src','../img/notattempted.gif');
 						myelemimg.attr('alt','n');						
 					}
 					break;
-				case 'incomplete':					
+				case 'incomplete':
 					if( myelemimg.attr('src') != '../img/incomplete.gif') {
 						myelemimg.attr('src','../img/incomplete.gif');
 						myelemimg.attr('alt','i');						
 					}
 					break;
-				case 'completed':					
+				case 'completed':
 					if( myelemimg.attr('src') != '../img/completed.gif') {
 						myelemimg.attr('src','../img/completed.gif');
 						myelemimg.attr('alt','c');						
 					}
 					break;
-				case 'failed':					
+				case 'failed':
 					if( myelemimg.attr('src') != '../img/failed.gif') {
 						myelemimg.attr('src','../img/failed.gif');
 						myelemimg.attr('alt','f');						
 					}
 					break;
-				case 'passed':					
+				case 'passed':
 					if( myelemimg.attr('src') != '../img/completed.gif' && myelemimg.attr('alt') != 'passed') {
 						myelemimg.attr('src','../img/completed.gif');
 						myelemimg.attr('alt','p');						
 					}
 					break;
-				case 'browsed':					
+				case 'browsed':
 					if( myelemimg.attr('src') != '../img/completed.gif' && myelemimg.attr('alt') != 'browsed') {
 						myelemimg.attr('src','../img/completed.gif');
 						myelemimg.attr('alt','b');						
@@ -1133,7 +1133,7 @@ function update_toc(update_action,update_id,change_ids)
 		return true;
 }
 
-function update_stats() {	
+function update_stats() {
 	if (execute_stats=='true') {
 		try {
 		cont_f = document.getElementById('content_id');
@@ -1156,11 +1156,11 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
 	logit_lms('update_progress_bar('+nbr_complete+','+nbr_total+','+mode+')',2);
 	logit_lms('could update with data: '+lms_lp_id+','+lms_view_id+','+lms_user_id,2);
 
-	if(mode == ''){mode='%';}
-	if(nbr_total == 0){nbr_total=1;}
-	var percentage = (nbr_complete/nbr_total)*100;
-	percentage = Math.round(percentage);
-					
+		if(mode == ''){mode='%';}
+		if(nbr_total == 0){nbr_total=1;}
+		var percentage = (nbr_complete/nbr_total)*100;
+		percentage = Math.round(percentage);
+		
 	var pr_text  = $("#progress_text");
 	var pr_full  = $("#progress_img_full");		
 	var pr_empty = $("#progress_img_empty");
@@ -1168,16 +1168,16 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
 	pr_full.attr('width',percentage*1.2);	
 	pr_empty.attr('width',(100-percentage)*1.2);
 		
-	var mytext = '';
-	switch(mode){
-		case 'abs':
-			mytext = nbr_complete + '/' + nbr_total;
-			break;
-		case '%':
-		default:
-			mytext = percentage + '%'; 
-			break;
-	}	
+		var mytext = '';
+		switch(mode){
+			case 'abs':
+				mytext = nbr_complete + '/' + nbr_total;
+				break;
+			case '%':
+			default:
+				mytext = percentage + '%'; 
+				break;
+		}
 	pr_text.html(mytext);
 	
 	return true;
@@ -1201,7 +1201,7 @@ function update_stats_page()
  */
 function update_message_frame(msg_msg)
 {
-	if(msg_msg==null){msg_msg='';}	
+	if(msg_msg==null){msg_msg='';}
 	if(!($("#msg_div_id"))){
 		logit_lms('In update_message_frame() - message frame has no document property',0);
 	}else{
@@ -1211,10 +1211,10 @@ function update_message_frame(msg_msg)
 }
 /**
  * Function that handles the saving of an item and switching from an item to another.
- * Once called, this function should be able to do the whole process of 
- * (1) saving the current item, 
- * (2) refresh all the values inside the SCORM API object, 
- * (3) open the new item into the content_id frame, 
+ * Once called, this function should be able to do the whole process of
+ * (1) saving the current item,
+ * (2) refresh all the values inside the SCORM API object,
+ * (3) open the new item into the content_id frame,
  * (4) refresh the table of contents
  * (5) refresh the progress bar (completion)
  * (6) refresh the message frame
@@ -1222,26 +1222,26 @@ function update_message_frame(msg_msg)
  * @param	string		This parameter can be a string specifying the next 
  *						item (like 'next', 'previous', 'first' or 'last') or the id to the next item  
  */
- 
-function switch_item(current_item, next_item) {
+
+function switch_item(current_item, next_item){
     //backup these params
     var orig_current_item = current_item;
     var orig_next_item = next_item;
     var orig_lesson_status = lesson_status;
-	//(1) save the current item	
+	//(1) save the current item
 	logit_lms('Called switch_item with params '+lms_item_id+' and '+next_item+'',0);
-	if (lms_lp_type==1 || lms_item_type=='asset' || session_time == '0' || session_time == '0:00:00'){
+	if(lms_lp_type==1 || lms_item_type=='asset' || session_time == '0' || session_time == '0:00:00'){
 		if (lms_lp_type==1) {
-        	xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, asset_timer, suspend_data, lesson_location,interactions, lms_item_core_exit);
+		xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, asset_timer, suspend_data, lesson_location,interactions, lms_item_core_exit);		
 		} else {
 			my_get_value_scorm=new Array();
     		my_get_value_scorm=ProcessValueScorm();
         	xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,my_get_value_scorm);
         }
 		if(item_objectives.length>0) {
-			xajax_save_objectives(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,item_objectives);
-		}
-	} else {
+		xajax_save_objectives(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,item_objectives);
+	}
+	}else{
         /** 
          * Because of SCORM 1.2's special rule about unsent commits and the fact
          * that a SCO should be SET TO 'completed' IF NO STATUS WAS SENT (and 
@@ -1267,13 +1267,13 @@ function switch_item(current_item, next_item) {
              */
         	//savedata('finish');                                 
         //}
-        // xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location,interactions, lms_item_core_exit);
+       // xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location,interactions, lms_item_core_exit);
 
 	}
 	execute_stats=false;
 	//(2) Refresh all the values inside this SCORM API object - use AJAX
-	xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,next_item);		
-
+	xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,next_item);
+	
 	status_info.push(lesson_status);
 	
 	//current item
@@ -1300,7 +1300,7 @@ function switch_item(current_item, next_item) {
 			info_lms_item[1]=next_item;
 		}	
 	}
-
+	
 	//(3) open the new item in the content_id frame
 	switch(next_item){
 		case 'next':
@@ -1315,11 +1315,11 @@ function switch_item(current_item, next_item) {
 			break;
 		default:
 			break;
-	}		
+	}
 	var mysrc = 'lp_controller.php?action=content&lp_id='+lms_lp_id+'&item_id='+next_item;
-	var cont_f = $("#content_id");
+	var cont_f = $("#content_id");		
 	
-	<?php if($oLP->mode == 'fullscreen'){ ?>		
+		<?php if($oLP->mode == 'fullscreen'){ ?>
 	cont_f = window.open(''+mysrc,'content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');
 	cont_f.onload=function(){
 		info_lms_item[0]=info_lms_item[1];
@@ -1331,23 +1331,23 @@ function switch_item(current_item, next_item) {
 		info_lms_item[1]= info_lms_item[1];
 	}
 
-	<?php } else { ?>
-		cont_f.attr("src",mysrc);
+		<?php } else { ?>
+			cont_f.attr("src",mysrc);								
 	<?php } ?>
-
+	
 	if(lms_lp_type==1 || lms_item_type=='asset'){
 		xajax_start_timer();
 	}	
-
-	//(4) refresh the audio player if needed  
+	
+	//(4) refresh the audio player if needed	
 	$.ajax({									
 		type: "GET",
 		url: "lp_nav.php",
 		data: "",
 		success: function(tmp_data) {
 		 		$("#media").html(tmp_data);							 				
-				}		
-  	});
+	}
+  	});			
 /*
     if ( lms_lp_type==2 && (orig_lesson_status == 'not attempted' || orig_lesson_status == '') && orig_current_item != orig_next_item) {
         params = 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id+'&iid='+orig_current_item;
@@ -1454,16 +1454,16 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,
 			is_interactions='false';
 		}
 	}
- 
+		 
  
  if (is_interactions=='true')  {
-        interact_string = '';
+         interact_string = '';
   		temp = '';
         for (i in interactions){
         	
         	interact_string += '&interact['+i+']=';
             interact_temp = '[';
-            for (j in interactions[i]) {            	
+            for (j in interactions[i]) {
             	temp = interactions[i][j];
             	temp = ''+temp; // if temp == 1 there are problems with indexOf and an integer number
             	//this fix when an interaction have ',' i.e:   {a,b,c,d} is replace to {a@.|@b@.|@c@.|@d} see DT#4444          	
@@ -1478,8 +1478,8 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,
       	
            interact_string += interact_temp;        
         }
-        //interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));         
-        params += interact_string;               
+        //interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));
+        params += interact_string;	
         is_interactions='false';
  }
 

+ 1 - 1
main/online/online_whoisonline.php

@@ -79,7 +79,7 @@ foreach($Users as $enreg)
   <td width="99%"><a <?php if($enreg['status'] == 1) echo 'class="master"'; ?> name="user_<?php echo $enreg['user_id']; ?>" href="<?php echo api_get_self(); ?>?showPic=<?php if($showPic == $enreg['user_id']) echo '0'; else echo $enreg['user_id']; ?>#user_<?php echo $enreg['user_id']; ?>"><b><?php echo $enreg['username']; ?></b></a></td>
 </tr>
 <tr>
-  <td width="99%"><small><?php echo api_ucfirst($enreg['lastname']).' '.api_ucfirst($enreg['firstname']); ?></small></td>
+  <td width="99%"><small><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></small></td>
 </tr>
 
 <?php if($showPic == $enreg['user_id']): ?>

+ 3 - 3
main/reservation/rsys.php

@@ -1237,7 +1237,7 @@ class Rsys {
 		
 		$sql = "SELECT  i1.name as col0,c.name as col1, 
 				DATE_FORMAT(r1.start_at ,'%Y-%m-%d %H:%i') as col2,
-				DATE_FORMAT(r1.end_at ,'%Y-%m-%d %H:%i') as col3, CONCAT(u.lastname,' ',u.firstname) as col4,
+				DATE_FORMAT(r1.end_at ,'%Y-%m-%d %H:%i') as col3, ".(api_is_western_name_order() ? "CONCAT(u.firstname,' ',u.lastname)" : "CONCAT(u.lastname,' ',u.firstname)")." as col4,
 				DATE_FORMAT(s.start_at ,'%Y-%m-%d %H:%i')  as col5,
 				DATE_FORMAT(s.end_at ,'%Y-%m-%d %H:%i')    as col6, s.accepted as col7
 				FROM ".Rsys :: getTable('subscription')." s, ".Rsys :: getTable('reservation')." r1, ".Database :: get_main_table(TABLE_MAIN_USER)." u," .Rsys :: getTable('item')." i1,".Rsys :: getTable('category')." c
@@ -1315,14 +1315,14 @@ class Rsys {
 		}
 		
 		
-		/*$sql = "SELECT dummy AS col0, CONCAT(u.lastname,' ',u.firstname) AS col1, s.user_id AS col2, accepted AS col3
+		/*$sql = "SELECT dummy AS col0, ".(api_is_western_name_order() ? "CONCAT(u.firstname,' ',u.lastname)" : "CONCAT(u.lastname,' ',u.firstname)")." AS col1, s.user_id AS col2, accepted AS col3
 								 	FROM ".Rsys :: getTable('subscription')." s
 								 	INNER JOIN ".Database :: get_main_table(TABLE_MAIN_USER)." u ON s.user_id = u.user_id ";
 		if (!empty ($_GET['rid'])) {
 			$sql .= " WHERE s.reservation_id = '".$_GET['rid']."'";
 		}
 		$sql .= " ORDER BY col".$column." ".$direction." LIMIT ".$from.",".$per_page;*/
-		$sql = "SELECT dummy AS col0, CONCAT(u.lastname,' ',u.firstname) AS col1, s.user_id AS col2, accepted AS col3, r.start_at, r.end_at, s.start_at, s.end_at
+		$sql = "SELECT dummy AS col0, ".(api_is_western_name_order() ? "CONCAT(u.firstname,' ',u.lastname)" : "CONCAT(u.lastname,' ',u.firstname)")." AS col1, s.user_id AS col2, accepted AS col3, r.start_at, r.end_at, s.start_at, s.end_at
 			FROM ".Rsys :: getTable('subscription')." s,".Database :: get_main_table(TABLE_MAIN_USER)." u,".Database :: get_main_table(TABLE_MAIN_RESERVATION_RESERVATION)." r
 			where u.user_id = s.user_id
 			and s.reservation_id = r.id";

+ 1 - 1
main/social/contacts.inc.php

@@ -29,7 +29,7 @@ $image_path = UserManager::get_user_picture_path_by_id ($user_id,'web',false,tru
         echo '&nbsp;&nbsp;Dokeos&nbsp;&nbsp;-&nbsp;&nbsp;';
         $user_id=api_get_user_id();
         $user_info=api_get_user_info($user_id);
-        echo $name_user=api_xml_http_response_encode($user_info['firstName'].' '.$user_info['lastName']) ; 
+        echo $name_user=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); 
          ?></td>
         </tr>
     </table>

+ 11 - 4
main/social/data_personal.inc.php

@@ -103,10 +103,17 @@ $language_variable=api_xml_http_response_encode(get_lang('PersonalData'));
 		echo '<div class="social-profile-info" style="float:left;position:relative">';			
 			echo '<dt>'.api_xml_http_response_encode(get_lang('UserName')).'</dt>
 			<dd>'. api_xml_http_response_encode($user_info['username']).'	</dd>';
-			echo '<dt>'.api_xml_http_response_encode(get_lang('FirstName')).'</dt>
-			<dd>'. api_xml_http_response_encode($user_info['firstname']).'</dd>';
-			echo '<dt>'.api_xml_http_response_encode(get_lang('LastName')).'</dt>
-			<dd>'. api_xml_http_response_encode($user_info['lastname']).'</dd>';
+			if (api_is_western_name_order()) {
+				echo '<dt>'.api_xml_http_response_encode(get_lang('FirstName')).'</dt>
+				<dd>'. api_xml_http_response_encode($user_info['firstname']).'</dd>';
+				echo '<dt>'.api_xml_http_response_encode(get_lang('LastName')).'</dt>
+				<dd>'. api_xml_http_response_encode($user_info['lastname']).'</dd>';
+			} else {
+				echo '<dt>'.api_xml_http_response_encode(get_lang('LastName')).'</dt>
+				<dd>'. api_xml_http_response_encode($user_info['lastname']).'</dd>';
+				echo '<dt>'.api_xml_http_response_encode(get_lang('FirstName')).'</dt>
+				<dd>'. api_xml_http_response_encode($user_info['firstname']).'</dd>';
+			}
 			echo '<dt>'.api_xml_http_response_encode(get_lang('OfficialCode')).'</dt>	
 			<dd>'. api_xml_http_response_encode($user_info['official_code']).'</dd>';
 			echo '<dt>'.api_xml_http_response_encode(get_lang('Email')).'</dt>

+ 1 - 1
main/social/group_contact.inc.php

@@ -59,7 +59,7 @@ for ($p=0;$p<count($list_groups);$p++) {
 		while ($j<$number_of_images) {
 			if ($list_friends_file[$j]<>"") {
 				$user_info=api_get_user_info($list_friends_id[$j]);				
-				$user_name=api_xml_http_response_encode($user_info['firstName'].' '.$user_info['lastName']) ;
+				$user_name=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName']));
 				if($list_friends_file[$j]==='unknown.jpg') {
 					$big='';
 				} else {

+ 930 - 924
main/social/profile.php

@@ -1,924 +1,930 @@
-<?php //$id: $
-/* For licensing terms, see /dokeos_license.txt */
-/**
-* This is the profile social main page
-* @author Julio Montoya <gugli100@gmail.com>
-* @author Isaac Flores Paz <florespaz_isaac@hotmail.com>
-* @package dokeos.social
-*/
-
-/**
- * Init
- */
-$language_file = array('registration','messages','userInfo','admin','forum','blog');
-$cidReset = true;	
-require '../inc/global.inc.php';
-require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
-require_once api_get_path(LIBRARY_PATH).'social.lib.php';
-require_once api_get_path(LIBRARY_PATH).'array.lib.php';
-$user_id = api_get_user_id();
-$show_full_profile = true;
-
-//I'm your friend? I can see your profile?
-if (isset($_GET['u'])) {
-	$user_id 	= (int) Database::escape_string($_GET['u']);	
-	// It's me! 
-	if (api_get_user_id() != $user_id) {
-		$user_info	= UserManager::get_user_info_by_id($user_id);	
-		$show_full_profile = false;	
-		if ($user_info==false) {
-			// user does no exist !!
-			api_not_allowed();
-		} else {
-			//checking the relationship between me and my friend
-			$my_status= UserFriend::get_relation_between_contacts(api_get_user_id(), $user_id);
-			if (in_array($my_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {	
-				$show_full_profile = true;			
-			}
-			//checking the relationship between my friend and me		
-			$my_friend_status = UserFriend::get_relation_between_contacts($user_id, api_get_user_id());		
-			if (in_array($my_friend_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
-				$show_full_profile = true;			
-			} else {
-				// im probably not a good friend
-				$show_full_profile = false;
-			}
-		}	
-	} else {
-		$user_info	= UserManager::get_user_info_by_id($user_id);	
-	}		
-} else {
-	$user_info	= UserManager::get_user_info_by_id($user_id);
-}
-
-$libpath = api_get_path(LIBRARY_PATH);
-require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
-require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
-require_once $libpath.'course.lib.php';
-require_once $libpath.'formvalidator/FormValidator.class.php';
-require_once $libpath.'magpierss/rss_fetch.inc';
-
-api_block_anonymous_users();
-
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.corners.min.js" type="text/javascript" language="javascript"></script>'; //jQuery corner
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js"></script>';
-$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
-$htmlHeadXtra[] = '
-<script type="text/javascript">
-function toogle_function (element_html, course_code){
-	elem_id=$(element_html).attr("id");	
-	id_elem=elem_id.split("_"); 
-	ident="div#div_group_"+id_elem[1];
-	 
-	id_button="#btn_"+id_elem[1]; 
-	elem_src=$(id_button).attr("src"); 
-	image_show=elem_src.split("/");
-	my_image=image_show[2];
-	var content = \'social_content\' + id_elem[1]; 
-	if (my_image=="nolines_plus.gif") {
-		$(id_button).attr("src","../img/nolines_minus.gif"); var action = "load_course";
-		$("div#"+content).show("slow");	
-	} else {
-		$("div#"+content).hide("slow");	
-		$(id_button).attr("src","../img/nolines_plus.gif"); var action = "unload";
-		return false;
-	}
-
-	 $.ajax({
-		contentType: "application/x-www-form-urlencoded",
-		beforeSend: function(objeto) {
-		$("div#"+content).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
-		type: "POST",
-		url: "../social/data_personal.inc.php",
-		data: "load_ajax="+id_elem+"&action="+action+"&course_code="+course_code,
-		success: function(datos) {
-		 //$("div#"+name_div_id).hide("slow");
-		 $("div#"+content).html(datos);
-		}
-	});		
-} 
-</script>';
-$htmlHeadXtra[] = '<script type="text/javascript">
-$(document).ready(function (){
-	$("input#id_btn_send_invitation").bind("click", function(){
-		if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
-			$("#form_register_friend").submit();
-		}
-	}); 
-});
-function change_panel (mypanel_id,myuser_id) {
-		$.ajax({
-			contentType: "application/x-www-form-urlencoded",
-			beforeSend: function(objeto) {
-			$("#id_content_panel").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
-			type: "POST",
-			url: "../messages/send_message.php",
-			data: "panel_id="+mypanel_id+"&user_id="+myuser_id,
-			success: function(datos) {
-			 $("div#id_content_panel_init").html(datos);
-			 $("div#display_response_id").html("");
-			}
-		});	
-}
-function action_database_panel (option_id,myuser_id) {
-	
-	if (option_id==5) {
-		my_txt_subject=$("#txt_subject_id").val();
-	} else {
-		my_txt_subject="clear";
-	}
-		my_txt_content=$("#txt_area_invite").val();
-	if (my_txt_content.length==0 || my_txt_subject.length==0) {
-		$("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageInvitationNotSent', '').'");
-		setTimeout("message_information_display()",3000);
-		return false;
-	}
-	$.ajax({
-		contentType: "application/x-www-form-urlencoded",
-		beforeSend: function(objeto) {
-		$("#display_response_id").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
-		type: "POST",
-		url: "../messages/send_message.php",
-		data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,
-		success: function(datos) {
-		 $("#display_response_id").html(datos);
-		}
-	});	
-}	
-function display_hide () {
-		setTimeout("hide_display_message()",3000);
-}
-function message_information_display() {
-	$("#display_response_id").html("");
-}
-function hide_display_message () {
-	$("div#display_response_id").html("");
-	try {
-		$("#txt_subject_id").val("");
-		$("#txt_area_invite").val("");
-	}catch(e) {
-		$("#txt_area_invite").val("");
-	}
-}	
-function register_friend(element_input) {
- if(confirm("'.get_lang('AddToFriends').'")) {
-		name_button=$(element_input).attr("id");
-		name_div_id="id_"+name_button.substring(13);
-		user_id=name_div_id.split("_");
-		user_friend_id=user_id[1];
-		 $.ajax({
-			contentType: "application/x-www-form-urlencoded",
-			beforeSend: function(objeto) {
-			$("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
-			type: "POST",
-			url: "../social/register_friend.php",
-			data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
-			success: function(datos) {
-				$("form").submit()
-			}
-		});
- }
-}
-
-</script>';
-if (isset($_GET['shared'])) {
-	$my_link='../social/index.php';
-	$link_shared='shared='.Security::remove_XSS($_GET['shared']);
-} else {
-	$my_link='../auth/profile.php';
-	$link_shared='';
-}
-$interbreadcrumb[]= array ('url' =>$my_link,'name' => get_lang('ModifyProfile') );
-
-$interbreadcrumb[]= array (
-	'url' => '../social/profile.php?'.$link_shared.'#remote-tab-1',
-	'name' => get_lang('ViewMySharedProfile')
-);
-
-if (isset($_GET['u']) && is_numeric($_GET['u'])) {
-	$info_user=api_get_user_info($_GET['u']);	
-	$interbreadcrumb[]= array (
-		'url' => '#',
-		'name' => $info_user['firstName'].' '.$info_user['lastName']
-	);	
-}
-if (isset($_GET['u'])) {
-	$param_user='u='.Security::remove_XSS($_GET['u']);
-}else {
-	$info_user=api_get_user_info(api_get_user_id());
-	$param_user='';	
-}
-$_SESSION['social_user_id'] = $user_id;
-/**
- * Helper functions definition
- */
-function get_logged_user_course_html($my_course, $count) {
-	global $nosession;
-	if (api_get_setting('use_session_mode')=='true' && !$nosession) {
-		global $now, $date_start, $date_end;
-	}
-	//initialise
-	$result = '';
-	// Table definitions
-	$main_user_table 		 = Database :: get_main_table(TABLE_MAIN_USER);
-	$tbl_session 			 = Database :: get_main_table(TABLE_MAIN_SESSION);
-	$course_database 		 = $my_course['db'];
-	$course_tool_table 		 = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
-	$tool_edit_table 		 = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
-	$course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
-		
-	$user_id = api_get_user_id();
-	$course_system_code = $my_course['k'];
-	$course_visual_code = $my_course['c'];
-	$course_title = $my_course['i'];
-	$course_directory = $my_course['d'];
-	$course_teacher = $my_course['t'];
-	$course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
-	$course_info = Database :: get_course_info($course_system_code);
-	//error_log(print_r($course_info,true));
-	$course_access_settings = CourseManager :: get_access_settings($course_system_code);
-	
-	$course_visibility = $course_access_settings['visibility'];
-	
-	$user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);		
-	//function logic - act on the data
-	$is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
-	if ($is_virtual_course) { 
-		// If the current user is also subscribed in the real course to which this
-		// virtual course is linked, we don't need to display the virtual course entry in
-		// the course list - it is combined with the real course entry.
-		$target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);		
-		$is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
-		if ($is_subscribed_in_target_course) {			
-			return; //do not display this course entry
-		}
-	}
-	$has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
-	if ($has_virtual_courses) { 
-		$return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
-		$course_display_title = $return_result['title'];
-		$course_display_code = $return_result['code'];
-	} else {
-		$course_display_title = $course_title;
-		$course_display_code = $course_visual_code;
-	}
-	$s_course_status=$my_course['s'];
-	$s_htlm_status_icon="";
-
-	if ($s_course_status==1) {
-		$s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
-	}
-	if ($s_course_status==2) {
-		$s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
-	}
-	if ($s_course_status==5) {
-		$s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student'));
-	}
-
-	//display course entry		
-	$result .= '<div id="div_'.$count.'">';
-	//$result .= '<a id="btn_'.$count.'" href="#" onclick="toogle_function(this,\''.$course_database.'\')">';
-	$result .= '<h2><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_function(this,\''.$course_database.'\' )">';
-	$result .= $s_htlm_status_icon;
-	
-	//show a hyperlink to the course, unless the course is closed and user is not course admin
-	if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
-		$result .= '<a href="javascript:void(0)" id="ln_'.$count.'"  onclick=toogle_function(this,\''.$course_database.'\');>&nbsp;'.$course_title.'</a></h2>';
-		/*
-		if(api_get_setting('use_session_mode')=='true' && !$nosession) {
-			if(empty($my_course['id_session'])) {
-				$my_course['id_session'] = 0;
-			}
-			if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
-				//$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
-				$result .= '<a href="#">'.$course_display_title.'</a>';
-			}
-		} else {
-			//$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
-			$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
-		}*/
-	} else {
-		$result .= $course_display_title." "." ".get_lang('CourseClosed')."";
-	}
-	// show the course_code and teacher if chosen to display this
-	// we dont need this! 	
-	/*
-			if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') {
-				$result .= '<br />';
-			}
-			if (api_get_setting('display_coursecode_in_courselist') == 'true') {
-				$result .= $course_display_code;
-			}
-			if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') {
-				$result .= ' &ndash; ';
-			}
-			if (api_get_setting('display_teacher_in_courselist') == 'true') {
-				$result .= $course_teacher;
-				if(!empty($course_teacher_email)) {
-					$result .= ' ('.$course_teacher_email.')';
-				}
-			}
-	*/
-	$current_course_settings = CourseManager :: get_access_settings($my_course['k']);
-	// display the what's new icons
-	//	$result .= show_notification($my_course);
-	if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
-		reset($digest);
-		$result .= '<ul>';
-		while (list ($key2) = each($digest[$thisCourseSysCode])) {
-			$result .= '<li>';
-			if ($orderKey[1] == 'keyTools') {
-				$result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
-				$result .= "$toolsList[$key2][\"name\"]</a>";
-			} else {
-				$result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
-			}
-			$result .= '</li>';
-			$result .= '<ul>';
-			reset($digest[$thisCourseSysCode][$key2]);
-			while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
-				$result .= '<li>';
-				if ($orderKey[2] == 'keyTools') {
-					$result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
-					$result .= "$toolsList[$key3][\"name\"]</a>";
-				} else {
-					$result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3));
-				}
-				$result .= '<ul compact="compact">';
-				reset($digest[$thisCourseSysCode][$key2][$key3]);
-				while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3])) {
-					$result .= '<li>';
-					$result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
-					$result .= '</li>';
-				}
-				$result .= '</ul>';
-				$result .= '</li>';
-			}
-			$result .= '</ul>';
-			$result .= '</li>';
-		}
-		$result .= '</ul>';
-	}
-	$result .= '</li>';		
-	$result .= '</div>';
-	
-	if (api_get_setting('use_session_mode')=='true' && !$nosession) {
-		$session = '';
-		$active = false;
-		if (!empty($my_course['session_name'])) {
-			
-			// Request for the name of the general coach
-			$sql = 'SELECT lastname, firstname 
-					FROM '.$tbl_session.' ts  LEFT JOIN '.$main_user_table .' tu
-					ON ts.id_coach = tu.user_id
-					WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
-			$rs = api_sql_query($sql, __FILE__, __LINE__);
-			$sessioncoach = api_store_result($rs);
-			$sessioncoach = $sessioncoach[0];
-		
-			$session = array();
-			$session['title'] = $my_course['session_name'];
-			if ( $my_course['date_start']=='0000-00-00' ) {
-				$session['dates'] = get_lang('WithoutTimeLimits');
-				if ( api_get_setting('show_session_coach') === 'true' ) {
-					$session['coach'] = get_lang('GeneralCoach').': '.$sessioncoach['lastname'].' '.$sessioncoach['firstname'];
-				}
-				$active = true;
-			} else {
-				$session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
-				if ( api_get_setting('show_session_coach') === 'true' ) {
-					$session['coach'] = get_lang('GeneralCoach').': '.$sessioncoach['lastname'].' '.$sessioncoach['firstname'];
-				}
-				$active = ($date_start <= $now && $date_end >= $now)?true:false;
-			}
-		}
-		$output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
-	} else {
-		$output = array ($my_course['user_course_cat'], $result);
-	}	
-	//$my_course['creation_date'];
-	return $output;
-}
-/**
- * Get user's feeds
- * @param   int User ID
- * @param   int Limit of posts per feed
- * @return  string  HTML section with all feeds included
- * @author  Yannick Warnier
- * @since   Dokeos 1.8.6.1
- */
-function get_user_feeds($user,$limit=5) {
-    if (!function_exists('fetch_rss')) { return '';}
-    $fields = UserManager::get_extra_fields();
-    $feed_fields = array();
-    $feeds = array();
-    $res = '<div class="sectiontitle">'.get_lang('RSSFeeds').'</div>';
-    $res .= '<div class="social-content-training">';
-    $feed = UserManager::get_extra_user_data_by_field($user,'rssfeeds');
-    if(empty($feed)) { return ''; }
-    $feeds = split(';',$feed['rssfeeds']);
-    if (count($feeds)==0) { return ''; }
-    foreach ($feeds as $url) {
-	if (empty($url)) { continue; }
-        $rss = fetch_rss($url);
-    	$res .= '<h2>'.$rss->channel['title'].'</h2>';
-        $res .= '<div class="social-rss-channel-items">';
-        $i = 1;
-        foreach ($rss->items as $item) {
-            if ($limit>=0 and $i>$limit) {break;}
-        	$res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
-            $res .= '<div class="social-rss-item-date">'.api_get_datetime($item['date_timestamp']).'</div>';
-            $res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />';
-            $i++;
-        }
-        $res .= '</div>';
-    }
-    $res .= '</div>';
-    $res .= '<div class="clear"></div><br />';
-    return $res;
-}
-/**
- * Display
- */
-Display :: display_header(null);
-
-// @todo here we must show the user information as read only 
-//User picture size is calculated from SYSTEM path
-
-$img_array= UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
-
-//print_r($user_info);
-echo $s="<script>$(document).ready( function(){
-		  $('.rounded').corners();		  
-		});</script>";
-			
-//echo '<div id="actions">';
-//echo '<a href="../auth/profile.php?show=1"">'.Display::return_icon('edit.gif').'&nbsp;'.api_convert_encoding(get_lang('EditInformation'),'UTF-8',$charset).'</a>';
-//echo '</div>';
-
-//Setting some course info 
-$my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
-$personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
-$course_list_code = array();
-$i=1;
-//print_r($personal_course_list);
-
-
-
-if (is_array($personal_course_list)) {
-	foreach ($personal_course_list as $my_course) {
-		if ($i<=10) {
-			$list[] = get_logged_user_course_html($my_course,$i);	
-			//$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']); cause double 
-			$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
-			
-		} else {
-			break;
-		}
-		$i++;
-	}
-	//to avoid repeted courses
-	$course_list_code = array_unique_dimensional($course_list_code);	
-}
-
-echo '<div class="actions-title">';
-if ($user_id == api_get_user_id())
-	echo get_lang('ViewMySharedProfile');
-else 
-	echo get_lang('ViewSharedProfile').' - '.ucfirst($user_info['firstname']).' '.$user_info['lastname'];
-		
-echo '</div>';					
-
-echo '<div id="social-profile-wrapper">';
-// RIGHT COLUMN
-    echo '<div id="social-profile-right">';			
-		//---- FRIENDS
-		
-		if ($show_full_profile) {
-			$list_path_friends= $list_path_normal_friends = $list_path_parents = array();
-			
-			$list_path_good_friends		= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND);	
-			$list_path_normal_friends	= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALFRIEND);			
-			$list_path_parents 			= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALPARENT);
-			
-			$list_path_friends = array_merge_recursive($list_path_good_friends, $list_path_normal_friends, $list_path_parents);
-			
-			$friend_html='';
-			$number_of_images=3;
-			$number_friends=0;
-			$list_friends_id=array();
-			$list_friends_dir=array();
-			$list_friends_file=array();
-			
-			if (count($list_path_friends)!=0) {
-				$friends_count = count($list_path_friends['id_friend']); 
-				
-				for ($z=0;$z< $friends_count ;$z++) {
-					$list_friends_id[]  = $list_path_friends['id_friend'][$z]['friend_user_id'];
-					$list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir'];
-					$list_friends_file[]= $list_path_friends['path_friend'][$z]['file'];
-				}
-				$number_friends= count($list_friends_dir);
-				$number_loop   = ($number_friends/$number_of_images);
-				$loop_friends  = ceil($number_loop);
-				$j=0;
-				$friend_html .= '<div class="sectiontitle">'.get_lang('SocialFriend').'</div>';	
-				$friend_html.= '<div id="friend-container" class="social-friend-container">';							
-				$friend_html.= '<div id="friend-header">';
-				//$friend_html.=  $friends_count.' '.get_lang('Friends');
-				if ($friends_count == 1)
-					$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friend').'</div>';
-				else 
-					$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friends').'</div>';
-				if (api_get_user_id() == $user_id)	
-					$friend_html.= '<div style="float:right;"><a href="index.php?#remote-tab-6">'.get_lang('SeeAll').'</a></div>';													
-					$friend_html.= '</div>'; // close div friend-header						
-								
-				for ($k=0;$k<$loop_friends;$k++) {				
-					if ($j==$number_of_images) {
-						$number_of_images=$number_of_images*2;
-					}
-					while ($j<$number_of_images) {
-						if ($list_friends_file[$j]<>"") {
-							$my_user_info=api_get_user_info($list_friends_id[$j]);
-							$name_user=$my_user_info['firstName'].' '.$my_user_info['lastName'];
-							$friend_html.='<div id=div_'.$list_friends_id[$j].' class="image_friend_network" ><span><center>';
-							// the height = 92 must be the sqme in the image_friend_network span style in default.css
-							$friends_profile = UserFriend::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92, 'medium_', 'width="85" height="90" ');
-							$friend_html.='<a href="profile.php?u='.$list_friends_id[$j].'&amp;'.$link_shared.'">';
-							$friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$list_friends_id[$j].'" title="'.$name_user.'" />';
-							$friend_html.= '</center></span>';
-							$friend_html.= '<center class="friend">'.$my_user_info['firstName'].' '.$my_user_info['lastName'].'</a></center>';
-							$friend_html.= '</div>';				
-						}
-						$j++; 
-					}				
-				}			
-			} else {
-				// No friends!! :(
-				$friend_html .= '<div class="sectiontitle">'.get_lang('Friends').'</div>';
-				$friend_html.= '<div id="friend-container" class="social-friend-container">';
-				$friend_html.= '<div id="friend-header">';				
-				$friend_html.= '<div style="float:left; padding:0px 8px 0px 8px;">'.get_lang('NoFriendsInYourContactList').'<br /><a href="'.api_get_path(WEB_PATH).'whoisonline.php">'.get_lang('TryAndFindSomeFriends').'</a></div>';				
-				$friend_html.= '</div>'; // close div friend-header					
-			}
-			$friend_html.= '</div>'; 		
-			echo $friend_html; 				
-			//Pending invitations	
-			if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
-				$pending_invitations = UserFriend::get_list_invitation_of_friends_by_user_id(api_get_user_id());
-				$list_get_path_web=UserFriend::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
-				$count_pending_invitations = count($pending_invitations);
-				//echo '<div class="clear"></div><br />';		
-					//javascript:register_friend(this)
-					//var_dump($pending_invitations);
-				echo '<div class="clear"></div><br />';
-				echo '<div id="social-profile-invitations" >';
-				if ($count_pending_invitations > 0) {
-					echo '<div class="sectiontitle">';
-					echo api_convert_encoding(get_lang('PendingInvitations'),$charset,'UTF-8'); 
-					echo '</div><br />';
-					for ($i=0;$i<$count_pending_invitations;$i++) {
-						//var_dump($invitations);
-						echo '<div id="dpending_'.$pending_invitations[$i]['user_sender_id'].'" class="friend_invitations">'; 
-							echo '<div style="float:left;width:60px;" >';
-								echo '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
-							echo '</div>';
-							echo '<div style="padding-left:70px;">';
-								echo ' '.api_convert_encoding(substr($pending_invitations[$i]['content'],0,50),$charset,'UTF-8');
-								echo '<br />';
-								echo '<a id="btn_accepted_'.$pending_invitations[$i]['user_sender_id'].'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
-								echo '<div id="id_response">&nbsp;</div>';
-							echo '</div>';
-						echo '</div>';
-						echo '<div class="clear"></div>';
-					}
-				}
-				echo '</div>';
-			}
-			
-			//--Productions			
-			$production_list =  UserManager::build_production_list($user_id);
-			if (!empty($production_list )) {
-				echo '<div class="clear"></div><br />';
-				echo '<div class="sectiontitle">';
-				echo get_lang('MyProductions');
-				echo '</div>';
-				echo '<div class="rounded1">';
-				echo $production_list;
-				echo '</div>';	
-			}			
-			
-			// Images uploaded by course			
-			$file_list = '';			
-			if (is_array($course_list_code) && count($course_list_code)>0) {
-				foreach ($course_list_code as $course) { 
-					$file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code']);
-				}			
-			}
-	
-			if (!empty($file_list)) {
-				echo '<div class="clear"></div><br />';
-				echo '<div class="sectiontitle">';
-				echo get_lang('ImagesUploaded');
-				echo '</div><br />';
-				echo '</br><div class="social-content-information">';
-				echo $file_list;
-				echo '</div>';		
-			}			
-			
-			//loading this information 
-			
-			//-- Competences
-			if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
-				echo '<div class="clear"></div>';
-				echo '<div class="sectiontitle">';				
-				echo get_lang('MoreInformation');
-				echo '</div>';
-			}
-			echo '<div class="social-content-competences">';
-			$cut_size = 220;
-			if (!empty($user_info['competences'])) {		
-				echo '<br />';
-				echo '<div class="social-background-content" style="width:100%;">';
-				echo '<div class="social-actions-message">'.get_lang('MyCompetences').'</div>';
-				echo cut($user_info['competences'],$cut_size);
-				echo '</div>';
-				echo '<br />';
-			}
-			
-			if (!empty($user_info['diplomas'])) {
-				echo '<div class="social-background-content" style="width:100%;" >';					
-				echo '<div class="social-actions-message">'.get_lang('MyDiplomas').'</div>';
-				echo cut($user_info['diplomas'],$cut_size); 
-				echo '</div>';
-				echo '<br />';
-			}
-			if (!empty($user_info['openarea'])) {
-				echo '<div class="social-background-content" style="width:100%;" >';	
-				echo '<div class="social-actions-message">'.get_lang('MyPersonalOpenArea').'</div>';
-				echo cut($user_info['openarea'],$cut_size); 
-				echo '</div>';
-				echo '<br />';
-			}
-			if (!empty($user_info['teach'])) {
-				echo '<div class="social-background-content" style="width:100%;" >';					
-				echo '<div class="social-actions-message">'.get_lang('MyTeach').'</div>';
-				echo cut($user_info['teach'],$cut_size);
-				echo '</div>';
-				echo '<br />';
-			}
-			echo '</div>';				
-		} else {
-			echo '<div class="clear"></div><br />';	
-		}
-				
-	echo '</div>'; // end of content section
-		
-		
-echo '<div id="social-profile-container">';
-	// LEFT COLUMN
-	echo '<div id="social-profile-left">';
-	
-			//--- User image
-			echo '<div class="social-content-image">';
-			echo '<div class="social-background-content" style="width:95%;" align="center">';
-			echo '<br/>';
-    	  	echo '<img src='.$img_array['dir'].$img_array['file'].' /> <br /><br />';
-    	  	echo '</div>';
-    	  	echo '</div>';
-    	  	echo '<br/>';
-    	  	echo '<div class="actions" style="margin-right:5px;">';
-    	  	if (api_get_user_id() == $user_id) {
-    	  		// if i'm me
-    	  		echo '<div>';
-    	  		echo Display::return_icon('email.gif');
-    	  		echo '&nbsp;<a href="../social/index.php#remote-tab-2">'.get_lang('MyInbox').'</a>&nbsp;'; 
-    	  		echo '</div>';
-    	  		echo '<div>';
-    	  		echo Display::return_icon('edit.gif');
-    	  		echo '&nbsp;<a href="../auth/profile.php?show=1">'.get_lang('EditInformation').'</a>&nbsp;';  
-    	  		echo '</div>'; 	  			
-    	  	} else {
-    	  		echo '&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />'; 
-    	  		//echo '&nbsp;&nbsp;<a href="#">'.get_lang('SendMessage').'</a>';	
-    	  	}
-    	  	echo '</div>';
-    	  	echo '<br />';
-    	  	
-    	  	// Send message or Add to friend links
-    	  	/*if (!$show_full_profile) {
-    	  		echo '&nbsp;&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />'; 		
-    	  	}*/
-    	  	
-			// Extra information
-			
-    	  	if ($show_full_profile) {    	  		
-				//-- Extra Data
-				$t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
-				$t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
-				$extra_user_data = UserManager::get_extra_user_data($user_id);
-				$extra_information = '';
-				if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
-					$extra_information = '<div class="sectiontitle">';
-					$extra_information .= get_lang('ExtraInformation');
-					$extra_information .= '</div><br />';
-					$extra_information .='<div class="social-content-information">';
-					$extra_information_value = '';
-					foreach($extra_user_data as $key=>$data) {
-						// get display text, visibility and type from user_field table
-						$field_variable = str_replace('extra_','',$key);
-						$sql = "SELECT field_display_text,field_visible,field_type FROM $t_uf WHERE field_variable ='$field_variable'";
-						$res_field = Database::query($sql,__FILE__,__LINE__);
-						$row_field = Database::fetch_row($res_field);
-						$field_display_text = $row_field[0];
-						$field_visible = $row_field[1];
-						$field_type = $row_field[2];												
-						
-						if ($field_visible == 1) {
-							if (is_array($data)) {																																
-								$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(',',$data).'<br />';								
-							} else {								
-								if ($field_type == 8) {							
-									$id_options = explode(';',$data);
-									$value_options = array();							
-									// get option display text from user_field_options table
-									foreach ($id_options as $id_option) {														
-										$sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
-										$res_options = Database::query($sql,__FILE__,__LINE__);
-										$row_options = Database::fetch_row($res_options);
-										$value_options[] = $row_options[0];
-									}
-									$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(' ',$value_options).'<br />'; 							
-								}
-								else {
-									$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.$data.'<br />';
-								}								
-							}
-						}
-					}
-					// if there are information to show
-					if (!empty($extra_information_value)) {
-						$extra_information .= $extra_information_value;
-					}
-					$extra_information .= '</div>';			
-					$extra_information .= '<br /><br />';
-				}
-				// 	if there are information to show				
-				if (!empty($extra_information_value))
-					echo $extra_information;
-				
-				
-				// ---- My Agenda Items
-				$my_agenda_items = show_simple_personal_agenda($user_id);
-				if (!empty($my_agenda_items)) {
-					echo '<div class="sectiontitle">';					
-					echo get_lang('MyAgenda');
-					echo '</div>';
-					$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
-					echo '<div class="social-content-agenda">';
-					echo '<div class="social-background-content">';	
-					echo $my_agenda_items; 
-					echo '</div>';
-					
-					echo '<br /><br />';
-					echo '</div>';
-				}
-					
-				//-----Announcements
-				$announcement_content = '';		
-				$my_announcement_by_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
-
-		    	foreach ($course_list_code as $course) {
-	    			$content = get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id);	
-	    			$course_info=api_get_course_info($course['code']); 			
-	    	  		if (!empty($content)) {		    	  			  
-						$announcement_content.= '<div class="social-background-content" style="width:100%">';	
-						$announcement_content.= '<div class="actions">'.$course_info['name'].'</div>';					
-						$announcement_content.= $content;	
-						$announcement_content.= '</div>';
-						$announcement_content.= '<br/>';
-	    	  		}
-
-	    	  	}
-	    	  	
-	    	  	if(!empty($announcement_content)) {
-	    	  		echo '<div class="sectiontitle">';
-	    	  		echo get_lang('Announcements');
-	    	  		echo '</div><br/>';
-	    	  		echo '<div class="social-content-announcements">';
-	    	  		echo $announcement_content.'<br/>';
-	    	  		echo '</div>';
-	    	  	}					
-    	  	}
-    echo '</div>';
-    
-    
-  	// CENTER COLUMN
-  	
-  	
-	echo '<div id="social-profile-content">';
-
-		    //--- Basic Information	
-		    echo '<div class="sectiontitle">';		
-			echo get_lang('Information');  //class="social-profile-info"
-			echo '</div>';
-			echo '<div class="social-content-information">';
-			if ($show_full_profile) {		 
-				echo '<div class="social-profile-info" >';					
-					echo '<dt>'.get_lang('UserName').'</dt>
-						  <dd>'. $user_info['username'].'	</dd>';					
-					if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
-						echo '<dt>'.get_lang('Name').'</dt>		
-						  	  <dd>'. $user_info['firstname'].' '.$user_info['lastname'].'</dd>';					
-					if (!empty($user_info['official_code']))					
-						echo '<dt>'.get_lang('OfficialCode').'</dt>	
-						  <dd>'.$user_info['official_code'].'</dd>';
-					if (!empty($user_info['email']))
-						if (api_get_setting('show_email_addresses')=='true')
-							echo '<dt>'.get_lang('Email').'</dt>			
-						  <dd>'.$user_info['email'].'</dd>';
-					if (!empty($user_info['phone']))
-						echo '<dt>'.get_lang('Phone').'</dt>			
-						  <dd>'. $user_info['phone'].'</dd>';
-					echo '</dl>';
-				echo '</div>';			
-			} else {
-				echo '<div class="social-profile-info" >';
-					echo '<dl>';
-					if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
-						echo '<dt>'.get_lang('Name').'</dt>		
-						  <dd>'. $user_info['firstname'].' '.$user_info['lastname'].'</dd>';					
-				echo '</div>';
-			}
-						
-			echo '<div class="clear"></div><br />';
-            echo '</div>';
-			// COURSES LIST
-			if ($show_full_profile) {							
-				//print_r($personal_course_list);		
-				//echo '<pre>';
-				if (is_array($list)) {
-					echo '<div class="sectiontitle">';
-					echo api_ucfirst(get_lang('MyCourses'));
-					echo '</div>';
-					echo '<div class="social-content-training">';
-					//Courses whithout sessions
-					$old_user_category = 0;
-					$i=1;
-					foreach($list as $key=>$value) {
-						if ( empty($value[2]) ) { //if out of any session		
-							echo $value[1];
-							//echo '<div id="loading'.$i.'">&nbsp;</div>';
-							//class="social-profile-rounded maincourse"							
-							echo '<div id="social_content'.$i.'"  style="background : #EFEFEF; padding:0px; ">';							
-							echo '</div>';		
-							$i++;
-						}
-					}				
-					$listActives = $listInactives = $listCourses = array();
-					foreach ( $list as $key=>$value ) {
-						if ( $value['active'] ) { //if the session is still active (as told by get_logged_user_course_html())
-							$listActives[] = $value;
-						} elseif ( !empty($value[2]) ) { //if there is a session but it is not active
-							$listInactives[] = $value;
-						}
-					}
-					/*
-					// --- Session registered
-					api_display_tool_title(get_lang('Sessions'));
-					if(count($listActives)>0) {			
-						echo "<ul class=\"courseslist\">\n";	
-						foreach ($listActives as $key => $value) {
-							if (!empty($value[2])) {
-								if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
-									$old_session = $value[2];
-									if ($key != 0) {
-										echo '</ul>';
-									}
-									//echo '<ul class="session_box"><li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
-									echo '<ul>';
-									if ( !empty($value[3]['coach']) ) {
-										echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
-									}
-									echo '</ul>';	
-									echo '<ul class="session_course_item">';
-								}
-							}
-							echo $value[1];	
-						}	
-						echo '</ul>';	
-					}
-					*/
-				}
-				echo '</ul><br />';
-                echo get_user_feeds($user_id);
-        		echo '</div>';
-		    }
-            echo '</div>';
-        echo '</div>';
-    echo '</div>';
-echo '</div>'; //from the main
-echo '<form id="id_reload" name="id_reload" action="profile.php">&nbsp;</form>';
-Display :: display_footer();
+<?php //$id: $
+/* For licensing terms, see /dokeos_license.txt */
+/**
+* This is the profile social main page
+* @author Julio Montoya <gugli100@gmail.com>
+* @author Isaac Flores Paz <florespaz_isaac@hotmail.com>
+* @package dokeos.social
+*/
+
+/**
+ * Init
+ */
+$language_file = array('registration','messages','userInfo','admin','forum','blog');
+$cidReset = true;	
+require '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'social.lib.php';
+require_once api_get_path(LIBRARY_PATH).'array.lib.php';
+$user_id = api_get_user_id();
+$show_full_profile = true;
+
+//I'm your friend? I can see your profile?
+if (isset($_GET['u'])) {	
+	$user_id 	= (int) Database::escape_string($_GET['u']);	
+	// It's me! 
+	if (api_get_user_id() != $user_id) {
+		$user_info	= UserManager::get_user_info_by_id($user_id);	
+		$show_full_profile = false;	
+		if ($user_info==false) {
+			// user does no exist !!
+			api_not_allowed();
+		} else {
+			//checking the relationship between me and my friend
+			$my_status= UserFriend::get_relation_between_contacts(api_get_user_id(), $user_id);
+			if (in_array($my_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {	
+				$show_full_profile = true;			
+			}
+			//checking the relationship between my friend and me		
+			$my_friend_status = UserFriend::get_relation_between_contacts($user_id, api_get_user_id());		
+			if (in_array($my_friend_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
+				$show_full_profile = true;			
+			} else {
+				// im probably not a good friend
+				$show_full_profile = false;
+			}
+		}	
+	} else {
+		$user_info	= UserManager::get_user_info_by_id($user_id);	
+	}		
+} else {
+	$user_info	= UserManager::get_user_info_by_id($user_id);
+}
+
+$libpath = api_get_path(LIBRARY_PATH);
+require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
+require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
+require_once $libpath.'course.lib.php';
+require_once $libpath.'formvalidator/FormValidator.class.php';
+require_once $libpath.'magpierss/rss_fetch.inc';
+
+api_block_anonymous_users();
+
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.corners.min.js" type="text/javascript" language="javascript"></script>'; //jQuery corner
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
+$htmlHeadXtra[] = '
+<script type="text/javascript">
+function toogle_function (element_html, course_code){
+	elem_id=$(element_html).attr("id");	
+	id_elem=elem_id.split("_"); 
+	ident="div#div_group_"+id_elem[1];
+	 
+	id_button="#btn_"+id_elem[1]; 
+	elem_src=$(id_button).attr("src"); 
+	image_show=elem_src.split("/");
+	my_image=image_show[2];
+	var content = \'social_content\' + id_elem[1]; 
+	if (my_image=="nolines_plus.gif") {
+		$(id_button).attr("src","../img/nolines_minus.gif"); var action = "load_course";
+		$("div#"+content).show("slow");	
+	} else {
+		$("div#"+content).hide("slow");	
+		$(id_button).attr("src","../img/nolines_plus.gif"); var action = "unload";
+		return false;
+	}
+
+	 $.ajax({
+		contentType: "application/x-www-form-urlencoded",
+		beforeSend: function(objeto) {
+		$("div#"+content).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
+		type: "POST",
+		url: "../social/data_personal.inc.php",
+		data: "load_ajax="+id_elem+"&action="+action+"&course_code="+course_code,
+		success: function(datos) {
+		 //$("div#"+name_div_id).hide("slow");
+		 $("div#"+content).html(datos);
+		}
+	});		
+}
+</script>';
+$htmlHeadXtra[] = '<script type="text/javascript">
+$(document).ready(function (){
+	$("input#id_btn_send_invitation").bind("click", function(){
+		if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
+			$("#form_register_friend").submit();
+		}
+	}); 
+});
+function change_panel (mypanel_id,myuser_id) {
+		$.ajax({
+			contentType: "application/x-www-form-urlencoded",
+			beforeSend: function(objeto) {
+			$("#id_content_panel").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
+			type: "POST",
+			url: "../messages/send_message.php",
+			data: "panel_id="+mypanel_id+"&user_id="+myuser_id,
+			success: function(datos) {
+			 $("div#id_content_panel_init").html(datos);
+			 $("div#display_response_id").html("");
+			}
+		});	
+}
+function action_database_panel (option_id,myuser_id) {
+	
+	if (option_id==5) {
+		my_txt_subject=$("#txt_subject_id").val();
+	} else {
+		my_txt_subject="clear";
+	}
+		my_txt_content=$("#txt_area_invite").val();
+	if (my_txt_content.length==0 || my_txt_subject.length==0) {
+		$("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageInvitationNotSent', '').'");
+		setTimeout("message_information_display()",3000);
+		return false;
+	}
+	$.ajax({
+		contentType: "application/x-www-form-urlencoded",
+		beforeSend: function(objeto) {
+		$("#display_response_id").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
+		type: "POST",
+		url: "../messages/send_message.php",
+		data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,
+		success: function(datos) {
+		 $("#display_response_id").html(datos);
+		}
+	});	
+}	
+function display_hide () {
+		setTimeout("hide_display_message()",3000);
+}
+function message_information_display() {
+	$("#display_response_id").html("");
+}
+function hide_display_message () {
+	$("div#display_response_id").html("");
+	try {
+		$("#txt_subject_id").val("");
+		$("#txt_area_invite").val("");
+	}catch(e) {
+		$("#txt_area_invite").val("");
+	}
+}	
+function register_friend(element_input) {
+ if(confirm("'.get_lang('AddToFriends').'")) {
+		name_button=$(element_input).attr("id");
+		name_div_id="id_"+name_button.substring(13);
+		user_id=name_div_id.split("_");
+		user_friend_id=user_id[1];
+		 $.ajax({
+			contentType: "application/x-www-form-urlencoded",
+			beforeSend: function(objeto) {
+			$("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
+			type: "POST",
+			url: "../social/register_friend.php",
+			data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
+			success: function(datos) {
+				$("form").submit()
+			}
+		});
+ }
+}
+
+</script>';
+if (isset($_GET['shared'])) {
+	$my_link='../social/index.php';
+	$link_shared='shared='.Security::remove_XSS($_GET['shared']);
+} else {
+	$my_link='../auth/profile.php';
+	$link_shared='';
+}
+$interbreadcrumb[]= array ('url' =>$my_link,'name' => get_lang('ModifyProfile') );
+
+$interbreadcrumb[]= array (
+	'url' => '../social/profile.php?'.$link_shared.'#remote-tab-1',
+	'name' => get_lang('ViewMySharedProfile')
+);
+
+if (isset($_GET['u']) && is_numeric($_GET['u'])) {
+	$info_user=api_get_user_info($_GET['u']);	
+	$interbreadcrumb[]= array (
+		'url' => 'javascript: void(0);',
+		'name' => api_get_person_name($info_user['firstName'], $info_user['lastName'])
+	);	
+}
+if (isset($_GET['u'])) {
+	$param_user='u='.Security::remove_XSS($_GET['u']);
+}else {
+	$info_user=api_get_user_info(api_get_user_id());
+	$param_user='';	
+}
+$_SESSION['social_user_id'] = $user_id;
+/**
+ * Helper functions definition
+ */
+function get_logged_user_course_html($my_course, $count) {
+	global $nosession;
+	if (api_get_setting('use_session_mode')=='true' && !$nosession) {
+		global $now, $date_start, $date_end;
+	}
+	//initialise
+	$result = '';
+	// Table definitions
+	$main_user_table 		 = Database :: get_main_table(TABLE_MAIN_USER);
+	$tbl_session 			 = Database :: get_main_table(TABLE_MAIN_SESSION);
+	$course_database 		 = $my_course['db'];
+	$course_tool_table 		 = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
+	$tool_edit_table 		 = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
+	$course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
+		
+	$user_id = api_get_user_id();
+	$course_system_code = $my_course['k'];
+	$course_visual_code = $my_course['c'];
+	$course_title = $my_course['i'];
+	$course_directory = $my_course['d'];
+	$course_teacher = $my_course['t'];
+	$course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
+	$course_info = Database :: get_course_info($course_system_code);
+	//error_log(print_r($course_info,true));
+	$course_access_settings = CourseManager :: get_access_settings($course_system_code);
+	
+	$course_visibility = $course_access_settings['visibility'];
+	
+	$user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);		
+	//function logic - act on the data
+	$is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
+	if ($is_virtual_course) { 
+		// If the current user is also subscribed in the real course to which this
+		// virtual course is linked, we don't need to display the virtual course entry in
+		// the course list - it is combined with the real course entry.
+		$target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);		
+		$is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
+		if ($is_subscribed_in_target_course) {			
+			return; //do not display this course entry
+		}
+	}
+	$has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
+	if ($has_virtual_courses) { 
+		$return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
+		$course_display_title = $return_result['title'];
+		$course_display_code = $return_result['code'];
+	} else {
+		$course_display_title = $course_title;
+		$course_display_code = $course_visual_code;
+	}
+	$s_course_status=$my_course['s'];
+	$s_htlm_status_icon="";
+
+	if ($s_course_status==1) {
+		$s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
+	}
+	if ($s_course_status==2) {
+		$s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
+	}
+	if ($s_course_status==5) {
+		$s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student'));
+	}
+
+	//display course entry		
+	$result .= '<div id="div_'.$count.'">';
+	//$result .= '<a id="btn_'.$count.'" href="#" onclick="toogle_function(this,\''.$course_database.'\')">';
+	$result .= '<h2><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_function(this,\''.$course_database.'\' )">';
+	$result .= $s_htlm_status_icon;
+	
+	//show a hyperlink to the course, unless the course is closed and user is not course admin
+	if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
+		$result .= '<a href="javascript:void(0)" id="ln_'.$count.'"  onclick=toogle_function(this,\''.$course_database.'\');>&nbsp;'.$course_title.'</a></h2>';
+		/*
+		if(api_get_setting('use_session_mode')=='true' && !$nosession) {
+			if(empty($my_course['id_session'])) {
+				$my_course['id_session'] = 0;
+			}
+			if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
+				//$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
+				$result .= '<a href="#">'.$course_display_title.'</a>';
+			}
+		} else {
+			//$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
+			$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
+		}*/
+	} else {
+		$result .= $course_display_title." "." ".get_lang('CourseClosed')."";
+	}
+	// show the course_code and teacher if chosen to display this
+	// we dont need this! 	
+	/*
+			if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') {
+				$result .= '<br />';
+			}
+			if (api_get_setting('display_coursecode_in_courselist') == 'true') {
+				$result .= $course_display_code;
+			}
+			if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') {
+				$result .= ' &ndash; ';
+			}
+			if (api_get_setting('display_teacher_in_courselist') == 'true') {
+				$result .= $course_teacher;
+				if(!empty($course_teacher_email)) {
+					$result .= ' ('.$course_teacher_email.')';
+				}
+			}
+	*/
+	$current_course_settings = CourseManager :: get_access_settings($my_course['k']);
+	// display the what's new icons
+	//	$result .= show_notification($my_course);
+	if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
+		reset($digest);
+		$result .= '<ul>';
+		while (list ($key2) = each($digest[$thisCourseSysCode])) {
+			$result .= '<li>';
+			if ($orderKey[1] == 'keyTools') {
+				$result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
+				$result .= "$toolsList[$key2][\"name\"]</a>";
+			} else {
+				$result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
+			}
+			$result .= '</li>';
+			$result .= '<ul>';
+			reset($digest[$thisCourseSysCode][$key2]);
+			while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
+				$result .= '<li>';
+				if ($orderKey[2] == 'keyTools') {
+					$result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
+					$result .= "$toolsList[$key3][\"name\"]</a>";
+				} else {
+					$result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3));
+				}
+				$result .= '<ul compact="compact">';
+				reset($digest[$thisCourseSysCode][$key2][$key3]);
+				while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3])) {
+					$result .= '<li>';
+					$result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
+					$result .= '</li>';
+				}
+				$result .= '</ul>';
+				$result .= '</li>';
+			}
+			$result .= '</ul>';
+			$result .= '</li>';
+		}
+		$result .= '</ul>';
+	}
+	$result .= '</li>';		
+	$result .= '</div>';
+	
+	if (api_get_setting('use_session_mode')=='true' && !$nosession) {
+		$session = '';
+		$active = false;
+		if (!empty($my_course['session_name'])) {
+			
+			// Request for the name of the general coach
+			$sql = 'SELECT lastname, firstname 
+					FROM '.$tbl_session.' ts  LEFT JOIN '.$main_user_table .' tu
+					ON ts.id_coach = tu.user_id
+					WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
+			$rs = api_sql_query($sql, __FILE__, __LINE__);
+			$sessioncoach = api_store_result($rs);
+			$sessioncoach = $sessioncoach[0];
+		
+			$session = array();
+			$session['title'] = $my_course['session_name'];
+			if ( $my_course['date_start']=='0000-00-00' ) {
+				$session['dates'] = get_lang('WithoutTimeLimits');
+				if ( api_get_setting('show_session_coach') === 'true' ) {
+					$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
+				}
+				$active = true;
+			} else {
+				$session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
+				if ( api_get_setting('show_session_coach') === 'true' ) {
+					$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
+				}
+				$active = ($date_start <= $now && $date_end >= $now)?true:false;
+			}
+		}
+		$output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
+	} else {
+		$output = array ($my_course['user_course_cat'], $result);
+	}	
+	//$my_course['creation_date'];
+	return $output;
+}
+/**
+ * Get user's feeds
+ * @param   int User ID
+ * @param   int Limit of posts per feed
+ * @return  string  HTML section with all feeds included
+ * @author  Yannick Warnier
+ * @since   Dokeos 1.8.6.1
+ */
+function get_user_feeds($user,$limit=5) {
+    if (!function_exists('fetch_rss')) { return '';}
+	$fields = UserManager::get_extra_fields();
+    $feed_fields = array();
+    $feeds = array();
+    $res = '<div class="sectiontitle">'.get_lang('RSSFeeds').'</div>';
+    $res .= '<div class="social-content-training">';
+    $feed = UserManager::get_extra_user_data_by_field($user,'rssfeeds');
+    if(empty($feed)) { return ''; }
+    $feeds = split(';',$feed['rssfeeds']);
+    if (count($feeds)==0) { return ''; }
+    foreach ($feeds as $url) {
+	if (empty($url)) { continue; }
+        $rss = fetch_rss($url);
+    	$res .= '<h2>'.$rss->channel['title'].'</h2>';
+        $res .= '<div class="social-rss-channel-items">';
+        $i = 1;
+        foreach ($rss->items as $item) {
+            if ($limit>=0 and $i>$limit) {break;}
+        	$res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
+            $res .= '<div class="social-rss-item-date">'.api_get_datetime($item['date_timestamp']).'</div>';
+            $res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />';
+            $i++;
+        }
+        $res .= '</div>';
+    }
+    $res .= '</div>';
+    $res .= '<div class="clear"></div><br />';
+    return $res;
+}
+/**
+ * Display
+ */
+Display :: display_header(null);
+
+// @todo here we must show the user information as read only 
+//User picture size is calculated from SYSTEM path
+
+$img_array= UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
+
+//print_r($user_info);
+// Added by Ivan Tcholakov, 03-APR-2009.
+if (USE_JQUERY_CORNERS_SCRIPT) {
+//
+echo $s="<script>$(document).ready( function(){
+		  $('.rounded').corners();		  
+		});</script>";
+//
+}
+//
+			
+//echo '<div id="actions">';
+//echo '<a href="../auth/profile.php?show=1"">'.Display::return_icon('edit.gif').'&nbsp;'.api_convert_encoding(get_lang('EditInformation'),'UTF-8',$charset).'</a>';
+//echo '</div>';
+
+//Setting some course info 
+$my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
+$personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
+$course_list_code = array();
+$i=1;
+//print_r($personal_course_list);
+
+
+
+if (is_array($personal_course_list)) {
+	foreach ($personal_course_list as $my_course) {
+		if ($i<=10) {
+			$list[] = get_logged_user_course_html($my_course,$i);	
+			//$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']); cause double 
+			$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
+			
+		} else {
+			break;
+		}
+		$i++;
+	}
+	//to avoid repeted courses
+	$course_list_code = array_unique_dimensional($course_list_code);	
+}
+
+echo '<div class="actions-title">';
+if ($user_id == api_get_user_id())
+	echo get_lang('ViewMySharedProfile');
+else
+	echo get_lang('ViewSharedProfile').' - '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
+		
+echo '</div>';					
+
+echo '<div id="social-profile-wrapper">';
+// RIGHT COLUMN
+    echo '<div id="social-profile-right">';			
+		//---- FRIENDS
+
+		if ($show_full_profile) {
+			$list_path_friends= $list_path_normal_friends = $list_path_parents = array();
+			
+			$list_path_good_friends		= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND);	
+			$list_path_normal_friends	= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALFRIEND);			
+			$list_path_parents 			= UserFriend::get_list_path_web_by_user_id($user_id, SOCIALPARENT);
+			
+			$list_path_friends = array_merge_recursive($list_path_good_friends, $list_path_normal_friends, $list_path_parents);
+			
+			$friend_html='';
+			$number_of_images=3;
+			$number_friends=0;
+			$list_friends_id=array();
+			$list_friends_dir=array();
+			$list_friends_file=array();
+			
+			if (count($list_path_friends)!=0) {
+				$friends_count = count($list_path_friends['id_friend']);
+
+				for ($z=0;$z< $friends_count ;$z++) {
+					$list_friends_id[]  = $list_path_friends['id_friend'][$z]['friend_user_id'];
+					$list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir'];
+					$list_friends_file[]= $list_path_friends['path_friend'][$z]['file'];
+				}
+				$number_friends= count($list_friends_dir);
+				$number_loop   = ($number_friends/$number_of_images);
+				$loop_friends  = ceil($number_loop);
+				$j=0;
+				$friend_html .= '<div class="sectiontitle">'.get_lang('SocialFriend').'</div>';	
+				$friend_html.= '<div id="friend-container" class="social-friend-container">';							
+					$friend_html.= '<div id="friend-header">';
+							//$friend_html.=  $friends_count.' '.get_lang('Friends');
+						if ($friends_count == 1)
+							$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friend').'</div>';
+						else 
+							$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friends').'</div>';
+						if (api_get_user_id() == $user_id)	
+					$friend_html.= '<div style="float:right;"><a href="index.php?#remote-tab-6">'.get_lang('SeeAll').'</a></div>';													
+					$friend_html.= '</div>'; // close div friend-header						
+								
+				for ($k=0;$k<$loop_friends;$k++) {				
+					if ($j==$number_of_images) {
+						$number_of_images=$number_of_images*2;
+					}
+					while ($j<$number_of_images) {
+						if ($list_friends_file[$j]<>"") {
+							$my_user_info=api_get_user_info($list_friends_id[$j]);
+							$name_user=api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']);
+							$friend_html.='<div id=div_'.$list_friends_id[$j].' class="image_friend_network" ><span><center>';
+							// the height = 92 must be the sqme in the image_friend_network span style in default.css
+							$friends_profile = UserFriend::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92, 'medium_', 'width="85" height="90" ');
+							$friend_html.='<a href="profile.php?u='.$list_friends_id[$j].'&amp;'.$link_shared.'">';
+							$friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$list_friends_id[$j].'" title="'.$name_user.'" />';
+							$friend_html.= '</center></span>';
+							$friend_html.= '<center class="friend">'.api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']).'</a></center>';
+							$friend_html.= '</div>';				
+						}
+						$j++; 
+					}				
+				}
+			} else {
+				// No friends!! :(
+					$friend_html .= '<div class="sectiontitle">'.get_lang('Friends').'</div>';
+					$friend_html.= '<div id="friend-container" class="social-friend-container">';					
+					$friend_html.= '<div id="friend-header">';
+				$friend_html.= '<div style="float:left; padding:0px 8px 0px 8px;">'.get_lang('NoFriendsInYourContactList').'<br /><a href="'.api_get_path(WEB_PATH).'whoisonline.php">'.get_lang('TryAndFindSomeFriends').'</a></div>';				
+				$friend_html.= '</div>'; // close div friend-header					
+			}
+			$friend_html.= '</div>';		
+			echo $friend_html; 				
+			//Pending invitations	
+			if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
+			$pending_invitations = UserFriend::get_list_invitation_of_friends_by_user_id(api_get_user_id());
+			$list_get_path_web=UserFriend::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
+			$count_pending_invitations = count($pending_invitations);
+			//echo '<div class="clear"></div><br />';		
+				//javascript:register_friend(this)
+				//var_dump($pending_invitations);
+			echo '<div class="clear"></div><br />';
+			echo '<div id="social-profile-invitations" >';
+			if ($count_pending_invitations > 0) {
+				echo '<div class="sectiontitle">';
+					echo api_convert_encoding(get_lang('PendingInvitations'),$charset,'UTF-8'); 
+					echo '</div><br />';
+				for ($i=0;$i<$count_pending_invitations;$i++) {
+					//var_dump($invitations);
+						echo '<div id="dpending_'.$pending_invitations[$i]['user_sender_id'].'" class="friend_invitations">'; 
+						echo '<div style="float:left;width:60px;" >';
+							echo '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
+						echo '</div>';
+						echo '<div style="padding-left:70px;">';
+								echo ' '.api_convert_encoding(substr($pending_invitations[$i]['content'],0,50),$charset,'UTF-8');
+							echo '<br />';
+							echo '<a id="btn_accepted_'.$pending_invitations[$i]['user_sender_id'].'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
+							echo '<div id="id_response">&nbsp;</div>';
+						echo '</div>';
+					echo '</div>';
+					echo '<div class="clear"></div>';
+				}
+			}
+			echo '</div>';
+			}
+			
+			//--Productions			
+			$production_list =  UserManager::build_production_list($user_id);
+			if (!empty($production_list )) {
+				echo '<div class="clear"></div><br />';
+				echo '<div class="sectiontitle">';
+				echo get_lang('MyProductions');
+				echo '</div>';
+				echo '<div class="rounded1">';
+				echo $production_list;
+				echo '</div>';	
+			}			
+			
+			// Images uploaded by course			
+			$file_list = '';
+			if (is_array($course_list_code) && count($course_list_code)>0) {
+			foreach ($course_list_code as $course) { 
+				$file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code']);
+			}
+			}
+
+			if (!empty($file_list)) {
+				echo '<div class="clear"></div><br />';
+				echo '<div class="sectiontitle">';
+				echo get_lang('ImagesUploaded');
+				echo '</div><br />';
+				echo '</br><div class="social-content-information">';
+				echo $file_list;
+				echo '</div>';		
+			}
+			
+			//loading this information 
+			
+			//-- Competences
+			if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
+				echo '<div class="clear"></div>';
+				echo '<div class="sectiontitle">';				
+				echo get_lang('MoreInformation');
+				echo '</div>';
+			}
+			echo '<div class="social-content-competences">';
+			$cut_size = 220;
+			if (!empty($user_info['competences'])) {		
+				echo '<br />';
+				echo '<div class="social-background-content" style="width:100%;">';
+				echo '<div class="social-actions-message">'.get_lang('MyCompetences').'</div>';
+				echo cut($user_info['competences'],$cut_size);
+				echo '</div>';
+				echo '<br />';
+			}
+			
+			if (!empty($user_info['diplomas'])) {	
+				echo '<div class="social-background-content" style="width:100%;" >';					
+				echo '<div class="social-actions-message">'.get_lang('MyDiplomas').'</div>';
+				echo cut($user_info['diplomas'],$cut_size); 
+				echo '</div>';
+				echo '<br />';
+			}
+			if (!empty($user_info['openarea'])) {	
+				echo '<div class="social-background-content" style="width:100%;" >';	
+				echo '<div class="social-actions-message">'.get_lang('MyPersonalOpenArea').'</div>';
+				echo cut($user_info['openarea'],$cut_size); 
+				echo '</div>';
+				echo '<br />';
+			}
+			if (!empty($user_info['teach'])) {	
+				echo '<div class="social-background-content" style="width:100%;" >';					
+				echo '<div class="social-actions-message">'.get_lang('MyTeach').'</div>';
+				echo cut($user_info['teach'],$cut_size);
+				echo '</div>';
+				echo '<br />';
+			}				
+			echo '</div>';				
+		} else {
+			echo '<div class="clear"></div><br />';	
+		}
+		
+	echo '</div>'; // end of content section
+			
+		
+echo '<div id="social-profile-container">';
+	// LEFT COLUMN
+	echo '<div id="social-profile-left">';
+
+			//--- User image
+			echo '<div class="social-content-image">';
+			echo '<div class="social-background-content" style="width:95%;" align="center">';
+			echo '<br/>';
+    	  	echo '<img src='.$img_array['dir'].$img_array['file'].' /> <br /><br />';
+    	  	echo '</div>';
+    	  	echo '</div>';
+    	  	echo '<br/>';
+    	  	echo '<div class="actions" style="margin-right:5px;">';
+    	  	if (api_get_user_id() == $user_id) {
+    	  		// if i'm me
+    	  		echo '<div>';
+    	  		echo Display::return_icon('email.gif');
+    	  		echo '&nbsp;<a href="../social/index.php#remote-tab-2">'.get_lang('MyInbox').'</a>&nbsp;'; 
+    	  		echo '</div>';
+    	  		echo '<div>';
+    	  		echo Display::return_icon('edit.gif');
+    	  		echo '&nbsp;<a href="../auth/profile.php?show=1">'.get_lang('EditInformation').'</a>&nbsp;';    	  			
+    	  		echo '</div>'; 	  			
+    	  	} else {
+    	  		echo '&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />'; 
+    	  		//echo '&nbsp;&nbsp;<a href="javascript: void(0);">'.get_lang('SendMessage').'</a>';	
+    	  	}
+    	  	echo '</div>';
+    	  	echo '<br />';
+    	  	
+    	  	// Send message or Add to friend links
+    	  	/*if (!$show_full_profile) {
+    	  		echo '&nbsp;&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />'; 		
+    	  	}*/
+    	  	
+			// Extra information
+    	  	
+    	  	if ($show_full_profile) {    	  		
+				//-- Extra Data							
+				$t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
+				$t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
+				$extra_user_data = UserManager::get_extra_user_data($user_id);
+				$extra_information = '';
+				if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
+					$extra_information = '<div class="sectiontitle">';
+					$extra_information .= get_lang('ExtraInformation');
+					$extra_information .= '</div><br />';
+					$extra_information .='<div class="social-content-information">';
+					$extra_information_value = '';
+						foreach($extra_user_data as $key=>$data) {
+						// get display text, visibility and type from user_field table
+						$field_variable = str_replace('extra_','',$key);
+						$sql = "SELECT field_display_text,field_visible,field_type FROM $t_uf WHERE field_variable ='$field_variable'";
+						$res_field = Database::query($sql,__FILE__,__LINE__);
+						$row_field = Database::fetch_row($res_field);
+						$field_display_text = $row_field[0];
+						$field_visible = $row_field[1];
+						$field_type = $row_field[2];												
+						
+						if ($field_visible == 1) {
+							if (is_array($data)) {																																
+								$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(',',$data).'<br />';								
+							} else {								
+								if ($field_type == 8) {							
+									$id_options = explode(';',$data);
+									$value_options = array();							
+									// get option display text from user_field_options table
+									foreach ($id_options as $id_option) {														
+										$sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
+										$res_options = Database::query($sql,__FILE__,__LINE__);
+										$row_options = Database::fetch_row($res_options);
+										$value_options[] = $row_options[0];
+									}
+									$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(' ',$value_options).'<br />'; 							
+								}
+								else {
+									$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.$data.'<br />';
+								}								
+							}
+						}
+					}
+					// if there are information to show
+					if (!empty($extra_information_value)) {
+						$extra_information .= $extra_information_value;
+				}
+					$extra_information .= '</div>';			
+					$extra_information .= '<br /><br />';
+				}
+				// 	if there are information to show				
+				if (!empty($extra_information_value))
+					echo $extra_information;
+				
+				
+				// ---- My Agenda Items
+				$my_agenda_items = show_simple_personal_agenda($user_id);
+				if (!empty($my_agenda_items)) {
+					echo '<div class="sectiontitle">';					
+					echo get_lang('MyAgenda');
+					echo '</div>';
+					$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
+					echo '<div class="social-content-agenda">';
+					echo '<div class="social-background-content">';	
+					echo $my_agenda_items; 
+					echo '</div>';
+
+					echo '<br /><br />';
+					echo '</div>';
+				}
+					
+				//-----Announcements
+				$announcement_content = '';		
+				$my_announcement_by_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
+
+		    	foreach ($course_list_code as $course) {
+	    			$content = get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id);	 			
+	    			$course_info=api_get_course_info($course['code']); 			
+	    	  		if (!empty($content)) {	 		    	  			  
+						$announcement_content.= '<div class="social-background-content" style="width:100%">';	
+						$announcement_content.= '<div class="actions">'.$course_info['name'].'</div>';					
+						$announcement_content.= $content;	
+						$announcement_content.= '</div>';
+						$announcement_content.= '<br/>';
+	    	  		}
+
+	    	  	}
+	    	  	
+	    	  	if(!empty($announcement_content)) {
+	    	  		echo '<div class="sectiontitle">';
+	    	  		echo get_lang('Announcements');
+	    	  		echo '</div><br/>';
+	    	  		echo '<div class="social-content-announcements">';
+	    	  		echo $announcement_content.'<br/>';
+	    	  		echo '</div>';
+	    	  	}					
+    	  	}
+    echo '</div>';
+    
+    
+  	// CENTER COLUMN
+  	
+  	
+	echo '<div id="social-profile-content">';
+
+		    //--- Basic Information	
+		    echo '<div class="sectiontitle">';		
+			echo get_lang('Information');  //class="social-profile-info"
+			echo '</div>';
+			echo '<div class="social-content-information">';
+			if ($show_full_profile) {		 
+				echo '<div class="social-profile-info" >';					
+					echo '<dt>'.get_lang('UserName').'</dt>
+						  <dd>'. $user_info['username'].'	</dd>';					
+					if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
+						echo '<dt>'.get_lang('Name').'</dt>		
+						  	  <dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';					
+					if (!empty($user_info['official_code']))					
+						echo '<dt>'.get_lang('OfficialCode').'</dt>	
+						  <dd>'.$user_info['official_code'].'</dd>';
+					if (!empty($user_info['email']))
+						if (api_get_setting('show_email_addresses')=='true')
+							echo '<dt>'.get_lang('Email').'</dt>			
+						  <dd>'.$user_info['email'].'</dd>';
+					if (!empty($user_info['phone']))
+						echo '<dt>'.get_lang('Phone').'</dt>			
+						  <dd>'. $user_info['phone'].'</dd>';
+					echo '</dl>';
+				echo '</div>';			
+			} else {
+				echo '<div class="social-profile-info" >';
+					echo '<dl>';
+					if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
+						echo '<dt>'.get_lang('Name').'</dt>		
+						  <dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';					
+				echo '</div>';
+			}
+
+			echo '<div class="clear"></div><br />';			
+			echo '</div>';		
+			// COURSES LIST
+			if ($show_full_profile) {							
+				//print_r($personal_course_list);		
+				//echo '<pre>';
+				if ( is_array($list) ) {
+					echo '<div class="sectiontitle">';
+					echo api_ucfirst(get_lang('MyCourses'));
+					echo '</div>';
+					echo '<div class="social-content-training">';
+					//Courses whithout sessions
+					$old_user_category = 0;
+					$i=1;
+					foreach($list as $key=>$value) {
+						if ( empty($value[2]) ) { //if out of any session				
+							echo $value[1];
+							//echo '<div id="loading'.$i.'">&nbsp;</div>';
+							//class="social-profile-rounded maincourse"							
+							echo '<div id="social_content'.$i.'"  style="background : #EFEFEF; padding:0px; ">';							
+							echo '</div>';		
+							$i++;
+						}
+					}				
+					$listActives = $listInactives = $listCourses = array();
+					foreach ( $list as $key=>$value ) {
+						if ( $value['active'] ) { //if the session is still active (as told by get_logged_user_course_html())
+							$listActives[] = $value;
+						} elseif ( !empty($value[2]) ) { //if there is a session but it is not active
+							$listInactives[] = $value;
+						}
+					}
+					/*
+					// --- Session registered
+					api_display_tool_title(get_lang('Sessions'));
+					if(count($listActives)>0) {			
+						echo "<ul class=\"courseslist\">\n";	
+						foreach ($listActives as $key => $value) {
+							if (!empty($value[2])) {
+								if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
+									$old_session = $value[2];
+									if ($key != 0) {
+										echo '</ul>';
+									}
+									//echo '<ul class="session_box"><li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
+									echo '<ul>';
+									if ( !empty($value[3]['coach']) ) {
+										echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
+									}
+									echo '</ul>';	
+									echo '<ul class="session_course_item">';
+								}
+							}
+							echo $value[1];	
+						}	
+						echo '</ul>';	
+					}
+					*/
+				}
+				echo '</ul><br />';
+                echo get_user_feeds($user_id);
+        		echo '</div>';
+		    }
+            echo '</div>';
+        echo '</div>';
+    echo '</div>';
+echo '</div>'; //from the main
+echo '<form id="id_reload" name="id_reload" action="profile.php">&nbsp;</form>';
+Display :: display_footer();

+ 1 - 1
main/social/qualify_contact.inc.php

@@ -27,7 +27,7 @@ $user_friend_relation=UserFriend::get_relation_between_contacts(api_get_user_id(
 	   	 	<td width="50%"><br/>	   	 		
 	   	 		<img src="<?php echo Security::remove_XSS($img_user[1]); ?>" />
 	   	 		<?php
-	   	 		echo '<br /><br />'.$name_user=api_xml_http_response_encode($user_info['firstName'].' '.$user_info['lastName']); 
+	   	 		echo '<br /><br />'.$name_user=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); 
 	   	 		?>
 	   	 	</td>
 	   	 <td width="50%"><div align="left">

+ 1 - 1
main/social/select_friend_response.php

@@ -60,7 +60,7 @@ cellpadding="0" cellspacing="0" bgcolor="#9DACBF">
                                 <?php 
                                 $user_id=$list_get_invitation[$i]['user_sender_id'];
                                 $user_info=api_get_user_info($user_id);
-                                echo api_xml_http_response_encode($user_info['firstName'].' '.$user_info['lastName']);
+                                echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName']));
                                 ?></td>
                                 </tr>
                             </table></td>

+ 5 - 4
main/social/select_options.php

@@ -10,16 +10,17 @@ $search=Database::escape_string(Security::remove_XSS($_POST['search']));
 $current_date=date('Y-m-d H:i:s',time()); 
 $html_form='<select id="id_search_name" name="id_search_name" size="8"" style="width:350px;">';
 $user_id = api_get_user_id();
+$is_western_name_order = api_is_western_name_order();
 if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
-	$sql = 'SELECT DISTINCT u.user_id as id,concat(u.firstname," ",u.lastname," ","( ",u.email," )") as name 
+	$sql = 'SELECT DISTINCT u.user_id as id, '.($is_western_name_order ? 'concat(u.firstname," ",u.lastname," ","( ",u.email," )")' : 'concat(u.lastname," ",u.firstname," ","( ",u.email," )")').' as name 
 	FROM '.$tbl_my_user_friend.' uf ' .
  	'INNER JOIN '.$tbl_my_user.' AS u  ON uf.friend_user_id = u.user_id ' .
- 	'WHERE relation_type<>6 AND friend_user_id<>'.(int)$user_id.' AND concat(u.firstName,u.lastName) like CONCAT("%","'.$search.'","%") ';
+ 	'WHERE relation_type<>6 AND friend_user_id<>'.(int)$user_id.' AND '.($is_western_name_order ? 'concat(u.firstname, " ", u.lastname)' : 'concat(u.lastname, " ", u.firstname)').' like CONCAT("%","'.$search.'","%") ';
 } elseif (api_get_setting('allow_social_tool')=='false' && api_get_setting('allow_message_tool')=='true') {
 	$valid=api_get_setting('time_limit_whosonline');
-	$sql='SELECT DISTINCT u.user_id as id,concat(u.firstname," ",u.lastname," ","( ",u.email," )") as name
+	$sql='SELECT DISTINCT u.user_id as id, '.($is_western_name_order ? 'concat(u.firstname," ",u.lastname," ","( ",u.email," )")' : 'concat(u.lastname," ",u.firstname," ","( ",u.email," )")').' as name
 	 FROM '.$tbl_my_user.' u INNER JOIN '.$track_online_table.' t ON u.user_id=t.login_user_id 
-	 WHERE DATE_ADD(login_date,INTERVAL "'.$valid.'" MINUTE) >= "'.$current_date.'" AND concat(u.firstName,u.lastName) like CONCAT("%","'.$search.'","%") '; 	
+	 WHERE DATE_ADD(login_date,INTERVAL "'.$valid.'" MINUTE) >= "'.$current_date.'" AND '.($is_western_name_order ? 'concat(u.firstname, " ", u.lastname)' : 'concat(u.lastname, " ", u.firstname)').' like CONCAT("%","'.$search.'","%") '; 	
 }
 
 $res=Database::query($sql,__FILE__,__LINE__);

+ 1 - 1
main/social/show_search_image.inc.php

@@ -63,7 +63,7 @@ if (count($list_path_friends)!=0) {
 		while ($j<$number_of_images) {
 			if ($list_friends_file[$j]<>"") {
 				$user_info=api_get_user_info($list_friends_id[$j]);
-				$user_name=api_xml_http_response_encode($user_info['firstName'].' '.$user_info['lastName']) ;
+				$user_name=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName']));
 				$friends_profile = UserFriend::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92);
 				$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$list_friends_id[$j].'  >
 				<span><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$list_friends_id[$j].'" title="'.$user_name.'" onclick=load_thick(\'qualify_contact.inc.php?path_user="'.urlencode($list_friends_dir[$j].$list_friends_file[$j]).'&amp;id_user="'.$list_friends_id[$j].'"\',"") /></center></span>

+ 1 - 1
main/survey/create_new_survey.php

@@ -215,7 +215,7 @@ if ((isset($_GET['action']) && $_GET['action'] == 'edit') && !empty($survey_id)
 		// Aditional Parameters
 		$form -> addElement('html','<div class="row">
 		<div class="label">
-			<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus">&nbsp;'.Display::return_icon('div_show.gif',null,array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>
+			<a href="javascript: void(0);" onclick="javascript: advanced_parameters();" ><span id="plus_minus">&nbsp;'.Display::return_icon('div_show.gif',null,array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>
 		</div>
 		<div class="formw">
 			&nbsp;	

File diff suppressed because it is too large
+ 356 - 336
main/survey/fillsurvey.php


File diff suppressed because it is too large
+ 191 - 200
main/survey/survey.lib.php


+ 1 - 1
main/survey/survey_invitation.php

@@ -149,7 +149,7 @@ while ($row = mysql_fetch_assoc($res))
 		echo '<tr>';
 		if (is_numeric($row['user']))
 		{
-			echo '			<td><a href="../user/userInfo.php?editMainUserInfo='.$row['user'].'">'.$row['firstname'].' '.$row['lastname'].'</a></td>';
+			echo '			<td><a href="../user/userInfo.php?editMainUserInfo='.$row['user'].'">'.api_get_person_name($row['firstname'], $row['lastname']).'</a></td>';
 		}
 		else
 		{

+ 218 - 218
main/survey/survey_invite.php

@@ -1,219 +1,219 @@
-<?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 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
-==============================================================================
-*/
-
-/**
-*	@package dokeos.survey
-* 	@author unknown, the initial survey that did not make it in 1.8 because of bad code
-* 	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
-*   @author Julio Montoya Dokeos: cleanup, refactoring, security improvements
-* 	@version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
-*
-* 	@todo checking if the additional emails are valid (or add a rule for this)
-* 	@todo check if the mailtext contains the **link** part, if not, add the link to the end
-* 	@todo add rules: title and text cannot be empty
-*/
-
-// name of the language file that needs to be included
-$language_file = 'survey';
-
-// including the global dokeos file
-require ('../inc/global.inc.php');
-
-// including additional libraries
-//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
-require_once('survey.lib.php');
-require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php");
-
-if (!api_is_allowed_to_edit(false,true))
-{
-	Display :: display_header(get_lang('Survey'));
-	Display :: display_error_message(get_lang('NotAllowed'), false);
-	Display :: display_footer();
-	exit;
-}
-
-// Database table definitions
-$table_survey 			= Database::get_course_table(TABLE_SURVEY);
-$table_survey_question 		= Database::get_course_table(TABLE_SURVEY_QUESTION);
-$table_survey_question_option 	= Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
-$table_course 			= Database::get_main_table(TABLE_MAIN_COURSE);
-$table_user 			= Database::get_main_table(TABLE_MAIN_USER);
+<?php
+/*
+==============================================================================
+	Dokeos - elearning and course management software
+
+	Copyright (c) 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
+==============================================================================
+*/
+
+/**
+*	@package dokeos.survey
+* 	@author unknown, the initial survey that did not make it in 1.8 because of bad code
+* 	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
+*   @author Julio Montoya Dokeos: cleanup, refactoring, security improvements
+* 	@version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
+*
+* 	@todo checking if the additional emails are valid (or add a rule for this)
+* 	@todo check if the mailtext contains the **link** part, if not, add the link to the end
+* 	@todo add rules: title and text cannot be empty
+*/
+
+// name of the language file that needs to be included
+$language_file = 'survey';
+
+// including the global dokeos file
+require ('../inc/global.inc.php');
+
+// including additional libraries
+//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
+require_once('survey.lib.php');
+require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
+require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
+require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php");
+
+if (!api_is_allowed_to_edit(false,true))
+{
+	Display :: display_header(get_lang('Survey'));
+	Display :: display_error_message(get_lang('NotAllowed'), false);
+	Display :: display_footer();
+	exit;
+}
+
+// Database table definitions
+$table_survey 					= Database :: get_course_table(TABLE_SURVEY);
+$table_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
+$table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
+$table_course 					= Database :: get_main_table(TABLE_MAIN_COURSE);
+$table_user 					= Database :: get_main_table(TABLE_MAIN_USER);
 $user_info 			= Database::get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
-
-// getting the survey information
-$survey_id = Security::remove_XSS($_GET['survey_id']);
-$survey_data = survey_manager::get_survey($survey_id);
-if (empty($survey_data)) {
-	Display :: display_header(get_lang('Survey'));
-	Display :: display_error_message(get_lang('InvallidSurvey'), false);
-	Display :: display_footer();
-	exit;
-}
-
-
-$urlname =strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
-if (api_strlen(strip_tags($survey_data['title'])) > 40)
-{
-	$urlname .= '...';
-}
-
-// breadcrumbs
-$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
-if (api_is_course_admin()) {
-    $interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
-} else {
-    $interbreadcrumb[] = array ('url' => 'survey_invite.php?survey_id='.$survey_id, 'name' => $urlname);    
-}
-$tool_name = get_lang('SurveyPublication');
-
-// Displaying the header
-Display::display_header($tool_name,'Survey');
-
-// checking if there is another survey with this code.
-// If this is the case there will be a language choice
-$sql = "SELECT * FROM $table_survey WHERE code='".Database::escape_string($survey_data['code'])."'";
-$result = api_sql_query($sql, __FILE__, __LINE__);
-if (Database::num_rows($result) > 1)
-{
-	Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
-}
-
-// invited / answered message
-if ($survey_data['invited'] > 0)
-{
-	$message  = '<a href="survey_invitation.php?view=answered&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
-	$message .= get_lang('HaveAnswered').' ';
-	$message .= '<a href="survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['invited'].'</a> ';
-	$message .= get_lang('WereInvited');
-	Display::display_normal_message($message, false);
-}
-
-// building the form for publishing the survey
-$form = new FormValidator('publish_form','post', api_get_self().'?survey_id='.$survey_id);
-
-$form->addElement('header', '', $tool_name);
-
-// Course users
-$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], true, $_SESSION['id_session'], '', 'ORDER BY lastname');
-$possible_users = array ();
-foreach ($complete_user_list as $index => $user)
-{
-	$possible_users[$user['user_id']] = $user['lastname'].' '.$user['firstname'];
-}
-$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
-$users->setElementTemplate('
-{javascript}
-<table{class}>
-<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
-<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
-<tr>
-  <td valign="top">{unselected}</td>
-  <td align="center">{add}<br /><br />{remove}</td>
-  <td valign="top">{selected}</td>
-</tr>
-</table>
-');
-// additional users
-$form->addElement('textarea', 'additional_users', get_lang('AdditonalUsers'), array ('cols' => 50, 'rows' => 2));
-// additional users comment
-$form->addElement('static', null, null, get_lang('AdditonalUsersComment'));
-// the title of the mail
-$form->addElement('text', 'mail_title', get_lang('MailTitle'),array('size' => '80'));
-// the text of the mail
-$form->addElement('html_editor', 'mail_text', get_lang('MailText'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
-// some explanation of the mail
-$form->addElement('static', null, null, get_lang('UseLinkSyntax'));
-$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
-// you cab send a reminder to unanswered people if the survey is not anonymous
-if ($survey_data['anonymous'] != 1) {
-    $form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered'));
-}
-// allow resending to all selected users
-$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
-// submit button
-$form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"');
-// The rules (required fields)
-$form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required');
-
-$portal_url = $_configuration['root_web'];
-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);
-		$portal_url = $url['url'];
-	}
-}	
-		  
-// show the URL that can be used by users to fill a survey without invitation
-$auto_survey_link = $portal_url.$_configuration['code_append'].
-            'survey/'.'fillsurvey.php?course='.$_course['sysCode'].
-            '&invitationcode=auto&scode='.$survey_data['survey_code'];
-$form->addElement('static',null, null, '<br \><br \>' . get_lang('AutoInviteLink'));
-$form->addElement('static',null, null, $auto_survey_link);
-if ($form->validate())
-{
-	$values = $form->exportValues();
-	// save the invitation mail
-	SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
-	// saving the invitations for the course users
-	$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], 
-                $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
-	// saving the invitations for the additional users
-	$values['additional_users'] = $values['additional_users'].';'; 	// this is for the case when you enter only one email
-	$temp = str_replace(',',';',$values['additional_users']);		// this is to allow , and ; as email separators
-	$additional_users = explode(';',$temp);
-	for($i=0; $i<count($additional_users); $i++)
-	{
-		$additional_users[$i] = trim($additional_users[$i]);
-	}
-	$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], 
-            $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
-	// updating the invited field in the survey table
-	SurveyUtil::update_count_invited($survey_data['code']);
-	$total_count = $count_course_users + $counter_additional_users;
-	Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
-}
-else
-{
-	// getting the invited users
-	$defaults = SurveyUtil::get_invited_users($survey_data['code']);
-	// getting the survey mail text
-	if (!empty($survey_data['reminder_mail']))
-	{
-		$defaults['mail_text'] = $survey_data['reminder_mail'];
-	}
-	else
-	{
-		$defaults['mail_text'] = $survey_data['invite_mail'];
-	}
-	$defaults['mail_title'] = $survey_data['mail_subject'];
-	$defaults['send_mail'] = 1;
-	$form->setDefaults($defaults);
-	$form->display();
-}
-
-// Footer
-Display :: display_footer();
-?>
+
+// getting the survey information
+$survey_id = Security::remove_XSS($_GET['survey_id']);
+$survey_data = survey_manager::get_survey($survey_id);
+if (empty($survey_data)) {
+	Display :: display_header(get_lang('Survey'));
+	Display :: display_error_message(get_lang('InvallidSurvey'), false);
+	Display :: display_footer();
+	exit;
+}
+
+
+$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
+if (api_strlen(strip_tags($survey_data['title'])) > 40)
+{
+	$urlname .= '...';
+}
+
+// breadcrumbs
+$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
+if (api_is_course_admin()) {
+    $interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
+} else {
+    $interbreadcrumb[] = array ('url' => 'survey_invite.php?survey_id='.$survey_id, 'name' => $urlname);    
+}
+$tool_name = get_lang('SurveyPublication');
+
+// Displaying the header
+Display::display_header($tool_name,'Survey');
+
+// checking if there is another survey with this code.
+// If this is the case there will be a language choice
+$sql = "SELECT * FROM $table_survey WHERE code='".Database::escape_string($survey_data['code'])."'";
+$result = api_sql_query($sql, __FILE__, __LINE__);
+if (Database::num_rows($result) > 1)
+{
+	Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
+}
+
+// invited / answered message
+if ($survey_data['invited'] > 0)
+{
+	$message  = '<a href="survey_invitation.php?view=answered&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
+	$message .= get_lang('HaveAnswered').' ';
+	$message .= '<a href="survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['invited'].'</a> ';
+	$message .= get_lang('WereInvited');
+	Display::display_normal_message($message, false);
+}
+
+// building the form for publishing the survey
+$form = new FormValidator('publish_form','post', api_get_self().'?survey_id='.$survey_id);
+
+$form->addElement('header', '', $tool_name);
+
+// Course users
+$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], true, $_SESSION['id_session'], '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
+$possible_users = array ();
+foreach ($complete_user_list as $index => $user)
+{
+	$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
+}
+$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
+$users->setElementTemplate('
+{javascript}
+<table{class}>
+<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
+<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
+<tr>
+  <td valign="top">{unselected}</td>
+  <td align="center">{add}<br /><br />{remove}</td>
+  <td valign="top">{selected}</td>
+</tr>
+</table>
+');
+// additional users
+$form->addElement('textarea', 'additional_users', get_lang('AdditonalUsers'), array ('cols' => 50, 'rows' => 2));
+// additional users comment
+$form->addElement('static', null, null, get_lang('AdditonalUsersComment'));
+// the title of the mail
+$form->addElement('text', 'mail_title', get_lang('MailTitle'),array('size' => '80'));
+// the text of the mail
+$form->addElement('html_editor', 'mail_text', get_lang('MailText'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
+// some explanation of the mail
+$form->addElement('static', null, null, get_lang('UseLinkSyntax'));
+$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
+// you cab send a reminder to unanswered people if the survey is not anonymous
+if ($survey_data['anonymous'] != 1) {
+    $form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered'));
+}
+// allow resending to all selected users
+$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
+// submit button
+$form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"');
+// The rules (required fields)
+$form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required');
+$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required');
+
+$portal_url = $_configuration['root_web'];
+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);
+		$portal_url = $url['url'];
+	}
+}	
+		  
+// show the URL that can be used by users to fill a survey without invitation
+$auto_survey_link = $portal_url.$_configuration['code_append'].
+            'survey/'.'fillsurvey.php?course='.$_course['sysCode'].
+            '&invitationcode=auto&scode='.$survey_data['survey_code'];
+$form->addElement('static',null, null, '<br \><br \>' . get_lang('AutoInviteLink'));
+$form->addElement('static',null, null, $auto_survey_link);
+if ($form->validate())
+{
+	$values = $form->exportValues();
+	// save the invitation mail
+	SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
+	// saving the invitations for the course users
+	$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], 
+                $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
+	// saving the invitations for the additional users
+	$values['additional_users'] = $values['additional_users'].';'; 	// this is for the case when you enter only one email
+	$temp = str_replace(',',';',$values['additional_users']);		// this is to allow , and ; as email separators
+	$additional_users = explode(';',$temp);
+	for($i=0; $i<count($additional_users); $i++)
+	{
+		$additional_users[$i] = trim($additional_users[$i]);
+	}
+	$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], 
+            $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
+	// updating the invited field in the survey table
+	SurveyUtil::update_count_invited($survey_data['code']);
+	$total_count = $count_course_users + $counter_additional_users;
+	Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
+}
+else
+{
+	// getting the invited users
+	$defaults = SurveyUtil::get_invited_users($survey_data['code']);
+	// getting the survey mail text
+	if (!empty($survey_data['reminder_mail']))
+	{
+		$defaults['mail_text'] = $survey_data['reminder_mail'];
+	}
+	else
+	{
+		$defaults['mail_text'] = $survey_data['invite_mail'];
+	}
+	$defaults['mail_title'] = $survey_data['mail_subject'];
+	$defaults['send_mail'] = 1;
+	$form->setDefaults($defaults);
+	$form->display();
+}
+
+// Footer
+Display :: display_footer();
+?>

+ 4 - 4
whoisonline.php

@@ -33,7 +33,7 @@ $htmlHeadXtra[] = '<link rel="stylesheet" href="./main/inc/lib/javascript/thickb
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready(function (){
 	$("input#id_btn_send_invitation").bind("click", function(){
-		if (confirm("'.get_lang('SendMessageInvitation').'")) {
+		if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
 			$("#form_register_friend").submit();
 		}
 	}); 
@@ -42,7 +42,7 @@ function change_panel (mypanel_id,myuser_id) {
 		$.ajax({
 			contentType: "application/x-www-form-urlencoded",
 			beforeSend: function(objeto) {
-			$("#id_content_panel").html("'.get_lang('Loading').'"); },
+			$("#id_content_panel").html("'.get_lang('Loading', '').'"); },
 			type: "POST",
 			url: "main/messages/send_message.php",
 			data: "panel_id="+mypanel_id+"&user_id="+myuser_id,
@@ -61,14 +61,14 @@ function action_database_panel(option_id,myuser_id) {
 	}
 	my_txt_content=$("#txt_area_invite").val();
 	if (my_txt_content.length==0 || my_txt_subject.length==0) {
-		$("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageEmptyMessageOrSubject').'");
+		$("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageEmptyMessageOrSubject', '').'");
 		setTimeout("message_information_display()",3000);
 		return false;
 	}
 	$.ajax({
 		contentType: "application/x-www-form-urlencoded",
 		beforeSend: function(objeto) {
-		$("#display_response_id").html("'.get_lang('Loading').'"); },
+		$("#display_response_id").html("'.get_lang('Loading', '').'"); },
 		type: "POST",
 		url: "main/messages/send_message.php",
 		data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,

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