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/albums.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/albums.php')
| -rw-r--r-- | modules/gallery/controllers/albums.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 5f62f798..732a1789 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -168,15 +168,27 @@ class Albums_Controller extends Items_Controller { $form = album::get_edit_form($album); if ($valid = $form->validate()) { - // Make sure that there's not a conflict if ($album->id != 1 && - Database::instance() + $form->edit_item->dirname->value != $album->name || + $form->edit_item->slug->value != $album->slug) { + // Make sure that there's not a conflict + $row = Database::instance() + ->select(array("name", "slug")) ->from("items") ->where("parent_id", $album->parent_id) ->where("id <>", $album->id) + ->open_paren() ->where("name", $form->edit_item->dirname->value) - ->count_records()) { - $form->edit_item->dirname->add_error("conflict", 1); + ->orwhere("slug", $form->edit_item->slug->value) + ->close_paren() + ->get() + ->current(); + if ($row->name == $form->edit_item->dirname->value) { + $form->edit_item->dirname->add_error("name_conflict", 1); + } + if ($row->slug == $form->edit_item->slug->value) { + $form->edit_item->slug->add_error("slug_conflict", 1); + } $valid = false; } } |
