X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupcreate.php;h=028d76a7822a99c5bf2f3b6a46d9743280a4054a;hb=8da5e98cba12c32f0b75a90d1ff0007b73f0fc8d;hp=cdb2afb5bec4095e750fa135edcca32053369def;hpb=861e0f02270c43e5303471ae9c419662cac76142;p=quix0rs-gnu-social.git diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index cdb2afb5be..028d76a782 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -99,15 +99,6 @@ class ApiGroupCreateAction extends ApiAuthAction { parent::handle($args); - if (!common_config('inboxes', 'enabled')) { - $this->serverError( - _('Inboxes must be enabled for groups to work'), - 400, - $this->format - ); - return false; - } - if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError( _('This method requires a POST.'), @@ -118,7 +109,7 @@ class ApiGroupCreateAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } @@ -126,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); @@ -190,7 +133,7 @@ class ApiGroupCreateAction extends ApiAuthAction break; default: $this->clientError( - _('API method not found!'), + _('API method not found.'), 404, $this->format );