| // +---------------------------------------------------------------------------+ require_once dirname(__FILE__) . '/UserDAO.php'; require_once SGL_CORE_DIR . '/AjaxProvider.php'; /** * Simple wrapper to UserDAO to use with AJAX. * * @package seagull * @subpackage user * @author Dmitri Lakachauskis */ class UserAjaxProvider extends SGL_AjaxProvider { function UserAjaxProvider() { SGL::logMessage(null, PEAR_LOG_DEBUG); parent::SGL_AjaxProvider(); $this->responseFormat = SGL_RESPONSEFORMAT_JSON; $this->da = &UserDAO::singleton(); } function &singleton() { static $instance; // If the instance is not there, create one if (!isset($instance)) { $class = __CLASS__; $instance = new $class(); } return $instance; } /** * Check if username is unique. * * @param string $username * @return array */ function isUniqueUsername() { $req = &SGL_Request::singleton(); $username = $req->get('username'); $ok = $this->da->isUniqueUsername($username); if ($ok) { $msg = 'Selected username is available'; $ret = array( 'type' => 'info', 'message' => SGL_Output::translate($msg) ); } else { $msg = 'This username already exist in the DB, please choose another'; $ret = array( 'type' => 'error', 'message' => SGL_Output::translate($msg) ); } return $ret; } } ?>