summaryrefslogtreecommitdiff
path: root/classes/Fave.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-03-05 03:56:04 +0000
committerZach Copley <zach@status.net>2010-03-05 03:56:04 +0000
commitb8001ea1079c4c8895fd2323e1e4a47c0d71fde3 (patch)
treeb732b239bf790c78c90f4c7d3be7044ce9f7da45 /classes/Fave.php
parente3c4b0c85d3fbae9604b22d3666fe36a3c1c7551 (diff)
parent064c45890f896f2af8a0231449fa5337bb79c509 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes/Fave.php')
-rw-r--r--classes/Fave.php50
1 files changed, 38 insertions, 12 deletions
diff --git a/classes/Fave.php b/classes/Fave.php
index 8113c8e16..a04f15e9c 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);
@@ -47,7 +77,7 @@ class Fave extends Memcached_DataObject
return $ids;
}
- function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since)
+ function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id)
{
$fav = new Fave();
$qry = null;
@@ -70,10 +100,6 @@ class Fave extends Memcached_DataObject
$qry .= 'AND notice_id <= ' . $max_id . ' ';
}
- if (!is_null($since)) {
- $qry .= 'AND modified > \'' . date('Y-m-d H:i:s', $since) . '\' ';
- }
-
// NOTE: we sort by fave time, not by notice time!
$qry .= 'ORDER BY modified DESC ';