From 1f82de459327870dd58b2e50362390f8ab4d2f1a Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 29 Dec 2013 17:53:24 +0200 Subject: [PATCH] admin model listeners --- ipf/admin/model.php | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/ipf/admin/model.php b/ipf/admin/model.php index 7b76a94..a0c069b 100644 --- a/ipf/admin/model.php +++ b/ipf/admin/model.php @@ -343,6 +343,37 @@ class DateHierarchyListFilter extends BaseListFilter { } } +class IPF_Admin_ModelListener +{ + public function beforeEdit($o) + { + $this->beforeChange($o); + } + + public function beforeAdd($o) + { + $this->beforeChange($o); + } + + public function beforeChange($o) + { + } + + public function afterEdit($o) + { + $this->afterChange($o); + } + + public function afterAdd($o) + { + $this->afterChange($o); + } + + public function afterChange($o) + { + } +} + class IPF_Admin_Model { static $models = array(); @@ -387,6 +418,7 @@ class IPF_Admin_Model var $inlineInstances = array(); var $perPage = 50; public $hidden = false; + public $modelListeners = array(); public function __construct($modelName) { @@ -608,24 +640,33 @@ class IPF_Admin_Model protected function _beforeEdit($o) { + foreach ($this->modelListeners as $l) + $l->beforeEdit($o); $this->_beforeChange($o); } protected function _beforeAdd($o) { + foreach ($this->modelListeners as $l) + $l->beforeAdd($o); $this->_beforeChange($o); } - protected function _beforeChange($o){ + protected function _beforeChange($o) + { } protected function _afterEdit($o) { + foreach ($this->modelListeners as $l) + $l->afterEdit($o); $this->_afterChange($o); } protected function _afterAdd($o) { + foreach ($this->modelListeners as $l) + $l->afterAdd($o); $this->_afterChange($o); } -- 2.49.0