Added config option check for disable_profiles and removed linking if it is disabled

This commit is contained in:
zanderwar 2017-11-03 08:32:03 +13:00
parent 54aeb23356
commit 3d8f0941ed
3 changed files with 27 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace SilverStripe\Blog\Model;
use PageController;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Control\RSS\RSSFeed;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataList;
@ -43,6 +44,14 @@ class BlogController extends PageController
'FilterDescription' => 'Text'
];
/**
* If enabled, blog author profiles will be turned off for this site
*
* @config
* @var bool
*/
private static $disable_profiles = false;
/**
* The current Blog Post DataList query.
*
@ -68,10 +77,16 @@ class BlogController extends PageController
/**
* Renders a Blog Member's profile.
*
* @throws HTTPResponse_Exception
*
* @return string
*/
public function profile()
{
if ($this->config()->get('disable_profiles')) {
$this->httpError(404, 'Not Found');
}
$profile = $this->getCurrentProfile();
if (!$profile) {

View File

@ -9,6 +9,7 @@ use SilverStripe\Blog\Model\BlogCategory;
use SilverStripe\Blog\Model\BlogPostFilter;
use SilverStripe\Blog\Model\BlogTag;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\DatetimeField;
use SilverStripe\Forms\HiddenField;
@ -712,6 +713,16 @@ class BlogPost extends Page
return $items;
}
/**
* Checks to see if User Profiles has been disabled via config
*
* @return bool
*/
public function getProfilesDisabled()
{
return Config::inst()->get(BlogController::class, 'disable_profiles');
}
/**
* Sets the label for BlogPost.Title to 'Post Title' (Rather than 'Page name').
*

View File

@ -29,7 +29,7 @@
<% loop $Credits %>
<% if not $First && not $Last %>, <% end_if %>
<% if not $First && $Last %> <%t SilverStripe\\Blog\\Model\\Blog.AND "and" %> <% end_if %>
<% if $URLSegment %>
<% if $URLSegment && not $Up.ProfilesDisabled %>
<a href="$URL">$Name.XML</a>
<% else %>
$Name.XML