Browse Source

Fixing query in order to view/delete correctly files in the dropbox see #5677

Julio Montoya 12 years ago
parent
commit
b72ed3e90e
2 changed files with 18 additions and 18 deletions
  1. 13 13
      main/dropbox/dropbox_class.inc.php
  2. 5 5
      main/dropbox/index.php

+ 13 - 13
main/dropbox/dropbox_class.inc.php

@@ -374,9 +374,9 @@ class Dropbox_Person
 	/**
 	 * Constructor for recreating the Dropbox_Person object
 	 *
-	 * @param unknown_type $userId
-	 * @param unknown_type $isCourseAdmin
-	 * @param unknown_type $isCourseTutor
+	 * @param int $userId
+	 * @param bool $isCourseAdmin
+	 * @param bool $isCourseTutor
 	 * @return Dropbox_Person
 	 */
 	function Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor) {
@@ -397,28 +397,28 @@ class Dropbox_Person
 		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
 		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
 		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
-        
-		// Find all entries where this person is the recipient
+               
+        // Find all entries where this person is the recipient
 		$sql = "SELECT DISTINCT r.file_id, r.cat_id 
                 FROM $post_tbl r INNER JOIN $person_tbl p 
-                    ON (r.dest_user_id = p.user_id AND r.file_id= p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
+                    ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
                 WHERE
-                    r.dest_user_id = ".intval($this->userId)."
-                    $condition_session ";
+                     p.user_id = ".intval($this->userId)." AND
+                     r.dest_user_id = ".intval($this->userId)." $condition_session ";
         
         $result = Database::query($sql);
 		while ($res = Database::fetch_array($result)) {
 			$temp = new Dropbox_Work($res['file_id']);
 			$temp->category = $res['cat_id'];
 			$this->receivedWork[] = $temp;
-		}
-
+		}        
 		// Find all entries where this person is the sender/uploader
-		$sql = "SELECT f.id
+        $sql = "SELECT DISTINCT f.id
 				FROM $file_tbl f INNER JOIN $person_tbl p
-				ON (f.uploader_id = p.user_id AND f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
+				ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
                 WHERE 
-                    f.uploader_id 	= '".Database::escape_string($this->userId)."'                     
+                    f.uploader_id 	= '".Database::escape_string($this->userId)."' AND 
+                    p.user_id       = '".Database::escape_string($this->userId)."'            
                     $condition_session
                 ";
         $result = Database::query($sql);

+ 5 - 5
main/dropbox/index.php

@@ -427,7 +427,8 @@ if ($action != 'add') {
 		// The content of the sortable table = the received files
 		foreach ($dropbox_person -> receivedWork as $dropbox_file) {
 			$dropbox_file_data = array();
-			if ($view_dropbox_category_received == $dropbox_file->category) { // we only display the files that are in the category that we are in.
+			if ($view_dropbox_category_received == $dropbox_file->category) {
+                // we only display the files that are in the category that we are in.
 				$dropbox_file_data[] = $dropbox_file->id;
 
 				if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
@@ -454,9 +455,9 @@ if ($action != 'add') {
 				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
 									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
 									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
-				//$action_icons='	<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'">'.Display::return_icon('deplacer.gif',get_lang('Move')).'</a>
-				//					<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
+                                    Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+				
 				// This is a hack to have an additional row in a sortable table
 
 				if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
@@ -598,7 +599,6 @@ if ($action != 'add') {
 				//$dropbox_file_data[] = $dropbox_file->author;
 				$receivers_celldata = '';
 
-
 				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
 									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
 									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>