X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FFave.php;h=a04f15e9c4e63cb1ddc0a0dc606eaa00dc355ccc;hb=27bfd1211d64298ee3c3b2d82d7b38ca1e1167ad;hp=8113c8e1668a508251323f117468da25d119f7f6;hpb=fdb64eed2f1d24ad38fe4a6bc680e3592647c0a6;p=quix0rs-gnu-social.git diff --git a/classes/Fave.php b/classes/Fave.php index 8113c8e166..a04f15e9c4 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 ';