diff --git a/plugins/SensitiveContent/README.md b/plugins/SensitiveContent/README.md index 9de210d381..1949bd18b9 100644 --- a/plugins/SensitiveContent/README.md +++ b/plugins/SensitiveContent/README.md @@ -19,6 +19,10 @@ if you want to customize the blocker image, add a line to your config.php: $config['site']['sensitivecontent']['blockerimage'] = "/path/to/image.jpg"; +if you want to activate the nsfw overlay for non-logged-in visitors add: + + $config['site']['sensitivecontent']['hideforvisitors'] = true; + ## Usage Individual users must go to their Settings page. A new sidebar menu item "Sensitive Content" diff --git a/plugins/SensitiveContent/SensitiveContentPlugin.php b/plugins/SensitiveContent/SensitiveContentPlugin.php index 70645ba030..36a6285aa5 100644 --- a/plugins/SensitiveContent/SensitiveContentPlugin.php +++ b/plugins/SensitiveContent/SensitiveContentPlugin.php @@ -22,6 +22,7 @@ class SensitiveContentPlugin extends Plugin static function settings($setting) { $settings['blockerimage'] = Plugin::staticPath('SensitiveContent', '').'img/blocker.png'; + $settings['hideforvisitors'] = false; $configphpsettings = common_config('site','sensitivecontent') ?: array(); foreach($configphpsettings as $configphpsetting=>$value) { @@ -146,20 +147,7 @@ EOB; function onStartShowAttachmentRepresentation($out, $file) { - $profile = Profile::current(); - - if (!is_null($profile) && $profile instanceof Profile) - { - $hidesensitive = $this->getHideSensitive($profile); - } - else - { - $hidesensitive = false; - } - - $classes = "sensitive-blocker"; //'sensitive-blocker'; - $thumbnail = null; try { $thumbnail = $file->getThumbnail(); @@ -190,18 +178,12 @@ EOB; function onEndShowScripts(Action $action) { $profile = $action->getScoped(); - if (!is_null($profile) && $profile instanceof Profile) - { - $hidesensitive = $this->getHideSensitive($profile) ? "true" : "false"; - } - else - { - $hidesensitive = "false"; - } + $hidesensitive = $this->getHideSetting($profile); + $hidesensitive_string = $hidesensitive ? "true" : "false"; $inline = <<getHideSetting($profile); - if (!is_null($profile) && $profile instanceof Profile) - { - $hidesensitive = $this->getHideSensitive($profile); - } - else - { - $hidesensitive = false; - } - - - $attrs = array_merge($attrs, + $attrs = array_merge($attrs, array('data-hidesensitive' => ($hidesensitive ? "true" : "false")) ); } + function getHideSetting($profile) { + if (isset($profile) && $profile instanceof Profile) { + return $this->getHideSensitive($profile); + } else { + return static::settings('hideforvisitors'); + } + } function getHideSensitive($profile) { $c = Cache::instance();