* @author Evan Prodromou <evan@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2013 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
{
parent::prepare($args);
- if (!common_logged_in()) {
- // TRANS: Client error displayed trying to create a group while not logged in.
- $this->clientError(_('You must be logged in to create a group.'), 403);
- }
-
// $this->scoped is the current user profile
if (!$this->scoped->hasRight(Right::CREATEGROUP)) {
// TRANS: Client exception thrown when a user tries to create a group while banned.
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) &&
- !Validate::uri($homepage,
- array('allowed_schemes' =>
- array('http', 'https')))) {
+ 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.'));
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
}
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;
- }
}