summaryrefslogtreecommitdiff
path: root/classes/Fave.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2010-02-24 20:52:45 -0500
committerCraig Andrews <candrews@integralblue.com>2010-02-24 20:52:45 -0500
commitc187bf55974347f7ddb4f28714af57861dce8f08 (patch)
tree4398b456d88ce79977959b25ba1a0f6fe0c1d77f /classes/Fave.php
parent20d6a7caed6636c28cc7b95c584549691dff4388 (diff)
parent8914b69d5055c1bc7d0604ee338ffdaf6b0a8606 (diff)
Merge branch '0.9.x' into 1.0.x
Conflicts: EVENTS.txt db/statusnet.sql lib/queuemanager.php
Diffstat (limited to 'classes/Fave.php')
-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);