From: Brion Vibber Date: Wed, 2 Mar 2011 01:17:19 +0000 (-0800) Subject: Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0f98457ddb5828bd0f53b8a8cde4ad91cbcaa986;hp=22c2695c222df0d4ccba9919627c0f6e86b07bfd;p=quix0rs-gnu-social.git Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x --- diff --git a/classes/Profile.php b/classes/Profile.php index 5e19605181..eb9299348d 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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; diff --git a/lib/command.php b/lib/command.php index 3fb4d76c75..29aa286d1d 100644 --- a/lib/command.php +++ b/lib/command.php @@ -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); }