From d503513eca13c9c212d2772e9791744725127a8e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 6 Nov 2010 21:54:28 -0700 Subject: Create item_before_create and item_before_update events, and make Item_Model::data_file public. This allows us to intercept and tweak data files before saving the model which enables the max_size module. --- modules/gallery/models/item.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/gallery/models') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index d16a5dc4..eaf09c9c 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -20,7 +20,7 @@ class Item_Model_Core extends ORM_MPTT { protected $children = "items"; protected $sorting = array(); - protected $data_file = null; + public $data_file = null; public function __construct($id=null) { parent::__construct($id); @@ -320,6 +320,7 @@ class Item_Model_Core extends ORM_MPTT { $this->updated = time(); if (!$this->loaded()) { // Create a new item. + module::event("item_before_create", $this); // Set a weight if it's missing. We don't do this in the constructor because it's not a // simple assignment. @@ -398,6 +399,7 @@ class Item_Model_Core extends ORM_MPTT { module::event("item_created", $this); } else { // Update an existing item + module::event("item_before_update", $item); // If any significant fields have changed, load up a copy of the original item and // keep it around. -- cgit v1.2.3