Browse Source

Minor - preventing PHP warning/notices

Julio Montoya 12 years ago
parent
commit
b3202bbfab
3 changed files with 37 additions and 33 deletions
  1. 10 9
      main/course_home/course_home.php
  2. 1 2
      main/dropbox/dropbox_init.inc.php
  3. 26 22
      main/inc/lib/thematic.lib.php

+ 10 - 9
main/course_home/course_home.php

@@ -36,8 +36,8 @@ use \ChamiloSession as Session;
 $language_file = array('course_home','courses');
 $use_anonymous = true;
 
-// Inlcuding the global initialization file.
-require dirname(__FILE__).'/../inc/global.inc.php';
+// Including the global initialization file.
+require_once dirname(__FILE__).'/../inc/global.inc.php';
 
 // Delete LP sessions - commented out after seeing that normal
 // users in their first learnpath step (1st SCO of a SCORM)
@@ -72,7 +72,7 @@ $(document).ready(function() {
 			success: function(data) {
 				eval("var info=" + data);
 				new_current_tool_image = info.image;
-				new_current_view       = "'.api_get_path(WEB_IMG_PATH).'" + info.view;
+				new_current_view = "'.api_get_path(WEB_IMG_PATH).'" + info.view;
 				//eyes
 				$("#" + tool_id).attr("src", new_current_view);
 				//tool
@@ -129,7 +129,7 @@ define('TOOL_STUDENT_VIEW',              'toolstudentview');
 define('TOOL_ADMIN_VISIBLE',             'tooladminvisible');
 
 $user_id 		= api_get_user_id();
-$course_code 	= api_get_course_id();
+//$course_code 	= api_get_course_id();
 $show_message = '';
 
 //Deleting group session
@@ -254,9 +254,10 @@ if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_
 	require 'vertical_activity.php';
 }
 $content = '<div id="course_tools">'.$content.'</div>';
-$tpl = new Template(null);
+//$tpl = new Template(null);
+//$tpl->assign('message', $show_message);
+//$tpl->assign('content', $content);
+//$tpl->display_one_col_template();
+Session::erase('_gid');
 
-$tpl->assign('message', $show_message);
-$tpl->assign('content', $content);
-$tpl->display_one_col_template();
-Session::erase('_gid');
+return array('content' => $content, 'message' => $show_message);

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

@@ -51,7 +51,6 @@ require_once 'dropbox_functions.inc.php';
 // protecting the script
 api_protect_course_script();
 
-
 /*	Libraries */
 
 // including the library for the dropbox
@@ -223,7 +222,7 @@ if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_se
  * Prevents access of all users that are not course members
  */
 
-if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(null, true)) {
+if ((!$is_course_member) && !api_is_allowed_to_edit(null, true)) {
 	if ($origin != 'learnpath') {
 		api_not_allowed(true);//print headers/footers
 	} else {

+ 26 - 22
main/inc/lib/thematic.lib.php

@@ -1033,28 +1033,32 @@ class Thematic
 	 * @return	int		Last done thematic advance id
 	 */
 	public function get_last_done_thematic_advance() {
-		$thematic_data          = $this->get_thematic_list();
-		$thematic_advance_data  = $this->get_thematic_advance_list(null, api_get_course_id(), true);
-
-		$a_thematic_advance_ids = array();
-		$last_done_advance_id = 0;
-		if (!empty($thematic_data)) {
-			foreach ($thematic_data as $thematic) {
-				$thematic_id = $thematic['id'];
-				if (!empty($thematic_advance_data[$thematic['id']])) {
-					foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
-						if ($thematic_advance['done_advance'] == 1) {
-							$a_thematic_advance_ids[] = $thematic_advance['id'];
-						}
-					}
-				}
-			}
-		}
-		if (!empty($a_thematic_advance_ids)) {
-			$last_done_advance_id = array_pop($a_thematic_advance_ids);
-			$last_done_advance_id = intval($last_done_advance_id);
-		}
-		return $last_done_advance_id;
+        $courseCode = api_get_course_id();
+
+        if (!empty($courseCode)) {
+            $thematic_data          = $this->get_thematic_list();
+            $thematic_advance_data  = $this->get_thematic_advance_list(null, $courseCode, true);
+
+            $a_thematic_advance_ids = array();
+            $last_done_advance_id = 0;
+            if (!empty($thematic_data)) {
+                foreach ($thematic_data as $thematic) {
+                    $thematic_id = $thematic['id'];
+                    if (!empty($thematic_advance_data[$thematic['id']])) {
+                        foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
+                            if ($thematic_advance['done_advance'] == 1) {
+                                $a_thematic_advance_ids[] = $thematic_advance['id'];
+                            }
+                        }
+                    }
+                }
+            }
+            if (!empty($a_thematic_advance_ids)) {
+                $last_done_advance_id = array_pop($a_thematic_advance_ids);
+                $last_done_advance_id = intval($last_done_advance_id);
+            }
+            return $last_done_advance_id;
+        }
 	}
 
 	/**