}
static public function figureOutScope(Profile $actor, array $groups, $scope=null) {
- if (is_null($scope)) {
- $scope = self::defaultScope();
- }
+ $scope = is_null($scope) ? self::defaultScope() : intval($scope);
// For private streams
try {
$user = $actor->getUser();
// FIXME: We can't do bit comparison with == (Legacy StatusNet thing. Let's keep it for now.)
- if ($user->private_stream && ($scope == Notice::PUBLIC_SCOPE || $scope == Notice::SITE_SCOPE)) {
+ if ($user->private_stream && ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE)) {
$scope |= Notice::FOLLOWER_SCOPE;
}
} catch (NoSuchUserException $e) {
public function isLocal()
{
- return ($this->is_local == Notice::LOCAL_PUBLIC ||
- $this->is_local == Notice::LOCAL_NONPUBLIC);
+ $is_local = intval($this->is_local);
+ return ($is_local === self::LOCAL_PUBLIC || $is_local === self::LOCAL_NONPUBLIC);
+ }
+
+ public function getScope()
+ {
+ return intval($this->scope);
}
public function isRepeat()
protected function _inScope($profile)
{
- if (!is_null($this->scope)) {
- $scope = $this->scope;
- } else {
- $scope = self::defaultScope();
- }
+ $scope = is_null($this->scope) ? self::defaultScope() : $this->getScope();
- if ($scope == 0 && !$this->getProfile()->isPrivateStream()) { // Not scoping, so it is public.
+ if ($scope === 0 && !$this->getProfile()->isPrivateStream()) { // Not scoping, so it is public.
return !$this->isHiddenSpam($profile);
}
function isPrivate()
{
return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
- $this->force_scope == 1);
+ intval($this->force_scope) === 1);
}
public function isLocal()
function handle($notice)
{
$this->plugin->broadcastNotice($notice);
- if ($notice->is_local == Notice::LOCAL_PUBLIC ||
- $notice->is_local == Notice::LOCAL_NONPUBLIC) {
+ if ($notice->isLocal()) {
$this->plugin->publicNotice($notice);
}
return true;
function handle($notice)
{
- if ($this->_isLocal($notice)) {
+ if ($notice->isLocal()) {
return Facebookclient::facebookBroadcastNotice($notice);
}
return true;
}
-
- /**
- * Determine whether the notice was locally created
- *
- * @param Notice $notice the notice
- *
- * @return boolean locality
- */
- function _isLocal($notice)
- {
- return ($notice->is_local == Notice::LOCAL_PUBLIC ||
- $notice->is_local == Notice::LOCAL_NONPUBLIC);
- }
}
*/
function onHandleQueuedNotice(&$notice)
{
- if ($notice->is_local == 1) {
+ if (intval($notice->is_local) === Notice::LOCAL_PUBLIC) {
$request = HTTPClient::start();
function onHandleQueuedNotice($notice)
{
- if ($notice->is_local == 1) {
+ if (intval($notice->is_local) === Notice::LOCAL_PUBLIC) {
// Try to avoid actually mucking with the
// notice content
$c = $notice->content;
// Add to the public timeline
- if ($notice->is_local == Notice::LOCAL_PUBLIC ||
- ($notice->is_local == Notice::REMOTE && !common_config('public', 'localonly'))) {
+ $is_local = intval($notice->is_local);
+ if ($is_local === Notice::LOCAL_PUBLIC ||
+ ($is_local === Notice::REMOTE && !common_config('public', 'localonly'))) {
$paths[] = array('public', null, null);
}
public function onEndShowNoticeOptionItems($nli)
{
// FIXME: Use bitmasks (but be aware that PUBLIC_SCOPE is 0!)
- if ($nli->notice->scope == Notice::PUBLIC_SCOPE ||
- $nli->notice->scope == Notice::SITE_SCOPE) {
+ // Also: AHHH, $scope and $scoped are scarily similar looking.
+ $scope = $nli->notice->getScope();
+ if ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE) {
$scoped = Profile::current();
if ($scoped instanceof Profile &&
$scoped->getID() !== $nli->notice->getProfile()->getID()) {