Jelajahi Sumber

Fixing calls of api_get_item_property_info() using int id instead of the code string

Julio Montoya 13 tahun lalu
induk
melakukan
baf8f34a9f

+ 5 - 5
main/inc/lib/main_api.lib.php

@@ -948,14 +948,14 @@ function api_get_course_id() {
  * Returns the current course id (integer)
  */
 function api_get_real_course_id() {
-    return $GLOBALS['_real_cid'];
+    return isset($_SESSION['_real_cid']) ? intval($_SESSION['_real_cid']) : 0;
 }
 
 /**
  * Returns the current course id (integer)
  */
-function api_get_course_int_id() {
-    return $GLOBALS['_real_cid'];
+function api_get_course_int_id() {	
+    return isset($_SESSION['_real_cid']) ? intval($_SESSION['_real_cid']) : 0;
 }
 
 
@@ -1123,6 +1123,7 @@ function api_get_course_info_by_id($id = null) {
             $_course['sysCode'      ]         = $course_data['code'           ]; // Use as key in db.
             $_course['path'         ]         = $course_data['directory'      ]; // Use as key in path.
             $_course['dbName'       ]         = $course_data['db_name'        ]; // Use as key in db list.
+            $_course['db_name'      ]         = $course_data['db_name'         ];
             $_course['dbNameGlu'    ]         = $_configuration['table_prefix'] . $course_data['db_name'] . $_configuration['db_glue']; // Use in all queries.
             $_course['titular'      ]         = $course_data['tutor_name'     ];
             $_course['language'     ]         = $course_data['course_language'];
@@ -1135,8 +1136,7 @@ function api_get_course_info_by_id($id = null) {
             $_course['subscribe_allowed']     = $course_data['subscribe'       ];
             $_course['unubscribe_allowed']    = $course_data['unsubscribe'     ];
 
-            $_course['real_id'      ]         = $course_data['id'              ];
-            $_course['db_name'      ]         = $course_data['db_name'         ];
+            $_course['real_id'      ]         = $course_data['id'              ];            
             $_course['title'        ]         = $course_data['title'           ];
 
         }

+ 2 - 2
main/inc/lib/thematic.lib.php

@@ -708,7 +708,7 @@ class Thematic
             $thematic_plan_id = $row_thematic_plan['id'];
             
             //Checking the session
-            $thematic_plan_data = api_get_item_property_info(api_get_course_id(), 'thematic_plan', $thematic_plan_id);
+            $thematic_plan_data = api_get_item_property_info(api_get_course_int_id(), 'thematic_plan', $thematic_plan_id);
             
             $update = false;            
             if (in_array($thematic_plan_id, $elements_to_show)) {
@@ -845,7 +845,7 @@ class Thematic
 				if (!empty($thematic_advance_data[$thematic['id']])) {
 					foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
 						
-						$item_info = api_get_item_property_info(api_get_course_id(), 'thematic_advance', $thematic_advance['id']);
+						$item_info = api_get_item_property_info(api_get_course_int_id(), 'thematic_advance', $thematic_advance['id']);
 						//var_dump($item_info );
 						
 												

+ 2 - 2
main/work/work.lib.php

@@ -846,7 +846,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 
 			if ($origin != 'learnpath') {
 				if ($is_allowed_to_edit) {
-					$action .= '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&curdirpath='.$my_sub_dir.'&origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$mydir.'">'.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).'</a>';						
+					$action .= '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&curdirpath='.$my_sub_dir.'&origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$mydir.'">'.Display::return_icon('edit.png', get_lang('Modify'), array(), 22).'</a>';						
 					$action .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'&delete_dir='.$mydir.'&delete2='.$id2.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('DirDelete').'"  >'.Display::return_icon('delete.png',get_lang('DirDelete'),'',22).'</a>';
 					$row[] = $action;
 				} else {
@@ -868,7 +868,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 		while ($work = Database::fetch_object($sql_result)) {
 			//Get the author ID for that document from the item_property table
 			$is_author = false;						
-			$item_property_data = api_get_item_property_info(api_get_course_id(), 'work', $work->id);
+			$item_property_data = api_get_item_property_info(api_get_course_int_id(), 'work', $work->id);
 			if (!$is_allowed_to_edit && $item_property_data['insert_user_id'] == api_get_user_id()) {
 				$is_author = true;
 			}

+ 2 - 2
main/work/work.php

@@ -822,7 +822,7 @@ else {
 $error_message = '';
 $user_id = api_get_user_id();
 
-if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
+if (isset($_POST['sec_token']) && $ctok == $_POST['sec_token']) { //check the token inserted into the form
 	if (!empty($_POST['submitWork']) && !empty($is_course_member)) {
 		if (!empty($_FILES['file']['size'])) {
 			$updir = $currentCourseRepositorySys . 'work/'; //directory path to upload
@@ -946,7 +946,7 @@ if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
 			//Get the author ID for that document from the item_property table
 			$is_author = false;
 			$item_to_edit_id = intval($_POST['item_to_edit']);
-			$item_to_edit_data = api_get_item_property_info(api_get_course_id(), 'work', $item_to_edit_id);
+			$item_to_edit_data = api_get_item_property_info(api_get_course_int_id(), 'work', $item_to_edit_id);
 			
 			if ($is_allowed_to_edit) {
 				$is_author = true;