]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Fave.php
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / classes / Fave.php
index 11e876ff19dcc1294aae6ddb8dfda6e7486eda11..a04f15e9c4e63cb1ddc0a0dc606eaa00dc355ccc 100644 (file)
@@ -21,18 +21,48 @@ 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 &pkeyGet($kv)
+    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 ';