summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-12-09 16:04:08 -0800
committerTim Almdal <tnalmdal@shaw.ca>2009-12-09 16:04:08 -0800
commitd521faf63d6fcca13445a3bd89387b3a6dc591d4 (patch)
tree4401496b9deea6155d847a4d920b981abf1d46fb /modules/gallery/helpers
parentdfc556e8a6e2c0636a93d87bc0cdb0f85f588fd4 (diff)
Add the REST delete processing for albums/photos/movies
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_rest.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_rest.php b/modules/gallery/helpers/gallery_rest.php
index 82d1bb5b..8b209bae 100644
--- a/modules/gallery/helpers/gallery_rest.php
+++ b/modules/gallery/helpers/gallery_rest.php
@@ -97,6 +97,40 @@ class gallery_rest_Core {
return rest::success();
}
+ static function delete($request) {
+ if (empty($request->path)) {
+ return rest::invalid_request();
+ }
+
+ $item = ORM::factory("item")
+ ->where("relative_url_cache", $request->path)
+ ->viewable()
+ ->find();
+
+ if (!$item->loaded) {
+ return rest::success();
+ }
+
+ if (!access::can("edit", $item)) {
+ return rest::not_found("Resource: {$request->path} permission denied.");
+ }
+
+ if ($item->id == 1) {
+ return rest::invalid_request("Attempt to delete the root album");
+ }
+
+ $item->delete();
+
+ if ($item->is_album()) {
+ $msg = t("Deleted album <b>%title</b>", array("title" => html::purify($item->title)));
+ } else {
+ $msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
+ }
+ log::success("content", $msg);
+
+ return rest::success();
+ }
+
private static function _get_children($item, $request) {
$children = array();
$limit = empty($request->limit) ? null : $request->limit;