diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-09-07 21:01:51 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-09-07 21:01:51 -0700 |
commit | f28353f4e1c573a33dc1c3375585ab040f8be2fc (patch) | |
tree | aa99bcedc2c7e5725733ca452323a7eb57fc9e8c /modules/gallery/controllers/movies.php | |
parent | dccfce4c00024fa170a060b1c4b1d2bb227964ae (diff) |
Add the 'Internet Address' field to all items, along with proper
validation for the fields.
Diffstat (limited to 'modules/gallery/controllers/movies.php')
-rw-r--r-- | modules/gallery/controllers/movies.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index c40cde9e..2ba6bb5b 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -72,14 +72,26 @@ class Movies_Controller extends Items_Controller { $form = photo::get_edit_form($photo); if ($valid = $form->validate()) { - // Make sure that there's not a conflict - if (Database::instance() + if ($form->edit_item->filename->value != $photo->name || + $form->edit_item->slug->value != $photo->slug) { + // Make sure that there's not a name or slug conflict + $row = Database::instance() + ->select(array("name", "slug")) ->from("items") ->where("parent_id", $photo->parent_id) ->where("id <>", $photo->id) + ->open_paren() ->where("name", $form->edit_item->filename->value) - ->count_records()) { - $form->edit_item->filename->add_error("conflict", 1); + ->orwhere("slug", $form->edit_item->slug->value) + ->close_paren() + ->get() + ->current(); + if ($row->name == $form->edit_item->filename->value) { + $form->edit_item->filename->add_error("name_conflict", 1); + } + if ($row->slug == $form->edit_item->slug->value) { + $form->edit_item->slug->add_error("slug_conflict", 1); + } $valid = false; } } |