Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x

* '1.0.x' of gitorious.org:statusnet/mainline:
  force the reply to a notice to have the same scope
This commit is contained in:
Zach Copley 2011-04-04 15:29:53 -07:00
commit 7fb963bb42

View File

@ -342,6 +342,8 @@ class Notice extends Memcached_DataObject
$notice->uri = $uri; $notice->uri = $uri;
$notice->url = $url; $notice->url = $url;
$reply = null;
// Handle repeat case // Handle repeat case
if (isset($repeat_of)) { if (isset($repeat_of)) {
@ -379,18 +381,21 @@ class Notice extends Memcached_DataObject
$notice->repeat_of = $repeat_of; $notice->repeat_of = $repeat_of;
} else { } else {
$notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final); $reply = self::getReplyTo($reply_to, $profile_id, $source, $final);
}
if (!empty($reply)) {
if (!empty($notice->reply_to)) {
$reply = Notice::staticGet('id', $notice->reply_to);
if (!$reply->inScope($profile)) { if (!$reply->inScope($profile)) {
// TRANS: Client error displayed when trying to reply to a notice a the target has no access to. // 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). // 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.'), throw new ClientException(sprintf(_('%1$s has no access to notice %2$d.'),
$profile->nickname, $reply->id), 403); $profile->nickname, $reply->id), 403);
} }
$notice->reply_to = $reply->id;
$notice->conversation = $reply->conversation; $notice->conversation = $reply->conversation;
// Scope set below
}
} }
if (!empty($lat) && !empty($lon)) { if (!empty($lat) && !empty($lon)) {
@ -416,7 +421,11 @@ class Notice extends Memcached_DataObject
} }
if (is_null($scope)) { // 0 is a valid value if (is_null($scope)) { // 0 is a valid value
if (!empty($reply)) {
$notice->scope = $reply->scope;
} else {
$notice->scope = common_config('notice', 'defaultscope'); $notice->scope = common_config('notice', 'defaultscope');
}
} else { } else {
$notice->scope = $scope; $notice->scope = $scope;
} }
@ -1529,7 +1538,7 @@ class Notice extends Memcached_DataObject
if (!empty($reply_to)) { if (!empty($reply_to)) {
$reply_notice = Notice::staticGet('id', $reply_to); $reply_notice = Notice::staticGet('id', $reply_to);
if (!empty($reply_notice)) { if (!empty($reply_notice)) {
return $reply_to; return $reply_notice;
} }
} }
@ -1568,8 +1577,10 @@ class Notice extends Memcached_DataObject
$last = $recipient->getCurrentNotice(); $last = $recipient->getCurrentNotice();
if (!empty($last)) { if (!empty($last)) {
return $last->id; return $last;
} }
return null;
} }
static function maxContent() static function maxContent()