本文整理汇总了PHP中User::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOne方法的具体用法?PHP User::findOne怎么用?PHP User::findOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::findOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reminder
public function reminder($id_user)
{
$i = 0;
if (Zend_Registry::isRegistered('Zend_Translate')) {
$translator = Zend_Registry::get('Zend_Translate');
}
if (!$id_user || $id_user == null) {
$modelReminder = new Reminder();
$dataReminders = $modelReminder->fetchToSendEmailAll();
} elseif ($id_user) {
$modelReminder = new Reminder();
$dataReminders = $modelReminder->fetchToSendEmail($id_user);
}
foreach ($dataReminders as $dataReminder) {
$modelUser = new User();
$dataUsers = $modelUser->findOne($dataReminder['created_by']);
$userEmail = $dataUser['email'];
$this->view->description = str_replace("ó", "ó", strip_tags($dataReminder['description']));
$body = $this->view->render('/_mail/reminder.phtml');
$client = new Logic_MailerAdapter();
$client->mail($userEmail, $translator->translate('Reminder') . ' - ' . $dataReminder['title'], array('type' => 1, 'content' => $body));
$modelReminder->setAsSent($dataReminder['id']);
$i++;
}
return $i;
}
示例2: findByEmail
/**
* @param string $email
* @return app\models\User|null User
*/
public static function findByEmail($email)
{
$dbUser = User::findOne(['email' => $email]);
if ($dbUser) {
return UserIdent::initFromDbInstance($dbUser);
}
return null;
}
示例3: testModel
public function testModel()
{
$this->assertEquals(User::find(1)->email, 'email1@example.com');
$this->assertEquals(User::first()->email, 'email1@example.com');
$this->assertEquals(User::last()->email, 'email3@example.com');
$this->assertEquals(User::count(), 3);
$this->assertEquals(User::findOne(['email'], ['email1@example.com'])->email, 'email1@example.com');
$this->assertEquals(User::findOne(['first_name', 'last_name'], ['John', 'Doe'])->email, 'email1@example.com');
$this->assertCount(3, User::all());
}
示例4: testAction
protected function testAction()
{
$translate = $this->application->getBootstrap()->getResource('translate');
$view = $this->application->getBootstrap()->getResource('view');
$view->setScriptPath(APPLICATION_PATH . '/views/scripts');
$u = new User();
$u_row = $u->findOne($_SERVER['argv'][6]);
$mailer = new Logic_Mailer($view, $translate);
$mailer->userPass('asdf', $u_row);
}
示例5: getList
public static function getList()
{
$time = time();
$return = [];
foreach (self::find()->asArray()->all() as $item) {
$user = User::findOne($item['user_id']);
if ($user) {
$inactiveSince = $time - $item['last_timestamp'];
$return[] = ['firstname' => $user->firstname, 'lastname' => $user->lastname, 'email' => $user->email, 'last_timestamp' => $item['last_timestamp'], 'is_active' => $inactiveSince >= 120 ? false : true, 'inactive_since' => round($inactiveSince / 60) . ' min'];
}
}
return $return;
}
示例6: sendEmail
/**
* Sends an email with a link, for resetting the password.
*
* @return boolean whether the email was send
*/
public function sendEmail()
{
/* @var $user User */
$user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
if ($user) {
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if ($user->save()) {
return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('app', 'Password reset for ') . \Yii::$app->cms->appName)->send();
}
}
return false;
}
示例7: dispatchLoopStartup
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if ($identity = Zend_Auth::getInstance()->getIdentity()) {
$user = new User();
$id = $identity->id;
$userRow = $user->findOne($id)->toArray();
if ($userRow['tmp_password'] === true && ($request->getControllerName() != 'auth' || $request->getActionName() != 'changepassword')) {
$conv = new Base_Controller_Action_Helper_IdConvert();
$id = $conv->strToHex($id);
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setGotoSimple('changepassword', 'auth', null, array('id' => $id));
}
}
}
示例8: sendEmail
/**
* Sends an email with a link, for resetting the password.
*
* @return boolean whether the email was send
*/
public function sendEmail()
{
/* @var $user User */
$user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
if ($user) {
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if ($user->save()) {
\Yii::$app->mailer->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->mailer->view->theme->pathMap, ['@app/mail' => ['@skeeks/cms/mail-templates']]);
return \Yii::$app->mailer->compose('@app/mail/password-reset-token', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('skeeks/cms', 'Password reset for ') . \Yii::$app->cms->appName)->send();
}
}
return false;
}
示例9: sendEmail
/**
* Sends an email with a link, for resetting the password.
*
* @return boolean whether the email was send
*/
public function sendEmail()
{
/* @var $user User */
$user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
if (!$user) {
return false;
}
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if (!$user->save()) {
return false;
}
return Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
}
示例10: updateWsClientaction
protected function updateWsClientaction()
{
$sql = 'SELECT id,login,first_name,surname,email from "user" where ws_client_id is null';
$model = new User();
$u = $model->getAdapter()->query($sql);
$users = $u->fetchAll();
foreach ($users as $user) {
$values = array();
$clientModel = new Wsclient();
$clientData = array('client_name' => $user['login'], 'pm_name' => $user['first_name'] . ' ' . $user['surname'], 'pm_email' => $user['email'], 'ip_address' => array());
$newClient = $clientModel->createRow($clientData);
$values['ws_client_id'] = $newClient->save();
$row = $model->findOne($user['id']);
$row->setFromArray($values);
$row->save();
}
}
示例11: currentUser
static function currentUser()
{
$cookie = new CookieSigner(Config::app()['BASE_KEY']);
if (isset($_SESSION['userId']) && ($userId = $_SESSION['userId'])) {
$user = new User();
return $user->findOne($userId);
} else {
if ($userId = $cookie->get('userId')) {
$user = new User();
$user->findOne($userId);
if ($user && $user->isAuthenticated('remember', $cookie->get('rememberToken'))) {
self::logIn($user);
return $user;
}
}
}
return null;
}
示例12: logIn
private function logIn()
{
$success = false;
if (!empty($_POST['email']) && !empty($_POST['pass'])) {
$user = User::findOne(['email' => $_POST['email']]);
if ($_POST['pass'] === $user->pass) {
$user->token = Text::generateRandomString();
$user->save();
setcookie('user_id', $user->id, 0, '/');
setcookie('token', $user->token, 0, '/');
$success = true;
}
}
if ($success) {
return $this->redirect('/admin');
}
return $this->redirect('/log-in?error=1');
}
示例13: buildSQl
protected function buildSQl()
{
$select = $this->dbModelTable->select();
$user = new User();
if (isset($this->filterdata['deleg_no']) and !empty($this->filterdata['deleg_no'])) {
$select->where('deleg_no = ?', $this->filterdata['deleg_no']);
}
if (isset($this->filterdata['employee']) and !empty($this->filterdata['employee'])) {
$tetaId = $user->findOne($this->filterdata['employee'])->teta_id;
$select->where('teta_id = ?', $tetaId);
} else {
if (isset($this->filterdata['branch']) and !empty($this->filterdata['branch'])) {
$userRowset = $user->fetchAll('id_branch = ' . $this->filterdata['branch']);
$inStmt = array();
foreach ($userRowset as $row) {
$inStmt[] = $row->teta_id;
}
$select->where('teta_id IN (?)', $inStmt);
}
}
return $select->__toString();
}
示例14: testSave
public function testSave()
{
$user = new User();
$user->name = 'John Doe';
$this->assertFalse($user->exists);
$this->assertEquals(0, User::count());
$this->assertEquals(null, $user->_id);
$user->save();
$this->assertTrue($user->exists);
$this->assertEquals(1, User::count());
$this->assertEquals('John Doe', $user->name);
$this->assertInstanceOf('MongoID', $user->_id);
$test = User::findOne(array('name' => 'John Doe'));
$this->assertEquals($test, $user);
// backup id
$id = $user->_id;
$user->name = 'Jane Doe';
$user->save();
$this->assertEquals('Jane Doe', $user->name);
$this->assertEquals($id, $user->_id);
$this->assertNotEquals($test, $user);
}
示例15: findIdentityByAccessToken
public static function findIdentityByAccessToken($token, $type = null)
{
return User::findOne(['tocken' => $token]);
}