Area Advanced Permissions

Permalink
I would like to setup area permissions on a newly created page.
I cannot figure out how to programmatically add area permissions.
I would also like to choose the block types that the page owner can add.
How can I achieve this?

I am creating my page like this:
$parentPage = Page::getByPath("/artisans");
$data = array('uID' => $u->uID,'name' => $u->uName,'cHandle' => $u->uID,'cDescription' => $u->uName);
$pt = CollectionType::getByHandle("page_member_profile");$newPage = $parentPage->add($pt,$data);


I am adding Page permissions like this:
$permissionsConfig = new stdClass;
$permissionsConfig->user[0]['uID'] = $u->getUserID();
$permissionsConfig->user[0]['canRead'] = 1;
$permissionsConfig->user[0]['canWrite'] = 1;
$permissionsConfig->user[0]['canApproveVersions'] = true;
$permissionsConfig->user[0]['canDelete'] = true;
$permissionsConfig->user[0]['canAdmin'] = false;
$newPage->assignPermissionSet($permissionsConfig);


Trying to add block types to the allowed list of addBlockTypes
$aa = Area::get($newPage, 'Main');
$ap = new Permissions($aa);
$cabt = array(15,16,24);
$ap->addBlockTypes = $cabt;
//$ps = $this->loadPermissionSet($ap); 
//$ps = $this->mergePermissionSet($ap); 
//$ps = $this->loadPermissionSet($ap);


If I print_r the $ap var after (changing it) I get the right values in the new permission object but I still need to reapply the Permissions to the...database??? or..Permission object?

What I need to do is programmatically add one page that has limited edit ability for one user of choice in the Main area of that page.

Thanks in advance for awesome replies.

luciddrew
 
andrewsturm replied on at Permalink Reply
I am also interested in this!