Browse Source

Feature #272 - Various corrections about mailing functionality.

Ivan Tcholakov 15 years ago
parent
commit
d8f4aa15f6

+ 1 - 1
main/announcements/announcements.inc.php

@@ -993,7 +993,7 @@ function send_announcement_email($user_list, $course_code, $_course, $mail_title
 		$mail_body .= '<'.$_user['mail'].">\n";
 		$mail_body .= $_course['official_code'].' '.$_course['name'];
 
-		api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
+		@api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
 	}
 }
 

+ 3 - 3
main/announcements/announcements.php

@@ -591,7 +591,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 							$headers="From:$sender_name\r\nReply-to: $email";
 							//@mail($to,$subject,$message,$headers);
 							//api_send_mail($to,$subject,$message,$headers);
-							api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
+							@api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
 							$sql_date="SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
 							$res_date=Database::query($sql_date, __FILE__, __LINE__);
 							$obj_date=Database::fetch_object($res_date);
@@ -705,7 +705,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 							    $email = $_SESSION['_user']['mail'];
 								$headers="From:$sender_name\r\nReply-to: $email";
 								//@mail($myrow["email"],stripslashes($emailTitle),$message,$headers);
-								api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
+								@api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
 	                        } else {
 	                            // intro of the email: receiver name and subject
 								$mail_body = api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS)."<br />\n".stripslashes($emailTitle)."<br />";
@@ -740,7 +740,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 													   'filename' => $row['filename']);
 								}
 
-								api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
+								@api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
 	                        }
 
 							$sql_date="SELECT * FROM $db_name WHERE survey_id='$surveyid'";

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

@@ -337,10 +337,10 @@ function get_dropbox_categories($filter='')
 	global $dropbox_cnf;
 
 	$return_array=array();
-	
+
 	$session_id = api_get_session_id();
 	$condition_session = api_get_session_condition($session_id);
-		
+
 	$sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE user_id='".$_user['user_id']."' $condition_session";
 
 	$result=Database::query($sql,__FILE__,__LINE__);
@@ -603,9 +603,9 @@ function display_add_form()
 		{
 			$complete_user_list_for_dropbox = CourseManager :: get_teacher_list_from_course_code($course_info['code']);
 		}
-	}    
+	}
+
 
-	
 
 	foreach ($complete_user_list_for_dropbox as $k => $e) {
 	    $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
@@ -1047,7 +1047,7 @@ function store_add_dropbox()
 		{
 			include_once(api_get_path(LIBRARY_PATH) . 'usermanager.lib.php');
 			$recipent_temp=UserManager :: get_user_info_by_id($recipient_id);
-			api_mail(api_get_person_name($recipent_temp['firstname'].' '.$recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'],
+			@api_mail(api_get_person_name($recipent_temp['firstname'].' '.$recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'],
 				get_lang('NewDropboxFileUploaded'),
 				get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)."\n".  get_lang('Email') ." : ".$_user['mail'], api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_user['mail']);
 				//get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName')." ".api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator'));
@@ -1156,7 +1156,7 @@ function feedback_form()
 	{
 		$token = Security::get_token();
 		$return .= '<textarea name="feedback" style="width: 80%; height: 80px;"></textarea>';
-		$return .= '<input type="hidden" name="sec_token" value="'.$token.'"/>';		
+		$return .= '<input type="hidden" name="sec_token" value="'.$token.'"/>';
 		$return .= '<br /><button type="submit" class="add" name="store_feedback" value="'.get_lang('Ok').'"
 					onclick="document.form_tablename.attributes.action.value = document.location;">'.get_lang('AddComment').'</button>';
 	}

+ 11 - 11
main/exercice/exercice.php

@@ -336,7 +336,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
 	$headers = "From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=" . ($charset ? $charset : 'ISO-8859-15');
 	//mail($emailid, $subject, $mess,$headers);
 
-	api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
+	@api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
 	if (in_array($origin, array (
 			'tracking_course',
 			'user_course'
@@ -532,7 +532,7 @@ if ($is_allowedToEdit) {
 					$sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="1" AND gl.ref_id="' . $exerciseId . '";';
 					$result = Database::query($sql, __FILE__, __LINE__);
 					$row = Database :: fetch_array($result, 'ASSOC');
-					//see 
+					//see
 					if (!empty($row['id'])) {
                  		$link = LinkFactory :: load($row['id']);
                      		if ($link[0] != null) {
@@ -860,7 +860,7 @@ if ($show == 'test') {
 		while ($row = Database :: fetch_array($result)) {
 			//validacion when belongs to a session
 			$session_img = api_get_session_image($row['session_id'], $_user['status']);
-			
+
 			if ($i % 2 == 0)
 				$s_class = "row_odd";
 			else
@@ -1132,7 +1132,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 		  <th><?php echo (($is_allowedToEdit||$is_tutor)?get_lang("CorrectTest"):get_lang("ViewTest")); ?></th>
 		 </tr>-->
 		<?php
-	
+
 	$session_id_and = ' AND ce.session_id = ' . api_get_session_id() . ' ';
 	if ($is_allowedToEdit || $is_tutor) {
 		$user_id_and = '';
@@ -1296,7 +1296,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 						//echo "<a href='exercise_show.php?action=edit&user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".Display :: return_icon('edit.gif', get_lang('Edit'));
 						//echo '&nbsp;';
 						$html_link.= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".Display :: return_icon('edit.gif', get_lang('Edit'));
-						$html_link.= '&nbsp;';						
+						$html_link.= '&nbsp;';
 					} else {
 						//echo "<a href='exercise_show.php?action=qualify&user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".Display :: return_icon('quizz_small.gif', get_lang('Qualify'));
 						//echo '&nbsp;';
@@ -1309,13 +1309,13 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 						//echo ' <a href="exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.gif', get_lang('Delete')).'</a>';
 						//echo '&nbsp;';
 						$html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.gif', get_lang('Delete')).'</a>';
-						$html_link.='&nbsp;';	
-					}					
+						$html_link.='&nbsp;';
+					}
 					if ($is_allowedToEdit) {
 						//echo ' <a href="exercice_history.php?cidReq=' . security::remove_XSS($_GET['cidReq']) . '&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
 						if ($filter==2){
 							$html_link.=' <a href="exercice_history.php?'.api_get_cidreq().'&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
-						}				
+						}
 					}
 				} else {
 					if ($revised) {
@@ -1324,7 +1324,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 
 					} else {
 					//	echo '&nbsp;' . get_lang('NoResult');
-						$html_link.='&nbsp;' . get_lang('NoResult');												
+						$html_link.='&nbsp;' . get_lang('NoResult');
 					}
 
 				}
@@ -1332,7 +1332,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 				if ($is_allowedToEdit || $is_tutor) {
 					$list_info [] = array($user_list_name,$quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);
 				} else {
-					$list_info [] = array($quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);					
+					$list_info [] = array($quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);
 				}
 				//$list_info [] = array($user_list_name,$quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);
 				//echo '</td>';
@@ -1351,7 +1351,7 @@ $table = new SortableTableFromArrayConfig($list_info, 1,20,'quiz_table');
 $table->set_additional_parameters($parameters);
 if ($is_allowedToEdit || $is_tutor) {
 	$table->set_header(0, get_lang('User'));
-	$secuence = 0;	
+	$secuence = 0;
 } else {
 	$secuence = 1;
 }

+ 60 - 60
main/exercice/exercise_result.php

@@ -351,8 +351,8 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
 		?>
 	</td>
 	<?php } else { ?>
-		<td>&nbsp;</td>	
-	<?php } ?>	
+		<td>&nbsp;</td>
+	<?php } ?>
 	</tr>
 	<?php
 }
@@ -376,13 +376,13 @@ function display_free_answer($answer)
 		<td width="55%">
 			<?php echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)); ?>
 		</td>
-	<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>	
+	<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
    <td width="45%">
     <?php echo get_lang('notCorrectedYet');?>
 
    </td>
    <?php } else { ?>
-		<td>&nbsp;</td>	
+		<td>&nbsp;</td>
 	<?php } ?>
 		</tr>
 	<?php
@@ -434,7 +434,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 					?>
 				</td>
 				<?php } else { ?>
-					<td>&nbsp;</td>	
+					<td>&nbsp;</td>
 				<?php } ?>
 		</tr>
 	<?php
@@ -473,9 +473,9 @@ if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionL
 
 if ($_configuration['tracking_enabled']) {
 	// Create an empty exercise
-	if (api_is_allowed_to_session_edit() )  
+	if (api_is_allowed_to_session_edit() )
 		$exeId= create_event_exercice($objExercise->selectId());
-}	 
+}
 $counter=0;
 
 // Loop over all question to show results for each of them, one by one
@@ -537,7 +537,7 @@ foreach ($questionList as $questionId) {
 					<i><?php echo get_lang("Comment"); ?></i>
 				</td>
 				<?php } else { ?>
-					<td>&nbsp;</td>	
+					<td>&nbsp;</td>
 				<?php } ?>
 				</tr>
 			<?php
@@ -560,7 +560,7 @@ foreach ($questionList as $questionId) {
 					<i><?php echo get_lang("Comment"); ?></i>
 				</td>
 				<?php } else { ?>
-					<td>&nbsp;</td>	
+					<td>&nbsp;</td>
 				<?php } ?>
 				</tr>
 			<?php
@@ -582,7 +582,7 @@ foreach ($questionList as $questionId) {
 									<i><?php echo get_lang("Comment"); ?></i><br /><br />
 								</td>
 								<?php } else { ?>
-									<td>&nbsp;</td>	
+									<td>&nbsp;</td>
 								<?php } ?>
 							</tr>
 			<?php
@@ -611,13 +611,13 @@ foreach ($questionList as $questionId) {
 
 	// get answer list for matching
 	$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.Database::escape_string($questionId).'" ';
-	$res_answer = Database::query($sql_answer, __FILE__, __LINE__);	
+	$res_answer = Database::query($sql_answer, __FILE__, __LINE__);
 	$answer_matching =array();
 	while ($real_answer = Database::fetch_array($res_answer)) {
 		$answer_matching[$real_answer['id']]= $real_answer['answer'];
 	}
 	$real_answers = array();
-	
+
 	// We're inside *one* question. Go through each possible answer for this question
 	for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
 
@@ -627,7 +627,7 @@ foreach ($questionList as $questionId) {
 		$answerCorrect=$objAnswerTmp->isCorrect($answerId);
 		$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
 		$numAnswer=$objAnswerTmp->selectAutoId($answerId);
-		
+
 		switch ($answerType) {
 			// for unique answer
 			case UNIQUE_ANSWER :
@@ -650,8 +650,8 @@ foreach ($questionList as $questionId) {
 				}
 				break;
 			case MULTIPLE_ANSWER_COMBINATION :
-				$studentChoice=$choice[$numAnswer];			
-			
+				$studentChoice=$choice[$numAnswer];
+
 				if ($answerCorrect == 1) {
 					if ($studentChoice) {
 						$real_answers[$answerId] = true;
@@ -664,7 +664,7 @@ foreach ($questionList as $questionId) {
 					} else {
 						$real_answers[$answerId] = true;
 					}
-				}			
+				}
 				break;
 			// for fill in the blanks
 			case FILL_IN_BLANKS :
@@ -827,10 +827,10 @@ foreach ($questionList as $questionId) {
 						$totalScore+=0;
 					}
 					break;
-			// for matching 
+			// for matching
 			case MATCHING :
-					if ($answerCorrect) {																			
-						if ($answerCorrect == $choice[$numAnswer]) {																		
+					if ($answerCorrect) {
+						if ($answerCorrect == $choice[$numAnswer]) {
 							$questionScore+=$answerWeighting;
 							$totalScore+=$answerWeighting;
 							$user_answer = '<span>'.$answer_matching[$choice[$numAnswer]].'</span>';
@@ -881,8 +881,8 @@ foreach ($questionList as $questionId) {
 
 				$arrques[] = $questionName;
 				$arrans[]  = $choice;
-				
-			
+
+
 				if($origin != 'learnpath') {
 					display_free_answer($choice);
 				}
@@ -903,27 +903,27 @@ foreach ($questionList as $questionId) {
 				if ($origin != 'learnpath') {
 					echo '<tr>';
 					echo '<td>'.api_parse_tex($answer_matching[$answerId]).'</td><td>'.api_parse_tex($user_answer).' / <b><span style="color: #008000;">'.api_parse_tex($answer_matching[$answerCorrect]).'</span></b></td>';
-					echo '</tr>';					
+					echo '</tr>';
 				}
 			}
 		}
 	} // end for that loops over all answers of the current question
-	
+
 	//
 	if ($answerType == MULTIPLE_ANSWER_COMBINATION) {
 		$final_answer = true;
 	 	foreach($real_answers as $my_answer) {
 	 		if (!$my_answer) {
 	 			$final_answer = false;
-	 		}		 		
-	 	}		 	
+	 		}
+	 	}
 	 	if ($final_answer) {
-	 		//getting only the first score where we save the weight of all the question 
+	 		//getting only the first score where we save the weight of all the question
 	 		$answerWeighting=$objAnswerTmp->selectWeighting(1);
 			$questionScore+=$answerWeighting;
 			$totalScore+=$answerWeighting;
-		}		
-	}		
+		}
+	}
 
 	// if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0)
 	// TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet
@@ -990,10 +990,10 @@ foreach ($questionList as $questionId) {
 					exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
 				}
 			} else {
-				exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);		
-			} 
-		} elseif ($answerType==MATCHING) {		
-			foreach ($matching as $j => $val) {							
+				exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
+			}
+		} elseif ($answerType==MATCHING) {
+			foreach ($matching as $j => $val) {
 				exercise_attempt($questionScore, $val, $quesId, $exeId, $j);
 			}
 		}
@@ -1006,7 +1006,7 @@ foreach ($questionList as $questionId) {
 			// In fact, we are not storing the results by answer ID, but by *position*, which is stored in $choice
 			exercise_attempt($questionScore,$choice,$quesId,$exeId,0);
 		} elseif ($answerType == HOT_SPOT) {
-			exercise_attempt($questionScore, $answer, $quesId, $exeId, 0);							
+			exercise_attempt($questionScore, $answer, $quesId, $exeId, 0);
 			if (is_array($exerciseResultCoordinates[$quesId])) {
 				foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
 					exercise_attempt_hotspot($exeId,$quesId,$idx,$choice[$idx],$val);
@@ -1065,7 +1065,7 @@ if ($_configuration['tracking_enabled']) {
 	$safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id;
 	$safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id;
 	$quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
-	if (api_is_allowed_to_session_edit() ) { 
+	if (api_is_allowed_to_session_edit() ) {
 		update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$quizDuration);
 	}
 }
@@ -1089,17 +1089,17 @@ if ($origin != 'learnpath') {
 }
 
 
-	
+
 // Email configuration settings
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
-$user_info	= UserManager::get_user_info_by_id(api_get_user_id());	
+$user_info	= UserManager::get_user_info_by_id(api_get_user_id());
 
 $firstName 	=  $user_info['firstname'];
 $lastName 	=  $user_info['lastname'];
-$mail 		=  $user_info['email'];	
+$mail 		=  $user_info['email'];
 $coursecode = api_get_course_id();
 $courseName = $_SESSION['_course']['name'];
-	
+
 $to = '';
 $teachers = array();
 if(api_get_setting('use_session_mode')=='true' && !empty($_SESSION['id_session'])) {
@@ -1124,16 +1124,16 @@ if($num>1) {
 
 
 // we are able to send emails to the teachers?
-if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) { 
-	// only for "simple tests" 
+if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
+	// only for "simple tests"
 	if ($origin != 'learnpath') {
 		//has a unique answer?
-		$mycharset = api_get_setting('platform_charset');
+		$mycharset = api_get_system_encoding();
 		$msg = '<html><head>
 			<link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type="text/css">
 			<meta content="text/html; charset='.$mycharset.'" http-equiv="content-type"></head>';
-			
-		if(count($arrques)>0) {		
+
+		if(count($arrques)>0) {
 			$msg .= '
 			<body><br />
 			<p>'.get_lang('OpenQuestionsAttempted').' :
@@ -1159,7 +1159,7 @@ if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
 			</tr></table>
 			<p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>
 			 <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
-			 
+
 			for($i=0;$i<sizeof($arrques);$i++) {
 				  $msg.='
 					<tr>
@@ -1179,22 +1179,22 @@ if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
 					$msg1= str_replace("#i#",$i,$msg);
 					$msg= str_replace("#course#",$courseName,$msg1);
 			}
-			
+
 			$msg.='</table><br>
 		 			<span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
 					<a href="#url#">#url#</a></span></body></html>';
-		
+
 			$msg1= str_replace("#url#",$url,$msg);
 			$mail_content = $msg1;
-			
+
 			$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 			$email_admin = api_get_setting('emailAdministrator');
-					
-			$subject = get_lang('OpenQuestionsAttempted');	
-			$result = api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));		
+
+			$subject = get_lang('OpenQuestionsAttempted');
+			$result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
 		} else {
 			$msg .= '<body>
-			<p>'.get_lang('ExerciseAttempted').' <br /> 
+			<p>'.get_lang('ExerciseAttempted').' <br />
 	    	</p>
 			<table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
 				<tr>
@@ -1213,25 +1213,25 @@ if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
 			    <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
 			    <td valign="top"> #mail#</td>
 			</tr></table>';
-			 
+
 			$msg= str_replace("#exercise#",$exerciseTitle,$msg);
 			$msg= str_replace("#firstName#",$firstName,$msg);
-			$msg= str_replace("#lastName#",$lastName,$msg);	
+			$msg= str_replace("#lastName#",$lastName,$msg);
 			$msg= str_replace("#mail#",$mail,$msg);
-			$msg= str_replace("#course#",$courseName,$msg);	
-			
+			$msg= str_replace("#course#",$courseName,$msg);
+
 			$msg.='<br />
 		 			<span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
-					<a href="#url#">#url#</a></span></body></html>';		
-		
+					<a href="#url#">#url#</a></span></body></html>';
+
 			$msg= str_replace("#url#",$url,$msg);
 			$mail_content = $msg;
-			
+
 			$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 			$email_admin = api_get_setting('emailAdministrator');
-			
+
 			$subject = get_lang('ExerciseAttempted');
-			$result = api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
+			$result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
 		}
 	}
 }

+ 76 - 76
main/exercice/exercise_show.php

@@ -22,7 +22,7 @@ require_once 'exercise.class.php';
 require_once 'question.class.php'; //also defines answer type constants
 require_once 'answer.class.php';
 require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');	
+require_once(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
 
 if ( empty ( $origin ) ) {
     $origin = $_REQUEST['origin'];
@@ -104,7 +104,7 @@ if (isset($_SESSION['expired_time'])) { //Only for exercice of type "One page"
 	if ($total_time_allowed < $current_time) {
 	  $sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = '$current_attempt' ";
 	  Database::query($sql_fraud,__FILE__,__LINE__);
-	}	
+	}
 }
 //Unset session for clock time
 unset($_SESSION['current_exercice_attempt'][$current_user_id]);
@@ -267,7 +267,7 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
 		echo $answer;
 		?>
 	</td>
-	
+
 	<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
 	<td width="20%" style="border-bottom: 1px solid #4171B5;">
 		<?php
@@ -289,13 +289,13 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
 		?>
 	</td>
 		<?php
-	    if ($ans==1) {	    	
+	    if ($ans==1) {
 	        $comm = get_comments($id,$questionId);
 		}
 	    ?>
 	 <?php } else { ?>
-		<td>&nbsp;</td>	
-	<?php } ?>	
+		<td>&nbsp;</td>
+	<?php } ?>
 	</tr>
 	<?php
 }
@@ -314,7 +314,7 @@ function display_fill_in_blanks_answer($answer,$id,$questionId)
 		<td>
 			<?php echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)); ?>
 		</td>
-		
+
 		<?php
 		if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {?>
 			<td>
@@ -322,7 +322,7 @@ function display_fill_in_blanks_answer($answer,$id,$questionId)
 			$comm = get_comments($id,$questionId);
 			?>
 			</td>
-		<?php } ?>	
+		<?php } ?>
 
 			</tr>
 	<?php
@@ -340,8 +340,8 @@ function display_free_answer($answer,$id,$questionId) {
 		<tr>
 		<td>
 			<?php if (!empty($answer)) {echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY));} ?>
-		</td> 
-		
+		</td>
+
 		<?php if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {?>
         <td>
         <?php
@@ -349,8 +349,8 @@ function display_free_answer($answer,$id,$questionId) {
         ?>
         </td>
     	<?php }?>
-    
-    
+
+
     </tr>
     <?php
 }
@@ -407,9 +407,9 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 			?>
 		</td>
 		<?php } else { ?>
-			<td>&nbsp;</td>	
+			<td>&nbsp;</td>
 		<?php } ?>
-		
+
 	</tr>
 	<?php
 }
@@ -424,7 +424,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 
 $coursecode = api_get_course_id();
 $courseName = $_SESSION['_course']['name'];
-	
+
 $to = '';
 $teachers = array();
 if(api_get_setting('use_session_mode')=='true' && !empty($_SESSION['id_session'])) {
@@ -609,8 +609,8 @@ if ($show_results) {
 				<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
 				<td><i><?php echo get_lang("Comment"); ?></i></td>
 				<?php } else { ?>
-				<td>&nbsp;</td>	
-				<?php } ?>	
+				<td>&nbsp;</td>
+				<?php } ?>
 			</tr>
 			<tr>
 			<td>&nbsp;</td>
@@ -633,9 +633,9 @@ if ($show_results) {
 				}
 
 				$numAnswer=$objAnswerTmp->selectAutoId($answerId);
-								
-				$studentChoice=$choice[$numAnswer];				
-				
+
+				$studentChoice=$choice[$numAnswer];
+
 				if ($studentChoice) {
 					$questionScore+=$answerWeighting;
 					$totalScore+=$answerWeighting;
@@ -671,9 +671,9 @@ if ($show_results) {
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
-			
+
 			$real_answers = array();
-			
+
 			for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
 				$answer=$objAnswerTmp->selectAnswer($answerId);
 				$answerComment=$objAnswerTmp->selectComment($answerId);
@@ -685,9 +685,9 @@ if ($show_results) {
 					$ind = $row['answer'];
 					$choice[$ind] = 1;
 				}
-				$numAnswer=$objAnswerTmp->selectAutoId($answerId);								
-				$studentChoice=$choice[$numAnswer];	
-					
+				$numAnswer=$objAnswerTmp->selectAutoId($answerId);
+				$studentChoice=$choice[$numAnswer];
+
 				if ($answerCorrect == 1) {
 					if ($studentChoice) {
 						$real_answers[$answerId] = true;
@@ -701,7 +701,7 @@ if ($show_results) {
 						$real_answers[$answerId] = true;
 					}
 				}
-							
+
 				echo '<tr><td>';
 				if ($answerId==1) {
 						display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
@@ -711,21 +711,21 @@ if ($show_results) {
 				echo '</td></tr>';
 				$i++;
 		 	}
-		 			 	
+
 		 	$final_answer = true;
 		 	foreach($real_answers as $my_answer) {
 		 		if (!$my_answer) {
 		 			$final_answer = false;
-		 		}		 		
+		 		}
 		 	}
-		 			 	
+
 		 	if ($final_answer) {
-		 		//getting only the first score where we save the weight of all the question 
+		 		//getting only the first score where we save the weight of all the question
 		 		$answerWeighting=$objAnswerTmp->selectWeighting(1);
 				$questionScore+=$answerWeighting;
 				$totalScore+=$answerWeighting;
 			}
-		 	
+
 		 	echo '</table>';
 		} elseif ($answerType == UNIQUE_ANSWER) {
 			?>
@@ -740,8 +740,8 @@ if ($show_results) {
 					<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
 					<td><i><?php echo get_lang("Comment"); ?></i></td>
 					<?php } else { ?>
-					<td>&nbsp;</td>	
-					<?php } ?>	
+					<td>&nbsp;</td>
+					<?php } ?>
 				</tr>
 				<tr>
 				<td>&nbsp;</td>
@@ -760,7 +760,7 @@ if ($show_results) {
 				$choice = Database::result($resultans,0,"answer");
 
 				$numAnswer=$objAnswerTmp->selectAutoId($answerId);
-								
+
 				$studentChoice=($choice == $numAnswer)?1:0;
 				if ($studentChoice) {
 				  	$questionScore+=$answerWeighting;
@@ -968,10 +968,10 @@ if ($show_results) {
 			} else {
 				$totalScore+=$questionScore;
 			}
-			
+
 			$arrques[] = $questionName;
             $arrans[]  = $choice;
-			
+
 			echo '<tr>
 			<td valign="top">'.display_free_answer($choice, $id, $questionId).'</td>
 			</tr>
@@ -1004,31 +1004,31 @@ if ($show_results) {
 			$questionScore=0;
 
 			while ($a_answers = Database::fetch_array($res_answers)) {
-				
+
 				$i_answer_id = $a_answers['id']; //3
 				$s_answer_label = $a_answers['answer'];  // your dady - you mother
 				$i_answer_correct_answer = $a_answers['correct']; //1 - 2
 				$i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
-				
-				$sql_user_answer = "SELECT answer 
-									FROM $TBL_TRACK_ATTEMPT 
+
+				$sql_user_answer = "SELECT answer
+									FROM $TBL_TRACK_ATTEMPT
 									WHERE exe_id = '$id' AND question_id = '$questionId' AND position='$i_answer_id_auto'";
-				$res_user_answer = Database::query($sql_user_answer, __FILE__, __LINE__);					
-				
+				$res_user_answer = Database::query($sql_user_answer, __FILE__, __LINE__);
+
 				if (Database::num_rows($res_user_answer)>0 ) {
 					$s_user_answer = Database::result($res_user_answer,0,0); //  rich - good looking
 				} else {
 					$s_user_answer = 0;
 				}
-				
+
 				$i_answerWeighting=$objAnswerTmp->selectWeighting($i_answer_id);
-				
+
 				$user_answer = '';
 				if (!empty($s_user_answer)) {
 					if ($s_user_answer == $i_answer_correct_answer)	{
 						$questionScore+=$i_answerWeighting;
 						$totalScore+=$i_answerWeighting;
-						$user_answer = '<span>'.$real_list[$i_answer_correct_answer].'</span>';											
+						$user_answer = '<span>'.$real_list[$i_answer_correct_answer].'</span>';
 					} else {
 						$user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$real_list[$s_user_answer].'</span>';
 					}
@@ -1166,15 +1166,15 @@ if ($show_results) {
 		</tr>
 		</table>
 
-		
+
 		<?php
 		$my_total_score  = float_format($questionScore,1);
 		$my_total_weight = float_format($questionWeighting,1);
-		
+
 		echo '<div id="question_score">';
-		echo get_lang('Score')." : $my_total_score/$my_total_weight";		
+		echo get_lang('Score')." : $my_total_score/$my_total_weight";
 		echo '</div>';
-	
+
 		unset($objAnswerTmp);
 		$i++;
 		$totalWeighting+=$questionWeighting;
@@ -1242,12 +1242,12 @@ if ($origin=='student_progress' && !isset($_GET['my_lp_id'])) {?>
 
 if ($origin != 'learnpath') {
 	$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&show=result';
-	
+
 	//we are not in learnpath tool
 	Display::display_footer();
 } else {
 	$url_email = api_get_path(WEB_CODE_PATH).'mySpace/lp_tracking.php?course='.api_get_course_id().'&origin=tracking_course&lp_id='.$learnpath_id.'&student_id='.api_get_user_id();
-	
+
 	if (!isset($_GET['fb_type'])) {
 		$lp_mode =  $_SESSION['lp_mode'];
 		$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
@@ -1260,9 +1260,9 @@ if ($origin != 'learnpath') {
 	} else {
 		if (!$is_allowedToEdit) {
 			send_notification($arrques, $arrans, $to);
-		}		
+		}
 		Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
-	}	
+	}
 }
 
 if (!$is_allowedToEdit) {
@@ -1282,18 +1282,18 @@ function send_notification($arrques, $arrans, $to) {
 	global $courseName, $exerciseTitle, $url_email;
     require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 	$user_info = UserManager::get_user_info_by_id(api_get_user_id());
-	
+
 	if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
 		return '';
 	}
-	
-	$mycharset = api_get_setting('platform_charset');
+
+	$mycharset = api_get_system_encoding();
     $msg = '<html><head>
             <link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type="text/css">
-            <meta content="text/html; charset='.$mycharset.'" http-equiv="content-type"></head>';	            
+            <meta content="text/html; charset='.$mycharset.'" http-equiv="content-type"></head>';
 	if(count($arrques)>0) {
 	    $msg .= '<body>
-	    <p>'.get_lang('OpenQuestionsAttempted').' : 
+	    <p>'.get_lang('OpenQuestionsAttempted').' :
 	    </p>
 	    <p>'.get_lang('AttemptDetails').' : <br />
 	    </p>
@@ -1316,7 +1316,7 @@ function send_notification($arrques, $arrans, $to) {
 	    </tr></table>
 	    <p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>
 	     <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
-	     
+
 	    for($i=0;$i<sizeof($arrques);$i++) {
 	              $msg.='
 	                    <tr>
@@ -1327,7 +1327,7 @@ function send_notification($arrques, $arrans, $to) {
 	                <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Answer').' </span></td>
 	                <td valign="top" bgcolor="#F3F3F3"><span class="style16"> #answer#</span></td>
 	                    </tr>';
-	
+
 	                    $msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	                    $msg= str_replace("#firstName#",$user_info['firstname'],$msg1);
 	                    $msg1= str_replace("#lastName#",$user_info['lastname'],$msg);
@@ -1340,20 +1340,20 @@ function send_notification($arrques, $arrans, $to) {
 	    $msg.='</table><br>
 	                    <span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
 	                    <a href="#url#">#url#</a></span></body></html>';
-	
+
 	    $msg1= str_replace("#url#",$url_email,$msg);
 	    $mail_content = $msg1;
-	
+
 	    $subject = get_lang('OpenQuestionsAttempted');
-	
-	
+
+
 	    $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 	    $email_admin = api_get_setting('emailAdministrator');
-	    $result = api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
+	    $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
 	} else {
-		
+
 		$msg .= '<body>
-		<p>'.get_lang('ExerciseAttempted').' <br /> 
+		<p>'.get_lang('ExerciseAttempted').' <br />
 	    </p>
 		<table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
 			<tr>
@@ -1372,24 +1372,24 @@ function send_notification($arrques, $arrans, $to) {
 		    <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
 		    <td valign="top"> #mail#</td>
 		</tr></table>';
-		 
+
 		$msg= str_replace("#exercise#",$exerciseTitle,$msg);
 		$msg= str_replace("#firstName#",$user_info['firstname'],$msg);
-		$msg= str_replace("#lastName#",$user_info['lastname'],$msg);	
+		$msg= str_replace("#lastName#",$user_info['lastname'],$msg);
 		$msg= str_replace("#mail#",$user_info['email'],$msg);
-		$msg= str_replace("#course#",$courseName,$msg);	
-		
+		$msg= str_replace("#course#",$courseName,$msg);
+
 		$msg.='<br />
 	 			<span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
-				<a href="#url#">#url#</a></span></body></html>';	
-	
+				<a href="#url#">#url#</a></span></body></html>';
+
 		$msg= str_replace("#url#",$url_email,$msg);
 		$mail_content = $msg;
-		
+
 		$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
 		$email_admin = api_get_setting('emailAdministrator');
-		
+
 		$subject = get_lang('ExerciseAttempted');
-		$result = api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
+		$result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
 	}
 }

+ 6 - 18
main/forum/forumfunction.inc.php

@@ -2958,19 +2958,13 @@ function send_mail($user_info=array(), $thread_information=array()) {
 		$thread_link= api_get_path('WEB_CODE_PATH').'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id'];
 	}
 	$email_body = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS)."\n\r";
-	$email_body .= '['.$_course['official_code'].'] - ['.$_course['name']."]<br>\n";
+	$email_body .= '['.$_course['official_code'].'] - ['.$_course['name']."]<br />\n";
 	$email_body .= get_lang('NewForumPost')."\n";
-	$email_body .= get_lang('YouWantedToStayInformed')."<br><br>\n";
+	$email_body .= get_lang('YouWantedToStayInformed')."<br /><br />\n";
 	$email_body .= get_lang('ThreadCanBeFoundHere')." : <a href=\"".$thread_link."\">".$thread_link."</a>\n";
 
-	//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
-	//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
-	if(empty($charset)) {
-		$charset='ISO-8859-1';
-	}
-
 	if ($user_info['user_id']<>$_user['user_id']) {
-		$newmail = api_mail_html(api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $user_info['email'], $email_subject, $email_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
+		@api_mail_html(api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $user_info['email'], $email_subject, $email_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
 	}
 }
 
@@ -3728,18 +3722,12 @@ function send_notifications($forum_id=0, $thread_id=0, $post_id=0) {
 		foreach ($users_to_be_notified as $key=>$value) {
 			if ($value['email'] <> $_user['email']) {
 				$email_body = api_get_person_name($value['firstname'], $value['lastname'], null, PERSON_NAME_EMAIL_ADDRESS)."\n\r";
-				$email_body .= '['.$_course['official_code'].'] - ['.$_course['name']."]<br>\n";
+				$email_body .= '['.$_course['official_code'].'] - ['.$_course['name']."]<br />\n";
 				$email_body .= get_lang('NewForumPost')."\n";
-				$email_body .= get_lang('YouWantedToStayInformed')."<br><br>\n";
+				$email_body .= get_lang('YouWantedToStayInformed')."<br /><br />\n";
 				$email_body .= get_lang('ThreadCanBeFoundHere')." : <a href=\"".$thread_link."\">".$thread_link."</a>\n";
 
-				//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
-				//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
-				if(empty($charset)) {
-					$charset='ISO-8859-1';
-				}
-
-				$newmail = api_mail_html(api_get_person_name($value['firstname'], $value['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $value['email'], $email_subject, $email_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
+				@api_mail_html(api_get_person_name($value['firstname'], $value['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $value['email'], $email_subject, $email_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
 			}
 		}
 	}

+ 1 - 1
main/inc/lib/add_course.lib.inc.php

@@ -2464,7 +2464,7 @@ function register_course($courseSysCode, $courseScreenCode, $courseRepository, $
 			$message .= get_lang('Tutor').' '.$titular."\n";
 			$message .= get_lang('Language').' '.$course_language;
 
-			api_mail($recipient_name, $recipient_email, $subject, $message,$siteName,$recipient_email);
+			@api_mail($recipient_name, $recipient_email, $subject, $message,$siteName,$recipient_email);
 		}
 
 	}

+ 1 - 1
main/inc/lib/system_announcements.lib.php

@@ -392,7 +392,7 @@ class SystemAnnouncementManager
 		$result = Database::query($sql,__FILE__,__LINE__);
 		while($row = Database::fetch_array($result,'ASSOC'))
 		{
-			api_mail_html(api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $row['email'], api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes($content), ENT_QUOTES, $charset), api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator'), api_get_setting('emailAdministrator'));
+			@api_mail_html(api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $row['email'], api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes($content), ENT_QUOTES, $charset), api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator'), api_get_setting('emailAdministrator'));
 		}
 	}
 }

+ 164 - 164
main/social/groups.php

@@ -19,12 +19,12 @@ api_block_anonymous_users();
 $this_section = SECTION_SOCIAL;
 
 $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/thickbox.js" type="text/javascript" language="javascript"></script>'; 
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
 $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
 
-// prepare anchor for message group topic 
+// prepare anchor for message group topic
 $anchor = '';
-if (isset($_GET['anchor_topic'])) {	
+if (isset($_GET['anchor_topic'])) {
 	$anchor = Security::remove_XSS($_GET['anchor_topic']);
 } else {
 	$match = 0;
@@ -39,27 +39,27 @@ if (isset($_GET['anchor_topic'])) {
 
 $htmlHeadXtra[] = '<script type="text/javascript">
 
-var counter_image = 1;	
+var counter_image = 1;
 function remove_image_form(id_elem1) {
 	var elem1 = document.getElementById(id_elem1);
 	elem1.parentNode.removeChild(elem1);
 	counter_image--;
-	var filepaths = document.getElementById("filepaths");	
-	if (filepaths.childNodes.length < 3) {		
-		var link_attach = document.getElementById("link-more-attach");		
+	var filepaths = document.getElementById("filepaths");
+	if (filepaths.childNodes.length < 3) {
+		var link_attach = document.getElementById("link-more-attach");
 		if (link_attach) {
 			link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>&nbsp;('.get_lang('MaximunFileSizeXMB').')\';
-		}			
-	}				        
+		}
+	}
 }
-		
-function add_image_form() {    														
-	// Multiple filepaths for image form					
-	var filepaths = document.getElementById("filepaths");	
+
+function add_image_form() {
+	// Multiple filepaths for image form
+	var filepaths = document.getElementById("filepaths");
 	if (document.getElementById("filepath_"+counter_image)) {
-		counter_image = counter_image + 1;				
+		counter_image = counter_image + 1;
 	}  else {
-		counter_image = counter_image; 
+		counter_image = counter_image;
 	}
 	var elem1 = document.createElement("div");
 	elem1.setAttribute("id","filepath_"+counter_image);
@@ -78,55 +78,55 @@ function add_image_form() {
 
 function validate_text_empty (str,msg) {
 	var str = str.replace(/^\s*|\s*$/g,"");
-	if (str.length == 0) {		 		
+	if (str.length == 0) {
 		alert(msg);
-		return true;			
-	}			
+		return true;
+	}
 }
 
 jQuery(document).ready(function() {
-		
+
    var valor = "'.$anchor.'";
 
-   $(".head").click(function() { 				
+   $(".head").click(function() {
 				$(this).next().next().slideToggle("fast");
-				image_clicked = $("#" + this.id + " img").attr("src");				
+				image_clicked = $("#" + this.id + " img").attr("src");
 				image_clicked_info = image_clicked.split("/");
 				image_real_clicked = image_clicked_info[image_clicked_info.length-1];
 				image_path = image_clicked.split("img");
-				current_path = image_path[0]+"img/";					
+				current_path = image_path[0]+"img/";
 				if (image_real_clicked == "div_show.gif") {
 					current_path = current_path+"div_hide.gif";
 					$("#" + this.id + " img").attr("src", current_path);
 				} else {
 					current_path = current_path+"div_show.gif";
 					$("#" + this.id + " img").attr("src", current_path)
-				}			
+				}
 				return false;
 		 	}).next().next().hide();
 
-   // anchor for current topic				
+   // anchor for current topic
    if (valor) {
-   		$("#"+valor).show();   			
-   		window.location = document.URL+"#"+valor;							 		
-   } 
-   	
+   		$("#"+valor).show();
+   		window.location = document.URL+"#"+valor;
+   }
+
 });
-	
 
-function show_icon_edit(element_html) {	
+
+function show_icon_edit(element_html) {
 	ident="#edit_image";
 	$(ident).show();
-}		
+}
 
 function hide_icon_edit(element_html)  {
 	ident="#edit_image";
 	$(ident).hide();
-}		
-		
+}
+
 </script>';
 
-$allowed_views = array('mygroups','newest','pop');		   	
+$allowed_views = array('mygroups','newest','pop');
 $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
 
 if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
@@ -139,10 +139,10 @@ if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
 	} else  {
 		$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
 		$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular'));
-	} 	
+	}
 } else {
 	$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
-	$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MessageList'));	
+	$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MessageList'));
 }
 
 Display :: display_header($tool_name, 'Groups');
@@ -150,54 +150,54 @@ Display :: display_header($tool_name, 'Groups');
 // save message group
 if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) {
 
-	if (isset($_POST['action'])) {	
+	if (isset($_POST['action'])) {
 		$title = $_POST['title'];
 		$content = $_POST['content'];
 		$group_id = intval($_POST['group_id']);
 		$parent_id = intval($_POST['parent_id']);
-				
+
 		if ($_POST['action'] == 'edit_message_group') {
-			$edit_message_id = 	intval($_POST['message_id']);					
+			$edit_message_id = 	intval($_POST['message_id']);
 			$res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, $edit_message_id);
-		} else {		
-			$res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id);	
+		} else {
+			$res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id);
 		}
-		
-		// display error messages 						
-		if (is_string($res)) {			
+
+		// display error messages
+		if (is_string($res)) {
 			Display::display_error_message($res);
 		}
-		
+
 		if ($res === true) {
 			$groups_user = 	GroupPortalManager::get_users_by_group($group_id);
-			$group_info = GroupPortalManager::get_group_data($group_id);			
+			$group_info = GroupPortalManager::get_group_data($group_id);
 			$admin_user_info = api_get_user_info(1);
-			$sender_name = api_get_person_name($admin_user_info['lastName'], $admin_user_info['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
+			$sender_name = api_get_person_name($admin_user_info['firstName'], $admin_user_info['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
 			$sender_email = $admin_user_info['mail'];
-			$subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'),$group_info['name']);			
-			$link = api_get_path(WEB_PATH).'main/social/groups?'.$_SERVER['QUERY_STRING'];			
+			$subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'),$group_info['name']);
+			$link = api_get_path(WEB_PATH).'main/social/groups?'.$_SERVER['QUERY_STRING'];
 			$text_link = '<a href="'.$link.'">'.get_lang('ClickHereToSeeMessageGroup')."</a><br />\r\n<br />\r\n".get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$link;
-						
+
 			$message = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'),$group_info['name'])."<br />$text_link";
-									
-			foreach ($groups_user as $group_user) {				
-				if ($group_user == $current_user) continue;				
+
+			foreach ($groups_user as $group_user) {
+				if ($group_user == $current_user) continue;
 				$group_user_info = api_get_user_info($group_user['user_id']);
-				$recipient_name = api_get_person_name($group_user_info['lastName'], $group_user_info['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
-				$recipient_email = $group_user_info['mail'];				
-				api_mail_html($recipient_name, $recipient_email, stripslashes($subject), $message, $sender_name, $sender_email);				
-			}	
+				$recipient_name = api_get_person_name($group_user_info['firstName'], $group_user_info['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
+				$recipient_email = $group_user_info['mail'];
+				@api_mail_html($recipient_name, $recipient_email, stripslashes($subject), $message, $sender_name, $sender_email);
+			}
 		}
-									
+
 		Security::clear_token();
-	}	
+	}
 }
 
 // getting group information
 $group_id	= intval($_GET['id']);
 $relation_group_title = '';
 $my_group_role = 0;
-if ($group_id != 0 ) {	
+if ($group_id != 0 ) {
 	$user_leave_message = false;
 	$user_added_group_message = false;
 	$group_info = GroupPortalManager::get_group_data($group_id);
@@ -208,68 +208,68 @@ if ($group_id != 0 ) {
 		if (api_get_user_id() == $user_leaved) {
 			GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
 			$user_leave_message = true;
-			
-		}	
-	}	
-	// add a user to a group if its open	
+
+		}
+	}
+	// add a user to a group if its open
 	if (isset($_GET['action']) && $_GET['action']=='join') {
 		// we add a user only if is a open group
-		$user_join = intval($_GET['u']);	
-		if (api_get_user_id() == $user_join && !empty($group_id)) {			
+		$user_join = intval($_GET['u']);
+		if (api_get_user_id() == $user_join && !empty($group_id)) {
 			if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
 				GroupPortalManager::add_user_to_group($user_join, $group_id);
-				$user_added_group_message = true;	
+				$user_added_group_message = true;
 			} else {
 				GroupPortalManager::add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER);
 				$user_added_group_message = true;
-			}				
+			}
 		}
-	}	
+	}
 }
 
 echo '<div id="social-content">';
 
-	echo '<div id="social-content-left">';	
+	echo '<div id="social-content-left">';
 		//this include the social menu div
 		if ($group_id != 0 ) {
-			SocialManager::show_social_menu('groups',$group_id);	
+			SocialManager::show_social_menu('groups',$group_id);
 		} else {
 			$show_menu = 'groups';
 			if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
 				$show_menu = $_GET['view'];
-			}			
+			}
 			SocialManager::show_social_menu($show_menu);
-		}	
+		}
 	echo '</div>';
 
 	echo '<div id="social-content-right">';
 
-if ($group_id != 0 ) {	
-	
+if ($group_id != 0 ) {
+
 	$group_info = GroupPortalManager::get_group_data($group_id);
-	
+
 	//Loading group information
 	if (isset($_GET['status']) && $_GET['status']=='sent') {
 		Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false);
-	}	
-	
+	}
+
 	if ($user_leave_message) {
 		Display::display_confirmation_message(get_lang('UserIsNotSubscribedToThisGroup'), false);
 	}
-	
+
 	if ($user_added_group_message) {
 		Display::display_confirmation_message(get_lang('UserIsSubscribedToThisGroup'), false);
 	}
-		
+
 	// details about the current group
 	echo '<div class="head_group">';
 
-		
+
 		echo '<div id="social-group-details">';
 				//Group's title
 				echo '<h2><a href="groups.php?id='.$group_id.'">'.$group_info['name'].'</a></h2>';
-							 
-				//Group's description 
+
+				//Group's description
 				echo '<div class="social-group-details-info">'.$group_info['description'].'</div>';
 				echo '<div class="social-group-details-info"><a target="_blank" href="'.$group_info['url'].'">'.$group_info['url'].'</a></div>';
 				//Privacy
@@ -281,31 +281,31 @@ if ($group_id != 0 ) {
 						echo get_lang('ThisIsACloseGroup');
 					}
 				echo '</div>';
-				
-				if (!empty($relation_group_title)) {				
+
+				if (!empty($relation_group_title)) {
 					echo '<div class="social-group-details-info">';
 					echo '<span>'.get_lang('StatusInThisGroup').' : </span>';
 					echo $relation_group_title;
 					echo '</div>';
-				}				
-				
+				}
+
 				//Group's tags
 				if (!empty($tags)) {
 					echo '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
-				}				
+				}
 		echo '</div>';
 	echo '</div>';
 	echo '<div class="clear"></div>';
-	
+
 	//-- Show message groups
-	echo '<div class="messages">';	
+	echo '<div class="messages">';
 		if (GroupPortalManager::is_group_member($group_id)) {
 			echo '<h3>'.get_lang('Topics').'</h3>';
-			$content = MessageManager::display_messages_for_group($group_id);				
+			$content = MessageManager::display_messages_for_group($group_id);
 			if (!empty($content)) {
-				echo $content;				
-			} else {	
-				echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouShouldCreateATopic').'</span></a></li>';				
+				echo $content;
+			} else {
+				echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouShouldCreateATopic').'</span></a></li>';
 			}
 		} else {
 			// if I already sent an invitation message
@@ -316,37 +316,37 @@ if ($group_id != 0 ) {
 			}
 		}
 	echo '</div>'; // end layout messages
-	
-} else {		
 
-		// My groups -----		
-		$results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0);	
+} else {
+
+		// My groups -----
+		$results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0);
 		$grid_my_groups = array();
 		if (is_array($results) && count($results) > 0) {
 			foreach ($results as $result) {
 				$id = $result['id'];
 				$url_open  = '<a href="groups.php?id='.$id.'">';
 				$url_close = '</a>';
-				
-				$name = api_strtoupper(cut($result['name'],25,true));				
-				if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {		 	
+
+				$name = api_strtoupper(cut($result['name'],25,true));
+				if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
 					$name .= Display::return_icon('admin_star.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
-				} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {			
+				} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
 					$name .= Display::return_icon('moderator_star.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
 				}
 				$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
 				if ($count_users_group == 1 ) {
-					$count_users_group = $count_users_group.' '.get_lang('Member');	
+					$count_users_group = $count_users_group.' '.get_lang('Member');
 				} else {
 					$count_users_group = $count_users_group.' '.get_lang('Members');
-				}					
-				
-				$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);							
-				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';			
-				$grid_item_1 = Display::return_icon('boxmygroups.jpg');						
+				}
+
+				$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
+				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
+				$grid_item_1 = Display::return_icon('boxmygroups.jpg');
 				$item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg','').'</div>';
 				$item_2 = '';
-				$item_3 = ''; 
+				$item_3 = '';
 				if ($result['description'] != '') {
 					$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
 					$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
@@ -354,126 +354,126 @@ if ($group_id != 0 ) {
 					$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
 					$item_3 = '<div class="box_description_group_content" ></div>';
 				}
-					
-				$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';			
-				$grid_item_2 = $item_1.$item_2.$item_3.$item_4;				
+
+				$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
+				$grid_item_2 = $item_1.$item_2.$item_3.$item_4;
 				$grid_my_groups[]= array($grid_item_1,$grid_item_2);
 			}
 		}
-				
-		// Newest groups --------		
+
+		// Newest groups --------
 		$results = GroupPortalManager::get_groups_by_age(4,false);
 		$grid_newest_groups = array();
 		foreach ($results as $result) {
 			$id = $result['id'];
 			$url_open  = '<a href="groups.php?id='.$id.'">';
-			$url_close = '</a>';			
-			$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));	
+			$url_close = '</a>';
+			$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
 			if ($count_users_group == 1 ) {
-					$count_users_group = $count_users_group.' '.get_lang('Member');	
+					$count_users_group = $count_users_group.' '.get_lang('Member');
 			} else {
 				$count_users_group = $count_users_group.' '.get_lang('Members');
-			}	
-			
-			$name = api_strtoupper(cut($result['name'],30,true));			
-			$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);							
-			$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';									
-			$grid_item_1 = Display::return_icon('boxmygroups.jpg');						
+			}
+
+			$name = api_strtoupper(cut($result['name'],30,true));
+			$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
+			$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
+			$grid_item_1 = Display::return_icon('boxmygroups.jpg');
 			$item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg','').'</div>';
-						
+
 			if ($result['description'] != '') {
 				$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
 				$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
 			} else {
 				$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
 				$item_3 = '<div class="box_description_group_content" ></div>';
-			}	
-			$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';			
+			}
+			$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
 			$grid_item_2 = $item_1.$item_2.$item_3.$item_4;
-						
-			$grid_newest_groups[]= array($grid_item_1,$grid_item_2);			
+
+			$grid_newest_groups[]= array($grid_item_1,$grid_item_2);
 		}
-		
-		// Pop groups -----		
+
+		// Pop groups -----
 		$results = GroupPortalManager::get_groups_by_popularity(4,false);
 		$grid_pop_groups = array();
-		
+
 		if (is_array($results) && count($results) > 0) {
 			foreach ($results as $result) {
 				$id = $result['id'];
 				$url_open  = '<a href="groups.php?id='.$id.'">';
 				$url_close = '</a>';
-				
-				$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));	
+
+				$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
 				if ($count_users_group == 1 ) {
-						$count_users_group = $count_users_group.' '.get_lang('Member');	
+						$count_users_group = $count_users_group.' '.get_lang('Member');
 				} else {
 					$count_users_group = $count_users_group.' '.get_lang('Members');
 				}
-	
-				$name = api_strtoupper(cut($result['name'],30,true));			
-				$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);							
-				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';									
-				$grid_item_1 = Display::return_icon('boxmygroups.jpg');						
+
+				$name = api_strtoupper(cut($result['name'],30,true));
+				$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
+				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
+				$grid_item_1 = Display::return_icon('boxmygroups.jpg');
 				$item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg').'</div>';
-				
+
 				if ($result['description'] != '') {
 					$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
-					$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';		
+					$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
 				} else {
 					$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
 					$item_3 = '<div class="box_description_group_content" ></div>';
-				}	
-					
-				$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';			
-				$grid_item_2 = $item_1.$item_2.$item_3.$item_4;							
-				$grid_pop_groups[]= array($grid_item_1,$grid_item_2);							
+				}
+
+				$item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
+				$grid_item_2 = $item_1.$item_2.$item_3.$item_4;
+				$grid_pop_groups[]= array($grid_item_1,$grid_item_2);
 			}
 		}
 
 		// display groups (newest, mygroups, pop)
-		echo '<div class="social-box-main1">';		   			   	
+		echo '<div class="social-box-main1">';
 		   	if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
 		   		$view_group = $_GET['view'];
 		   		switch ($view_group) {
-		   			case 'mygroups' :		   			                  
+		   			case 'mygroups' :
 		        		if (count($grid_my_groups) > 0) {
 		        			echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('MyGroups')).'</div>';
 		        			Display::display_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
 		        		}
 		        		break;
-		        	case 'newest' :		
+		        	case 'newest' :
 		        		if (count($grid_newest_groups) > 0) {
-							echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';				
-							Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));		
+							echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';
+							Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
 						}
 		        		break;
-		        	default :	
+		        	default :
 		        		if (count($grid_pop_groups) > 0) {
 							echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Popular')).'</div>';
 							Display::display_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
 						}
-		        		break;					 
-		   		}		   		
-		   	} else {		   		                  
+		        		break;
+		   		}
+		   	} else {
 		        if (count($grid_my_groups) > 0) {
 		        	echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('MyGroups')).'</div>';
 		        	Display::display_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
-		        }		        	        	                 		
+		        }
 				if (count($grid_newest_groups) > 0) {
-					echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';				
-					Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));		
+					echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';
+					Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
 				}
 				if (count($grid_pop_groups) > 0) {
 					echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Popular')).'</div>';
 					Display::display_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
 				}
-		   	}		   	
-								
-		echo '</div>';	
-	
+		   	}
+
+		echo '</div>';
+
 }
 	echo '</div>';
-	
-echo '</div>';	
+
+echo '</div>';
 Display :: display_footer();

+ 25 - 25
main/survey/survey.lib.php

@@ -40,7 +40,7 @@ $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
 		}
 		$(document).ready(function () {
 		  setFocus();
-		});		
+		});
 	</script>';
 
 
@@ -69,7 +69,7 @@ class survey_manager
 		global $_course;
 
 		// table definition
-		
+
 		if (!empty($course_code)) {
 			$my_course_id = $course_code;
 		} else if (isset($_GET['course'])) {
@@ -454,7 +454,7 @@ class survey_manager
 		//update into item_property (delete)
 		api_item_property_update(api_get_course_info(), TOOL_SURVEY, Database::escape_string($survey_id), 'delete', api_get_user_id());
 
-		return void;
+		return true;
 	}
 
 	function copy_survey($parent_survey, $new_survey_id)
@@ -1686,7 +1686,7 @@ class yesno extends question
 	 */
 	function render_question($form_content, $answers=array())
 	{
-		
+
 		if (is_array($form_content['options'])) { // check if data is correct
 			foreach ($form_content['options'] as $key=>$value)
 			{
@@ -1758,8 +1758,8 @@ class multiplechoice extends question
 		$this->html .= '		</div>';
 		$this->html .= '		<div class="formw">';
 		$total_number_of_answers = count($form_content['answers']);
-		$this->html .= ' 			<table>';		
-		if (is_array($form_content['answers'])) { // check if data is correct		
+		$this->html .= ' 			<table>';
+		if (is_array($form_content['answers'])) { // check if data is correct
 			foreach ($form_content['answers'] as $key=>$value) {
 				$this->html .= '	<tr>';
 				$this->html .= '		<td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
@@ -1852,7 +1852,7 @@ class personality extends question
 
 
 		$question_values=array();
-		
+
 		// values of question options
 		if(is_array($form_content['values'])) { // check if data is correct
 			foreach ($form_content['values'] as $key=>$value) {
@@ -1867,12 +1867,12 @@ class personality extends question
 				//$this->html .= '		<td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
 				$this->html .= '		<td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key])), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
 				$this->html .= '		<td>';
-	
+
 				if ($total_number_of_answers> 2)
 				{
 					$this->html .=$question_values[$count];
 				}
-	
+
 				if ($key<$total_number_of_answers-1)
 				{
 					$this->html .= '		<input type="image" src="../img/down.gif"  value="move_down['.$key.']" name="move_down['.$key.']"/>';
@@ -1963,11 +1963,11 @@ class multipleresponse extends question
 				if ($key<$total_number_of_answers-1) {
 					$this->html .= '			<input type="image" src="../img/down.gif"  value="move_down['.$key.']" name="move_down['.$key.']"/>';
 				}
-	
+
 				if ($key>0) {
 					$this->html .= '			<input type="image" src="../img/up.gif"  value="move_up['.$key.']" name="move_up['.$key.']"/>';
 				}
-	
+
 				if ($total_number_of_answers> 2) {
 					$this->html .= '			<input type="image" src="../img/delete.gif"  value="delete_answer['.$key.']" name="delete_answer['.$key.']"/>';
 				}
@@ -2780,7 +2780,7 @@ class SurveyUtil {
 
 		echo '<div class="actions">';
 		echo '<a href="reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview')).' '.get_lang('BackTo').' '.get_lang('ReportingOverview').'</a>';
-		
+
 		if ($survey_data['number_of_questions'] > 0) {
 			echo '<div id="question_report_questionnumbers">'.get_lang('GoToQuestion').': ';
 			for($i=1; $i<=($survey_data['number_of_questions']); $i++ )
@@ -2799,12 +2799,12 @@ class SurveyUtil {
 				}
 			}
 			echo '</div>';
-	
+
 			// getting the question information
 			$sql = "SELECT * FROM $table_survey_question WHERE survey_id='".Database::escape_string($_GET['survey_id'])."' AND type<>'pagebreak' AND type<>'comment' ORDER BY sort ASC LIMIT ".$offset.",1";
 			$result = Database::query($sql, __FILE__, __LINE__);
 			$question = Database::fetch_array($result);
-	
+
 			// navigate through the questions (next and previous)
 			if ($_GET['question'] <> 0)
 			{
@@ -2830,7 +2830,7 @@ class SurveyUtil {
 
 		echo '<br />';
 
-		
+
 
 
 		if ($question['type'] == 'score')
@@ -3040,9 +3040,9 @@ class SurveyUtil {
 		echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1a.submit();"><img align="absbottom" src="'.api_get_path(WEB_IMG_PATH).'csv.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
 		echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1b.submit();"><img align="absbottom" src="'.api_get_path(WEB_IMG_PATH).'excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a>';
 		echo '</div>';
-				
 
-		
+
+
 		// the form
 		echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'">';
 		echo '<input type="hidden" name="export_report" value="export_report">';
@@ -3053,8 +3053,8 @@ class SurveyUtil {
 		echo '<input type="hidden" name="export_format" value="xls">';
 		echo '</form>';
 		echo '<form id="form2" name="form2" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'">';
-		
-		
+
+
 		// the table
 		echo '<br /><table class="data_table" border="1">';
 		// getting the number of options per question
@@ -3143,7 +3143,7 @@ class SurveyUtil {
 				WHERE sq.survey_id = '".Database::escape_string($_GET['survey_id'])."'
 				ORDER BY sq.sort ASC, sqo.sort ASC";
 		$result = Database::query($sql, __FILE__, __LINE__);
-		
+
 			while ($row = Database::fetch_array($result)) {
 				// we show the options if
 				// 1. there is no question filter and the export button has not been clicked
@@ -3160,8 +3160,8 @@ class SurveyUtil {
 					}
 					//no column at all if the question was not a question
 				}
-			} 
-		
+			}
+
 		echo '	</tr>';
 
 		// getting all the answers of the users
@@ -3272,7 +3272,7 @@ class SurveyUtil {
 						}
 					}
 				}
-	
+
 			}
 		}
 		echo '</tr>';
@@ -4279,7 +4279,7 @@ class SurveyUtil {
                 }
             }
 
-            api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
+            @api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
 
         }
 
@@ -4326,7 +4326,7 @@ class SurveyUtil {
 		if (!empty($course_db)) {
 			$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION,$course_db);
 		} else {
-			$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);	
+			$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
 		}
 
 	 	$table_user = Database :: get_main_table(TABLE_MAIN_USER);

+ 16 - 18
main/wiki/wiki.inc.php

@@ -206,7 +206,7 @@ function detect_irc_link($input)
 function make_wiki_link_clickable($input)
 {
 	global $_course;
-	
+
 	if (isset($_SESSION['_gid']))
 	{
 		$_clean['group_id']=(int)$_SESSION['_gid'];
@@ -563,11 +563,11 @@ function save_new_wiki() {
 		   Database::query($sql,__LINE__,__FILE__);
 
 		   check_emailcue(0, 'A');
-		   
+
 		   $_POST['reflink']=$_clean['reflink'];
-		   
+
 		   return get_lang('NewWikiSaved');
-		   
+
 		}
 	}//end filter no _uass
 }
@@ -598,7 +598,7 @@ return true;
 		}
 		$(document).ready(function () {
 		  setFocus();
-		});		
+		});
 </script>
 <?php
 	//form
@@ -767,7 +767,7 @@ return true;
 function display_wiki_entry($newtitle)
 {
 	global $charset, $tbl_wiki, $tbl_wiki_conf, $groupfilter, $page;
-	
+
 	if($newtitle)
 	{
 		$pageMIX=$newtitle; //display the page after it is created
@@ -925,7 +925,7 @@ function display_wiki_entry($newtitle)
 			echo '<form name="form_export2DOC" method="post" action="index.php" >';
 			echo '<input type=hidden name="export2DOC" value="export2doc">';
 			echo '<input type=hidden name="titleDOC" value="'.api_htmlentities($title, ENT_QUOTES, $charset).'">';
-			echo '<input type=hidden name="contentDOC" value="'.api_htmlentities($content, ENT_QUOTES, $charset).'">';			
+			echo '<input type=hidden name="contentDOC" value="'.api_htmlentities($content, ENT_QUOTES, $charset).'">';
 			echo '<input type="image" src="../img/wiki/wexport2doc.png" border ="0" title="'.get_lang('ExportToDocArea').'" alt="'.get_lang('ExportToDocArea').'" style=" border:none; margin-top: -6px">';
 			echo '</form>';
 			echo '</span>';
@@ -1680,8 +1680,6 @@ function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
 	{
 		while ($row=Database::fetch_array($result))
 		{
-			if(empty($charset)){$charset='ISO-8859-1';}
-			$headers = 'Content-Type: text/html; charset='. $charset;
 			$userinfo = Database::get_user_info_from_id($row['user_id']);	//$row['user_id'] obtained from tbl_wiki_mailcue
 			$name_to = api_get_person_name($userinfo['firstname'], $userinfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
 			$email_to = $userinfo['email'];
@@ -1694,7 +1692,7 @@ function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
 			$email_body .= $email_assignment.'<br /><br /><br />';
 			$email_body .= '<font size="-2">'.get_lang('EmailWikiChangesExt_1').': <strong>'.get_lang('NotifyChanges').'</strong><br />';
 			$email_body .= get_lang('EmailWikiChangesExt_2').': <strong>'.get_lang('NotNotifyChanges').'</strong></font><br />';
-			api_mail_html($name_to, $email_to, $email_subject, $email_body, $sender_name, $sender_email, $headers);
+			@api_mail_html($name_to, $email_to, $email_subject, $email_body, $sender_name, $sender_email);
 		}
 	}
 }
@@ -1707,7 +1705,7 @@ function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
 function export2doc($wikiTitle, $wikiContents, $groupId)
 {
 	global $_course;
-	
+
 	$template =
 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{LANGUAGE}" lang="{LANGUAGE}">
@@ -1759,7 +1757,7 @@ function export2doc($wikiTitle, $wikiContents, $groupId)
 
 	$wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
 
-	// replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents  
+	// replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents
 	if (api_strpos($wikiContents,'../../courses/') !== false) {
 		$web_course_path = api_get_path(WEB_COURSE_PATH);
 		$wikiContents = str_replace('../../courses/',$web_course_path,$wikiContents);
@@ -1773,8 +1771,8 @@ function export2doc($wikiTitle, $wikiContents, $groupId)
 	file_put_contents( $exportPath, $wikiContents );
 	$doc_id = add_document($_course, $groupPath.'/'.$wikiFileName, 'file', filesize($exportPath), $wikiTitle);
 	api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(), $groupId);
-	
-	return $doc_id; 	
+
+	return $doc_id;
     // TODO: link to go document area
 }
 
@@ -1870,9 +1868,9 @@ function auto_add_page_users($assignment_type)
    // $content_orig_A='<div align="center" style="background-color: #F5F8FB;  border:double">'.$photo.'</br>'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</br>('.get_lang('Teacher').')</div><br/><div>';
 
 	$content_orig_A='<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6"><table border="0"><tr><td style="font-size:24px">'.get_lang('AssignmentDesc').'</td></tr><tr><td>'.$photo.'</br>'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</td></tr></table></div>';
-	
+
 	$content_orig_B='<br/><div align="center" style="font-size:24px">'.get_lang('AssignmentDescription').': '.$title_orig.'</div><br/>'.$_POST['content'];
-	
+
     //Second: student list (names, photo and links to their works).
 	//Third: Create Students work pages.
 
@@ -1916,9 +1914,9 @@ function auto_add_page_users($assignment_type)
 
 				//AssignmentLinktoTeacherPage
 			 	$all_students_pages[] = '<li>'.strtoupper($o_user_to_add['lastname']).', '.$o_user_to_add['firstname'].' [['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>'; //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
-				
+
 				//$all_students_pages[] = '<li><table border="0"><tr><td width="200">'.api_get_person_name($o_user_to_add['lastname'], $o_user_to_add['firstname']).'</td><td>[['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</td></tr></table></li>';
-				
+
 				$_POST['assignment']=2;
 
 			}

+ 2 - 2
tests/main/inc/lib/mail.lib.inc.test.php

@@ -12,7 +12,7 @@ class TestMail extends UnitTestCase {
  		$recipient_email='';
  		$subject='';
  		$message='';
- 		$res=api_mail($recipient_name, $recipient_email, $subject, $message);
+ 		$res=@api_mail($recipient_name, $recipient_email, $subject, $message);
  		$mensajee->expectOnce($mail);
  		$this->assertTrue(is_numeric($res));
 		//var_dump($res);
@@ -25,7 +25,7 @@ class TestMail extends UnitTestCase {
  		$recipient_name='';
  		$recipient_email='';
  		$subject='';
- 		$res=api_mail_html($recipient_name, $recipient_email, $subject);
+ 		$res=@api_mail_html($recipient_name, $recipient_email, $subject);
  		$mensajee->expectOnce($mail);
 		$this->assertTrue(is_numeric($res));
 		//var_dump($res);