当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::findFirst方法代码示例

本文整理汇总了PHP中app\models\Users::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::findFirst方法的具体用法?PHP Users::findFirst怎么用?PHP Users::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Users的用法示例。


在下文中一共展示了Users::findFirst方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: profileAction

 /**
  * Edit the active user profile
  *
  */
 public function profileAction()
 {
     //Get session info
     $auth = $this->session->get('auth');
     //Query the active user
     $user = Users::findFirst($auth['id']);
     if ($user == false) {
         return $this->forward('index/index');
     }
     if (!$this->request->isPost()) {
         $this->tag->setDefault('name', $user->name);
         $this->tag->setDefault('email', $user->email);
     } else {
         $name = $this->request->getPost('name', array('string', 'striptags'));
         $email = $this->request->getPost('email', 'email');
         $user->name = $name;
         $user->email = $email;
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Your profile information was updated successfully');
         }
     }
 }
开发者ID:kenikori,项目名称:phalcon2_invo,代码行数:30,代码来源:InvoicesController.php

示例2: indexAction

 public function indexAction()
 {
     if ($this->request->getQuery('zone')) {
         $zone = Zones::findFirst($this->request->getQuery('zone'));
     }
     if ($this->request->getQuery('advertiser')) {
         $advertiser = Users::findFirst($this->request->getQuery('advertiser'));
     }
     $this->view->banners = $this->find();
     $this->view->title = Functions::mb_ucfirst(trim(($this->request->getQuery('archived') == '1' ? " архивные" : '') . ($this->request->getQuery('filter') == 'deactivated' ? " деактивированные" : ($this->request->getQuery('filter') == 'finished' ? " выполненные" : '')) . " баннеры")) . ($this->request->getQuery('archive') == '1' ? " в архиве" : '') . (isset($advertiser) && $advertiser ? " рекламодателя \"{$advertiser->getUsername()}\"" : '') . (isset($zone) && $zone ? " в зоне \"{$zone->name}\"" : '');
     \Phalcon\Tag::prependTitle("Баннеры");
 }
开发者ID:atnartur,项目名称:SimpleBannerRotator,代码行数:12,代码来源:BannersController.php

示例3: startAction

 /**
  * This action authenticate and logs an user into the application
  *
  */
 public function startAction()
 {
     if ($this->request->isPost()) {
         $email = $this->request->getPost('email');
         $password = $this->request->getPost('password');
         $user = Users::findFirst(array("(email = :email: OR username = :email:) AND password = :password: AND active = 'Y'", 'bind' => array('email' => $email, 'password' => sha1($password))));
         if ($user != false) {
             $this->_registerSession($user);
             $this->flash->success('Welcome ' . $user->name);
             return $this->forward('invoices/index');
         }
         $this->flash->error('Wrong email/password');
     }
     return $this->forward('session/index');
 }
开发者ID:kenikori,项目名称:phalcon2_invo,代码行数:19,代码来源:SessionController.php

示例4: startAction

 public function startAction()
 {
     if ($this->request->isPost()) {
         $email = $this->request->getPost('email', 'email');
         $password = $this->request->getPost('password');
         $password = sha1($password);
         $user = Users::findFirst(['conditions' => 'email = ?0 AND password = ?1 AND active= ?2 ', 'bind' => [$email, $password, 'Y']]);
         if ($user != false) {
             $this->auth->login($user->toArray());
             return $this->goToMain();
         }
         $this->flash->error('Не верный email или password');
     }
     return $this->dispatcher->forward(array('controller' => 'session', 'action' => 'index'));
 }
开发者ID:kofeinstyle,项目名称:coc,代码行数:15,代码来源:SessionController.php

示例5: profileAction

 public function profileAction()
 {
     $id = $this->dispatcher->getParam('id');
     $user = Users::findFirst($id);
     if ($user && $id) {
         if ($this->request->isPost()) {
             $action = $this->request->getPost('action');
             if ($action == "change_info") {
                 if ($user->update($this->request->getPost(), array('fname', 'lname', 'thname'))) {
                     $this->auth->refresh_user();
                     $this->flashSession->success("Информация о рекламодателе обновлена");
                 } else {
                     foreach ($user->getMessages() as $message) {
                         $this->flashSession->error($message->getMessage());
                     }
                 }
             } elseif ($action == "change_email") {
                 if ($user->update($this->request->getPost(), array('email'))) {
                     $this->auth->refresh_user();
                     $this->flashSession->success("E-mail рекламодателя изменён");
                 } else {
                     foreach ($user->getMessages() as $message) {
                         $this->flashSession->error($message->getMessage());
                     }
                 }
             } elseif ($action == "change_password") {
                 if ($this->request->getPost('password') === $this->request->getPost('password_confirm')) {
                     if ($user->update(array('password' => $this->auth->hash($this->request->getPost('password'))))) {
                         $this->auth->refresh_user();
                         $this->flashSession->success('Пароль рекламодателя успешно изменён');
                     } else {
                         foreach ($user->getMessages() as $message) {
                             $this->flashSession->error($message->getMessage());
                         }
                     }
                 } else {
                     $this->flashSession->error('Пароль и повтор пароля должны совпадать.');
                 }
             }
         }
         $this->view->user = $user;
         $this->view->title = $user->getUsername() . " - Управление";
         \Phalcon\Tag::prependTitle($user->getUsername() . " - Управление");
     } else {
         $this->dispatcher->forward(array("namespace" => 'App\\Controllers', "controller" => "error", "action" => "notFound"));
     }
 }
开发者ID:atnartur,项目名称:SimpleBannerRotator,代码行数:47,代码来源:AdvertisersController.php

示例6: getUserFromDb

 public function getUserFromDb()
 {
     $id = $this->auth->getUserId();
     return Users::findFirst(['conditions' => 'id = ?0', 'bind' => [$id]]);
 }
开发者ID:kofeinstyle,项目名称:coc,代码行数:5,代码来源:ControllerBase.php

示例7: testRefunds

 public function testRefunds()
 {
     $user = Users::findFirst();
     // Create Invoice
     $user->createAsStripeCustomer($this->getTestToken());
     $invoice = $user->invoiceFor('Phalcon PHP Cashier', 1000);
     // Create the refund
     $refund = $user->refund($invoice->charge);
     // Refund Tests
     $this->assertEquals(1000, $refund->amount);
 }
开发者ID:duythien,项目名称:cashier,代码行数:11,代码来源:CashierTest.php

示例8: login

 /**
  * Attempt to log in a user by using an ORM object and plain-text password.
  *
  * @param string $email email to log in
  * @param string $password password to check against
  * @param boolean $remember enable autologin
  * @return boolean
  */
 public function login($user, $password, $remember = false)
 {
     if (!is_object($user)) {
         $email = $user;
         // email not specified
         if (!$email) {
             return null;
         }
         // Load the user
         $user = Users::findFirst(array('email=:email:', 'bind' => array(':email' => $email)));
     }
     if ($user) {
         // Create a hashed password
         if (is_string($password)) {
             $password = $this->hash($password);
         }
         // If user have login role and the passwords match, perform a login
         if ($user->password === $password) {
             if ($remember === true) {
                 // Create a new autologin token
                 $token = new Tokens();
                 $token->user_id = $user->id;
                 $token->user_agent = sha1($this->request->getUserAgent());
                 $token->token = $this->create_token();
                 $token->created = time();
                 $token->expires = time() + $this->_config['lifetime'];
                 if ($token->create() === true) {
                     // Set the autologin cookie
                     $this->cookies->set('authautologin', $token->token, time() + $this->_config['lifetime']);
                 }
             }
             // Finish the login
             $this->complete_login($user);
             // Regenerate session_id
             // session_regenerate_id();
             // Store user in session
             $this->session->set($this->_config['session_key'], serialize($user));
             // Store user's roles in session
             if ($this->_config['session_role']) {
                 $this->session->set($this->_config['session_role'], $user->type);
             }
             return true;
         } else {
             // Login failed
             return false;
         }
     }
     // No user found
     return null;
 }
开发者ID:atnartur,项目名称:SimpleBannerRotator,代码行数:58,代码来源:Auth.php


注:本文中的app\models\Users::findFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。