فهرست منبع

[svn r10648] add the possibility to delete a photo in Image Manager

Julian Prud'homme 18 سال پیش
والد
کامیت
a448cf1df8

+ 25 - 1
main/inc/lib/fckeditor/editor/plugins/ImageManager/Classes/ImageManager.php

@@ -408,6 +408,28 @@ class ImageManager
 		
 	}
 	
+	function _deletePictureInDatabase($relative){
+		
+		$path = "/images/".substr($relative,1);
+		
+		$dbDocumentTable = Database::get_course_table(TABLE_DOCUMENT);
+		$dbItemPropertyTable = Database::get_course_table(TABLE_ITEM_PROPERTY);
+		
+		//Select the id of the picture to delete
+		$sql="SELECT id FROM ".$dbDocumentTable." WHERE path='".$path."'";
+		$result=api_sql_query($sql);
+		$image_id=mysql_result($result,0,0);
+		
+		//Delete the picture in the documents table
+		$sql="DELETE FROM ".$dbDocumentTable." WHERE id='".$image_id."'";
+		$result=api_sql_query($sql);
+		
+		//Delete the picture in the item_property table
+		$sql="DELETE FROM ".$dbItemPropertyTable." WHERE ref='".$image_id."'";
+		$result=api_sql_query($sql);
+		
+	}
+	
 
 	/**
 	 * Process upload files. The file must be an 
@@ -561,8 +583,10 @@ class ImageManager
 	 */
 	function deleteFiles() 
 	{
-		if(isset($_GET['delf']))
+		if(!empty($_GET['delf'])){
 			$this->_delFile(rawurldecode($_GET['delf']));
+			$this->_deletePictureInDatabase(rawurldecode($_GET['delf']));
+		}
 	}
 
 	/**

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/ImageManager/config.inc.php

@@ -148,7 +148,7 @@ $IMConfig['allow_replace'] = false;
 
   FALSE - No deleting allowed
 */
-$IMConfig['allow_delete'] = false;
+$IMConfig['allow_delete'] = true;
 
 /*
   Possible values: true, false

BIN
main/inc/lib/fckeditor/editor/plugins/ImageManager/icon.gif


+ 2 - 1
main/inc/lib/fckeditor/editor/plugins/ImageManager/images.php

@@ -60,7 +60,8 @@ function drawFiles($list, &$manager)
 		<?php if($IMConfig['allow_delete'] == true) { ?>
 			<a href="images.php?dir=<?php echo $relative; ?>&amp;delf=<?php echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>
 		<?php } ?>
-			<a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a>
+		<!--EDIT IMAGE ; TEMPORALY DELETED-->
+			<!--<a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a>-->
 		<?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?>
 		</td></tr></table></td> 
 	  <?php