diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-07-16 11:19:34 -0700 | 
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-07-16 11:19:34 -0700 | 
| commit | 5b3b675b6d8a1cd9a5f2b9455c551791e18d88ff (patch) | |
| tree | 239f6042596a5168b9023706c33a0f89ebaf6d1d /modules/gallery/libraries | |
| parent | 2864aceb8117d0644b264ceca4d0f84fd028538f (diff) | |
Non-trivial changes to the event handling code:
1) The item_updated event no longer takes the old and new items.
   Instead we overload ORM to track the original data and make
   that available via the item.  This will allow us to move event
   publishing down into the API methods which in turn will give us
   more stability since we won't require each controller to remember
   to do it.
2) ORM class now tracks the original values.  It doesn't track
   the original relationships (no need for that, yet)
3) Added new events:
     item_deleted
     group_deleted
     user_deleted
Diffstat (limited to 'modules/gallery/libraries')
| -rw-r--r-- | modules/gallery/libraries/MY_ORM.php | 27 | 
1 files changed, 26 insertions, 1 deletions
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 2bd9b4eb..319cbe09 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -18,6 +18,9 @@   * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.   */  class ORM extends ORM_Core { +  // Track the original value of this ORM instance so that we can look it up in ORM::original() +  protected $original = null; +    public function open_paren() {      $this->db->open_paren();      return $this; @@ -30,7 +33,29 @@ class ORM extends ORM_Core {    public function save() {      model_cache::clear($this->object_name, $this->{$this->primary_key}, $this->primary_key); -    return parent::save(); +    $result = parent::save(); +    $this->original = $this->object; +    return $result; +  } + +  public function __set($column, $value) { +    if (!isset($this->original)) { +      $this->original = $this->object; +    } + +    return parent::__set($column, $value); +  } + +  public function __unset($column) { +    if (!isset($this->original)) { +      $this->original = $this->object; +    } + +    return parent::__unset($column); +  } + +  public function original($column) { +    return $this->original[$column];    }  }  | 
