From 87229c84afbda98679146558235bc7212ea404ee Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 6 Feb 2011 12:51:09 +0100 Subject: XML-RPC deleteAttachment now uses media_delete Functionality changes: * deleteAttachment now triggers MEDIA_DELETE_FILE (closes FS#1568) * deletion success msg in mediamanager is correct, even when the ns dir was deleted * media_delete changed quite a bit --- lib/exe/xmlrpc.php | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d40e338b2..945dc3f67 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -674,27 +674,15 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function deleteAttachment($id){ $id = cleanID($id); $auth = auth_quickaclcheck(getNS($id).':*'); - if($auth < AUTH_DELETE) return new IXR_ERROR(1, "You don't have permissions to delete files."); - global $conf; - global $lang; - - // check for references if needed - $mediareferences = array(); - if($conf['refcheck']){ - $mediareferences = ft_mediause($id,$conf['refshow']); - } - - if(!count($mediareferences)){ - $file = mediaFN($id); - if(@unlink($file)){ - addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE); - io_sweepNS($id,'mediadir'); - return 0; - } - //something went wrong - return new IXR_ERROR(1, 'Could not delete file'); - } else { + $res = media_delete($id, $auth); + if ($res & DOKU_MEDIA_DELETED) { + return 0; + } elseif ($res & DOKU_MEDIA_NOT_AUTH) { + return new IXR_ERROR(1, "You don't have permissions to delete files."); + } elseif ($res & DOKU_MEDIA_INUSE) { return new IXR_ERROR(1, 'File is still referenced'); + } else { + return new IXR_ERROR(1, 'Could not delete file'); } } -- cgit v1.2.3