*/
class NewgroupAction extends FormAction
{
+ protected $group;
+
+ function getGroup() {
+ return $this->group;
+ }
+
function title()
{
// TRANS: Title for form to create a group.
parent::handlePost();
if (Event::handle('StartGroupSaveForm', array($this))) {
- $nickname = Nickname::normalize($this->trimmed('newnickname'));
+ $nickname = Nickname::normalize($this->trimmed('newnickname'), true);
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
$private = $this->boolean('private');
$aliasstring = $this->trimmed('aliases');
- if ($this->nicknameExists($nickname)) {
- // TRANS: Group create form validation error.
- throw new ClientException(_('Nickname already in use. Try another one.'));
- } else if (!User_group::allowedNickname($nickname)) {
- // TRANS: Group create form validation error.
- throw new ClientException(_('Not a valid nickname.'));
- } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
+ if (!is_null($homepage) && (strlen($homepage) > 0) &&
!common_valid_http_url($homepage)) {
// TRANS: Group create form validation error.
throw new ClientException(_('Homepage is not a valid URL.'));
}
if (!empty($aliasstring)) {
- $aliases = array_map('common_canonical_nickname', array_unique(preg_split('/[\s,]+/', $aliasstring)));
+ $aliases = array_map(array('Nickname', 'normalize'), array_unique(preg_split('/[\s,]+/', $aliasstring)));
} else {
$aliases = array();
}
return;
}
- foreach ($aliases as $alias) {
- if (!Nickname::isValid($alias)) {
- // TRANS: Group create form validation error.
- // TRANS: %s is the invalid alias.
- throw new ClientException(sprintf(_('Invalid alias: "%s"'), $alias));
- }
- if ($this->nicknameExists($alias)) {
- // TRANS: Group create form validation error. %s is the already used alias.
- throw new ClientException(sprintf(_('Alias "%s" already in use. Try another one.'),
- $alias));
- }
- // XXX assumes alphanum nicknames
- if (strcmp($alias, $nickname) == 0) {
- // TRANS: Group create form validation error.
- throw new ClientException(_('Alias cannot be the same as nickname.'));
- }
- }
-
if ($private) {
$force_scope = 1;
$join_policy = User_group::JOIN_POLICY_MODERATE;
common_redirect($group->homeUrl(), 303);
}
}
-
- function nicknameExists($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;
- }
}