本文整理匯總了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));
}
示例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;
}
}
示例3: User
function __construct($user_id = 1)
{
$user = new User($user_id);
if ($user->exists()) {
$this->currentUser = $user;
}
}
示例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;
}
示例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));
}
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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));
}
示例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);
}
示例11: testUserExistence
function testUserExistence()
{
$user = new User(2);
$this->assertTrue($user->exists());
$this->assertTrue(!empty($user->name()));
$this->assertTrue(!empty($user->pass()));
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例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);
}