當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::exists方法代碼示例

本文整理匯總了PHP中User::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::exists方法的具體用法?PHP User::exists怎麽用?PHP User::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在User的用法示例。


在下文中一共展示了User::exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testExists

 /**
  * testExists function
  * @return void
  */
 public function testExists()
 {
     $this->loadFixtures('User');
     $TestModel = new User();
     $this->assertTrue($TestModel->exists(1));
     $TestModel->id = 2;
     $this->assertTrue($TestModel->exists());
     $TestModel->delete();
     $this->assertFalse($TestModel->exists());
     $this->assertFalse($TestModel->exists(2));
 }
開發者ID:TerrasAppSolutions,項目名稱:seeg-mapbiomas-workspace,代碼行數:15,代碼來源:ModelReadTest.php

示例2: email_login

function email_login($email, $password)
{
    $CI =& get_instance();
    $user = new User();
    $user->where(array('email' => $email, 'password' => $password))->get();
    if ($user->exists()) {
        if ($user->profile->type == "ประชาชนทั่วไป") {
            $timediff = timeDiff($user->last_login, date("Y-m-d H:i:s", now()));
            $webboard_status_config = new Webboard_status_config(1);
            if ($timediff > $webboard_status_config->memlock) {
                $user->m_status = "ban";
                $user->last_login = $user->last_login;
            } else {
                $user->m_status = "active";
                $user->last_login = date("Y-m-d H:i:s", now());
            }
        }
        $user->save();
        if ($user->m_status == "ban") {
            return FALSE;
        }
        $_SESSION['id'] = $user->id;
        // $CI->session->set_userdata('id',$user->id);
        $_SESSION['level'] = $user->level_id;
        // $CI->session->set_userdata('level',$user->level_id);
        //$log = fopen("log.txt", "a");
        //fwrite($log, ' '.$user->last_login.' - '.$user->email.' เข้าสู่ระบบ'.'\r\n');
        //fclose($log);
        file_put_contents('log.txt', $user->last_login . ' - ' . $user->email . ' เข้าสู่ระบบ' . "\n", FILE_APPEND);
        return TRUE;
    } else {
        return FALSE;
    }
}
開發者ID:unisexx,項目名稱:thaigcd2015,代碼行數:34,代碼來源:auth_helper.php

示例3: User

 function __construct($user_id = 1)
 {
     $user = new User($user_id);
     if ($user->exists()) {
         $this->currentUser = $user;
     }
 }
開發者ID:VedranBrnjetic,項目名稱:BBCTestRecipe,代碼行數:7,代碼來源:application.php

示例4: queue_keywords_for_update

 /**
  * Check for not-updated-today, not-deleted  keywords
  * And set for rank update if exist
  * 
  * daily
  */
 public function queue_keywords_for_update()
 {
     $keyword_rank = new Keyword_rank();
     $keyword_rank_ids = $keyword_rank->where('date', date('Y-m-d'))->get()->all_to_single_array('keyword_id');
     if (empty($keyword_rank_ids)) {
         $keyword_rank_ids = array(0);
     }
     $keywords = new Keyword();
     $keywords->where('is_deleted', 0)->where_not_in('id', $keyword_rank_ids)->get();
     if (!$keywords->exists()) {
         log_message('CRON_ERROR', __FUNCTION__ . ' > ' . 'No keywords for rank update');
         return;
     }
     $acc = $this->getAAC();
     foreach ($keywords as $keyword) {
         $user = new User($keyword->user_id);
         if (!$user->exists()) {
             continue;
         }
         $acc->setUser($user);
         if (!$acc->isGrantedPlan('local_search_keyword_tracking')) {
             continue;
         }
         $args = $keyword->to_array();
         $this->jobQueue->addJob('tasks/google_rank_task/grabber', $args, array('thread' => self::GOOGLE_RANK_THREAD));
     }
     $ids_str = implode(', ', array_values($keywords->all_to_single_array('id')));
     log_message('CRON_SUCCESS', __FUNCTION__ . ' > ' . 'Keywords for rank update ids: ' . $ids_str);
     return;
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:36,代碼來源:google_rank_cron.php

示例5: inviteUser

 public function inviteUser($userId = null)
 {
     if ($userId) {
         $user = new User($userId);
         $email = $user->email;
     } else {
         $email = $this->input->post('email');
     }
     if ($email) {
         $group = $this->config->item('admin_group', 'ion_auth');
         $adminGroup = $this->ion_auth->getGroupByName($group);
         $result = $this->ion_auth->invite($email, array($adminGroup->id), $userId);
         if ($result) {
             if (!$userId) {
                 $user = new User($result['id']);
                 $user->save(array('manager_user' => new User($this->c_user->id)));
             }
             if ($user->exists()) {
                 $sender = $this->get('core.mail.sender');
                 $params['to'] = $email;
                 $params['data'] = array('link' => site_url('auth/invite/' . $result['code']), 'sitename' => $this->config->config['OCU_site_name']);
             }
         }
         if ($success = $result && $sender->sendInviteMail($params)) {
             $this->addFlash(lang('invite_success'), 'success');
         } else {
             $this->addFlash(lang('invite_error'));
         }
         if ($userId) {
             redirect('admin/manage_admins');
         }
         echo json_encode(array('success' => $success));
     }
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:34,代碼來源:manage_admins.php

示例6: log_in

 public function log_in()
 {
     // backup username for invalid logins
     $uname = $this->email;
     // Create a temporary user object
     $u = new User();
     // Get this users stored record via their email
     $u->where('email', $uname)->where('active', 1)->get();
     if (!$u->exists()) {
         return false;
     }
     // Give this user their stored salt
     $this->salt = $u->salt;
     // Validate and get this user by their property values,
     // this will see the 'encrypt' validation run, encrypting the password with the salt
     $this->validate()->get();
     // If the username and encrypted password matched a record in the database,
     // this user object would be fully populated, complete with their ID.
     // If there was no matching record, this user would be completely cleared so their id would be empty.
     if ($this->exists()) {
         // Login succeeded
         return TRUE;
     } else {
         // Login failed, so set a custom error message
         //$this->error_message('login', 'Username or password invalid');
         // restore username for login field
         //$this->username = $uname;
         return FALSE;
     }
 }
開發者ID:jotavejv,項目名稱:CMS,代碼行數:30,代碼來源:user.php

示例7: _ops_update

function _ops_update()
{
    require_login();
    $msg = '';
    $uid = max(0, intval($_POST['uid']));
    $user = new User();
    if ($uid) {
        $user->retrieve($uid);
        $user->merge($_POST);
        if (!$user->exists()) {
            $msg = 'User not found!';
        } else {
            if ($user->update()) {
                $msg = 'User updated!';
            } else {
                $msg = 'User update failed!';
            }
        }
    } else {
        $user->merge($_POST);
        if ($user->create()) {
            $msg = 'User inserted!';
        } else {
            $msg = 'User insert failed!';
        }
    }
    redirect('users/manage', $msg);
}
開發者ID:469306621,項目名稱:Languages,代碼行數:28,代碼來源:ops_update.php

示例8: update

 public function update($id, $request)
 {
     $config = new Config(CONFIG . 'app.json');
     $config->parseFile();
     $data = $request->getParameters();
     if (isset($data['userSubmit'])) {
         $deny_fields = ['id', 'rank'];
         if (User::exists($id)) {
             $user = User::find($id);
             foreach ($data as $k => $value) {
                 if (isset($user->{$k}) && !in_array($k, $deny_fields)) {
                     switch ($k) {
                         case 'username':
                             $u_c = $user->getMainChannel();
                             $u_c->name = $value;
                             $u_c->save();
                             break;
                         case 'pass':
                             $value = !empty($value) ? password_hash($value, PASSWORD_BCRYPT) : $user->pass;
                             break;
                     }
                     $user->{$k} = $value;
                 }
                 $user->save();
             }
             $r = new ViewResponse("admin/user/edit", ['user' => $user]);
         }
         return $r;
     }
 }
開發者ID:boulama,項目名稱:DreamVids,代碼行數:30,代碼來源:user_controller.php

示例9: run

 /**
  * Daily social statistic collect
  * Add new access token to Queue
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $types = array('facebook', 'twitter', 'linkedin', 'google', 'instagram');
     $tokens = Access_token::inst()->where_in('type', $types)->get();
     $aac = $this->getAAC();
     $acceptedUsersIds = array();
     $now = new \DateTime('UTC');
     foreach ($tokens as $_token) {
         $now->modify('1 minutes');
         $user = new User($_token->user_id);
         if (!$user->exists()) {
             continue;
         }
         $aac->setUser($user);
         if (!$aac->isGrantedPlan('social_activity')) {
             continue;
         }
         $args = $_token->to_array();
         foreach ($_token->social_group->get() as $profile) {
             $args['profile_id'] = $profile->id;
             if (!in_array($args['user_id'], $acceptedUsersIds) && $args['type'] != 'instagram') {
                 array_push($acceptedUsersIds, $args['user_id']);
             }
         }
     }
     $this->jobQueue->addJob('tasks/social_reports_task/statistic', $acceptedUsersIds, array('thread' => self::SOCIAL_THREAD));
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:34,代碼來源:social_reports_cron.php

示例10: User

 /**
  * Creates a new user
  */
 function user_put()
 {
     /* Check for an existing user
        ------------------------------------------------- */
     $uuid = $this->put('uuid');
     $existing_user = new User();
     $existing_user->get_by_uuid($uuid);
     if ($existing_user->exists()) {
         $output = array('User with UUID ' . $uuid . ' already exists');
     } else {
         // They don't exist, create them
         $user = new User();
         $user->uuid = $uuid;
         if ($user->save()) {
             $output = array('User created with UUID: ' . $uuid);
             log_message('error', 'User created');
         } else {
             $output = array('Error saving user');
             log_message('error', 'Error creating user');
         }
     }
     /* TODO - return dance and robot data here
        ------------------------------------------------- */
     $this->response($output);
 }
開發者ID:CodeClub,項目名稱:robo-boogie,代碼行數:28,代碼來源:users.php

示例11: testUserExistence

 function testUserExistence()
 {
     $user = new User(2);
     $this->assertTrue($user->exists());
     $this->assertTrue(!empty($user->name()));
     $this->assertTrue(!empty($user->pass()));
 }
開發者ID:VedranBrnjetic,項目名稱:BBCTestRecipe,代碼行數:7,代碼來源:user_test.php

示例12: run

 /**
  * Daily social statistic collect
  * Add new access token to Queue
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $types = array('twitter');
     $tokens = Access_token::inst()->where_in('type', $types)->get();
     $aac = $this->getAAC();
     $now = new \DateTime('UTC');
     foreach ($tokens as $_token) {
         $now->modify('1 minutes');
         $user = new User($_token->user_id);
         if (!$user->exists()) {
             continue;
         }
         $aac->setUser($user);
         if (!$aac->isGrantedPlan('social_activity')) {
             continue;
         }
         $args = $_token->to_array();
         foreach ($_token->social_group->get() as $profile) {
             $args['profile_id'] = $profile->id;
             //Twitter tasks
             $this->jobQueue->addJob('tasks/twitter_task/searchUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/updateFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/randomRetweet', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/randomFavourite', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/sendWelcomeMessage', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/followNewFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/unfollowUnsubscribedUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
         }
     }
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:37,代碼來源:twitter_cron.php

示例13: factory

 /**
  * Get a new UsersActivations for a User.
  *
  * @param User $user
  * @return UsersActivations
  */
 public static function factory(User $user)
 {
     $ua = new self();
     if (!$user->exists()) {
         throw new RuntimeException(__("Cannot create a user activation for non-existent user."));
     }
     $ua->user_id = $user->id;
     return $ua;
 }
開發者ID:lchen01,項目名稱:STEdwards,代碼行數:15,代碼來源:UsersActivations.php

示例14: login

 public static function login($username, $password)
 {
     $userID = self::idByUsername($username);
     $user = new User($userID);
     if ($user->exists() && $user->password == self::encryptPassword($password)) {
         return $user->id;
     }
     return false;
 }
開發者ID:nickyleach,項目名稱:OSTSurvey,代碼行數:9,代碼來源:User.php

示例15: __construct

 /**
  * Create a new API framework for a given User
  *
  * @param User $u
  */
 public function __construct(User $u)
 {
     if (!$u || !$u->exists() || !$u->user_id) {
         throw new Exception("Invalid user specified!");
     }
     // send User to parent ini
     $ini = array('user' => $u);
     parent::__construct(APPPATH . $this->api_path, $this->namespace, $ini);
 }
開發者ID:kaakshay,項目名稱:audience-insight-repository,代碼行數:14,代碼來源:AIRAPI.php


注:本文中的User::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。