diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 21:20:36 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 21:20:36 -0800 |
commit | e39c8df19fc0dadcfe65cb8a3ed6529648c6c9cf (patch) | |
tree | 93d84939d2ff6a7272308bba35809d80f8008148 /modules/gallery/models | |
parent | 6aee6cde2519b125a3b1209d3a6cd441b5d3c526 (diff) |
Fix some validation checks to check to see if the original was loaded
before deciding whether or not we changed a value.
Change valid_name to be cascading, not parallel.
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a7f73d0e..58ff86ed 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -782,21 +782,15 @@ class Item_Model extends ORM_MPTT { if (strpos($this->name, "/") !== false) { $v->add_error("name", "no_slashes"); return; - } - - if (rtrim($this->name, ".") !== $this->name) { + } else if (rtrim($this->name, ".") !== $this->name) { $v->add_error("name", "no_trailing_period"); - return; - } - - if ($this->is_movie() || $this->is_photo()) { - if ($this->loaded()) { + } else if ($this->is_movie() || $this->is_photo()) { + if ($this->original()->loaded()) { // Existing items can't change their extension $new_ext = pathinfo($this->name, PATHINFO_EXTENSION); $old_ext = pathinfo($this->original()->name, PATHINFO_EXTENSION); if (strcasecmp($new_ext, $old_ext)) { $v->add_error("name", "illegal_data_file_extension"); - return; } } else { // New items must have an extension @@ -804,9 +798,7 @@ class Item_Model extends ORM_MPTT { $v->add_error("name", "illegal_data_file_extension"); } } - } - - if (db::build() + } else if (db::build() ->from("items") ->where("parent_id", "=", $this->parent_id) ->where("name", "=", $this->name) @@ -908,7 +900,7 @@ class Item_Model extends ORM_MPTT { * This field cannot be changed after it's been set. */ public function read_only(Validation $v, $field) { - if ($this->loaded() && $this->original()->$field != $this->$field) { + if ($this->original()->loaded() && $this->original()->$field != $this->$field) { $v->add_error($field, "read_only"); } } |