summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-16 04:32:00 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-16 04:32:00 +0000
commit930452aa6b93755003d4ce28143fccb4f23801b0 (patch)
treee0c6c39f70ccd9a04024a32e75fa313852ea8f4c /core/helpers
parent33f1187220404bca6597de5368048316ece5139a (diff)
Support renaming albums, photos and movies.
Fixes ticket #278.
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/album.php8
-rw-r--r--core/helpers/item.php6
-rw-r--r--core/helpers/photo.php4
3 files changed, 15 insertions, 3 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 7c667751..c60527b2 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -76,7 +76,9 @@ class album_Core {
->label(t("Add an album to %album_title", array("album_title" => $parent->title)));
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Description"));
- $group->input("name")->label(t("Directory Name"));
+ $group->input("name")->label(t("Directory Name"))
+ ->callback("item::validate_no_slashes")
+ ->error_messages("no_slashes", t("The directory name can't contain the \"/\" character"));
$group->hidden("type")->value("album");
$group->submit("")->value(t("Create"));
$form->add_rules_from(ORM::factory("item"));
@@ -91,7 +93,9 @@ class album_Core {
$group->input("title")->label(t("Title"))->value($parent->title);
$group->textarea("description")->label(t("Description"))->value($parent->description);
if ($parent->id != 1) {
- $group->dirname->label(t("Directory Name"))->value($parent->name);
+ $group->input("dirname")->label(t("Directory Name"))->value($parent->name)
+ ->callback("item::validate_no_slashes")
+ ->error_messages("no_slashes", t("The directory name can't contain the \"/\" character"));
}
$sort_order = $group->group("sort_order", array("id" => "gAlbumSortOrder"))
diff --git a/core/helpers/item.php b/core/helpers/item.php
index b051bb0e..bd54f2b1 100644
--- a/core/helpers/item.php
+++ b/core/helpers/item.php
@@ -72,4 +72,10 @@ class item_Core {
$album->save();
graphics::generate($album);
}
+
+ static function validate_no_slashes($input) {
+ if (strpos($input->value, "/") !== false) {
+ $input->add_error("no_slashes", 1);
+ }
+ }
} \ No newline at end of file
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index 6467e797..0015bd99 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -129,7 +129,9 @@ class photo_Core {
$group->input("title")->label(t("Title"))->value($photo->title);
$group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("filename")->label(t("Filename"))->value($photo->name)
- ->error_messages("conflict", t("There is already a file with this name"));
+ ->callback("item::validate_no_slashes")
+ ->error_messages("conflict", t("There is already a file with this name"))
+ ->error_messages("no_slashes", t("The directory name can't contain the \"/\" character"));
$group->submit("")->value(t("Modify"));
$form->add_rules_from(ORM::factory("item"));
return $form;