Programmatically adding permission of adding a subpage to a group who has the permission of editing a page
Permalink
I have a huge website with advanced permissions where pages under a given path have permissions given to different group users (one per page) for editing their page content
Now, I want to add for the group the permission to add subpage but didn't find how to do that
here is some of my code:
Note:
As I was unable to find an API solution, I tried to look in the db:
I've seen in the database that the only change is in the table PagePermissionAssignments where an insert is done with
1st column cID which is the pageID
2nd column "15" for pkID (which is "add_subpage")
and a strange 3rd column named paID which I don't understand how it works
Thank you
Now, I want to add for the group the permission to add subpage but didn't find how to do that
here is some of my code:
$list = new \Concrete\Core\Page\PageList(); $list-> filterByPath('/associations'); $pages = $list->getResults(); foreach ($pages as $page) { $title = $page->getCollectionName(); echo $title; // $pk = \Concrete\Core\Permission\Key::PagePermissionKey::getByHandle("edit_page_contents"); $permissions = new Permissions($page); if ($permissions->canEditPageContents()) { echo "<pre>acces: "; print_r($permissions->canEditPageContents()); echo "</pre>"; //uggly and useless informations... I can't find there any informations about the group //my question here: how to find the group who can edit page contents, so that I may give that group the permission of adding page to the current page with sthing like the next line: //$page->assignPermissions($group,array('add_subpage')); }
Note:
As I was unable to find an API solution, I tried to look in the db:
I've seen in the database that the only change is in the table PagePermissionAssignments where an insert is done with
1st column cID which is the pageID
2nd column "15" for pkID (which is "add_subpage")
and a strange 3rd column named paID which I don't understand how it works
Thank you
Have a look below, it creates a folder and a group of users with certain permissions, maybe something from it may be modified to your needs:
Viewing 15 lines of 68 lines. View entire code block.
Thanks Linuxoid!
But I wasn't able to fix...
so I made in a other way, searching if there was a usergroup matching an element of the page
if it may interest anybody here is my code
But I wasn't able to fix...
so I made in a other way, searching if there was a usergroup matching an element of the page
if it may interest anybody here is my code
<?php $nh = Loader::helper('navigation'); $list = new \Concrete\Core\Page\PageList(); $list-> filterByPath('/associations'); $pages = $list->getResults(); foreach ($pages as $page) { if (is_object($page) && !$page->isError()) { $title = $page->getCollectionName(); $url = $nh->getLinkToCollection($page); echo "<a href=\"" .$url ."\" target=\"_blank\">"; echo $title; echo "</a>"; $acronyme=preg_replace("/^.*\((.*)\)/","$1",$title); echo " acronyme: " .$acronyme; $autorise=array("add_subpage");
Viewing 15 lines of 27 lines. View entire code block.