Sub-page Permissions programmatically
Permalink 1 user found helpful
When creating a user I am creating a unique calendar for each user which they can control. This works fine, but when I log in as that user I am unable to create events on the calendar - this is due to the sub-page permissions which is not allowing it. I can set these manually on the new create page Calendar, but how do I go about doing it programmatically so that it is done when adding the user as opposed to having to do it manually.
This is my code, I tried using the canAddSubCollection but this doesn't seem to work unless I am doing something wrong.
This is my code, I tried using the canAddSubCollection but this doesn't seem to work unless I am doing something wrong.
class createUserCalendar extends Object { public function createSpecialUserInfo($ui) { // Load the collection types and page models Loader::Model('collection_types'); Loader::model('collection_attributes'); Loader::Model('page'); // Set collection type $ct = CollectionType::getByHandle('left_sidebar'); // Get User ID $uid = $ui->getUserID(); // Page Data array to give to $page->add $pageData = array( "cName" => "My Calendar", "cHandle" => "mycalendar" . $uid); $page = Page::getByID(1);
Viewing 15 lines of 48 lines. View entire code block.
It looks like this is pretty close. I think you will want to check out
function BuildPermissionsFromArray in concrete/models/permissions.php.
I think you'll want to do basically the same thing as you're doing for groups for the users.
Isn't really going to do anything because they aren't options in the function in the permissions model.