summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c803cf)
raw | patch | inline | side by side (parent: 6c803cf)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 18 Jan 2006 07:55:10 +0000 (07:55 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 18 Jan 2006 07:55:10 +0000 (07:55 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2513 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_glpi.inc | patch | blob | history | |
plugins/admin/systems/class_glpiAttachmentPool.inc | patch | blob | history |
diff --git a/include/class_glpi.inc b/include/class_glpi.inc
index 67f02d7aff127bfe14c7dee2532f4a20e2d1094a..fc8dd37f64f254ae84703c3da90d846da9fcbec3 100644 (file)
--- a/include/class_glpi.inc
+++ b/include/class_glpi.inc
function getAttachments()
{
+ $ret = array();
if($this->is_connected){
$qry = "SELECT * FROM glpi_docs WHERE name!='';";
- $ret = $this->query($qry);
+ $re = $this->query($qry);
+
+ foreach($re as $entry){
+ $ret[$entry['ID']]=$entry;
+ }
+
return($ret);
}else{
echo "not connected";
$values = preg_replace("/, $/","",$values);
$namen = preg_replace("/, $/","",$namen);
$str .= "(".$namen.") VALUES (".$values.");";
- print $str;
}else{
$str = "UPDATE glpi_docs SET ";
foreach($tmp as $name => $value){
}
}
+
+ /* Check if given attachment id is used in any Device
+ ( - avoid removing of used attachments)
+ */
+ function is_attachmentUsed($id)
+ {
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_doc_device WHERE FK_doc =".$id." LIMIT 1; ";
+ return(count($this->query($qry)));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
/* Monitor handling
*/
diff --git a/plugins/admin/systems/class_glpiAttachmentPool.inc b/plugins/admin/systems/class_glpiAttachmentPool.inc
index 4c7984cf32800256ee8965cc958b6a8e1462798b..2d96528ec12db25488908fdca6083d8920271392 100644 (file)
/* attribute list for save action */
var $ignore_account = TRUE;
- var $attributes = array("name","comment","mime","filename");
+ var $attributes = array("name","comment","mime","filename","date_mod");
var $objectclasses = array("whatever");
var $parent;
var $edit = false;
var $entry = false;
-
+ var $date_mod ="";
var $name ="";
var $comment ="";
var $mime ="";
}
if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
- $this->parent->handle->deleteAttachment($this->delAttach);
- $attach = $this->parent->handle->getAttachments();
+ if($this->parent->handle->is_attachmentUsed($this->delAttach)){
+ print_red(_("Can't delete this attachment, it is still in use."));
+ }else{
+ $this->parent->handle->deleteAttachment($this->delAttach);
+ $attach = $this->parent->handle->getAttachments();
+ }
}
/* Someone tries to upload a file */
/* save attachment*/
if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
if(count($this->check())==0){
+ $this->date_mod = date("Y-m-d H:i:s");
$this->save_entry();
$this->edit= false;
$this->entry = array();