summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-20 12:03:32 -0500
committerEvan Prodromou <evan@status.net>2010-02-20 12:03:32 -0500
commit36d21fa7162ca94ce100433da53439a67e815ba1 (patch)
tree8b3b80b0bb29a4d56f73c0652d87a0ffda2b962d /classes
parent866b6470629b570b9f817553f85f6d8e801f0d43 (diff)
Add events for favor and disfavor
Added events to core code for when someone favors or disfavors a notice.
Diffstat (limited to 'classes')
-rw-r--r--classes/Fave.php44
1 files changed, 37 insertions, 7 deletions
diff --git a/classes/Fave.php b/classes/Fave.php
index 8113c8e16..0b6eec2bc 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -21,17 +21,47 @@ class Fave extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- static function addNew($user, $notice) {
- $fave = new Fave();
- $fave->user_id = $user->id;
- $fave->notice_id = $notice->id;
- if (!$fave->insert()) {
- common_log_db_error($fave, 'INSERT', __FILE__);
- return false;
+ static function addNew($profile, $notice) {
+
+ $fave = null;
+
+ if (Event::handle('StartFavorNotice', array($profile, $notice, &$fave))) {
+
+ $fave = new Fave();
+
+ $fave->user_id = $profile->id;
+ $fave->notice_id = $notice->id;
+
+ if (!$fave->insert()) {
+ common_log_db_error($fave, 'INSERT', __FILE__);
+ return false;
+ }
+
+ Event::handle('EndFavorNotice', array($profile, $notice));
}
+
return $fave;
}
+ function delete()
+ {
+ $profile = Profile::staticGet('id', $this->user_id);
+ $notice = Notice::staticGet('id', $this->notice_id);
+
+ $result = null;
+
+ if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
+
+ $result = parent::delete();
+
+ if ($result) {
+ Event::handle('EndDisfavorNotice', array($profile, $notice));
+ }
+ }
+
+ return $result;
+ }
+
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave', $kv);