Hey Bob,
I read the hint with the parent in a seperate group and also a the answer with load, list and view instead of just load. I didnt try it yet, because I didnt want to put time into a direction that might not lead to the goal.
But I will keep this information in mind. So if I get this right, we would need three resoure groups (RG) if we use the resource tree at all, all for context mgr:
- all resources (permissions: be member of "admin" UG to do anything)
- parent folder of all the single "only me" resources (permissions: be member of "clients" UG)
- a single "only me" resource (permissions: be member of this RG with only this resource in it)
I am trying to put that into one script for creating a "Single Page Admin" with only few inputs inside a form. could start like this:
<?php
$newname = $fullname;
$newfullname = $fullname;
$email = $email;
// create user
$user = $modx->newObject('modUser', array ('username'=>$newname));
$newpass = substr(str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 1).substr(md5(time()),1, 10);
$user->set('password',md5($newpass));
// create profile
$userProfile = $modx->newObject('modUserProfile');
$userProfile->set('fullname',$fullname);
$userProfile->set('email',$email);
$success = $user->addOne($userProfile);
if ($success) {
$user->save();
}
// create own page
$page = $this->modx->newObject('modDocument');
$page->set('parent',5);
$alias= $modx->runSnippet('makeAlias',array('title' => $fullname));
$page->set('alias',$alias);
$page->set('pagetitle',$fullname);
$page->set('template',7);
$page->set('published',0);
$page->set('cacheable',1);
$page->set('hidemenu',0);
$doc->setContent('<h2>Hi, my name is '.$fullname.'</h2>');
$page->fromArray($pagedata);
$page->save();
$newpageid = $page->get('id');
// create own resource group
$group = $this->modx->newObject('modResourceGroup');
$groupdata = array('name'=>'RG_'.str_replace(' ', '', $loginname,'private_memgroup'=>0,'private_webgroup'=>0);
$group->fromArray($groupdata);
$group->save();
$newgroupid = $group->get('id');
// put resource into own group
$page->joinGroup($newgroupid);
// set Placeholders for welcome email
$modx->setPlaceholders(array(
'fullname' => $newname,
'email' => $email,
'password' => $newpass,
),'cuc.');
// send new email to SPA
$message = $modx->getChunk('newUserMail');
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'[email protected]');
$modx->mail->set(modMail::MAIL_FROM_NAME,'Guido Gallenkamp');
$modx->mail->set(modMail::MAIL_SUBJECT,'Die Spritze immer am Mann!');
$modx->mail->address('to',$email);
$modx->mail->setHTML(false);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
}
$modx->mail->reset();
Id be happy if we could mak this possible like putting it into a CMP or making a MODX extra of it. I know that if will be needed
Cheers!