]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
authorBrion Vibber <brion@pobox.com>
Wed, 2 Mar 2011 01:17:19 +0000 (17:17 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 2 Mar 2011 01:17:19 +0000 (17:17 -0800)
classes/Profile.php
lib/command.php

index 5e196051815fc63612da1fe05be18b36aea94b9c..eb9299348d4f386401f72177683fb9316dd6d9d2 100644 (file)
@@ -186,6 +186,10 @@ class Profile extends Memcached_DataObject
         $notice = $this->getNotices(0, 1);
 
         if ($notice->fetch()) {
+            if ($notice instanceof ArrayWrapper) {
+                // hack for things trying to work with single notices
+                return $notice->_items[0];
+            }
             return $notice;
         } else {
             return null;
index 3fb4d76c75f131ff74f245362a646cde59d43086..29aa286d1db0d890950a962f0eb3053db4dceb7b 100644 (file)
@@ -287,6 +287,18 @@ class FavCommand extends Command
     function handle($channel)
     {
         $notice = $this->getNotice($this->other);
+
+        $fave            = new Fave();
+        $fave->user_id   = $this->user->id;
+        $fave->notice_id = $notice->id;
+        $fave->find();
+
+        if ($fave->fetch()) {
+            // TRANS: Error message text shown when a favorite could not be set because it has already been favorited.
+            $channel->error($this->user, _('Could not create favorite: already favorited.'));
+            return;
+        }
+
         $fave = Fave::addNew($this->user->getProfile(), $notice);
 
         if (!$fave) {
@@ -300,7 +312,7 @@ class FavCommand extends Command
 
         $other = User::staticGet('id', $notice->profile_id);
 
-        if ($other && $other->id != $user->id) {
+        if ($other && $other->id != $this->user->id) {
             if ($other->email && $other->emailnotifyfav) {
                 mail_notify_fave($other, $this->user, $notice);
             }