Skip to content

Commit

Permalink
Add path_delete() for WebDAV DELETE requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Aug 29, 2014
1 parent 80cb9dd commit bccd612
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mnemo/docs/CHANGES
Expand Up @@ -2,8 +2,8 @@
v4.3.0-git
----------

[jan] Add put() method to API to support WebDAV PUT requests.
[jan] Add browse() method to API to support WebDAV access.
[jan] Add browse(), put(), and path_delete() methods to API to support WebDAV
access.


------
Expand Down
35 changes: 35 additions & 0 deletions mnemo/lib/Api.php
Expand Up @@ -307,6 +307,41 @@ public function put($path, $content, $content_type)
return array($memo['uid']);
}

/**
* Deletes a file from the Mnemo tree.
*
* @param string $path The path to the file.
*
* @return string The note's UID
* @throws Mnemo_Exception
*/
public function path_delete($path)
{
if (substr($path, 0, 5) == 'mnemo') {
$path = substr($path, 5);
}
$path = trim($path, '/');
$parts = explode('/', $path);

if (count($parts) != 3 ||
!Mnemo::hasPermission($parts[1], Horde_Perms::DELETE)) {

throw new Mnemo_Exception(_("Notepad does not exist or no permission to delete"), 403);
}
$notepadID = $parts[1];

/* Create a Mnemo storage instance. */
try {
$storage = $GLOBALS['injector']
->getInstance('Mnemo_Factory_Driver')
->create($notepadID);
} catch (Mnemo_Exception $e) {
throw new Mnemo_Exception(sprintf(_("Connection failed: %s"), $e->getMessage()), 500);
}

return $storage->delete($parts[2]);
}

/**
* Returns an array of UIDs for all notes that the current user is
* authorized to see.
Expand Down
6 changes: 2 additions & 4 deletions mnemo/package.xml
Expand Up @@ -27,8 +27,7 @@
</stability>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [jan] Add put() method to API to support WebDAV PUT requests.
* [jan] Add browse() method to API to support WebDAV access.
* [jan] Add browse(), put(), and path_delete() methods to API to support WebDAV access.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -1247,8 +1246,7 @@
<date>2014-05-06</date>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [jan] Add put() method to API to support WebDAV PUT requests.
* [jan] Add browse() method to API to support WebDAV access.
* [jan] Add browse(), put(), and path_delete() methods to API to support WebDAV access.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit bccd612

Please sign in to comment.