exit(1);
}
-require_once INSTALLDIR . '/lib/apiauth.php';
-
/**
* Make a new group. Sets the authenticated user as the administrator of the group.
*
$this->user = $this->auth_user;
- $this->nickname = $this->arg('nickname');
+ $this->nickname = Nickname::normalize($this->arg('nickname'));
$this->fullname = $this->arg('full_name');
$this->homepage = $this->arg('homepage');
$this->description = $this->arg('description');
break;
default:
$this->clientError(
- // TRANS: Client error given when an API method was not found (404).
+ // TRANS: Client error displayed when coming across a non-supported API method.
_('API method not found.'),
404,
$this->format
*/
function validateParams()
{
- $valid = Validate::string(
- $this->nickname, array(
- 'min_length' => 1,
- 'max_length' => 64,
- 'format' => NICKNAME_FMT
- )
- );
-
- if (!$valid) {
- $this->clientError(
- // TRANS: Validation error in form for group creation.
- _(
- 'Nickname must have only lowercase letters ' .
- 'and numbers and no spaces.'
- ),
- 403,
- $this->format
- );
- return false;
- } elseif ($this->groupNicknameExists($this->nickname)) {
+ if ($this->groupNicknameExists($this->nickname)) {
$this->clientError(
// TRANS: Client error trying to create a group with a nickname this is already in use.
_('Nickname already in use. Try another one.'),
);
return false;
- } elseif (
- !is_null($this->homepage)
- && strlen($this->homepage) > 0
- && !Validate::uri(
- $this->homepage, array(
- 'allowed_schemes' =>
- array('http', 'https')
- )
- )) {
+ } elseif (!is_null($this->homepage)
+ && strlen($this->homepage) > 0
+ && !common_valid_http_url($this->homepage)) {
$this->clientError(
// TRANS: Client error in form for group creation.
_('Homepage is not a valid URL.'),
foreach ($this->aliases as $alias) {
- $valid = Validate::string(
- $alias, array(
- 'min_length' => 1,
- 'max_length' => 64,
- 'format' => NICKNAME_FMT
- )
- );
-
- if (!$valid) {
+ if (!Nickname::isValid($alias)) {
$this->clientError(
// TRANS: Client error shown when providing an invalid alias during group creation.
// TRANS: %s is the invalid alias.
*/
function groupNicknameExists($nickname)
{
- $local = Local_group::staticGet('nickname', $nickname);
+ $local = Local_group::getKV('nickname', $nickname);
if (!empty($local)) {
return true;
}
- $alias = Group_alias::staticGet('alias', $nickname);
+ $alias = Group_alias::getKV('alias', $nickname);
if (!empty($alias)) {
return true;