17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1712 Views |
-
How to set permissions to a user to see and edit a concrete tree branch?

13 June 2008 at 9:33pm Last edited: 13 June 2008 9:41pm
Hi all:
Supose my tree is:
=>Home
=>Product
=>...
=>News
=====>New1
=====>New2
=====>...
=>About us
I need that a concrete user only can see, edit and create new news.
Ideally, the user should not see the rest of the tree, but if it can see it but no edit it, it will be enough for me.Any ideas?
Thanks in advance.
-
Re: How to set permissions to a user to see and edit a concrete tree branch?

14 June 2008 at 11:06am
AFAIK there currently is no 'cms' way of doing that.
You could however create a special member group in security, code in permissions and change the canEdit, canCreate etc methods in Page.php.
see http://doc.silverstripe.com/doku.php?id=security#security_in_the_cms
I'm not sure if that's the recommended way, but more or less worked for me once... although it feels weird it constantly checks it for every page again and again.. (queries... )
-
Re: How to set permissions to a user to see and edit a concrete tree branch?

16 June 2008 at 10:02pm Last edited: 16 June 2008 10:03pm
Hi dio5:
Thank you for your answer.
I have read the doc in http://doc.silverstripe.com/doku.php?id=security#security_in_the_cms but i don´t understand well how to apply it.
I try to debug my PageType but, when the user cliks on site tree in CMS, my page type controller is not called (the init function is not called).
I have search in the doc and in the forum but i can´t find a sample. Can someone give me a sample of the usage of this?Thanks to all.
-
Re: How to set permissions to a user to see and edit a concrete tree branch?

17 June 2008 at 8:50pm Last edited: 17 June 2008 8:53pm
Hi all:
I finally edited the file sapphire/core/model/SiteTree.php. In the can function I changed the first part like this. (will supose the user mail is "usermail" and the page type is "pagetype"):
function can($perm, $member = null) {
if(!isset($member)) {
$member = Member::currentUser();
}
if($member && $member->isAdmin()) {
if ($member->Email != "usermail")
return true;
}switch(strtolower($perm)) {
case 'edit':
if ($member->Email == "usermail")
{
if ($this->ClassName == "pagetype")
return true;
else
return false;
}
if((Permission::check('CMS_ACCESS_CMSMain') &&
(($this->Editors == 'LoggedInUsers' && $member) ||
($this->Editors == 'OnlyTheseUsers' && $member &&
$member->isInGroup($this->EditorsGroup)))) == false)
return false;
break;
....I don´t know if this is the best way to do it but it works for me.
bye -
Re: How to set permissions to a user to see and edit a concrete tree branch?

19 June 2008 at 1:34am
hi,
I did it by changing the canEdit etc methods in Page.php
something like:
function canEdit()
{
if (Permission::check("NEWSAUTHORS") && !Permission::check("ADMIN"))
{
if($this->class == "News")
{
return true;
}
else
{
return false;
}
}
return true;
}Of course you'll have to create a permission and a group with that permission code first...
-
Re: How to set permissions to a user to see and edit a concrete tree branch?

19 June 2008 at 2:36am
Hi.
I've created a new permission to restrict the access to a especific pagetype.
Now, users that don't have the right (permission) to edit that pagetype are unable to edit it.
What I would like to know is if it's possible to completely restrict the access to that pagetype so users without that permission wouldn't be able to even see the page.Thanks in advance
-
Re: How to set permissions to a user to see and edit a concrete tree branch?

19 June 2008 at 2:41am Last edited: 19 June 2008 2:43am
Don't think that's possible at the moment, as I assume you'll need to mess with getChildrenAsUL or stagechildren() for that deeper in the core...
Might be wrong though.
Please someone fix these line breaks/paragraphs!
| 1712 Views | ||
|
Page:
1
|
Go to Top |



