X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupcreate.php;h=3eb3ae5fcce4cd003b4c96c491bd7d47687d1e15;hb=ad651c35353021d05ef4a013e57c17d0b885c5dc;hp=aeae1c2b2c4074f3aca7372e608a0c4272887437;hpb=da9d02b0381e1acb2a5250392d91b0ebe6e87c1b;p=quix0rs-gnu-social.git diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index aeae1c2b2c..3eb3ae5fcc 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -22,6 +22,8 @@ * @category API * @package StatusNet * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -39,6 +41,9 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -94,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.'), @@ -113,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; } @@ -121,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': @@ -185,7 +135,7 @@ class ApiGroupCreateAction extends ApiAuthAction break; default: $this->clientError( - _('API method not found!'), + _('API method not found.'), 404, $this->format ); @@ -313,7 +263,7 @@ class ApiGroupCreateAction extends ApiAuthAction if (!$valid) { $this->clientError( - sprintf(_('Invalid alias: "%s"'), $alias), + sprintf(_('Invalid alias: "%s".'), $alias), 403, $this->format ); @@ -358,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; }