Created
February 6, 2009 19:54
-
-
Save twinge/59578 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#retrieve values from form for the new community | |
our $communityName = getInParam('name'); | |
my $communityTitle = getInParam('title'); | |
my $description = getInParam('description'); | |
my $templateID = getInParam('template'); | |
my $type = getInParam('type') || 'community'; | |
my $parent = getInParam('parent'); | |
my $nestingType = getInParam('nestingType'); | |
if($parent) | |
{ | |
my $parentAuthResource = 'GCX:' . $serverName . ':' . $parent . ':authz-admin'; | |
if(Authorization::check($guid, $parentAuthResource)->{$parentAuthResource} ne 'yes') | |
{ | |
$parent = undef; | |
$nestingType = undef; | |
} | |
} | |
else | |
{ | |
$parent = undef; | |
$nestingType = undef; | |
} | |
my $hidden = 'N'; | |
if(getInParam('browseable') eq 'no') | |
{ | |
$hidden = 'Y'; | |
} | |
#create the community | |
if(Community::create($communityName, $communityTitle, $description, $hidden, $type, $parent, $nestingType) == 0) | |
{ | |
die "invalid community name"; | |
} | |
#install the system module into the new community | |
Module::install('system', undef, undef, $communityName); | |
#List of modules to install in all communities | |
#use additionalModule parameter when calling this report for additional modules that need to be installed for the new community type | |
my @modules = ( | |
'resourceCenter', | |
'deleteMyCommunity', | |
'toolbox', | |
'adminReports', | |
'authorization', | |
'blog', | |
'calendar', | |
'chatroom', | |
'communitySettings', | |
'feedback', | |
'listOfLinks', | |
'mailMyCommunity', | |
'memberAdmin', | |
'messageBoard', | |
'news', | |
'omnibar', | |
'peopleLocator', | |
'prayer', | |
'profileEditor', | |
'search', | |
'subscriptions', | |
'wiki', | |
getInParam('additionalModule'), | |
); | |
#is this community a project? | |
if($type eq 'project') | |
{ | |
push @modules, 'project'; | |
} | |
else | |
{ | |
push @modules, 'projectAdmin'; | |
} | |
#install all modules in the new community | |
foreach my $moduleName (@modules) | |
{ | |
Module::install($moduleName, undef, undef, $communityName); | |
} | |
SQL::connectToCommunity($communityName, 'new'); | |
SQL::query('new', 'DELETE FROM system_moduleAttributes WHERE moduleName=? AND grouping=? AND name=?', 'communitySettings', 'communitySettings', 'defaultAccessLevel'); | |
SQL::query('new', 'INSERT INTO system_moduleAttributes (moduleName, grouping, name, value, frozen) VALUES (?, ?, ?, ?, ?)', 'communitySettings', 'communitySettings', 'defaultAccessLevel', scalar getInParam('access') || 'private', 'N'); | |
my @templateParameters; | |
foreach my $key (keys %$inparams) | |
{ | |
if($key =~ /^template_/i) | |
{ | |
foreach my $value (getInParam($key)) | |
{ | |
push @templateParameters, $key, $value; | |
} | |
} | |
} | |
Web::post(relativeToAbsoluteURL('/moduleinput/' . $communityName . '/communitySettings/communitySettings_template', $currentURL), ['template' => scalar getInParam('template'), @templateParameters]); | |
$returncommunity = $communityName; | |
$returnscreen = 'home'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment