summaryrefslogtreecommitdiff
path: root/actions/apigroupcreate.php
diff options
context:
space:
mode:
authorEric Helgeson <erichelgeson@gmail.com>2009-11-18 15:53:33 -0500
committerEric Helgeson <erichelgeson@gmail.com>2009-11-18 15:54:24 -0500
commit199ccdb53fbd732eeced3edf734e39687729da9b (patch)
tree9b32c2c2de01b8a339da9c6ea276189f0be2b917 /actions/apigroupcreate.php
parent8f2db3820f6ab2c8881521c0adc9a6427b5ea86b (diff)
Consolidate group creation into static function in User_group
Diffstat (limited to 'actions/apigroupcreate.php')
-rw-r--r--actions/apigroupcreate.php62
1 files changed, 7 insertions, 55 deletions
diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php
index 895dfb7ab..8827d1c5c 100644
--- a/actions/apigroupcreate.php
+++ b/actions/apigroupcreate.php
@@ -117,61 +117,13 @@ class ApiGroupCreateAction extends ApiAuthAction
return;
}
- $group = new User_group();
-
- $group->query('BEGIN');
-
- $group->nickname = $this->nickname;
- $group->fullname = $this->fullname;
- $group->homepage = $this->homepage;
- $group->description = $this->description;
- $group->location = $this->location;
- $group->created = common_sql_now();
-
- $result = $group->insert();
-
- if (!$result) {
- common_log_db_error($group, 'INSERT', __FILE__);
- $this->serverError(
- _('Could not create group.'),
- 500,
- $this->format
- );
- return;
- }
-
- $result = $group->setAliases($this->aliases);
-
- if (!$result) {
- $this->serverError(
- _('Could not create aliases.'),
- 500,
- $this->format
- );
- return;
- }
-
- $member = new Group_member();
-
- $member->group_id = $group->id;
- $member->profile_id = $this->user->id;
- $member->is_admin = 1;
- $member->created = $group->created;
-
- $result = $member->insert();
-
- if (!$result) {
- common_log_db_error($member, 'INSERT', __FILE__);
- $this->serverError(
- _('Could not set group membership.'),
- 500,
- $this->format
- );
- return;
- }
-
- $group->query('COMMIT');
-
+ $group = User_group::register(array('nickname' => $this->nickname,
+ 'fullname' => $this->fullname,
+ 'homepage' => $this->homepage,
+ 'description' => $this->description,
+ 'location' => $this->location,
+ 'aliases' => $this->aliases,
+ 'userid' => $this->user->id));
switch($this->format) {
case 'xml':
$this->showSingleXmlGroup($group);