21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1107 Views |
-
Child inherit Parent edit permissions

25 February 2009 at 2:34am
Hello,
Is it possible to set all children to automatically use their parents user permissions. I don't want the users to have to set the permissions every time they create a page or news item.
Thanks in advance.
Liam -
Re: Child inherit Parent edit permissions

25 February 2009 at 5:05am Last edited: 25 February 2009 5:07am
Hi Liam
In 2.3 there is an option on each page to inherit it's parents settings, which you can set to a default using the Defaults array.
In 2.2x you can do this using the OnBeforeWrite function in the Pages model class like so:
function onBeforeWrite() {
//If the page already exists in the database, don't take parent permissions
if (!$this->exists()) {
if($parent = $this->Parent()) {
if($parent->Viewers) $this->Viewers = $parent->Viewers;
if($parent->Editors) $this->Editors = $parent->Editors;
if($parent->ViewersGroup) $this->ViewersGroup = $parent->ViewersGroup;
if($parent->EditorsGroup) $this->EditorsGroup = $parent->EditorsGroup;
}
}parent::onBeforeWrite();
} -
Re: Child inherit Parent edit permissions

25 February 2009 at 5:14am
Ahh, I'm using 2.2.3.
That's why I couldn't find the option!Thanks for the code for 2.2x.
As always a great reply, thanks Aram. -
Re: Child inherit Parent edit permissions

25 February 2009 at 12:31pm
Do you need to call this function somehow or should it just run? I can't seem to get it to work.
Sorry for my noobness. -
Re: Child inherit Parent edit permissions

25 February 2009 at 12:37pm Last edited: 25 February 2009 12:37pm
The function gets run automatically before the page is saved/written.
if you want it to retake the permisions each time you save it then remove the first if() statement so that it will do it for existing pages, otherwise this will only work when creating a new page.
| 1107 Views | ||
|
Page:
1
|
Go to Top |



