From: Brion Vibber Date: Tue, 29 Mar 2011 23:26:20 +0000 (-0700) Subject: Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=674e3c2a0ef4d91f502974b34c8f58029accced7;hp=-c;p=quix0rs-gnu-social.git Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x Conflicts: actions/apistatusesretweet.php actions/repeat.php classes/Notice.php lib/command.php --- 674e3c2a0ef4d91f502974b34c8f58029accced7 diff --combined classes/Notice.php index 81ccd8d74f,33b54b0cc7..86954e3678 --- a/classes/Notice.php +++ b/classes/Notice.php @@@ -350,31 -350,14 +350,31 @@@ class Notice extends Memcached_DataObje $repeat = Notice::staticGet('id', $repeat_of); - if (!empty($repeat) && - $repeat->scope != Notice::SITE_SCOPE && + if (empty($repeat)) { + throw new ClientException(_('Cannot repeat; original notice is missing or deleted.')); + } + + if ($profile->id == $repeat->profile_id) { + // TRANS: Client error displayed when trying to repeat an own notice. + throw new ClientException(_('You cannot repeat your own notice.')); + } + + if ($repeat->scope != Notice::SITE_SCOPE && $repeat->scope != Notice::PUBLIC_SCOPE) { - // TRANS: Client exception thrown when trying to repeat a private notice. + // TRANS: Client error displayed when trying to repeat a non-public notice. throw new ClientException(_('Cannot repeat a private notice.'), 403); } - // XXX: Check for access...? + if (!$repeat->inScope($profile)) { + // The generic checks above should cover this, but let's be sure! + // TRANS: Client error displayed when trying to repeat a notice you cannot access. + throw new ClientException(_('Cannot repeat a notice you cannot read.'), 403); + } + + if ($profile->hasRepeated($repeat->id)) { + // TRANS: Client error displayed when trying to repeat an already repeated notice. + throw new ClientException(_('You already repeated that notice.')); + } $notice->repeat_of = $repeat_of; } else { @@@ -384,7 -367,9 +384,9 @@@ if (!empty($notice->reply_to)) { $reply = Notice::staticGet('id', $notice->reply_to); if (!$reply->inScope($profile)) { - throw new ClientException(sprintf(_("%s has no access to notice %d"), + // TRANS: Client error displayed when trying to reply to a notice a the target has no access to. + // TRANS: %1$s is a user nickname, %2$d is a notice ID (number). + throw new ClientException(sprintf(_('%1$s has no access to notice %2$d.'), $profile->nickname, $reply->id), 403); } $notice->conversation = $reply->conversation; @@@ -1585,15 -1570,6 +1587,15 @@@ return $location; } + /** + * Convenience function for posting a repeat of an existing message. + * + * @param int $repeater_id: profile ID of user doing the repeat + * @param string $source: posting source key, eg 'web', 'api', etc + * @return Notice + * + * @throws Exception on failure or permission problems + */ function repeat($repeater_id, $source) { $author = Profile::staticGet('id', $this->profile_id); @@@ -2090,7 -2066,6 +2092,6 @@@ * * @return boolean whether the profile is in the notice's scope */ - function inScope($profile) { // If there's no scope, anyone (even anon) is in scope.