From 654b103355f1bda15246e651fa91f3c9e08c3901 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Jan 2010 13:41:46 -0800 Subject: Validate the model type. --- modules/gallery/models/item.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index e929f30d..395ba52c 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -26,7 +26,8 @@ class Item_Model extends ORM_MPTT { "title" => array("rules" => array("length[0,255]", "required")), "slug" => array("rules" => array("length[0,255]", "required")), "description" => array("rules" => array("length[0,65535]")), - "parent_id" => array("rules" => array("Item_Model::valid_parent")) + "parent_id" => array("rules" => array("Item_Model::valid_parent")), + "type" => array("rules" => array("Item_Model::valid_type")), ); /** @@ -736,6 +737,13 @@ class Item_Model extends ORM_MPTT { } } + /** + * Make sure that the type is valid. + */ + static function valid_type($value) { + return in_array($value, array("album", "photo", "movie")); + } + /** * Make sure that the parent id refers to an album. */ -- cgit v1.2.3