summaryrefslogtreecommitdiff
path: root/modules/user/models
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-16 12:29:16 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-16 12:31:40 -0700
commit0f766b149d0cee7af664f2321fddc6f04cda70ac (patch)
tree51d8cd4e26df82955d57eefaa46349568d054126 /modules/user/models
parent43324fd12a23b35707300ff110f207552c3811f1 (diff)
Second non-trivial change to the event code. We now publish model
related events from within the model handling code. The only exception to this currently is item_created which is challenging because we have to save the item using ORM_MPTT::add_to_parent() before the object itself is fully set up. When we get that down to one call to save() we can publish that event from within the model also.
Diffstat (limited to 'modules/user/models')
-rw-r--r--modules/user/models/group.php13
-rw-r--r--modules/user/models/user.php13
2 files changed, 26 insertions, 0 deletions
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index e0724e30..bb3fb58b 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -32,4 +32,17 @@ class Group_Model extends ORM {
parent::delete($id);
module::event("group_deleted", $old);
}
+
+ public function save() {
+ if (!$this->loaded) {
+ $created = 1;
+ }
+ parent::save();
+ if (isset($created)) {
+ module::event("group_created", $this);
+ } else {
+ module::event("group_updated", $this);
+ }
+ return $this;
+ }
} \ No newline at end of file
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index e3260270..0234f186 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -59,4 +59,17 @@ class User_Model extends ORM {
return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s",
md5($this->email), $size, $default ? "&d=" . urlencode($default) : "");
}
+
+ public function save() {
+ if (!$this->loaded) {
+ $created = 1;
+ }
+ parent::save();
+ if (isset($created)) {
+ module::event("user_created", $this);
+ } else {
+ module::event("user_updated", $this);
+ }
+ return $this;
+ }
} \ No newline at end of file