summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/photos.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-07 21:01:51 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-07 21:01:51 -0700
commitf28353f4e1c573a33dc1c3375585ab040f8be2fc (patch)
treeaa99bcedc2c7e5725733ca452323a7eb57fc9e8c /modules/gallery/controllers/photos.php
parentdccfce4c00024fa170a060b1c4b1d2bb227964ae (diff)
Add the 'Internet Address' field to all items, along with proper
validation for the fields.
Diffstat (limited to 'modules/gallery/controllers/photos.php')
-rw-r--r--modules/gallery/controllers/photos.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index dd6d3ab5..159501c0 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -62,18 +62,29 @@ class Photos_Controller extends Items_Controller {
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
+ $valid = $form->validate();
if ($valid = $form->validate()) {
- if ($form->edit_item->filename->value != $photo->name) {
- // 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_item->filename->value)
- ->count_records()) {
- $form->edit_item->filename->add_error("conflict", 1);
- $valid = false;
+ 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)
+ ->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;
}
}