本文整理汇总了PHP中Model_User::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::fetchRow方法的具体用法?PHP Model_User::fetchRow怎么用?PHP Model_User::fetchRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::fetchRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldSendEmail
public function testShouldSendEmail()
{
if (!$this->_testsEnabled) {
return;
}
$pwless = new Garp_Auth_Adapter_Passwordless();
$pwless->requestToken(array('email' => self::TEST_EMAIL));
$userModel = new Model_User();
$theUser = $userModel->fetchRow();
$authModel = new Model_AuthPasswordless();
$authRecord = $authModel->fetchRow();
$tokenUrl = new Garp_Util_FullUrl(array(array('method' => 'passwordless'), 'auth_submit')) . '?uid=' . $theUser->id . '&token=' . $authRecord->token;
$storedMessage = file_get_contents(GARP_APPLICATION_PATH . '/../tests/tmp/' . self::TEST_EMAIL . '.tmp');
$expectedMessage = Garp_Util_String::interpolate($this->_getMockEmailMessage(), array('LOGIN_URL' => $tokenUrl));
// Pass thru actual Mime part, otherwise the two wil never be the same
$mp = new Zend_Mime_Part($expectedMessage);
$mp->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$mp->type = Zend_Mime::TYPE_TEXT;
$mp->disposition = Zend_Mime::DISPOSITION_INLINE;
$mp->charset = 'iso-8859-1';
// Just check for the token url. Message is encoded so checking for entire message to be
// correct is overly complex (and not the responsibility of this unit test).
$this->assertTrue(strpos($storedMessage, $mp->getContent("\r\n")) !== false);
}
示例2: validateemailAction
/**
* Validate email address. In scenarios where users receive an email validation email,
* this action is used to validate the address.
*
* @return void
*/
public function validateemailAction()
{
$this->view->title = __('activate email page title');
$auth = Garp_Auth::getInstance();
$authVars = $auth->getConfigValues();
$request = $this->getRequest();
$activationCode = $request->getParam('c');
$activationEmail = $request->getParam('e');
$emailValidColumn = $authVars['validateemail']['email_valid_column'];
if (!$activationEmail || !$activationCode) {
throw new Zend_Controller_Action_Exception('Invalid request.', 404);
}
$userModel = new Model_User();
// always collect fresh data for this one
$userModel->setCacheQueries(false);
$activationCodeClause = 'MD5(CONCAT(' . $userModel->getAdapter()->quoteIdentifier($authVars['validateemail']['token_column']) . ',' . 'MD5(email),' . 'MD5(' . $userModel->getAdapter()->quote($authVars['salt']) . '),' . 'MD5(id)' . ')) = ?';
$select = $userModel->select()->where($activationCodeClause, $activationCode)->where('MD5(email) = ?', $activationEmail);
$user = $userModel->fetchRow($select);
if (!$user) {
$this->view->error = __('invalid email activation code');
} else {
$user->{$emailValidColumn} = 1;
if (!$user->save()) {
$this->view->error = __('activate email error');
} elseif ($auth->isLoggedIn()) {
// If the user is currently logged in, update the cookie
$method = $auth->getStore()->method;
$userData = $auth->getUserData();
// Sanity check: is the user that has just validated his email address
// the currently logged in user?
if ($userData['id'] == $user->id) {
$userData[$emailValidColumn] = 1;
$auth->store($userData, $method);
}
}
$this->view->user = $user;
}
}
示例3: _createOrFetchUserRecord
protected function _createOrFetchUserRecord(array $userData)
{
$userModel = new Model_User();
$userData = $userModel->filterColumns($userData);
$select = $userModel->select()->where('email = ?', $userData['email']);
if ($userRecord = $userModel->fetchRow($select)) {
return $userRecord->id;
}
return $userModel->insert($userData);
}
示例4: make
/**
* Make an existing user admin
*
* @param array $args
* @return void
*/
public function make(array $args = array())
{
$userModel = new Model_User();
if (!empty($args)) {
$id = $args[0];
} else {
$id = Garp_Cli::prompt('What is the id or email address of the user?');
}
$select = $userModel->select();
if (is_numeric($id)) {
$filterColumn = 'id';
} else {
$filterColumn = 'email';
}
$select->where($filterColumn . ' = ?', $id);
$user = $userModel->fetchRow($select);
if (!$user) {
Garp_Cli::errorOut('Error: could not find user with ' . $filterColumn . ' ' . $id);
} else {
$user->role = 'admin';
if ($user->save()) {
// For completeness sake, check if the user has an AuthLocal
// record. We disregard the fact wether the user already has any
// of the other Auth- records.
$authLocalModel = new Model_AuthLocal();
$authLocalRecord = $authLocalModel->fetchRow($authLocalModel->select()->where('user_id = ?', $user->id));
if (!$authLocalRecord) {
$newAuthLocalData = array('password' => trim(Garp_Cli::prompt('Choose a password:')), 'user_id' => $user->id);
$authLocalModel->insert($newAuthLocalData);
}
Garp_Cli::lineOut('User with ' . $filterColumn . ' ' . $id . ' is now administrator');
} else {
Garp_Cli::errorOut('Error: could not make user with ' . $filterColumn . ' ' . $id . ' administrator');
}
}
}