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.