summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/photos.php
diff options
context:
space:
mode:
authorroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
committerroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
commitc62d1f440f077ba806b7ff0c6b90ef89c79b2fd3 (patch)
treeb64f05e2a7bd8db7200e3c407904e255826b4cf2 /modules/gallery/controllers/photos.php
parentb96ac1eb81b7ccd5bd050ffab0ca9ce1feec8f4f (diff)
parentcaa2002d7777e0ceb884d4c628650804620ca2b6 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/controllers/photos.php')
-rw-r--r--modules/gallery/controllers/photos.php43
1 files changed, 27 insertions, 16 deletions
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 6a62e859..79ad674a 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -62,37 +62,48 @@ 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_photo->filename->value != $photo->name) {
- // 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
+ if ($row = Database::instance()
+ ->select(array("name", "slug"))
->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);
+ ->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 ($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->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);
- module::event("item_updated", $orig, $photo);
-
- log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
+ log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
message::success(
- t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
+ t("Saved photo %photo_title",
+ array("photo_title" => html::purify($photo->title))));
print json_encode(
- array("result" => "success",
- "location" => url::site("photos/$photo->id")));
+ array("result" => "success"));
} else {
print json_encode(
array("result" => "error",