Sfoglia il codice sorgente

Feature #272 - Mailing: Duplicate statements for loading the configuration file have been removed.

Ivan Tcholakov 15 anni fa
parent
commit
c088a21b36

+ 47 - 53
main/announcements/announcements.php

@@ -46,8 +46,8 @@ api_protect_course_script();
 -----------------------------------------------------------
 */
 // Configuration settings
-$display_announcement_list = true;
-$display_form             = false;
+$display_announcement_list	 = true;
+$display_form				 = false;
 $display_title_list 		 = true;
 
 // Maximum title messages to display
@@ -124,7 +124,6 @@ $lib = api_get_path(LIBRARY_PATH); //avoid useless function calls
 require_once($lib.'groupmanager.lib.php');
 require_once('announcements.inc.php');
 require_once($lib.'mail.lib.inc.php');
-require_once(api_get_path(INCLUDE_PATH).'conf/mail.conf.php');
 require_once($lib.'debug.lib.inc.php');
 require_once($lib.'tracking.lib.php');
 require_once($lib.'fckeditor/fckeditor.php');
@@ -140,20 +139,17 @@ $safe_newContent = $_POST['newContent'];
 
 if (!empty($_POST['To']))
 {
-	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 		api_not_allowed();
 	}
 	$display_form = true;
 
-	$form_elements= array ('emailTitle'=>$safe_emailTitle, 'newContent'=>$safe_newContent, 'id'=>Security::remove_XSS($_POST['id']), 'emailoption'=>Security::remove_XSS($_POST['email_ann']));
-    $_SESSION['formelements']=$form_elements;
+	$form_elements = array ('emailTitle'=>$safe_emailTitle, 'newContent'=>$safe_newContent, 'id'=>Security::remove_XSS($_POST['id']), 'emailoption'=>Security::remove_XSS($_POST['email_ann']));
+    $_SESSION['formelements'] = $form_elements;
 
     $form_elements            	= $_SESSION['formelements'];
-
 	$title_to_modify            = $form_elements["emailTitle"];
-
 	$content_to_modify          = $form_elements["newContent"];
-
 	$announcement_to_modify     = $form_elements["id"];
 }
 
@@ -166,16 +162,16 @@ if (!empty($_POST['To']))
 $setting_select_groupusers = true;
 if (empty($_POST['To']) and !$_SESSION['select_groupusers'])
 {
-	$_SESSION['select_groupusers']="hide";
+	$_SESSION['select_groupusers'] = "hide";
 }
 $select_groupusers_status=$_SESSION['select_groupusers'];
 if (!empty($_POST['To']) and ($select_groupusers_status=="hide"))
 {
-	$_SESSION['select_groupusers']="show";
+	$_SESSION['select_groupusers'] = "show";
 }
 if (!empty($_POST['To']) and ($select_groupusers_status=="show"))
 {
-	$_SESSION['select_groupusers']="hide";
+	$_SESSION['select_groupusers'] = "hide";
 }
 
 /*
@@ -187,7 +183,7 @@ if (!empty($_POST['To']) and ($select_groupusers_status=="show"))
 // display the form
 if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To']))
 {
-	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+	if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 		api_not_allowed();
 	}
 	$display_form = true;
@@ -341,10 +337,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	// change visibility -> studentview -> course manager view
 	if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') {
 		if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") {
-			if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+			if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 				api_not_allowed();
 			}
-			
+
 			$id=intval($_GET['id']);
 			if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
 				if ($ctok == $_GET['sec_token']) {
@@ -363,10 +359,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	if (!empty($_GET['action']) AND $_GET['action']=='delete' AND isset($_GET['id'])) {
 		//Database::query("DELETE FROM  $tbl_announcement WHERE id='$delete'",__FILE__,__LINE__);
 		$id=intval(addslashes($_GET['id']));
-		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 			api_not_allowed();
 		}
-				
+
 		if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
 
 			// tooledit : visibility = 2 : only visibile for platform administrator
@@ -411,10 +407,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	-----------------------------------------------------------
 	*/
 	if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
-		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {		 
+		if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
 			api_not_allowed();
 		}
-			
+
 		$display_form = true;
 
 		// RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
@@ -520,7 +516,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 
 	$emailTitle=(!empty($_POST['emailTitle'])?$safe_emailTitle:'');
 	$newContent=(!empty($_POST['newContent'])?$safe_newContent:'');
-	
+
 	$submitAnnouncement=isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0;
 
 	$id = 0;
@@ -537,7 +533,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 			// there is an Id => the announcement already exists => update mode
 			if ($ctok == $_POST['sec_token']) {
 				$file_comment = $_POST['file_comment'];
-				$file = $_FILES['user_upload'];		
+				$file = $_FILES['user_upload'];
 				$edit_id = edit_advalvas_item($id,$emailTitle,$newContent,$_POST['selectedform'],$file,$file_comment);
 				if (!$delete) {
 				    update_added_resources("Ad_Valvas", $id);
@@ -547,18 +543,18 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 		} else {
 			//insert mode
 			if ($ctok == $_POST['sec_token']) {
-				
+
 				if (!$surveyid) {
 					$result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".intval($_SESSION['id_session'])." OR session_id=0",__FILE__,__LINE__);
 					list($orderMax) = Database::fetch_row($result);
 					$order = $orderMax + 1;
 					$file = $_FILES['user_upload'];
 					$file_comment = $_POST['file_comment'];
-					if (!empty($_SESSION['toolgroup'])) {						
+					if (!empty($_SESSION['toolgroup'])) {
 						$insert_id=store_advalvas_group_item($safe_emailTitle,$safe_newContent,$order,array('GROUP:'.$_SESSION['toolgroup']),$_POST['selectedform'],$file,$file_comment);
 					} else {
 						$insert_id=store_advalvas_item($safe_emailTitle,$safe_newContent,$order,$_POST['selectedform'],$file,$file_comment);
-					}					
+					}
 				    store_resources($_SESSION['source_type'],$insert_id);
 				    $_SESSION['select_groupusers']="hide";
 				    $message = get_lang('AnnouncementAdded');
@@ -696,7 +692,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 						    */
 
 							$emailSubject = "[" . $_course['official_code'] . "] " . $emailTitle;
-							
+
 	                        if ($surveyid) {
 	                        	$newContentone=str_replace("#page#","choose_language.php",$newContent);
 								$newContenttwo=str_replace("#temp#",$template,$newContentone);
@@ -722,16 +718,16 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 	                            $mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)." \n";
 	                            $mail_body .= "<br /> \n<a href=\"".api_get_path(WEB_COURSE_PATH).$_course['id']."\">";
 	                            $mail_body .= $_course['official_code'].' '.$_course['name'] . "</a>";
-	                            
+
 								//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)
-								
-								$recipient_name	= api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS);
+
+								$recipient_name	= api_get_person_name($myrow["firstname"], $myrow["lastname"], null, PERSON_NAME_EMAIL_ADDRESS);
 		                        $mailid = $myrow["email"];
-		                        
-		                        $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
+
+		                        $sender_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
 		                        $sender_email = $_SESSION['_user']['mail'];
-		                        
+
 								$data_file = array();
 								if (!empty($_FILES['user_upload'])) {
 									$courseDir = $_course['path'].'/upload/announcements/';
@@ -743,7 +739,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 									$data_file = array('path' => $sys_course_path.$courseDir.$row['path'],
 													   'filename' => $row['filename']);
 								}
-		                        
+
 								api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
 	                        }
 
@@ -973,9 +969,7 @@ if (!$surveyid) {
 			}
 			//validation when belongs to a session
 			$session_img = api_get_session_image($myrow['session_id'], $_user['status']);
-			
-			
-			
+
 			echo "\t\t\t\t\t\t".Display::return_icon('lp_announcement.png', api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow['end_date']))), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))."  <a style=\"text-decoration:none\" href=\"announcements.php?".api_get_cidreq()."#".$myrow['id']."\" ".$class.">" . api_trunc_str($title, $length) . "</a>\n" . $session_img;
 			echo "\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
 		}
@@ -1011,8 +1005,8 @@ if (!empty($error_message)) {
 
 if ($display_form == true) {
 
-	$content_to_modify=stripslashes($content_to_modify);
-	$title_to_modify=stripslashes($title_to_modify);
+	$content_to_modify = stripslashes($content_to_modify);
+	$title_to_modify = stripslashes($title_to_modify);
 
 	// DISPLAY ADD ANNOUNCEMENT COMMAND
 	echo '<form method="post" name="f1" enctype = "multipart/form-data" action="'.api_get_self().'?publish_survey='.Security::remove_XSS($surveyid).'&id='.Security::remove_XSS($_GET['id']).'&db_name='.$db_name.'&cidReq='.Security::remove_XSS($_GET['cidReq']).'" style="margin:0px;">'."\n";
@@ -1051,7 +1045,7 @@ if ($display_form == true) {
 			// setting the variables for the form elements: the message has to be sent by email
 			$email_ann = '1';
 			// setting the variables for the form elements: the title of the email
-			$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'),' > ',$_course['name']);				
+			$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'),' > ',$_course['name']);
 			// setting the variables for the form elements: the message of the email
 			$content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),' > ',$_course['name'],$since);
 			// when we want to remind the users who have never been active then we have a different subject and content for the announcement
@@ -1309,7 +1303,7 @@ if ($display_announcement_list && !$surveyid) {
 					WHERE announcement.id = toolitemproperties.ref
 					AND toolitemproperties.tool='announcement'
 					$cond_user_id
-					$condition_session		
+					$condition_session
 					AND toolitemproperties.visibility='1'
 					ORDER BY display_order DESC";
 			} else {
@@ -1478,17 +1472,17 @@ if ($display_announcement_list && !$surveyid) {
 					echo	"<a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."&sec_token=".$stok."\">".
 							Display::return_icon('down.gif', get_lang('Down'))."</a>";
 				}
-				
+
 				//delete attachment file
 				if($_GET['action'] == 'delete') {
 					$id = $_GET['id_attach'];
 					delete_announcement_attachment_file($id);
 				}
-					
+
 				// show attachment list
 				$attachment_list = array();
-				$attachment_list = get_attachment($myrow['id']);				
-								
+				$attachment_list = get_attachment($myrow['id']);
+
 				if (count($attachment_list)>0) {
 					$realname=$attachment_list['path'];
 					$user_filename=$attachment_list['filename'];
@@ -1499,22 +1493,22 @@ if ($display_announcement_list && !$surveyid) {
 					echo '<a href="'.$full_file_name.'';
 					echo ' "> '.$user_filename.' </a>';
 					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
-					
+
 					if (api_is_allowed_to_edit()) {
 						echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
-					}					
-				}					
-	    		
-																	
+					}
+				}
+
+
 				echo "</td>\n</tr>\n";
 
 				$iterator ++;
-			} else { // end of is_allowed_to_edit 
+			} else { // end of is_allowed_to_edit
 				//students view
 				// show attachment list
 				$attachment_list = array();
-				$attachment_list = get_attachment($myrow['id']);				
-								
+				$attachment_list = get_attachment($myrow['id']);
+
 				if (count($attachment_list)>0) {
 					$realname=$attachment_list['path'];
 					$user_filename=$attachment_list['filename'];
@@ -1524,8 +1518,8 @@ if ($display_announcement_list && !$surveyid) {
 					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
 					echo '<a href="'.$full_file_name.'';
 					echo ' "> '.$user_filename.' </a>';
-					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';					
-				}	
+					echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
+				}
 			}
 
 			echo "<tr><td width=\"100%\" colspan=\"3\"><a href=\"#top\">".Display::return_icon('top.gif', get_lang('Top'))."</a></td></tr>";

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

@@ -50,8 +50,6 @@ require_once('dropbox_config.inc.php');
 // the dropbox file that contains additional functions
 require_once('dropbox_functions.inc.php');
 
-require(api_get_path(INCLUDE_PATH).'/conf/mail.conf.php');
-
 include_once(api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php');
 include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
 

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

@@ -68,7 +68,6 @@
 */
 require_once(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
 require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
-require_once(api_get_path(INCLUDE_PATH).'/conf/mail.conf.php');
 require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
 require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
 get_notifications_of_user();
@@ -83,7 +82,7 @@ $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#forum_title").focus();
 $("#category_title").focus();
-$("#search_title").focus();				
+$("#search_title").focus();
 }
 $(document).ready(function () {
   setFocus();
@@ -2322,7 +2321,7 @@ function store_reply($values) {
 		if ($current_forum['approval_direct_post']=='1' AND !api_is_allowed_to_edit(null,true)) {
 			$message.='<br />'.get_lang('MessageHasToBeApproved').'<br />';
 		}
-				
+
 		$message.='<br />'.get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />';
 		$message.=get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&amp;thread='.$values['thread_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'&amp;gradebook='.$gradebook.'">'.get_lang('Message').'</a>';
 
@@ -3959,8 +3958,8 @@ function get_thread_user_post($course_db, $thread_id, $user_id )
 		 				}
 			 			$hand_forums.= '</div>';
 		 			}
-		 			$i++;					
-	 			}	 				 			
+		 			$i++;
+	 			}
 				$forum_results .='<div id="social-forum">';
  				$forum_results .='<div class="clear"></div><br />';
  				$forum_results .='<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('forum.gif',get_lang('Forum')).'&nbsp;'.$forum['forum_title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../forum/viewforum.php?cidReq='.$my_course_code.'&gidReq=&forum='.$forum['forum_id'].' " >'.get_lang('SeeForum').'</a></div></div>';
@@ -3968,7 +3967,7 @@ function get_thread_user_post($course_db, $thread_id, $user_id )
  				if ($post_counter > 0 ) {
 					$forum_results .=$hand_forums;
  				}
-				$forum_results .='</div>';				
+				$forum_results .='</div>';
  			}$j++;
  		}
  	}

+ 13 - 14
main/wiki/index.php

@@ -54,8 +54,7 @@ require_once api_get_path(LIBRARY_PATH).'course.lib.php';
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'text.lib.php';
 require_once api_get_path(LIBRARY_PATH).'security.lib.php';
-require_once api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php';
-require_once api_get_path(INCLUDE_PATH).'conf/mail.conf.php';
+require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 require_once 'wiki.inc.php';
@@ -80,8 +79,8 @@ function setFocus(){
 	}
 	$(document).ready(function () {
 	  setFocus();
-	});				
-		
+	});
+
 </script>';
 
 
@@ -442,10 +441,10 @@ echo '<td>';
 		if (check_addnewpagelock()==0)
 		{
 			$protect_addnewpage= '<img src="../img/wiki/lockadd.gif" title="'.get_lang('AddOptionProtected').'" alt="'.get_lang('AddOptionProtected').'" width="8" height="8" />';
-			$lock_unlock_addnew='unlockaddnew';						
+			$lock_unlock_addnew='unlockaddnew';
 		}
 		else
-		{					
+		{
 			$protect_addnewpage= '<img src="../img/wiki/unlockadd.gif" title="'.get_lang('AddOptionUnprotected').'" alt="'.get_lang('AddOptionUnprotected').'" width="8" height="8" />';
 			$lock_unlock_addnew='lockaddnew';
 		}
@@ -520,11 +519,11 @@ if ($_POST['export2DOC'])
 	$contentDOC=$_POST['contentDOC'];
 	$groupIdDOC=(int)$_SESSION['_gid'];
 	$export2doc = export2doc($titleDOC,$contentDOC,$groupIdDOC);
-	
+
 	if ($export2doc) {
 		Display::display_normal_message(get_lang('ThePageHasBeenExportedToDocArea'));
 	}
-	
+
 }
 
 if ($_GET['action']=='more')
@@ -1505,11 +1504,11 @@ if ($_GET['action']=='edit')
 				}
 				//form
 				echo '<form name="form1" method="post" action="'.api_get_self().'?action=showpage&amp;title='.$page.'&group_id='.Security::remove_XSS($_GET['group_id']).'">';
-				
-				
+
+
 				echo '<div id="wikititle" >';
 				echo '<div style="width:70%;float:left;">'.$icon_assignment.str_repeat('&nbsp;',3).$title.'</div>';
-				
+
 				if((api_is_allowed_to_edit(false,true) || api_is_platform_admin()) && $row['reflink']!='index')
 				{
 
@@ -1917,7 +1916,7 @@ if ($_GET['action']=='recentchanges')
 		if (check_notify_all()==1)
 		{
 			$notify_all= '<img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('FullNotifyByEmail').'" alt="'.get_lang('FullNotifyByEmail').'" style="vertical-align:middle;" />'.get_lang('NotNotifyChanges');
-			$lock_unlock_notify_all='unlocknotifyall';			
+			$lock_unlock_notify_all='unlocknotifyall';
 		}
 		else
 		{
@@ -1927,8 +1926,8 @@ if ($_GET['action']=='recentchanges')
 
 	}
 
-	echo '<div class="actions"><span style="float: right;">';	
-	echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.$page.'">'.$notify_all.'</a>';	
+	echo '<div class="actions"><span style="float: right;">';
+	echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.$page.'">'.$notify_all.'</a>';
 	echo '</span>'.get_lang('RecentChanges').'</div>';