Bläddra i källkod

[svn r12519] Fixed breadcrumb so that:
- it shows the learning path name (and points to the current learnpath if clicked)
- it shows the tool name but points the user to the course homepage if the learnpath tool itself is not visible

Yannick Warnier 18 år sedan
förälder
incheckning
3dc103e04e
1 ändrade filer med 33 tillägg och 3 borttagningar
  1. 33 3
      main/newscorm/lp_header.php

+ 33 - 3
main/newscorm/lp_header.php

@@ -17,10 +17,40 @@ if(isset($_SESSION['lpobject'])){
 	$temp = $_SESSION['lpobject'];
 	$_SESSION['oLP'] = unserialize($temp);
 }
-//$nameTools = $_SESSION['oLP']->get_name();
+$path_name = htmlspecialchars($_SESSION['oLP']->get_name());
+$path_id = $_SESSION['oLP']->get_id();
+
+// Check if the learnpaths list should be accessible to the user
+$show_link = true;
+if(!api_is_allowed_to_edit()) //if the user has no edit permission (simple user)
+{
+	$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
+	$result = api_sql_query("SELECT * FROM $course_tool_table WHERE name='learnpath'",__FILE__,__LINE__);
+	if(Database::num_rows($result)>0)
+	{
+		$row = Database::fetch_array($result);
+		if($row['visibility'] == '0') //if the tool is *not* visible
+		{
+			$show_link = false;
+		}
+	}
+	else
+	{
+		$show_link = false;
+	}
+}
+
 $header_hide_main_div = true;
-$interbreadcrumb[]= array ("url"=>"./lp_controller.php?action=list", "name"=> get_lang(ucfirst(TOOL_LEARNPATH)));
-//$interbreadcrumb[]= array ("url"=>"./lp_controller.php?action=view&lp_id=".$_SESSION['oLP']->get_id(), "name"=> $nameTools);
+if($show_link)
+{
+	$interbreadcrumb[]= array ("url"=>"./lp_controller.php?action=list", "name"=> get_lang(ucfirst(TOOL_LEARNPATH)));
+}
+else //if the tool is hidden and the user has no edit permissions, make the breadcrumb link point to the course homepage
+{
+	$web_course_path = api_get_path(WEB_COURSE_PATH);
+	$interbreadcrumb[]= array ("url"=>$web_course_path.$_course['path'].'/index.php', "name"=> get_lang(ucfirst(TOOL_LEARNPATH)));
+}
+$interbreadcrumb[] = array("url"=>"./lp_controller.php?action=view&lp_id=".$path_id,'name'=>$path_name);
 $noPHP_SELF = true;
 Display::display_header($nameTools,"Path", null);
 ?>