diff --git a/modules/gallery/controllers/move.php b/modules/gallery/controllers/move.php
index f8b85b6fc0..3ce4454664 100644
--- a/modules/gallery/controllers/move.php
+++ b/modules/gallery/controllers/move.php
@@ -34,12 +34,10 @@ public function save($source_id) {
$source = ORM::factory("item", $source_id);
$target = ORM::factory("item", Input::instance()->post("target_id"));
- access::required("view", $source);
- access::required("edit", $source);
- access::required("view", $target);
- access::required("edit", $target);
-
- item::move($source, $target);
+ $message = item::move($source, $target);
+ if (!empty($message)) {
+ message.info($message);
+ }
print json_encode(
array("result" => "success",
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 15bbe97734..6a740de491 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -47,27 +47,28 @@ static function move($source, $target) {
$orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
$orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
$orig_slug = $source->slug;
+ $message = "";
for ($i = 0; $i < 5; $i++) {
try {
$source->save();
if ($orig_name != $source->name) {
switch ($source->type) {
case "album":
- message::info(
+ $message =
t("Album %old_name renamed to %new_name to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
+ array("old_name" => $orig_name, "new_name" => $source->name));
break;
case "photo":
- message::info(
+ $message =
t("Photo %old_name renamed to %new_name to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
+ array("old_name" => $orig_name, "new_name" => $source->name));
break;
case "movie":
- message::info(
+ $message =
t("Movie %old_name renamed to %new_name to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
+ array("old_name" => $orig_name, "new_name" => $source->name));
break;
}
}
@@ -95,6 +96,8 @@ static function move($source, $target) {
if ($target->album_cover_item_id == null) {
item::make_album_cover($source);
}
+
+ return $message;
}
static function make_album_cover($item) {
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index 0839b14477..692d0895e2 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -99,7 +99,7 @@ static function put($request) {
if ($entity = $request->params->entity) {
// Only change fields from a whitelist.
foreach (array("album_cover", "captured", "description",
- "height", "mime_type", "name", "parent", "rand_key", "resize_dirty",
+ "height", "mime_type", "name", "rand_key", "resize_dirty",
"resize_height", "resize_width", "slug", "sort_column", "sort_order",
"thumb_dirty", "thumb_height", "thumb_width", "title", "view_count",
"width") as $key) {
@@ -113,11 +113,6 @@ static function put($request) {
break;
case "parent":
- if (property_exists($entity, "parent")) {
- $parent = rest::resolve($entity->parent);
- access::required("edit", $parent);
- $item->parent_id = $parent->id;
- }
break;
default:
if (property_exists($entity, $key)) {
@@ -125,8 +120,15 @@ static function put($request) {
}
}
}
+
+ // There is an explicit save in item::move
+ if (property_exists($entity, "parent")) {
+ $parent = rest::resolve($entity->parent);
+ item::move($item, $parent);
+ } else {
+ $item->save();
+ }
}
- $item->save();
if (isset($request->params->members) && $item->sort_column == "weight") {
$weight = 0;