. * * @category API * @package GNUSocial * @author Hannes Mannerheim * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://www.gnu.org/software/social/ */ if (!defined('GNUSOCIAL')) { exit(1); } class ApiCheckNicknameAction extends ApiAction { function prepare($args) { parent::prepare($args); return true; } function handle($args) { parent::handle($args); $nickname = $this->trimmed('nickname'); if ($this->nicknameExists($nickname)) { $nickname_ok = 0; } else if (!User::allowed_nickname($nickname)) { $nickname_ok = 0; } else { $nickname_ok = 1; } $this->initDocument('json'); $this->showJsonObjects($nickname_ok); $this->endDocument('json'); } function nicknameExists($nickname) { $user = User::staticGet('nickname', $nickname); return is_object($user); } }