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


PHP UserModel::find方法代码示例

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


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

示例1: login

 /**
  * Display listing of the resource
  *
  * @return Response
  */
 public function login()
 {
     //set the user array to gather data from user form
     $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
     /*
     $hashpassword = Hash::Make(Input::get('password'));
     var_dump($hashpassword);
     die();
     */
     if (Auth::check()) {
         return Redirect::to('/');
     }
     if (Auth::attempt($userdata)) {
         // cauta userul in baza de date
         $user = UserModel::find(Auth::user()->id);
         if ($user->active == 0) {
             //daca userul nu este activ
             Auth::logout();
             Session::flush();
             return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Login successful', 'success'));
         }
         //if($user->active == '0')
         //daca userul este activ
         Session::put('current_user', Input::get('username'));
         Session::put('user_access', $user->access);
         Session::put('user_id', $user->id);
         return Redirect::to('/');
     } else {
         return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Incorrect username or password', 'danger'));
     }
     //else if Auth
 }
开发者ID:dannyneamtu,项目名称:lara_project1,代码行数:37,代码来源:UserController.php

示例2: areatoname

 public function areatoname()
 {
     $userInfo = UserModel::find($this->uid);
     $areaName = $userInfo->area ? $this->getAreaName($userInfo->area) : '';
     //        return $userInfo->area ? AreaModel::find($userInfo->area)->cityname : '未知城市';
     return $areaName ? $areaName : '未知城市';
 }
开发者ID:946493655,项目名称:culture,代码行数:7,代码来源:TalksModel.php

示例3: loginUser

 /**
  * Login user and store user informations in session
  * @param  string $login User login
  * @param  string $pass User password
  * @param  string $mode authorization method email/login
  * @param  string $role webmaster/administrator/admin
  * @return boolean
  */
 function loginUser($login, $password, $mode = "email", $role = "webmaster")
 {
     if (empty($login)) {
         return false;
     }
     $users = new UserModel();
     $c = new Criteria();
     if ($mode == "login") {
         $c->add("login", $login);
     } else {
         $c->add("email", $login);
     }
     $c->add("password", $password);
     $c->add("role", $role);
     $c->add("active", "1");
     $row = $users->find($c);
     if (!empty($row)) {
         foreach ($row as $key => $value) {
             $this->set($key, $value);
         }
         if (empty($row['login'])) {
             $this->set("login", $row['email']);
         }
         return true;
     }
     return false;
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:35,代码来源:Session.php

示例4: pageController

function pageController()
{
    $errors = [];
    if (!Auth::isLoggedIn()) {
        header('Location: users.create.php');
        exit;
    }
    $userObject = UserModel::find($_SESSION['user_id']);
    if (!empty($_POST)) {
        try {
            $userObject->first_name = Input::getString('firstName');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $userObject->last_name = Input::getString('lastName');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::get('password1') == Input::get('password2')) {
            try {
                $userObject->password = Input::getPassword('password1', $userObject->first_name, $userObject->last_name, $userObject->email);
            } catch (Exception $e) {
                $errors[] = $e->getMessage();
            }
        }
        $userObject->save();
    }
    return ['user' => $userObject, 'errors' => $errors];
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:30,代码来源:users.edit.php

示例5: update

 function update()
 {
     $userModel = new UserModel();
     $goods_info = $userModel->find("id={$_GET['id']}");
     print_r($goods_info);
     $test = '用户修改表单';
     $this->display('UserEdit.php', array("goods_info" => $goods_info, "test" => $test));
 }
开发者ID:ShuiMuQinHua,项目名称:YmPHP,代码行数:8,代码来源:UserControl.php

示例6: getUName

 public function getUName()
 {
     $uid = $this->uid ? $this->uid : 0;
     $userName = '';
     if ($uid) {
         $userModel = UserModel::find($uid);
         $userName = $userModel ? $userModel->username : '';
     }
     return $userName ? $userName : '本站';
 }
开发者ID:946493655,项目名称:culture,代码行数:10,代码来源:ThemeModel.php

示例7: pageController

function pageController()
{
    //initializes the session variable if none exists otherwise it resets it
    //a user id was passed to this page to display
    if (!empty($_GET['id'])) {
        $userID = $_GET['id'];
        $userObject = UserModel::find($userID);
        $userAds = $userObject->getAds();
    }
    return array('userObject' => $userObject, 'userAds' => $userAds);
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:11,代码来源:users.show.php

示例8: user

 /**
  * 获取当前登录用户信息
  */
 protected function user()
 {
     // 获取当前登录用户 Uid
     $uid = Session::get('uid');
     if (!$uid) {
         return null;
     }
     // 获取当前登录用户信息
     $user = UserModel::find($uid);
     return $user ? $user[0] : null;
 }
开发者ID:qxy735,项目名称:YuYi-General,代码行数:14,代码来源:BaseController.php

示例9: user_model_test

function user_model_test($delete)
{
    $user = new UserModel("Not", "Here", "not.here@nowhere.com", "password", date("Y-m-d H:i:s"));
    $user->save();
    $user->print_fields();
    $user->set("failed_login_attempts", 3);
    $user->set("first_name", "User");
    $user->set("last_name", "McUsage");
    $user->save();
    $user->print_fields();
    if ($delete) {
        $user->delete();
    }
    $um = UserModel::find(UserModel::first()->id);
    $um->print_fields();
    $um = UserModel::find(UserModel::last()->id);
    $um->print_fields();
    UserModel::find(999);
}
开发者ID:spencerbartz,项目名称:horrie_international,代码行数:19,代码来源:user_model.php

示例10: profile_update

 /**
  * Updates the user data
  *
  * @global type $STRINGS
  * @param type $params
  */
 public function profile_update($params)
 {
     global $STRINGS;
     $userid = array_shift($params);
     //remove url params
     $params = array_slice($params, 1);
     //check if the password is set
     if (empty($params['password'])) {
         //no password is provided -> remove key
         unset($params['password']);
     } else {
         //compute new password and store
         $params['password'] = sha1($params['password']);
     }
     $success = UserModel::update($userid, $params);
     $success == true ? $alert = BootstrapHelper::alert('success', $STRINGS['event:success'], $STRINGS['user:update:success']) : ($alert = BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:update:failed']));
     //refresh the user data
     $this->_data->user = UserModel::find($userid);
     new UserProfileView($this->_data, $alert);
 }
开发者ID:robertboloc,项目名称:presence-manager,代码行数:26,代码来源:UserController.php

示例11: testDeleteAll

 public function testDeleteAll()
 {
     $userTable = new UserModel();
     $letterTable = new LetterListModel();
     $userTable->deleteAll();
     $letter = $letterTable->find();
     $user = $userTable->find();
     $this->assertTrue($letter == null && $user == null);
 }
开发者ID:chen8840,项目名称:LMJ-s-project,代码行数:9,代码来源:LetterListModelTest.php

示例12: compute_intervals

 private function compute_intervals($params)
 {
     if (isset($params[0]) && !empty($params[0])) {
         //a user is specified
         $users = array('user' => UserModel::find($params[0]));
     } else {
         //all users
         $users = UserModel::find_all();
     }
     if ($users) {
         foreach ($users as $user) {
             //get activity without incidences
             $activity = ActivityModel::find_all_by_user_not_computed($user->id);
             if ($activity) {
                 $activity_entries = array();
                 //group 2 by 2
                 $grouped_activities = null;
                 for ($i = 0; $i < count($activity); $i = $i + 2) {
                     //group only when we have both members
                     if ($activity[$i] && $activity[$i + 1]) {
                         $grouped_activities[] = array($activity[$i], $activity[$i + 1]);
                         //mark activities as computed
                         $activity_entries[] = $activity[$i]->id;
                         $activity_entries[] = $activity[$i + 1]->id;
                     }
                 }
                 $intervals = null;
                 foreach ($grouped_activities as $gactivity) {
                     //check data integrity
                     if ($gactivity[0]->action == 'checkin' && $gactivity[1]->action == 'checkout') {
                         //compute the interval
                         $date_start = new DateTime(date(DATE_ATOM, $gactivity[0]->timestamp));
                         $date_end = new DateTime(date(DATE_ATOM, $gactivity[1]->timestamp));
                         $date_diff = $date_start->diff($date_end);
                         $interval = new stdClass();
                         $interval->userid = $gactivity[0]->userid;
                         $interval->timestart = $gactivity[0]->timestamp;
                         $interval->timestop = $gactivity[1]->timestamp;
                         $interval->timediff = $gactivity[1]->timestamp - $gactivity[0]->timestamp;
                         $interval->week = date('W', $gactivity[0]->timestamp);
                         $interval->month = date('n', $gactivity[0]->timestamp);
                         $interval->year = date('o', $gactivity[0]->timestamp);
                         $interval->y = $date_diff->y;
                         $interval->m = $date_diff->m;
                         $interval->d = $date_diff->d;
                         $interval->h = $date_diff->h;
                         $interval->i = $date_diff->i;
                         $interval->s = $date_diff->s;
                         $intervals[] = $interval;
                     } else {
                         die(print_r("FATAL: Corrupted database!\n"));
                     }
                 }
                 //save the intervals to the DB
                 if ($intervals) {
                     IntervalModel::create_multiple($intervals);
                 }
                 if ($activity_entries) {
                     ActivityModel::mark_as_computed($activity_entries);
                 }
             }
         }
     }
 }
开发者ID:robertboloc,项目名称:presence-manager,代码行数:64,代码来源:CronController.php

示例13: testUpdate

 /**
  * Tests the update method
  */
 public function testUpdate()
 {
     //update main tester user data
     UserModel::update('999999', array('UUID' => '1x3'));
     $updated_user = UserModel::find('999999');
     //check if the data is updated
     $this->assertEquals($updated_user->UUID, '1x3');
 }
开发者ID:robertboloc,项目名称:presence-manager,代码行数:11,代码来源:ModelTest.php

示例14: resetPassword

 public function resetPassword()
 {
     $this->view = new HTMLView();
     if ($this->request->isPOST()) {
         $post = $this->request->postData();
         $user = new UserModel();
         if ($this->request->isQueryArgSet('token')) {
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $user->password = @$post['password'];
                 if ($user->save()) {
                     $user->deletePasswordResetTokens();
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Password Set, Please Login');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessageArray($user->getErrors());
                 }
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($post['email'] && $user->find($post['email'], 'email')) {
                 $token = $user->getPasswordResetTokenData();
                 if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) {
                     $user->incrementPasswordResetEmailCount();
                     $link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]);
                     // Send Email
                     $mailer = new Mailer();
                     $mailer->setSubject('Password Reset Token');
                     $mailer->addAddress($user->email);
                     $mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]);
                     $mailer->send();
                     // errors handled within
                     // Show Message
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Email Sent');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessage('Too Many Attempts, Please Try Again Later');
                 }
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Email is Invalid/Non-Existent');
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             }
         }
     } else {
         if ($this->request->isQueryArgSet('token')) {
             $user = new UserModel();
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Token is Invalid/Expired, Please Request a New One');
             }
             $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]);
         }
     }
     $this->view->render(true);
 }
开发者ID:bitcalc,项目名称:allspark,代码行数:66,代码来源:authcontroller.php

示例15: finished

 public function finished($user_id, $token)
 {
     if (true === $this->init($user_id, $token)) {
         $this->layout->content = View::make('laravel-quiz::contents.finished')->with('quiz', $this->quiz)->with('result', $this->result);
         $user = \UserModel::find($user_id);
         if ($user) {
             VisitModel::add($user, $this->quiz);
         }
     }
 }
开发者ID:xjtuwangke,项目名称:laravel-quiz,代码行数:10,代码来源:QuizController.php


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