diff options
Diffstat (limited to 'core/controllers/movies.php')
| -rw-r--r-- | core/controllers/movies.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/core/controllers/movies.php b/core/controllers/movies.php index 3d820506..55bbb0e5 100644 --- a/core/controllers/movies.php +++ b/core/controllers/movies.php @@ -69,13 +69,24 @@ class Movies_Controller extends Items_Controller { access::required("edit", $photo); $form = photo::get_edit_form($photo); - if ($form->validate()) { - // @todo implement changing the name. This is not trivial, we have - // to check for conflicts and rename the album itself, etc. Needs an - // api method. + if ($valid = $form->validate()) { + // Make sure that there's not a conflict + if (Database::instance() + ->from("items") + ->where("parent_id", $photo->parent_id) + ->where("id <>", $photo->id) + ->where("name", $form->edit_photo->filename->value) + ->count_records()) { + $form->edit_photo->filename->add_error("conflict", 1); + $valid = false; + } + } + + if ($valid) { $orig = clone $photo; $photo->title = $form->edit_photo->title->value; $photo->description = $form->edit_photo->description->value; + $photo->rename($form->edit_photo->filename->value); $photo->save(); module::event("item_updated", $orig, $photo); |
