From 50c677ad4c696efed3398b420b40ec92b1c2088e Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Tue, 10 Jan 2012 16:37:55 +0100 Subject: [PATCH] minor - add the c_id field in queries in document.lib.php --- main/inc/lib/document.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 0e23d86b27..0d867d5b51 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -853,6 +853,7 @@ return 'application/octet-stream'; * @todo now only files/folders in a folder get visibility 2, we should rename them too. */ public static function delete_document($_course, $path, $base_work_dir) { + $TABLE_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); @@ -883,7 +884,7 @@ return 'application/octet-stream'; api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'delete', api_get_user_id(), null, null, null, null, $current_session_id); //query to delete from document table - $remove_from_document_sql = "DELETE FROM ".$TABLE_DOCUMENT." WHERE id = ".$row['id']; + $remove_from_document_sql = "DELETE FROM ".$TABLE_DOCUMENT." WHERE c_id = $course_id AND id = ".$row['id']; self::unset_document_as_template($row['id'], $_course, api_get_user_id()); Database::query($remove_from_document_sql); @@ -930,7 +931,7 @@ return 'application/octet-stream'; rename($base_work_dir.$old_item_path, $base_work_dir.$new_item_path); */ self::unset_document_as_template($deleted_items['id'], api_get_course_id(), api_get_user_id()); - $sql = "UPDATE $TABLE_DOCUMENT set path = '".$new_item_path."' WHERE id = ".$deleted_items['id']; + $sql = "UPDATE $TABLE_DOCUMENT set path = '".$new_item_path."' WHERE c_id = $course_id AND id = ".$deleted_items['id']; Database::query($sql); } @@ -962,7 +963,7 @@ return 'application/octet-stream'; $sqlipd = "DELETE FROM $TABLE_ITEMPROPERTY WHERE ref = ".$row['id']." AND tool='".TOOL_DOCUMENT."'"; $resipd = Database::query($sqlipd); self::unset_document_as_template($row['id'],api_get_course_id(), api_get_user_id()); - $sqldd = "DELETE FROM $TABLE_DOCUMENT WHERE id = ".$row['id']; + $sqldd = "DELETE FROM $TABLE_DOCUMENT WHERE c_id = $course_id AND id = ".$row['id']; $resdd = Database::query($sqldd); } }