From 7e9c17bd152d328d5ed75468a84c6d6db276bbb6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 1 Jul 2011 21:50:04 -0400 Subject: [PATCH] make the default scope depend on site/private --- README | 5 +++-- classes/Notice.php | 15 ++++++++++++++- lib/default.php | 2 +- scripts/createsim.php | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README b/README index 74ef138a2a..f5a0e27cc5 100644 --- a/README +++ b/README @@ -1496,8 +1496,9 @@ Configuration options specific to notices. contentlimit: max length of the plain-text content of a notice. Default is null, meaning to use the site-wide text limit. 0 means no limit. -defaultscope: default scope for notices. Defaults to 0; set to - 1 to keep notices private to this site by default. +defaultscope: default scope for notices. If null, the default + scope depends on site/private. It's 1 if the site is private, + 0 otherwise. Set this value to override. message ------- diff --git a/classes/Notice.php b/classes/Notice.php index 87363158dd..29824ab700 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -448,7 +448,7 @@ class Notice extends Memcached_DataObject if (!empty($reply)) { $notice->scope = $reply->scope; } else { - $notice->scope = common_config('notice', 'defaultscope'); + $notice->scope = self::defaultScope(); } } else { $notice->scope = $scope; @@ -2469,5 +2469,18 @@ class Notice extends Memcached_DataObject $skip = array('_original', '_profile'); return array_diff($vars, $skip); } + + static function defaultScope() + { + $scope = common_config('notice', 'defaultscope'); + if (is_null($scope)) { + if (common_config('site', 'private')) { + $scope = 1; + } else { + $scope = 0; + } + } + return $scope; + } } diff --git a/lib/default.php b/lib/default.php index 938716b3a4..4a7d6110c5 100644 --- a/lib/default.php +++ b/lib/default.php @@ -288,7 +288,7 @@ $default = 'gc_limit' => 1000), // max sessions to expire at a time 'notice' => array('contentlimit' => null, - 'defaultscope' => 0), // set to 0 for default open + 'defaultscope' => null), // null means 1 if site/private, 0 otherwise 'message' => array('contentlimit' => null), 'location' => diff --git a/scripts/createsim.php b/scripts/createsim.php index 14790aa8f3..e3677e1564 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -72,7 +72,7 @@ function newNotice($i, $tagmax) { global $userprefix; - $options = array('scope' => common_config('notice', 'defaultscope')); + $options = array('scope' => Notice::defaultScope()); $n = rand(0, $i - 1); $user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n)); -- 2.39.5