X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fapigroupcreate.php;h=561c721975763b0226985c289d8636ce06b44eed;hb=4238875ebe784dfcac2d639ef48cae005923f86d;hp=2dd0e9db1b570a9f31ed25a5e1f63b740b50544e;hpb=29d0871e5a5b2561387bcad40ef4644ee1c2be08;p=quix0rs-gnu-social.git diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index 2dd0e9db1b..561c721975 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -67,11 +67,11 @@ class ApiGroupCreateAction extends ApiAuthAction * * @return boolean success flag */ - protected function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->nickname = Nickname::normalize($this->arg('nickname')); + $this->nickname = Nickname::normalize($this->arg('nickname'), true); $this->fullname = $this->arg('full_name'); $this->homepage = $this->arg('homepage'); $this->description = $this->arg('description'); @@ -130,22 +130,13 @@ class ApiGroupCreateAction extends ApiAuthAction */ function validateParams() { - if ($this->groupNicknameExists($this->nickname)) { - // TRANS: Client error trying to create a group with a nickname this is already in use. - $this->clientError(_('Nickname already in use. Try another one.'), 403); - - } elseif (!User_group::allowedNickname($this->nickname)) { - // TRANS: Client error in form for group creation. - $this->clientError(_('Not a valid nickname.'), 403); - - } elseif (!is_null($this->homepage) + if (!is_null($this->homepage) && strlen($this->homepage) > 0 && !common_valid_http_url($this->homepage)) { // TRANS: Client error in form for group creation. $this->clientError(_('Homepage is not a valid URL.'), 403); - } elseif ( - !is_null($this->fullname) + } elseif (!is_null($this->fullname) && mb_strlen($this->fullname) > 255) { // TRANS: Client error in form for group creation. $this->clientError(_('Full name is too long (maximum 255 characters).'), 403); @@ -165,7 +156,7 @@ class ApiGroupCreateAction extends ApiAuthAction if (!empty($this->aliasstring)) { $this->aliases = array_map( - 'common_canonical_nickname', + array('Nickname', 'normalize'), // static call to Nickname::normalize array_unique(preg_split('/[\s,]+/', $this->aliasstring)) ); } else { @@ -183,53 +174,8 @@ class ApiGroupCreateAction extends ApiAuthAction 403); } - foreach ($this->aliases as $alias) { - - if (!Nickname::isValid($alias)) { - // TRANS: Client error shown when providing an invalid alias during group creation. - // TRANS: %s is the invalid alias. - $this->clientError(sprintf(_('Invalid alias: "%s".'), $alias), 403); - } - if ($this->groupNicknameExists($alias)) { - // TRANS: Client error displayed when trying to use an alias during group creation that is already in use. - // TRANS: %s is the alias that is already in use. - $this->clientError(sprintf(_('Alias "%s" already in use. Try another one.'), $alias), 403); - } - - // XXX assumes alphanum nicknames - - if (strcmp($alias, $this->nickname) == 0) { - // TRANS: Client error displayed when trying to use an alias during group creation that is the same as the group's nickname. - $this->clientError(_('Alias can\'t be the same as nickname.'), 403); - } - } - // Everything looks OK return true; } - - /** - * Check to see whether a nickname is already in use by a group - * - * @param String $nickname The nickname in question - * - * @return boolean true or false - */ - function groupNicknameExists($nickname) - { - $local = Local_group::getKV('nickname', $nickname); - - if (!empty($local)) { - return true; - } - - $alias = Group_alias::getKV('alias', $nickname); - - if (!empty($alias)) { - return true; - } - - return false; - } }