Permissions

Permalink
Is it possible.. programatically (using PHP) set page, area or block permissions for an individual user and/or group. I have advanced permissions enabled.

Im my App the user fills out a form... my App then creates a new page with core content generated from the information in the form. I am able to create a new page and add specific blocks to specific areas with specified content & settings. what I now want to do is limit access to that page to the superAdmins group only until it's approved.

Is it possible to use the Permissions class to do this as I can't see any way to set permissions in PHP?

JimboJetset
 
MadQuint replied on at Permalink Reply
Hi,

Sounds similar to one of my projects. Well, in the controller, once the page has been programmatically added add the following code:

//$page is the newly created collection object
$pxml->guests['canRead'] = false;
$pxml->registered['canRead'] = false;
$pxml->group[0]['gID'] = ADMIN_GROUP_ID;
$pxml->group[0]['canRead'] = true;
$pxml->group[0]['canWrite'] = true;
$pxml->group[0]['canApproveVersions'] = true;
$pxml->group[0]['canDelete'] = true;
$pxml->group[0]['canAdmin'] = true;
$pxml->user[0]['uID']=$this->getUID();
$pxml->user[0]['canRead'] = true;
$pxml->user[0]['canWrite'] = false; 
$pxml->user[0]['canAdmin'] = false; 
$page->assignPermissionSet($pxml);


At this point you inform the superadmin / admin of the newly inserted page (via email). Admin can then, through sitemap interface, set new permissions for that specific page.

Not sure if you solved this problem already but I'm replying in case someone else comes across this thread with the same needs.

http://www.concrete5.org/community/forums/customizing_c5/programmat...

Cheers