mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
FEATURE: make the permissions for viewing better navigator separate from the CMS permissions
This commit is contained in:
parent
8329322693
commit
400dc15f0e
@ -7,4 +7,7 @@ LeftAndMain:
|
||||
- 'betternavigator/javascript/BN.LeftAndMain.Preview.js'
|
||||
ContentController:
|
||||
extensions:
|
||||
- BetterNavigator
|
||||
- BetterNavigator
|
||||
Permission:
|
||||
extensions:
|
||||
- BetterNavigator_Permissions
|
@ -25,7 +25,7 @@ class BetterNavigator extends DataExtension {
|
||||
public function BetterNavigator() {
|
||||
$isDev = Director::isDev();
|
||||
|
||||
if($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
if($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
if($this->owner && $this->owner->dataRecord && $this->owner->dataRecord instanceof SiteTree) {
|
||||
|
||||
//Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
|
||||
@ -50,6 +50,7 @@ class BetterNavigator extends DataExtension {
|
||||
'Stage' => Versioned::current_stage(),
|
||||
'LoginLink' => Config::inst()->get('Security', 'login_url'),
|
||||
'Mode' => Director::get_environment_type(),
|
||||
'CanEdit' => Permission::check('BETTERNAVIGATOR_CANEDIT'),
|
||||
'IsDeveloper' => $isDeveloper
|
||||
));
|
||||
|
||||
@ -62,3 +63,39 @@ class BetterNavigator extends DataExtension {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class BetterNavigator_Permissions extends Extension implements PermissionProvider
|
||||
{
|
||||
/**
|
||||
* Provide permissions for viewing better navigator on the front end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providePermissions()
|
||||
{
|
||||
return array(
|
||||
"BETTERNAVIGATOR_CANEDIT" => array(
|
||||
'name' => 'Show Better Navigator `Edit in CMS` Option',
|
||||
'category' => 'Front End'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function requireDefaultRecords()
|
||||
{
|
||||
$contentGroup = Group::get()->filter('code', 'content-authors')->first();
|
||||
$previousPermissions = Permission::get()->filter('Code', 'BETTERNAVIGATOR_CANEDIT');
|
||||
|
||||
if ($contentGroup && $contentGroup->exists() && !$previousPermissions->count()) {
|
||||
Permission::create(
|
||||
array(
|
||||
'Code' => 'BETTERNAVIGATOR_CANEDIT',
|
||||
'Type' => 1,
|
||||
'GroupID' => $contentGroup->ID
|
||||
)
|
||||
)->write();
|
||||
|
||||
DB::alteration_message('Default Better Navigator permissions created', 'created');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,9 @@
|
||||
<span class="bn-disabled"><span class="bn-icon-view"></span>Deleted from draft site</span>
|
||||
<% end_if %>
|
||||
<% end_if %>
|
||||
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a>
|
||||
|
||||
<% if $CanEdit %>
|
||||
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a>
|
||||
<% end_if %>
|
||||
<% if $Member %>
|
||||
<a href="Security/logout?BackURL=$Link"><span class="bn-icon-user"></span>Log out<% if $Member.FirstName %><span class="light"> ($Member.FirstName)</span><% end_if %></a>
|
||||
<% else %>
|
||||
|
Loading…
Reference in New Issue
Block a user