本文整理匯總了PHP中Model_Users::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Users::getInstance方法的具體用法?PHP Model_Users::getInstance怎麽用?PHP Model_Users::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Users
的用法示例。
在下文中一共展示了Model_Users::getInstance方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerAction
/**
*
*/
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);
}
}
示例2: init
/**
*
*/
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();
}
示例3: 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();
}
示例4: authenticate
/**
* 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;
}
示例5: usergamesAction
/**
*
*/
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');
}
示例6: get_user
function get_user($pReload = FALSE)
{
if ($pReload || is_null($this->_user)) {
// process
$this->_user = Model_Users::getInstance()->get($this->user);
}
return $this->_user;
}
示例7: editAction
/**
*
*/
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);
}