Created
February 6, 2009 19:45
-
-
Save twinge/59572 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
sub create($%) { | |
my GCX::Runtime::Community $self = shift; | |
my (%params) = @_; | |
my $system = $params{'system'}; | |
#short-circuit on invalid community names or invalid guid | |
($params{'name'} = $params{'display_name'}) =~ s/[^a-z0-9_~\-]/_/g; | |
return undef if(!$self->isValidName($params{'name'}, $system) ||$params{'guid'} !~ /^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/io); | |
#default values | |
$params{'hidden'} = 'N' if($params{'hidden'} ne 'Y'); | |
$params{'language'} = 'en' if(!$params{'language'}); | |
$params{'title'} = $params{'display_name'} if(!defined $params{'title'}); | |
$params{'type'} = 'community' if(!$system->dbh->selectrow_array('SELECT SQL_CACHE COUNT(*) FROM spaceTypes WHERE name = ?', undef, $params{'type'})); | |
.... | |
my $affectedRows = $system->dbh->do( | |
q{ | |
INSERT INTO community SET | |
name = ?, | |
display_name = ?, | |
title = ?, | |
dbname = ?, | |
username = ?, | |
password = ?, | |
language = ?, | |
description = ?, | |
hidden = ?, | |
lft = ?, | |
rgt = ?, | |
type = ? | |
}, undef, | |
$params{'name'}, | |
$params{'display_name'}, | |
$params{'title'}, | |
$dbName, | |
$userName, | |
$password, | |
$params{'language'}, | |
$params{'description'}, | |
$params{'hidden'}, | |
$lft, | |
$lft + 1, | |
$params{'type'}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment