4 * StatusNet, the distributed open-source microblogging tool
8 * Returns 1 if nickname is ok, 0 if not
12 * LICENCE: This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
22 * You should have received a copy of the GNU Affero General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * @author Hannes Mannerheim <h@nnesmannerhe.im>
28 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
29 * @link http://www.gnu.org/software/social/
32 if (!defined('GNUSOCIAL')) { exit(1); }
34 class ApiCheckNicknameAction extends ApiAction
37 function prepare($args)
39 parent::prepare($args);
44 function handle($args)
46 parent::handle($args);
48 $nickname = $this->trimmed('nickname');
50 if ($this->nicknameExists($nickname)) {
52 } else if (!User::allowed_nickname($nickname)) {
58 $this->initDocument('json');
59 $this->showJsonObjects($nickname_ok);
60 $this->endDocument('json');
63 function nicknameExists($nickname)
65 $user = User::staticGet('nickname', $nickname);
66 return is_object($user);