Browse Source

Using smarty for the course home page + some fixes in SQL queries c_id added

Julio Montoya 13 years ago
parent
commit
773ff63a91

+ 43 - 53
main/course_home/2column.php

@@ -13,7 +13,7 @@
  *	@package chamilo.course_home
  */
 
-require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
+
 
 /*	MAIN CODE */
 
@@ -33,7 +33,7 @@ if (api_is_allowed_to_edit(null, true)) {
 		$msgDestroy = get_lang('DelLk').'<br />';
 		$msgDestroy .= '<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;';
 		$msgDestroy .= '<a href="'.api_get_self().'?destroy=yes&amp;id='.$id.'">'.get_lang('Yes').'</a>';
-		Display :: display_confirmation_message($msgDestroy, false);
+		$show_message .= Display :: return_message($msgDestroy, 'confirmation',false);
 	}
 
 	/*
@@ -47,93 +47,83 @@ if (api_is_allowed_to_edit(null, true)) {
 
   	/*	HIDE */
 
-	elseif ($_GET['hide']) { // visibility 1 -> 0
+	elseif ($_GET['hide']) { // visibility 1 -> 0        
 		Database::query("UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'");
-		Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
+		$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
 	}
 
     /*	REACTIVATE */
 
 	elseif ($_GET["restore"]) { // visibility 0,2 -> 1
 		Database::query("UPDATE $tool_table SET visibility=1  WHERE c_id = $course_id AND id='".$id."'");
-		Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
+		$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
 	}
 }
 
 // Work with data post askable by admin of course
 
+// Work with data post askable by admin of course
 if (api_is_platform_admin()) {
-	// Show message to confirm that a tools must be hide from available tools
+	// Show message to confirm that a tool it to be hidden from available tools
 	// visibility 0,1->2
-	if ($_GET['askDelete']) {
-?>
-			<div id="toolhide">
-			<?php echo get_lang('DelLk'); ?>
-			<br />&nbsp;&nbsp;&nbsp;
-			<a href="<?php echo api_get_self(); ?>"><?php echo get_lang('No'); ?></a>&nbsp;|&nbsp;
-			<a href="<?php echo api_get_self(); ?>?delete=yes&id=<?php echo $id; ?>"><?php echo get_lang('Yes'); ?></a>
-			</div>
-<?php
-	}
-
-	/*
-	 * Process hiding a tools from available tools.
-	 * visibility=2 are only view  by Dokeos Administrator visibility 0,1->2
-	 */
-
-	elseif (isset($_GET['delete']) && $_GET['delete']) {
+	if (!empty($_GET['askDelete'])) {
+        $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
+            <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
+            <a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
+        </div>';
+	} elseif (isset($_GET['delete']) && $_GET['delete']) {
+        /*
+        * Process hiding a tools from available tools.
+        */
+		//where $id is set?
+		$id = intval($id);
 		Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
 	}
 }
 
 /*	TOOLS VISIBLE FOR EVERYBODY */
 
-echo '<div class="everybodyview">';
-echo '<table width="100%">';
-
-CourseHome::show_tool_2column(TOOL_PUBLIC);
-
-echo '</table>';
-echo '</div>';
+$content .=  '<div class="everybodyview">';
+$content .=  '<table width="100%">';
+$content .= CourseHome::show_tool_2column(TOOL_PUBLIC);
+$content .= '</table>';
+$content .= '</div>';
 
 /*	COURSE ADMIN ONLY VIEW */
 
 // Start of tools for CourseAdmins (teachers/tutors)
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	echo "<div class=\"courseadminview\">";
-	echo "<span class=\"viewcaption\">";
-	echo get_lang('CourseAdminOnly');
-	echo "</span>";
-	echo "<table width=\"100%\">";
+	$content .= "<div class=\"courseadminview\">";
+	$content .= "<span class=\"viewcaption\">";
+	$content .= get_lang('CourseAdminOnly');
+	$content .= "</span>";
+	$content .= "<table width=\"100%\">";
 
-	CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
+	$content .= CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
 
 	/*	INACTIVE TOOLS - HIDDEN (GREY) LINKS */
 
-	echo	"<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n",
-			"<tr>\n",
-			"<td colspan=\"4\">\n",
-			"<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n", get_lang('InLnk'), "</font></div>",
-			"</td>\n",
-			"</tr>\n";
+	$content .=	"<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n".
+			"<tr>\n".
+			"<td colspan=\"4\">\n".
+			"<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n".get_lang('InLnk')."</font></div>".
+			"</td>\n".
+			"</tr>";
 
-	CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
+	$content .= CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
 
-	echo	"</table>";
-	echo	"</div> ";
+	$content .=	"</table>";
+	$content .=	"</div> ";
 }
 
 /*	Tools for platform admin only */
 
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-?>
-		<div class="platformadminview">
-		<span class="viewcaption"><?php echo get_lang('PlatformAdminOnly'); ?></span>
+    
+		$content .='<div class="platformadminview">
+		<span class="viewcaption">'.get_lang('PlatformAdminOnly').'</span>
 		<table width="100%">
-<?php
-			CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN);
-?>
+			'.CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN).'
 		</table>
-		</div>
-<?php
+		</div>';
 }

+ 65 - 78
main/course_home/3column.php

@@ -13,15 +13,10 @@
  *	@package chamilo.course_home
  */
 
-require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
-
 $hide = isset($_GET['hide']) && $_GET['hide'] == 'yes' ? 'yes' : null;
 $restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
 $id = isset($_GET['id']) ? intval($_GET['id']) : null;
-
-$TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
 $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
-
 $course_id = api_get_course_int_id();
 
 // WORK with data post askable by admin of course
@@ -103,22 +98,19 @@ elseif ($destroy) {
 
 elseif ($hide) { // visibility 1 -> 0
 	Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
-	Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
+	$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
 }
 
 /*	REACTIVATE */
 
 elseif ($restore) { // visibility 0,2 -> 1
 	Database::query("UPDATE $TBL_ACCUEIL SET visibility=1  WHERE c_id = $course_id AND id=$id");
-	Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
+	$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
 }
-
 /*
  * Editing "apparance" of  a tools  on the course Home Page.
  */
-
 elseif (isset($update) && $update) {
-
 	$result 	= Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
 	$tool		= Database::fetch_array($result);
 	$racine		= $_configuration['root_sys'].'/'.$currentCourseID.'/images/';
@@ -126,46 +118,46 @@ elseif (isset($update) && $update) {
 	$name		= $tool[1];
 	$image		= $tool[3];
 
-	echo "<tr>\n",
-		"<td colspan=\"4\">\n",
-		"<table>\n",
-		"<tr>\n",
-		"<td>\n",
-		"<form method=\"post\" action=\"".api_get_self()."\">\n",
-		"<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
-		"Image : ".Display::return_icon($image)."\n",
-		"</td>\n",
-		"<td>\n",
-		"<select name=\"image\">\n",
-		"<option selected>", $image, "</option>\n";
+	$content .= "<tr>\n".
+		"<td colspan=\"4\">\n".
+		"<table>\n".
+		"<tr>\n".
+		"<td>\n".
+		"<form method=\"post\" action=\"".api_get_self()."\">\n".
+		"<input type=\"hidden\" name=\"id\" value=\"$id\">\n".
+		"Image : ".Display::return_icon($image)."\n".
+		"</td>\n".
+		"<td>\n".
+		"<select name=\"image\">\n".
+		"<option selected>". $image. "</option>\n";
 
 	if ($dir = @opendir($chemin)) {
 		while ($file = readdir($dir)) {
 			if ($file == '..' || $file == '.') {
 				unset($file);
 			}
-			echo "<option>", $file, "</option>\n";
+			$content .= "<option>". $file. "</option>\n";
 		}
 		closedir($dir);
 	}
 
-	echo "</select>\n",
-		"</td>\n",
-		"</tr>\n",
-		"<tr>\n",
-		"<td>", get_lang('NameOfTheLink'), " : </td>\n",
-		"<td><input type=\"text\" name=\"name\" value=\"", $name, "\"></td>\n",
-		"</tr>\n",
-		"<tr>\n",
-		"<td>Lien :</td>\n",
-		"<td><input type=\"text\" name=\"link\" value=\"", $link, "\"></td>\n",
-		"</tr>\n",
-		"<tr>\n",
-		"<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"", get_lang('Ok'), "\"></td>\n",
-		"</tr>\n",
-		"</form>\n",
-		"</table>\n",
-		"</td>\n",
+	$content .= "</select>\n".
+		"</td>\n".
+		"</tr>\n".
+		"<tr>\n".
+		"<td>". get_lang('NameOfTheLink'). " : </td>\n".
+		"<td><input type=\"text\" name=\"name\" value=\"". $name. "\"></td>\n".
+		"</tr>\n".
+		"<tr>\n".
+		"<td>Lien :</td>\n".
+		"<td><input type=\"text\" name=\"link\" value=\"". $link. "\"></td>\n".
+		"</tr>\n".
+		"<tr>\n".
+		"<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"". get_lang('Ok'). "\"></td>\n".
+		"</tr>\n".
+		"</form>\n".
+		"</table>\n".
+		"</td>\n".
 		"</tr>\n";
 	}
 }
@@ -177,21 +169,17 @@ if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach())
 	// Show message to confirm that a tools must be hide  from aivailable tools
 	// visibility 0,1->2
 	if ($askDelete) {
-		echo "<table align=\"center\"><tr>\n",
-			"<td colspan=\"4\">\n",
-			"<br /><br />\n",
-			"<font color=\"#ff0000\">",
-			"&nbsp;&nbsp;&nbsp;",
-			"<strong>",get_lang('DelLk'),"</strong>",
-			"<br />&nbsp;&nbsp;&nbsp;\n",
-			"<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
-			"&nbsp;|&nbsp;\n",
-			"<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
-			"</font>\n",
-			"<br /><br /><br />\n",
-			"</td>\n",
-			"</tr>",
-			"</table>\n";
+		$content .= "<table align=\"center\"><tr><td colspan=\"4\">
+            <br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
+			<br />&nbsp;&nbsp;&nbsp;
+			<a href=\"".api_get_self()."\">".get_lang('No')."</a>
+			&nbsp;|&nbsp;
+			<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
+			</font>
+			<br /><br /><br />
+			</td>
+			</tr>
+			</table>\n";
 	} // if remove
 
 	/*
@@ -204,44 +192,43 @@ if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach())
 	}
 }
 
-echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
+$content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
 
 /*	TOOLS  FOR  EVERYBODY */
 
-echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
-echo "<tr>\n<td colspan=\"6\">";
+$content .= "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
+$content .= "<tr>\n<td colspan=\"6\">";
 
-CourseHome::show_tool_3column('Basic');
-CourseHome::show_tool_3column('External');
+$content .= CourseHome::show_tool_3column('Basic');
+$content .= CourseHome::show_tool_3column('External');
 
-echo "</td>\n</tr>\n";
+$content .= "</td>\n</tr>\n";
 
 
 /*	PROF ONLY VIEW */
 
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
-		"<tr>\n","<td colspan=\"6\">\n",
-		"<font color=\"#F66105\">\n", get_lang('CourseAdminOnly'), "</font>\n",
-		"</td>\n","</tr>\n";
-	echo "<tr>\n<td colspan=\"6\">";
-	CourseHome::show_tool_3column('courseAdmin');
-	echo "</td>\n</tr>\n";
+	$content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
+		"<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
+		</td></tr>\n";
+	$content .= "<tr>\n<td colspan=\"6\">";
+	$content .=CourseHome::show_tool_3column('courseAdmin');
+	$content .= "</td>\n</tr>\n";
 }
 
 
 /*	TOOLS FOR PLATFORM ADMIN ONLY */
 
 if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	echo "<tr>","<td colspan=\"6\">",
-		"<hr noshade size=\"1\" />",
-		"</td>","</tr>\n",
-		"<tr>\n","<td colspan=\"6\">\n",
-		"<font color=\"#F66105\" >", get_lang('PlatformAdminOnly'), "</font>\n",
-		"</td>\n","</tr>\n";
-	echo "<tr>\n<td colspan=\"6\">";
-	CourseHome::show_tool_3column('platformAdmin');
-	echo "</td>\n</tr>\n";
+	$content .=  "<tr>"."<td colspan=\"6\">".
+		"<hr noshade size=\"1\" />".
+		"</td>"."</tr>\n".
+		"<tr>\n"."<td colspan=\"6\">\n".
+		"<font color=\"#F66105\" >". get_lang('PlatformAdminOnly'). "</font>\n".
+		"</td>\n"."</tr>\n";
+	$content .=  "<tr>\n<td colspan=\"6\">";
+	$content .= CourseHome::show_tool_3column('platformAdmin');
+	$content .=  "</td>\n</tr>\n";
 }
 
-echo "</table>\n";
+$content .=  "</table>\n";

+ 55 - 79
main/course_home/activity.php

@@ -13,9 +13,8 @@
  *	@package chamilo.course_home
  */
 
-require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
-
 $id = isset($_GET['id']) ? intval($_GET['id']) : null;
+$course_id = api_get_course_int_id();
 
 //	MAIN CODE
 
@@ -24,13 +23,13 @@ if (api_is_allowed_to_edit(null, true)) {
 	if (!empty($_GET['hide'])) {
 		$sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id=".$id;
 		Database::query($sql);
-		Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
+		$show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
 	} elseif (!empty($_GET['restore'])) {
 		// visibility 0,2 -> 1
 		// REACTIVATE
 		$sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
 		Database::query($sql);
-		Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
+		//$show_message = Display::return_message(get_lang('ToolIsNowVisible'),'confirmation');
 	}
 }
 
@@ -39,17 +38,14 @@ if (api_is_platform_admin()) {
 	// Show message to confirm that a tool it to be hidden from available tools
 	// visibility 0,1->2
 	if (!empty($_GET['askDelete'])) {
-?>
-	<div id="toolhide"><?php echo get_lang('DelLk'); ?><br />&nbsp;&nbsp;&nbsp;
-	<a href="<?php echo api_get_self(); ?>"><?php echo get_lang('No'); ?></a>&nbsp;|&nbsp;
-	<a href="<?php echo api_get_self(); ?>?delete=yes&id=<?php echo Security::remove_XSS($_GET['id']); ?>"><?php echo get_lang('Yes'); ?></a>
-	</div>
-<?php
-	}
-	/*
-	 * Process hiding a tools from available tools.
-	 */
-	elseif (isset($_GET['delete']) && $_GET['delete']) {
+        $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
+            <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
+            <a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
+        </div>';
+	} elseif (isset($_GET['delete']) && $_GET['delete']) {
+        /*
+        * Process hiding a tools from available tools.
+        */
 		//where $id is set?
 		$id = intval($id);
 		Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
@@ -72,90 +68,70 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 	} else {
 		$path_work = '';
 	}
+    
+	$content .=  '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
+		<div class="normal-message" id="id_normal_message" style="display:none">';
+			$content .=  '<img src="'.$server_protocol.$current_host.'/'.$path_work.'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
+			$content .=  get_lang('PleaseStandBy');
 
-?>
-	<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
-		<div class="normal-message" id="id_normal_message" style="display:none">
-<?php
-			echo '<img src="'.$server_protocol.$current_host.'/'.$path_work.'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
-			echo get_lang('PleaseStandBy');
-?>
-		</div>
+		$content .=  '</div>
 		<div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
-	</div>
+	</div>';
+
 
-<?php
 	if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
-?>
-	<div class="courseadminview">
-		<span class="viewcaption"><?php echo get_lang('SessionData'); ?></span>
-		<table class="course_activity_home">
-<?php
-			echo show_session_data($id_session);
-?>
-		</table>
-	</div>
-<?php
+
+        $content .= '<div class="courseadminview">
+            <span class="viewcaption">'.get_lang('SessionData').'</span>
+            <table class="course_activity_home">'.CourseHome::show_session_data($id_session).'
+            </table>
+        </div>';
 	}
-?>
-	<div class="courseadminview">
-		<span class="viewcaption"><?php echo get_lang('Authoring'); ?></span>		
-<?php
-			$my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
-			CourseHome::show_tools_category($my_list);
-?>
-	</div>
-	<div class="courseadminview">
-		<span class="viewcaption"><?php echo get_lang('Interaction'); ?></span>
-<?php
-        $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
-        $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
-        $my_list = array_merge($my_list,$list2);
-        CourseHome::show_tools_category($my_list);
-?>
-	</div>
+
+	$content .= '<div class="courseadminview">
+		<span class="viewcaption">'.get_lang('Authoring').'</span>';
+    $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);    
+	$content .= CourseHome::show_tools_category($my_list).'</div>';
+    
+	$content .= '<div class="courseadminview"><span class="viewcaption">'.get_lang('Interaction').'</span>';
+
+    $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
+    $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
+    $my_list = array_merge($my_list,$list2);
+    $content .= CourseHome::show_tools_category($my_list);
+
+	$content .= '</div>
 	<div class="courseadminview">
-		<span class="viewcaption"><?php echo get_lang('Administration'); ?></span>		
-<?php
+		<span class="viewcaption">'.get_lang('Administration').'</span>';
         $theme = api_get_setting('homepage_view');
         $rows = false;
         if ($theme  == 'activity_big') {
             $rows = 4;
         }
         $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
-        CourseHome::show_tools_category($my_list, $rows);
-?>	
-	</div>
-<?php
+        $content .= CourseHome::show_tools_category($my_list, $rows);
+	$content .=  '</div>';
 } elseif (api_is_coach()) {
 	if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
-?>
-		<div class="courseadminview">
-			<span class="viewcaption"><?php echo get_lang('SessionData'); ?></span>
-			<table class="course_activity_home">
-<?php
-				echo CourseHome::show_session_data($id_session);
-?>
-			</table>
-		</div>
-<?php
+
+		$content .= '<div class="courseadminview">
+			<span class="viewcaption">'.get_lang('SessionData').'</span>
+			<table class="course_activity_home">';
+				$content .= CourseHome::show_session_data($id_session);
+             $content .=  '</table></div>';
 	}
-?>
-		<div class="Authoringview">
-<?php
-				$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
-				CourseHome::show_tools_category($my_list);
-?>
-		</div>
-<?php
 
+    $content .=  '<div class="Authoringview">';
+				$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
+				$content .= CourseHome::show_tools_category($my_list);
+    $content .= '		</div>';
 //	TOOLS AUTHORING
 
 } else {
 	$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
 	if (count($my_list) > 0) {
-        echo '<div class="Authoringview">';
-        CourseHome::show_tools_category($my_list);
-        echo '</div>'; 
+        $content .= '<div class="Authoringview">';
+        $content .= CourseHome::show_tools_category($my_list);
+        $content .= '</div>'; 
 	}
 }

+ 20 - 23
main/course_home/course_home.php

@@ -121,26 +121,23 @@ if (isset($_SESSION['_gid'])) {
 // The section for the tabs
 $this_section = SECTION_COURSES;
 
-// Libraries
-require_once api_get_path(LIBRARY_PATH).'course.lib.php';
-
 /*	Constants */
 
-define('TOOL_PUBLIC', 				'Public');
-define('TOOL_PUBLIC_BUT_HIDDEN', 	'PublicButHide');
-define('TOOL_COURSE_ADMIN', 		'courseAdmin');
-define('TOOL_PLATFORM_ADMIN', 		'platformAdmin');
-define('TOOL_AUTHORING', 			'toolauthoring');
-define('TOOL_INTERACTION',			'toolinteraction');
-define('TOOL_COURSE_PLUGIN',		'toolcourseplugin'); //all plugins that can be enabled in courses
-define('TOOL_ADMIN', 				'tooladmin');
-define('TOOL_ADMIN_PLATFORM', 		'tooladminplatform');
+define('TOOL_PUBLIC',                   'Public');
+define('TOOL_PUBLIC_BUT_HIDDEN',        'PublicButHide');
+define('TOOL_COURSE_ADMIN',             'courseAdmin');
+define('TOOL_PLATFORM_ADMIN',           'platformAdmin');
+define('TOOL_AUTHORING',                'toolauthoring');
+define('TOOL_INTERACTION',              'toolinteraction');
+define('TOOL_COURSE_PLUGIN',            'toolcourseplugin'); //all plugins that can be enabled in courses
+define('TOOL_ADMIN',                    'tooladmin');
+define('TOOL_ADMIN_PLATFORM',           'tooladminplatform');
 
 //define('TOOL_ADMIN_PLATFORM_VISIBLE', 'tooladminplatformvisible');
 //define('TOOL_ADMIN_PLATFORM_INVISIBLE', 'tooladminplatforminvisible');
 //define('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
-define('TOOL_STUDENT_VIEW', 		'toolstudentview');
-define('TOOL_ADMIN_VISIBLE', 		'tooladminvisible');
+define('TOOL_STUDENT_VIEW',              'toolstudentview');
+define('TOOL_ADMIN_VISIBLE',             'tooladminvisible');
 
 
 /*	Virtual course support code	*/
@@ -240,9 +237,6 @@ if (!empty($auto_lunch)) {
     }
 }
 
-Display::display_header(null, 'Home');
-
-
 $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
 
 $temps = time();
@@ -253,10 +247,9 @@ $reqdate = "&reqdate=$temps";
 //display course title for course home page (similar to toolname for tool pages)
 //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
 
-/*	Introduction section
-	(editable by course admins) */
+/*	Introduction section (editable by course admins) */
 
-Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
+$content = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, array(
 		'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
 		'CreateDocumentDir'    => 'document/',
 		'BaseHref'             => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
@@ -267,9 +260,10 @@ Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
 	the setting homepage_view is adjustable through
 	the platform administration section */
     
+require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
 
 if ($show_autolunch_lp_warning) {    
-    Display::display_warning_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'));
+    $show_message = Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'),'warning');
 }
 if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') {
 	require 'activity.php';
@@ -281,6 +275,9 @@ if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_
 	require 'vertical_activity.php';
 }
 
-/*	FOOTER */
 
-Display::display_footer();
+$tpl = new Template($tool_name);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 27 - 29
main/inc/introductionSection.inc.php

@@ -31,6 +31,8 @@ $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
 $intro_editAllowed = $is_allowed_to_edit;
 $session_id = api_get_session_id();
 
+$introduction_section = '';
+
 global $charset;
 $intro_cmdEdit = empty($_GET['intro_cmdEdit']) ? '' : $_GET['intro_cmdEdit'];
 $intro_cmdUpdate = isset($_POST['intro_cmdUpdate']);
@@ -106,7 +108,7 @@ if ($intro_editAllowed) {
 	/* Delete Command */
 	if ($intro_cmdDel) {
 		Database::query("DELETE FROM $TBL_INTRODUCTION WHERE c_id = $course_id AND id='".$moduleId."' AND session_id='".intval($session_id)."'");
-		Display::display_confirmation_message(get_lang('IntroductionTextDeleted'));
+		$introduction_section .= Display::return_message(get_lang('IntroductionTextDeleted'),'confirmation');
 	}
 }
 
@@ -116,7 +118,7 @@ if ($intro_editAllowed) {
 /* Retrieves the module introduction text, if exist */
 
 $sql = "SELECT intro_text FROM $TBL_INTRODUCTION 
-        WHERE c_id = $course_id AND id='".Database::escape_string($moduleId)."' AND session_id='".intval($session_id)."'";
+        WHERE c_id = $course_id AND id='".Database::escape_string($moduleId)."' AND session_id = '".intval($session_id)."'";
 $intro_dbQuery = Database::query($sql);
 if (Database::num_rows($intro_dbQuery) > 0) {
 	$intro_dbResult = Database::fetch_array($intro_dbQuery);
@@ -128,13 +130,10 @@ if (Database::num_rows($intro_dbQuery) > 0) {
 /* Determines the correct display */
 
 if ($intro_cmdEdit || $intro_cmdAdd) {
-
 	$intro_dispDefault = false;
 	$intro_dispForm = true;
 	$intro_dispCommand = false;
-
 } else {
-
 	$intro_dispDefault = true;
 	$intro_dispForm = false;
 
@@ -151,12 +150,11 @@ if ($intro_cmdEdit || $intro_cmdAdd) {
 if ($intro_dispForm) {
 	$default['intro_content'] = $intro_content;
 	$form->setDefaults($default);
-	echo '<div id="courseintro" style="width: 98%">';
-	$form->display();
-	echo '</div>';
+	$introduction_section .= '<div id="courseintro" style="width: 98%">';
+	$introduction_section .= $form->return_form();
+	$introduction_section .= '</div>';
 }
 
-
 $thematic_description_html = '';
 
 if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
@@ -208,6 +206,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 		$thematic_description_html .= '<div>'.$thematic_advance_info['content'].'</div>';
 		$thematic_description_html .= '<div>'.get_lang('DurationInHours').' : '.$thematic_advance_info['duration'].'</div>';
 		$thematic_description_html .= '<br />';
+        
 		if (!empty($thematic_advance_info2)){
 			$thematic_info2 = $thematic->get_thematic_list($thematic_advance_info2['thematic_id']);
 		
@@ -227,44 +226,43 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 	} 
 }
 $style_introduction_section = 'style="margin-left:10%; margin-right:10%;"';
-echo '<div '.$style_introduction_section.'>';
+$introduction_section .= '<div '.$style_introduction_section.'>';
 if ($intro_dispDefault) {
 	//$intro_content = make_clickable($intro_content); // make url in text clickable
 	$intro_content = text_filter($intro_content); // parse [tex] codes
 	if (!empty($intro_content))	{
-		echo "<table align=\"center\"><tr><td>$intro_content</td></tr></table>";
+		$introduction_section .=  "<table align=\"center\"><tr><td>$intro_content</td></tr></table>";
 	}
 }
 
 if ($intro_dispCommand) {    
 	if (empty($intro_content)) {
 		// Displays "Add intro" commands
-		echo "<div id=\"courseintro_empty\">";
+		$introduction_section .=  "<div id=\"courseintro_empty\">";
 		if (!empty ($GLOBALS['_cid'])) {			
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdAdd=1\">";
-			echo Display::return_icon('introduction_add.gif', get_lang('AddIntro')).' ';
-			echo get_lang('AddIntro');
-			
-			echo "</a>";
+			$introduction_section .=  "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdAdd=1\">";
+			$introduction_section .=  Display::return_icon('introduction_add.gif', get_lang('AddIntro')).' ';
+			$introduction_section .=  get_lang('AddIntro');			
+			$introduction_section .=  "</a>";
 		} else {
-			echo "<a href=\"".api_get_self()."?intro_cmdAdd=1\">\n".get_lang('AddIntro')."</a>";
+			$introduction_section .= "<a href=\"".api_get_self()."?intro_cmdAdd=1\">\n".get_lang('AddIntro')."</a>";
 		}
-		echo "</div>";
+		$introduction_section .= "</div>";
 
 	} else {
-
 		// Displays "edit intro && delete intro" commands
-		echo "<div id=\"courseintro_icons\"><p>";
+		$introduction_section .=  "<div id=\"courseintro_icons\"><p>";
 		if (!empty ($GLOBALS['_cid'])) {
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdEdit=1\">".Display::return_icon('edit.png',get_lang('Modify'),'',22)."</a>";			
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'),'',22)."</a>";
+			$introduction_section .=  "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdEdit=1\">".Display::return_icon('edit.png',get_lang('Modify'),'',22)."</a>";			
+			$introduction_section .=  "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'),'',22)."</a>";
 		} else {
-			echo "<a href=\"".api_get_self()."?intro_cmdEdit=1\">".Display::return_icon('edit.png',get_lang('Modify'),'',22)."</a>";			
-			echo "<a href=\"".api_get_self()."?intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'),'',22)."</a>";
+			$introduction_section .=  "<a href=\"".api_get_self()."?intro_cmdEdit=1\">".Display::return_icon('edit.png',get_lang('Modify'),'',22)."</a>";			
+			$introduction_section .=  "<a href=\"".api_get_self()."?intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'),'',22)."</a>";
 		}
-		echo "</p></div>";
+		$introduction_section .=  "</p></div>";
 	}
 }
-echo '</div>';
-echo $thematic_description_html;
-echo '<div class="clear"></div>';
+$introduction_section .=  '</div>';
+$introduction_section .=  $thematic_description_html;
+$introduction_section .=  '<div class="clear"></div>';
+

+ 77 - 82
main/inc/lib/course_home.lib.php

@@ -9,9 +9,7 @@ class CourseHome {
      * Gets the html content to show in the 3 column view
      */
     public static function show_tool_3column($cat) {
-
-        global $_user;
-        $charset = api_get_system_encoding();
+        global $_user;        
         $TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
         $TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
 
@@ -19,14 +17,13 @@ class CourseHome {
         $table = new HTML_Table('width="100%"');
         $all_tools = array();
         
-        $course_id = api_get_course_int_id();
-        
+        $course_id = api_get_course_int_id();        
         
         switch ($cat) {
             case 'Basic' :
-                $condition_display_tools = ' WHERE t.c_id = '.$course_id.' AND  a.link=t.link AND t.position="basic" ';
+                $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND  a.link=t.link AND t.position="basic" ';
                 if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
-                    $condition_display_tools = ' WHERE t.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
+                    $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
                 }
 
                 $sql = "SELECT a.*, t.image img, t.row, t.column  FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
@@ -35,23 +32,23 @@ class CourseHome {
             case 'External' :
                 if (api_is_allowed_to_edit()) {
                     $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
-                            WHERE t.c_id = '.$course_id.' AND ((a.link=t.link AND t.position='external')
+                            WHERE a.c_id = $course_id AND ((a.link=t.link AND t.position='external')
                             OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
                             ORDER BY a.id";
                 } else {
                     $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
-                            WHERE t.c_id = '.$course_id.' AND (a.visibility = 1 AND ((a.link=t.link AND t.position='external')
+                            WHERE a.c_id = $course_id AND (a.visibility = 1 AND ((a.link=t.link AND t.position='external')
                             OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)))
                             ORDER BY a.id";
                 }
                 break;
             case 'courseAdmin' :
                 $sql = "SELECT a.*, t.image img, t.row, t.column  FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
-                        WHERE t.c_id = '.$course_id.' AND admin=1 AND a.link=t.link ORDER BY t.row, t.column";
+                        WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link ORDER BY t.row, t.column";
                 break;
 
             case 'platformAdmin' :
-                $sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE t.c_id = '.$course_id.' AND visibility = 2 ORDER BY id";
+               $sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE c_id = $course_id AND visibility = 2 ORDER BY id";
         }
         $result = Database::query($sql);
 
@@ -190,8 +187,7 @@ class CourseHome {
                             $lnk[] = $link;
                         }
                     }*/
-                }
-                //echo "<div class=courseadmin>";
+                }                
                 if (is_array($lnk)) {
                     foreach ($lnk as & $this_lnk) {
                         if ($tool['adminlink']) {
@@ -212,8 +208,9 @@ class CourseHome {
             $table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
             $cell_number ++;
         }
-        $table->display();
-    } // end function showtools2($cat)
+        return $table->toHtml();
+    } // end
+    
 
     /**
      * Displays the tools of a certain category.
@@ -222,30 +219,32 @@ class CourseHome {
      * @param string $course_tool_category	contains the category of tools to display:
      * "Public", "PublicButHide", "courseAdmin", "claroAdmin"
      */
-    function show_tool_2column($course_tool_category) {
-        $charset = api_get_system_encoding();
+    function show_tool_2column($course_tool_category) {        
+        $html = '';        
         $web_code_path = api_get_path(WEB_CODE_PATH);
         $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
+        
+        $course_id = api_get_course_int_id();
 
         switch ($course_tool_category) {
             case TOOL_PUBLIC:
-                    $condition_display_tools = ' WHERE visibility = 1 ';
+                    $condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 ';
                     if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
-                        $condition_display_tools = ' WHERE visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'") ';
+                        $condition_display_tools = ' WHERE c_id = '.$course_id.' AND (visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) ';
                     }
                     $result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id");
                     $col_link ="##003399";
                     break;
-            case TOOL_PUBLIC_BUT_HIDDEN:
-                    $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=0 AND admin=0 ORDER BY id");
+            case TOOL_PUBLIC_BUT_HIDDEN:                
+                    $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility=0 AND admin=0 ORDER BY id");
                     $col_link ="##808080";
                     break;
             case TOOL_COURSE_ADMIN:
-                    $result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id");
+                    $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND admin=1 AND visibility != 2 ORDER BY id");
                     $col_link ="##003399";
                     break;
-            case TOOL_PLATFORM_ADMIN:
-                    $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id");
+            case TOOL_PLATFORM_ADMIN:                    
+                    $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility = 2  ORDER BY id");
                     $col_link ="##003399";
         }
         $i = 0;
@@ -256,9 +255,7 @@ class CourseHome {
                 $temp_row['image'] = str_replace('.gif', '_na.gif', $temp_row['image']);
             }
             $all_tools_list[] = $temp_row;
-        }
-        
-        $course_id = api_get_course_int_id();
+        }        
 
         // Grabbing all the links that have the property on_homepage set to 1
         $course_link_table 			= Database::get_course_table(TABLE_LINK);
@@ -268,25 +265,22 @@ class CourseHome {
             case TOOL_PUBLIC:
                 $sql_links="SELECT tl.*, tip.visibility
                         FROM $course_link_table tl
-                        LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
-                        WHERE 	tl.c_id = $course_id AND 
-                        		tip.c_id = $course_id AND
-                        		tl.on_homepage='1' AND tip.visibility = 1";
+                        LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
+                        WHERE tl.on_homepage='1' AND tip.visibility = 1";
                 break;
             case TOOL_PUBLIC_BUT_HIDDEN:
                 $sql_links="SELECT tl.*, tip.visibility
                     FROM $course_link_table tl
-                    LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
-                    WHERE 	tl.c_id = $course_id AND 
-                        	tip.c_id = $course_id AND
-                        	tl.on_homepage='1' AND tip.visibility = 0";
+                    LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
+                    WHERE tl.on_homepage='1' AND tip.visibility = 0";
+                
                 break;
             default:
                 $sql_links = null;
                 break;
         }
         if ($sql_links != null) {
-            $properties = array();
+            $properties = array();            
             $result_links = Database::query($sql_links);
             while ($links_row = Database::fetch_array($result_links)) {
                 unset($properties);
@@ -297,8 +291,7 @@ class CourseHome {
                 $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
                 $all_tools_list[] = $properties;
             }
-        }
-
+        }        
         if (isset($all_tools_list)) {
             $lnk = array();
             foreach ($all_tools_list as & $tool) {
@@ -320,7 +313,7 @@ class CourseHome {
                 }
 
                 if (!($i % 2)) {
-                    echo "<tr valign=\"top\">";
+                    $html .= "<tr valign=\"top\">";
                 }
 
                 // NOTE : Table contains only the image file name, not full path
@@ -333,18 +326,18 @@ class CourseHome {
                 $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
 
                 $tool['link'] = $tool['link'];
-                echo '<td width="50%" height="30">';
+                $html .=  '<td width="50%" height="30">';
 
                 if (strpos($tool['name'], 'visio_') !== false) {
-                    echo '<a  '.$class.' href="javascript: void(0);" onclick="javascript: window.open(\'' . htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()) . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '">';
+                    $html .=  '<a  '.$class.' href="javascript: void(0);" onclick="javascript: window.open(\'' . htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()) . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '">';
                 } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
-                    echo '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq() . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '"'.$class.'>';
+                    $html .=  '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq() . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '"'.$class.'>';
                 } else {
-                    echo '<a href="'. htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $tool['target'], '" '.$class.'>';
+                    $html .=  '<a href="'.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$tool['target'].'" '.$class.'>';
                 }
 
                 $tool_name = self::translate_tool_name($tool);
-                echo Display::return_icon($tool['image'], $tool_name),'&nbsp;', $tool_name,'</a>';
+                $html .=  Display::return_icon($tool['image'], $tool_name).'&nbsp;'.$tool_name.'</a>';
 
                 // This part displays the links to hide or remove a tool.
                 // These links are only visible by the course manager.
@@ -369,7 +362,7 @@ class CourseHome {
                         }
                     }
                     if ($tool['adminlink']) {
-                        echo '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
+                        $html .=  '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
                     }
 
                 }
@@ -395,19 +388,19 @@ class CourseHome {
                 if (is_array($lnk)) {
                     foreach ($lnk as & $this_link) {
                         if (!$tool['adminlink']) {
-                            echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
+                            $html .=  '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
                         }
                     }
                 }
                 // Allow editing of invisible homepage links (modified external_module)
                 if ($tool['added_tool'] == 1 && api_is_allowed_to_edit(null, true) && !$tool['visibility']
                         && $tool['image'] != 'scormbuilder.gif' && $tool['image'] != 'scormbuilder_na.gif') {
-                    echo '<a class="nobold" href="'.api_get_path(WEB_CODE_PATH).'external_module/external_module.php?'.api_get_cidreq().'&amp;id='.$tool['id'].'">'.get_lang('Edit').'</a>';
+                    $html .=  '<a class="nobold" href="'.api_get_path(WEB_CODE_PATH).'external_module/external_module.php?'.api_get_cidreq().'&amp;id='.$tool['id'].'">'.get_lang('Edit').'</a>';
                 }
-                echo "</td>";
+                $html .=  "</td>";
 
                 if ($i % 2) {
-                    echo "</tr>";
+                    $html .=  "</tr>";
                 }
 
                 $i++;
@@ -415,8 +408,9 @@ class CourseHome {
         }
 
         if ($i % 2) {
-            echo "<td width=\"50%\">&nbsp;</td></tr>";
+            $html .=  "<td width=\"50%\">&nbsp;</td></tr>";
         }
+        return $html;
     }
 
     /**
@@ -428,8 +422,7 @@ class CourseHome {
      */
 
     public static function get_tools_category($course_tool_category) {
-        global $_user;
-        $web_code_path      = api_get_path(WEB_CODE_PATH);
+        global $_user;        
         $course_tool_table  = Database::get_course_table(TABLE_TOOL_LIST);
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
         $is_platform_admin  = api_is_platform_admin();
@@ -631,8 +624,7 @@ class CourseHome {
                 $all_tools_list = array();
             }
         }
-        $web_code_path      = api_get_path(WEB_CODE_PATH);
-        $course_tool_table  = Database::get_course_table(TABLE_TOOL_LIST);
+        $web_code_path      = api_get_path(WEB_CODE_PATH);        
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
         $is_platform_admin  = api_is_platform_admin();
         
@@ -774,14 +766,16 @@ class CourseHome {
         }
         
         $i = 0;
+        
+        $html = '';
          
         if (!empty($items))    
-        foreach($items as $item) {         
+        foreach($items as $item) {        
             switch($theme) {
                 case 'activity_big':
                     $data = '';                    
                     if ($i == 0) {
-                         echo '<table style="width:100%">';
+                         $html .= '<table style="width:100%">';
                     }
                     $row_per = 33;
                     $mod = 3;                    
@@ -792,65 +786,66 @@ class CourseHome {
                     $mod_result = $mod - 1;
                     
                     if ($i % $mod == 0) {
-                        echo '<tr valign="top">';
+                        $html .=  '<tr valign="top">';
                     }
                                               
-                    echo '<td width="'.$row_per.'%">';
+                    $html .=  '<td width="'.$row_per.'%">';
                         $image = (substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.'))).'.png';
                         $image = Display::tag('center', Display::return_icon($image, $item['name'], array('id'=>'toolimage_'.$item['tool']['id']), 64));
                         //experimental changes nothing serious
                         //$my_icon = api_get_path(WEB_CODE_PATH).'img/icons/64/'.$image;
                         //$image = Display::tag('span', Display::return_icon($image, $item['name'], array('id'=>'toolimage_'.$item['tool']['id'],'style'=>'opacity:0'), 64),array('class'=>'image-wrap','style'=>'background:url('.$my_icon.')'));                        
                         $data .= Display::url($image , $item['url_params']['href'], $item['url_params']);
-                        echo Display::div($data, array('class'=>'big_icon')); //box-image reflection
-						echo Display::tag('center', Display::div($item['visibility'].$item['extra'].$item['link'], array('class'=>'content')));
-                    echo '</td>';
+                        $html .=  Display::div($data, array('class'=>'big_icon')); //box-image reflection
+						$html .=  Display::tag('center', Display::div($item['visibility'].$item['extra'].$item['link'], array('class'=>'content')));
+                    $html .=  '</td>';
                     
                     if ($i % $mod == $mod_result) {
-                        echo '</tr>';
+                        $html .=  '</tr>';
                     }
                     if ($i == count($items) -1) {
-                        echo '</table>';
+                        $html .=  '</table>';
                     }               
                     break;
                 case 'activity':  
                     if ($i == 0) {
-                         echo '<table class="course_activity_home">';
+                         $html .=  '<table class="course_activity_home">';
                     }                    
                     if (!($i % 2)) {
-                        echo '<tr valign="top">';
+                        $html .=   '<tr valign="top">';
                     }                                        
-                    echo '<td width="50%">';
-                        echo $item['extra']; 
-                        echo $item['visibility'];
-                        echo $item['icon'];
-                        echo $item['link'];                        
-                    echo '</td>';                    
+                    $html .=  '<td width="50%">';
+                        $html .=  $item['extra']; 
+                        $html .=  $item['visibility'];
+                        $html .=  $item['icon'];
+                        $html .=  $item['link'];                        
+                    $html .=  '</td>';                    
                     if ($i % 2) {
-                        echo '</tr>';
+                        $html .=  '</tr>';
                     }
                     if ($i == count($items) -1) {
-                        echo '</table>';
+                        $html .=  '</table>';
                     }               
                     break;
                 case 'vertical_activity':
                     if ($i == 0) {
-                        echo '<ul>';
+                        $html .=  '<ul>';
                     }                    
-                    echo '<li>';
-                        echo $item['extra']; 
-                        echo $item['visibility'];
-                        echo $item['icon'];
-                        echo $item['link'];  
-                    echo '</li>';
+                    $html .=  '<li>';
+                        $html .=  $item['extra']; 
+                        $html .=  $item['visibility'];
+                        $html .=  $item['icon'];
+                        $html .=  $item['link'];  
+                    $html .=  '</li>';
                     
                     if ($i == count($items) -1) {
-                        echo '</ul>';
+                        $html .=  '</ul>';
                     }
                     break;    
             }   
             $i++;         
-        }        
+        }
+        return $html;
     }
 
     /**

+ 6 - 0
main/inc/lib/display.lib.php

@@ -41,10 +41,16 @@ class Display {
      * @return html code for adding an introduction
      */
     public static function display_introduction_section($tool, $editor_config = null) {
+        echo self::return_introduction_section($tool, $editor_config);
+    }
+    
+    public static function return_introduction_section($tool, $editor_config = null) {
         $is_allowed_to_edit = api_is_allowed_to_edit();
         $moduleId = $tool;
         if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
+            $introduction_section = null;
             require api_get_path(INCLUDE_PATH).'introductionSection.inc.php';
+            return $introduction_section;
         }
     }