mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
BUGFIX: Removed project-specific code.
BUGFIX: Don't throw an error if you try to create a template without a subdomain
This commit is contained in:
parent
e2220c0b07
commit
3acc4aae80
@ -93,21 +93,7 @@ class SubsiteAdmin extends GenericDataAdmin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addintranet($data, $form) {
|
function addintranet($data, $form) {
|
||||||
if($data['Name'] && $data['Subdomain']) {
|
if($data['Name'] && ($data['Subdomain'] || $data['Type'] == 'template')) {
|
||||||
/*
|
|
||||||
$SQL_email = Convert::raw2sql($data['AdminEmail']);
|
|
||||||
$member = DataObject::get_one('Member', "`Email`='$SQL_email'");
|
|
||||||
|
|
||||||
if(!$member) {
|
|
||||||
$member = Object::create('Member');
|
|
||||||
$nameParts = explode(' ', $data['AdminName']);
|
|
||||||
$member->FirstName = array_shift($nameParts);
|
|
||||||
$member->Surname = join(' ', $nameParts);
|
|
||||||
$member->Email = $data['AdminEmail'];
|
|
||||||
$member->write();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(isset($data['TemplateID']) && $data['TemplateID']) {
|
if(isset($data['TemplateID']) && $data['TemplateID']) {
|
||||||
$template = DataObject::get_by_id('Subsite_Template', $data['TemplateID']);
|
$template = DataObject::get_by_id('Subsite_Template', $data['TemplateID']);
|
||||||
} else {
|
} else {
|
||||||
@ -133,39 +119,13 @@ class SubsiteAdmin extends GenericDataAdmin {
|
|||||||
$intranet->Subdomain = $data['Subdomain'];
|
$intranet->Subdomain = $data['Subdomain'];
|
||||||
$intranet->write();
|
$intranet->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: This stuff is pretty oriwave2-specific...
|
|
||||||
$groupObjects = array();
|
|
||||||
|
|
||||||
// create Staff, Management and Administrator groups
|
|
||||||
$groups = array(
|
|
||||||
'Administrators' => array('CL_ADMIN', 'CMS_ACCESS_CMSMain', 'CMS_ACCESS_AssetAdmin', 'CMS_ACCESS_SecurityAdmin', 'CMS_ACCESS_IntranetAdmin'),
|
|
||||||
'Management' => array('CL_MGMT'),
|
|
||||||
'Staff' => array('CL_STAFF')
|
|
||||||
);
|
|
||||||
foreach($groups as $name => $perms) {
|
|
||||||
$group = new Group();
|
|
||||||
$group->SubsiteID = $intranet->ID;
|
|
||||||
$group->Title = $name;
|
|
||||||
$group->write();
|
|
||||||
|
|
||||||
foreach($perms as $perm) {
|
|
||||||
Permission::grant($group->ID, $perm);
|
|
||||||
}
|
|
||||||
|
|
||||||
$groupObjects[$name] = $group;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
$member->Groups()->add($groupObjects['Administrators']);
|
|
||||||
*/
|
|
||||||
|
|
||||||
Director::redirect('admin/subsites/show/' . $intranet->ID);
|
Director::redirect('admin/subsites/show/' . $intranet->ID);
|
||||||
} else {
|
} else {
|
||||||
echo "You must provide a Name and Subdomain.";
|
if($data['Type'] == 'template') echo "You must provide a name for your new template.";
|
||||||
|
else echo "You must provide a name and subdomain for your new site.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user