X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupcreate.php;h=145806356c77d2b74224635ed19cc854e92d9629;hb=ddb656fcd2a3233b26e28987d2f3425944908d30;hp=895dfb7abae5f2074217a47c9e25be65fd49d20f;hpb=aa0d9a86152d2485de6de5ec572ae87085ebe780;p=quix0rs-gnu-social.git diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index 895dfb7aba..145806356c 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -117,60 +117,14 @@ 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, + 'local' => true)); switch($this->format) { case 'xml': @@ -181,7 +135,7 @@ class ApiGroupCreateAction extends ApiAuthAction break; default: $this->clientError( - _('API method not found!'), + _('API method not found.'), 404, $this->format ); @@ -354,9 +308,9 @@ class ApiGroupCreateAction extends ApiAuthAction function groupNicknameExists($nickname) { - $group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); - if (!empty($group)) { + if (!empty($local)) { return true; }