summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/photos.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-07 21:09:52 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-07 21:09:52 -0700
commit78a42d9b8397e36bdd2a84e1fd6b4f49f0873b78 (patch)
treee02fcc189e0cc6accce7910e3e7d067b5595499b /modules/gallery/controllers/photos.php
parentf28353f4e1c573a33dc1c3375585ab040f8be2fc (diff)
1. Actually set the slug to the new value in the controllers.
2. Fix up an issue where we were crashing if there were no conflicting rows 3. Amend Item_Model so that if you change the slug, it flushes the cache for all children
Diffstat (limited to 'modules/gallery/controllers/photos.php')
-rw-r--r--modules/gallery/controllers/photos.php36
1 files changed, 19 insertions, 17 deletions
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 159501c0..959097b2 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -67,30 +67,32 @@ class Photos_Controller extends Items_Controller {
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 = 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;
}
- if ($row->slug == $form->edit_item->slug->value) {
- $form->edit_item->slug->add_error("slug_conflict", 1);
- }
- $valid = false;
}
}
if ($valid) {
$photo->title = $form->edit_item->title->value;
$photo->description = $form->edit_item->description->value;
+ $photo->slug = $form->edit_item->slug->value;
$photo->rename($form->edit_item->filename->value);
$photo->save();
module::event("item_edit_form_completed", $photo, $form);