/** * */ public function registerAction() { $register_form = new Form_Userregister(); if ($register_form->isValid($this->_getAllParams())) { $ut = Model_Users::getInstance(); $email = $this->_getParam('email'); $username = $this->_getParam('username'); $password = $this->_getParam('password'); $pw2 = $this->_getParam('password2'); if ($password != $pw2) { $comment = array('error' => 'Passwords mismatch'); return $this->_forward('hi', NULL, NULL, $comment); } $pwMD5 = md5($password); $found = $ut->findOne(array('email' => $email)); if ($found) { $comment = array('error' => "Already have user with email {$email}"); $this->_forward('hi', NULL, NULL, $comment); return; } $data = array('username' => $username, 'password' => $pwMD5, 'email' => $email); $user = $ut->get(NULL, $data); $user->save(); $user->password = Zupal_Authorizer::encrypt_password($password, $user->identity()); $user->save(); $this->_forward('hi', NULL, NULL, array('message' => 'User Registered.')); } else { $comment = array('reload_register' => true, 'error' => "Incomplete Form"); $this->_forward('hi', NULL, NULL, $comment); } }
/** * */ public function init() { if (!($user = Model_Users::getInstance()->current_user())) { $params = array('error' => 'You must be logged in to play Syner-G'); $this->forward('index', 'index', NULL, $params); } parent::init(); }
public function init() { if (!($this->_user = Model_Users::getInstance()->current_user())) { $params = array('error' => 'You must be logged in to play Syner-G'); $this->forward('index', 'index', NULL, $params); return FALSE; } $this->_active_session = Synerg_Model_Gamesessions::getInstance()->active_session(); return parent::init(); }
/** * Performs an authentication attempt * * @throws Zend_Auth_Adapter_Exception If authentication cannot * be performed * @return Zend_Auth_Result */ public function authenticate() { $stub = Model_Users::getInstance(); $user = $stub->find_one(array('username' => array($this->get_username(), 'LIKE'))); if ($user && $user->is_saved() && self::encrypt_password($this->get_password(), $user->identity()) == $user->password) { $result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user); } else { $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, NULL); } return $result; }
/** * */ public function usergamesAction() { $data = array(); $game = $this->_getParam('game', ''); $user = $this->_getParam('user'); if ($user) { $user = Model_Users::getInstance()->get($user); } else { $user = Model_Users::current_user(); } $params = array('user' => $user->identity()); $game_type = $game ? Game_Model_Gametypes::game_type($game) : NULL; $user_sessions = Game_Model_Gamesessionplayers::getInstance()->find($prarams); foreach ($user_sessions as $us) { $session = $us->session(); if ($game_type && !$session->is_game_type($game_type)) { continue; } $out[] = $session->toArray(TRUE); } $this->_store('id', $out, 'name'); }
function get_user($pReload = FALSE) { if ($pReload || is_null($this->_user)) { // process $this->_user = Model_Users::getInstance()->get($this->user); } return $this->_user; }
/** * */ public function editAction() { $id = $this->_getParam('id'); $user = Model_Users::getInstance()->get($id); if (!$user) { $params = array('error' => "cannot find user id {$id}"); $this->_forward('index', NULL, NULL, $params); } $this->view->form = new Administer_Form_Zupalusers($user); }