Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Permission question


Go to End


699 Views

Avatar
Mackodlak

Community Member, 95 Posts

11 May 2011 at 9:45pm

Edited: 11/05/2011 11:44pm

Hello guys,

have a problem with permission. I am making a new page type. The idea is to be able to add a link every day to sth interesting and calling it "Link of the day" (LOTD). I made a new form for adding links and displaying it and it works fine. Template looks sth like this:

example.ss:

...
<div id="newLOTDForm">
<h2>Unos novog LOTD-a</h2>
$NewLOTDForm
<ul>
<% control getLOTDs %>
<li><a href="$LOTD">$LName</a></li>
<% end_control %>
</ul>
</div>
...

Now I wish that only some ppl can see the part with adding the new link so i wanted to implement permission provider:

<?php
class LOTDPage extends Page implements PermissionProvider {

...

function providePermissions() {
return array("UNOSLOTD" => "Unos LOTD");
}

}

This part works, in SS CMS Security part I can see another checkbox called "Unos LOTD" and aparently it works when I'm logged in... If I'm not logged in (I'm just some visitor) I shouldn't be able to access the form to enter new LOTD so I decided to check it inside "NewLOTDForum" function:

example.php:

...
function NewLOTDForm() {
if(!Permission::check('UNOSLOTD')){
Security::permissionFailure();
exit();
}
...

Well it doesn't work. If I'm not logged in the whole thing breaks and visiting the LOTD link returns blank page. I am doing sth wrong, I know, I thought I would figure it out, but I can't for some time now, pls help.

The idea is to be able to enter new LOTD and edit/delete existing ones. Visitors should only see the list of LOTD's alrdy entered, admins/content should be able to see the form for entering new LOTDs and editing/deleting existing ones.