Browse Source

[svn r17457] Fixed bug resolved the mistake and add &origin=$origin to all links realted to them with learning path on the forum see FS#3256 and FS#3401

Carlos Vargas 16 years ago
parent
commit
3cc12a8ac9

+ 17 - 5
main/forum/editpost.php

@@ -104,7 +104,7 @@ include('forumfunction.inc.php');
 ==============================================================================
 		MAIN DISPLAY SECTION
 ==============================================================================
-*/
+*/
 /*
 -----------------------------------------------------------
 	Retrieving forum and forum categorie information
@@ -144,9 +144,19 @@ $table_link 			= Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
 -----------------------------------------------------------
 	Header
 -----------------------------------------------------------
-*/
-Display :: display_header(null);
-api_display_tool_title($nameTools);
+*/
+//are we in a lp ?
+$origin = '';
+if (isset($_GET['origin'])) {
+	$origin =  Security::remove_XSS($_GET['origin']);
+}
+
+if ($origin=='learnpath') {
+	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
+} else {
+	Display :: display_header(null);
+	api_display_tool_title($nameTools);
+}
 //echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
 /*
 -----------------------------------------------------------
@@ -212,4 +222,6 @@ if (!empty($values) and $_POST['SubmitPost']) {
 	
 }
 // footer
-Display :: display_footer();
+if ($origin!='learnpath') {
+	Display :: display_footer();
+}

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

@@ -1762,7 +1762,7 @@ function store_thread($values) {
 
 		if ($current_forum['approval_direct_post']=='1' AND !api_is_allowed_to_edit()) {
 			$message.=get_lang('MessageHasToBeApproved').'<br />';
-			$message.=get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'">'.get_lang('Forum').'</a><br />';
+			$message.=get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />';
 		} else {
 			$message.=get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />';
 			$message.=get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&origin='.$origin.'&amp;thread='.$last_thread_id.'">'.get_lang('Message').'</a>';
@@ -2214,9 +2214,10 @@ function store_reply($values) {
 function show_edit_post_form($current_post, $current_thread, $current_forum, $form_values='') {
 	global $forum_setting;
 	global $_user;
+	global $origin;
 
 	// initiate the object
-	$form = new FormValidator('edit_post', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']));
+	$form = new FormValidator('edit_post', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']));
 
 	// settting the form elements
 	$form->addElement('hidden', 'post_id', $current_post['post_id']);
@@ -2300,6 +2301,7 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
 function store_edit_post($values) {
 	global $table_threads;
 	global $table_posts;
+	global $origin;
 	// first we check if the change affects the thread and if so we commit the changes (sticky and post_title=thread_title are relevant)
 	if (array_key_exists('is_first_post_of_thread',$values) AND $values['is_first_post_of_thread']=='1') {
 		$sql="UPDATE $table_threads SET thread_title='".Database::escape_string($values['post_title'])."',
@@ -2342,8 +2344,8 @@ function store_edit_post($values) {
 	//update_added_resources('forum_post',$values['post_id']);
 
 	$message=get_lang('EditPostStored').'<br />';
-	$message.=get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'">'.get_lang('Forum').'</a><br />';
-	$message.=get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.$values['thread_id'].'&amp;post='.Security::remove_XSS($_GET['post']).'">'.get_lang('Message').'</a>';
+	$message.=get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'">'.get_lang('Forum').'</a><br />';
+	$message.=get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;thread='.$values['thread_id'].'&amp;post='.Security::remove_XSS($_GET['post']).'">'.get_lang('Message').'</a>';
 
 	session_unregister('formelements');
 	session_unregister('origin');
@@ -3009,13 +3011,14 @@ function prepare4display($input='') {
  * @version march 2008, dokeos 1.8.5
  */
 function forum_search() {
+	global $origin;
 	// initiate the object
-	$form = new FormValidator('forumsearch');
+	$form = new FormValidator('forumsearch','post','forumsearch.php?origin='.$origin.'');
 
 	// settting the form elements
 	$form->addElement('header', '', get_lang('ForumSearch'));
 	$form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"');
-	$form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation'), $dissertation[$_GET['opleidingsonderdeelcode']]['code']);
+	$form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation')/*, $dissertation[$_GET['opleidingsonderdeelcode']]['code']*/);
 	$form->addElement('submit', 'SubmitForumCategory', get_lang('Search'));
 
 	// setting the rules
@@ -3042,6 +3045,7 @@ function forum_search() {
  */
 function display_forum_search_results($search_term) {
 	global $table_categories, $table_forums, $table_threads, $table_posts; 
+	global $origin;
 	
 	// defining the search strings as an array
 	if (strstr($search_term,'+')) {
@@ -3086,10 +3090,10 @@ function display_forum_search_results($search_term) {
 		}
 		
 		if ($display_result == true) {
-			$search_results_item = '<li><a href="viewforumcategory.php?forumcategory='.$forum_list[$row['forum_id']]['forum_category'].'&amp;search='.urlencode($search_term).'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
-			$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'&amp;search='.urlencode($search_term).'">'.$forum_list[$row['forum_id']]['forum_title'].'</a> > ';
+			$search_results_item = '<li><a href="viewforumcategory.php?forumcategory='.$forum_list[$row['forum_id']]['forum_category'].'&origin='.$origin.'&amp;search='.urlencode($search_term).'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
+			$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'&amp;origin='.$origin.'&amp;search='.urlencode($search_term).'">'.$forum_list[$row['forum_id']]['forum_title'].'</a> > ';
 			//$search_results_item .= '<a href="">THREAD</a> > ';
-			$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;thread='.$row['thread_id'].'&amp;search='.urlencode($search_term).'">'.$row['post_title'].'</a>';
+			$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;origin='.$origin.'&amp;thread='.$row['thread_id'].'&amp;search='.urlencode($search_term).'">'.$row['post_title'].'</a>';
 			$search_results_item .= '<br />';
 			if (strlen($row['post_title']) > 200 ) {
 				$search_results_item .= substr(strip_tags($row['post_title']),0,200).'...';
@@ -3102,7 +3106,9 @@ function display_forum_search_results($search_term) {
 	}
 	echo '<div class="row"><div class="form_header">'.count($search_results).' '.get_lang('ForumSearchResults').'</div></div>';
 	echo '<ol>';
-	echo implode($search_results);
+	if($search_results)	{
+		echo implode($search_results);
+	}
 	echo '</ol>';
 }
 
@@ -3113,8 +3119,8 @@ function display_forum_search_results($search_term) {
  * @version April 2008, dokeos 1.8.5
  */
 function search_link() {
-	
-	$return = '<a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif', get_lang('Search')).' '.get_lang('Search').'</a>';
+	global $origin;
+	$return = '<a href="forumsearch.php?'.api_get_cidreq().'&action=search&origin='.$origin.'"> '.Display::return_icon('search.gif', get_lang('Search')).' '.get_lang('Search').'</a>';
 	if (!empty($_GET['search'])) {
 		$return .= ': '.Security::remove_XSS($_GET['search']).' ';
 		$url = api_get_self().'?';

+ 13 - 3
main/forum/forumsearch.php

@@ -64,6 +64,11 @@ include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
 include('forumfunction.inc.php');
 include('forumconfig.inc.php');
 
+//are we in a lp ?
+$origin = '';
+if (isset($_GET['origin'])) {
+	$origin =  Security::remove_XSS($_GET['origin']);
+}
 
 // name of the tool
 $nameTools=get_lang('Forum');
@@ -73,7 +78,11 @@ $interbreadcrumb[]=array('url' => 'index.php','name' => $nameTools);
 $interbreadcrumb[]=array('url' => 'forumsearch.php','name' => get_lang('ForumSearch'));
 
 // Display the header
-Display :: display_header($nameTools);
+if ($origin=='learnpath') {
+	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
+} else {
+	Display :: display_header($nameTools);
+}
 
 // Display the tool title
 api_display_tool_title($nameTools);
@@ -88,5 +97,6 @@ event_access_tool(TOOL_FORUM);
 forum_search();
 
 // footer
-Display::display_footer();
-?>
+if ($origin!='learnpath') {
+	Display :: display_footer();
+}

+ 3 - 1
main/forum/newthread.php

@@ -213,4 +213,6 @@ if (!empty($values) and isset($values['SubmitPost'])) {
 		FOOTER
 ==============================================================================
 */
-Display :: display_footer();
+if ($origin!='learnpath') {
+	Display :: display_footer();
+}

+ 2 - 2
main/forum/viewforum.php

@@ -347,7 +347,7 @@ if(is_array($threads)) {
 			}
 			echo "</td>\n";
 			echo "\t\t<td>";			
-			echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($my_forum)."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($my_search))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
+			echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($my_search))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
 			echo "\t\t<td>".$row['thread_replies']."</td>\n";
 			if ($row['user_id']=='0') {
 				$name=prepare4display($row['thread_poster_name']);
@@ -399,7 +399,7 @@ if(is_array($threads)) {
 				}
 			}
 			$icon_liststd = 'group.gif';
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&amp;action=notify&amp;content=thread&amp;id=".$row['thread_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";
+			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&origin=".$origin."&amp;action=notify&amp;content=thread&amp;id=".$row['thread_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";
 			if ($userinf['status']=='1') {
 				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=liststd&amp;content=thread&amp;id='.$row['thread_id'].'">'.icon('../img/'.$icon_liststd,get_lang('StudentList')).'</a>';			
 			}

+ 18 - 5
main/forum/viewforumcategory.php

@@ -93,7 +93,7 @@ if(!api_is_allowed_to_edit(false,true)) {
 */
 $current_forum_category=get_forum_categories($_GET['forumcategory']);
 $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => $nameTools);
-$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => prepare4display($current_forum_category['cat_title']));
+$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => prepare4display($current_forum_category['cat_title']));
 
 
 if (!empty($_GET['action']) && !empty($_GET['content'])) {	  
@@ -102,8 +102,18 @@ if (!empty($_GET['action']) && !empty($_GET['content'])) {
 	}
 }
 
-Display :: display_header(null);
-api_display_tool_title($nameTools);
+//are we in a lp ?
+$origin = '';
+if (isset($_GET['origin'])) {
+	$origin =  Security::remove_XSS($_GET['origin']);
+}
+
+if ($origin=='learnpath') {
+	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
+} else {
+	Display :: display_header(null);
+	api_display_tool_title($nameTools);
+}
 
 /*
 ------------------------------------------------------------------------------------------------------
@@ -307,7 +317,7 @@ if ($action_forums!='add') {
 				} else {
 					$session_displayed = '';
 				}
-				echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:''))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment'])."</td>\n";
+				echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:''))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment'])."</td>\n";
 				
 				//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
 				// the number of topics and posts
@@ -359,4 +369,7 @@ if ($action_forums!='add') {
 		FOOTER
 ==============================================================================
 */
-Display :: display_footer();
+// footer
+if ($origin!='learnpath') {
+	Display :: display_footer();
+}

+ 3 - 1
main/forum/viewthread.php

@@ -96,12 +96,14 @@ if (!empty($_GET['gradebook'])) {
 		);
 }
 $my_search=isset($_GET['search']) ? $_GET['search'] : '';
+
+
 if ($origin=='learnpath') {
 	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
 } else {
 
 	$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($my_search)),"name" => $nameTools);
-	$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum_category['cat_title']));
+	$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum_category['cat_title']));
 	if (isset($_GET['gradebook']) and $_GET['gradebook']=='view') {
 		$info_thread=get_thread_information(Security::remove_XSS($_GET['thread']));
 		$interbreadcrumb[]=array("url" => "viewforum.php?forum=".$info_thread['forum_id']."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum['forum_title']));	

+ 1 - 1
main/forum/viewthread_nested.inc.php

@@ -68,7 +68,7 @@ foreach ($rows as $post) {
 	// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum
 	// The course admin him/herself can do this off course always
 	if (($current_forum['allow_edit']==1 AND $post['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) {
-		echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$post['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
+		echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;origin=".$origin."&amp;post=".$post['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
 	}
 	if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
 		echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=delete&amp;content=post&amp;id=".$post['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n";

+ 3 - 3
main/forum/viewthread_threaded.inc.php

@@ -163,7 +163,7 @@ if ($prev_id<0)
 }
 
 //first message img
-echo '<a title="'.get_lang('FirstMessage').'" href="viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$prev_next_array[0]."\" $class>".$first_page_text."</a>";
+echo '<a title="'.get_lang('FirstMessage').'" href="viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;origin=".$origin."&amp;post=".$prev_next_array[0]."\" $class>".$first_page_text."</a>";
 // prev message link 
 if ($href_prev==1)
 {
@@ -186,7 +186,7 @@ else
 echo '<a href='.$href_next.' '.$class_next.' >'.$next_message.'</a>';
 
 //last message img
-echo '<a title="'.get_lang('LastMessage').'" href="viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$prev_next_array[$max-1]."\" $class>".$last_page_text."</a>";
+echo '<a title="'.get_lang('LastMessage').'" href="viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;origin=".$origin."&amp;post=".$prev_next_array[$max-1]."\" $class>".$last_page_text."</a>";
 
 echo '</center>';
 
@@ -231,7 +231,7 @@ echo $rows[$display_post_id]['post_date'].'<br /><br />';
 // The course admin him/herself can do this off course always
 if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])))
 {
-	echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$rows[$display_post_id]['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
+	echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;origin=".$origin."&amp;post=".$rows[$display_post_id]['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
 }
 if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))
 {