fixed bug [ 1051483 ] deleting an infolog entry not delete it's attachments.

I also delete empty dirs (after last attachment was deleted).
This commit is contained in:
Ralf Becker 2005-02-09 16:24:17 +00:00
parent 311af5f7b8
commit c427c5d8af

View File

@ -322,6 +322,10 @@
function unlink2($link_id,$app,&$id,$owner='',$app2='',$id2='') function unlink2($link_id,$app,&$id,$owner='',$app2='',$id2='')
{ {
if ($this->debug)
{
echo "<p>bolink::unlink('$link_id','$app','$id','$owner','$app2','$id2')</p>\n";
}
if ($link_id < 0) // vfs-link? if ($link_id < 0) // vfs-link?
{ {
return $this->delete_attached(-$link_id); return $this->delete_attached(-$link_id);
@ -336,6 +340,10 @@
} }
if (!is_array($id)) if (!is_array($id))
{ {
if (!$app2 && !$id2)
{
$this->delete_attached($app,$id); // deleting all attachments
}
return solink::unlink($link_id,$app,$id,$owner,$app2,$id2); return solink::unlink($link_id,$app,$id,$owner,$app2,$id2);
} }
if (isset($id[$link_id])) if (isset($id[$link_id]))
@ -654,14 +662,22 @@
return False; // dont delete more than all attachments of an entry return False; // dont delete more than all attachments of an entry
} }
$vfs_data = $this->vfs_path($app,$id,$fname,RELATIVE_ROOT); $vfs_data = $this->vfs_path($app,$id,$fname,RELATIVE_ROOT);
$Ok = false;
if ($this->vfs->file_exists($vfs_data)) if ($this->vfs->file_exists($vfs_data))
{ {
$this->vfs->override_acl = 1; $this->vfs->override_acl = 1;
$Ok = $this->vfs->delete($vfs_data); $Ok = $this->vfs->delete($vfs_data);
$this->vfs->override_acl = 0; $this->vfs->override_acl = 0;
return $Ok;
} }
return False; // if filename given (and now deleted) check if dir is empty and remove it in that case
if ($fname && !count($this->vfs->ls($vfs_data=$this->vfs_path($app,$id,'',RELATIVE_ROOT))))
{
$this->vfs->override_acl = 1;
$this->vfs->delete($vfs_data);
$this->vfs->override_acl = 0;
}
return $Ok;
} }
/*! /*!