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


PHP Sentry::user_exists方法代码示例

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


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

示例1: remove_credits

 /**
  * Remove user credits depending of order
  *
  * @access public
  * @param  object	          $order = Order object
  * @param  array of objects   $products = Products from order
  * @return void
  */
 public static function remove_credits($order = false, $products = false)
 {
     if (!is_numeric($order->user_id)) {
         return false;
     }
     // Get user to edit
     if (!\Sentry::user_exists((int) $order->user_id)) {
         return false;
     }
     $user = new \Sentry_User((int) $order->user_id);
     // Remove user credits
     $seek = $user->get('metadata.seek_credits') - ($order->seek > 0 ? 1 : 0);
     $seek >= 0 or $seek = 0;
     $careerone = $user->get('metadata.careerone_credits') - ($order->careerone > 0 ? 1 : 0);
     $careerone >= 0 or $careerone = 0;
     $update = array('metadata' => array('seek_credits' => $seek, 'careerone_credits' => $careerone));
     // Update user credits
     if ($user->update($update)) {
         return true;
     }
     return false;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:30,代码来源:payment.php

示例2: action_create

 public function action_create()
 {
     if (!Sentry::user()->has_access('users_create')) {
         Response::redirect('');
     }
     if (Input::method() == 'POST') {
         $val = Model_Users::validate('create');
         if (!$val->run()) {
             // no valid values
             Session::set_flash('error', implode(' ', $val->error()));
         } else {
             // valid values
             if (Sentry::user_exists(Input::post('username'))) {
                 // the user exist
                 Session::set_flash('error', 'User ' . Input::post('username') . ' already exists');
             } else {
                 $user_id = Sentry::user()->create(array('username' => Input::post('username'), 'email' => Input::post('email'), 'password' => Input::post('password'), 'metadata' => array('department' => Input::post('department'), 'first_name' => Input::post('first_name'), 'last_name' => Input::post('last_name'))));
                 if (!$user_id) {
                     // user has not been created
                     Session::set_flash('error', 'User not created');
                 } else {
                     // user has been created
                     $user = Sentry::user($user_id);
                     $user->add_to_group(Input::post('group'));
                     Session::set_flash('success', 'User successfuly created');
                     Response::redirect('users');
                 }
             }
         }
     }
     View::set_global('groups', Sentry::group()->all());
     $this->template->h2 = 'Create a new user';
     $this->template->title = 'User » Create';
     $this->template->js .= Asset::js(array('mylibs/jquery.validate.js', 'script.js'));
     $this->template->content = View::forge('users/create');
 }
开发者ID:roine,项目名称:wawaw,代码行数:36,代码来源:users.php

示例3: action_login

 public function action_login()
 {
     $redirect = Session::get('redirect');
     $vars = array('email' => 'jonathan@ikonfx.com', 'password' => '123456', 'username' => 'jonathan', 'metadata' => array('first_name' => 'jonathan', 'last_name' => 'de montalembert', 'department' => 'test'));
     // $user_id = Sentry::user()->create($vars, true);
     if (Sentry::check()) {
         Response::redirect($redirect);
     }
     $this->template = \View::forge('login');
     if (Input::post()) {
         if (Sentry::user_exists(Input::post('username'))) {
             // User exists
             if (Sentry::attempts()->get_limit() > Sentry::attempts(Input::post('username'))->get()) {
                 // max attempts not reached
                 $valid_login = Sentry::login(Input::post('username'), Input::post('password'));
                 if ($valid_login) {
                     Session::set_flash('success', 'Welcome back ' . ucwords(Input::post('username')));
                     Response::redirect($redirect);
                 } else {
                     $data['username'] = Input::post('username');
                     $data['password'] = Input::post('password');
                     Session::set_flash('error', 'Username OR/AND Password incorrects. You tried ' . Sentry::attempts(Input::post('username'))->get() . '/' . Sentry::attempts()->get_limit());
                 }
             } else {
                 // max attempts reached
                 Session::set_flash('error', 'You\'ve reached your max attempts and will have to wait for ' . Sentry::attempts(Input::post('username'))->get_time() . ' minutes');
             }
         } else {
             // user do not exists
             Session::set_flash('error', 'User do not exists');
         }
     }
     $this->template->title = $data['title'] = 'Welcome to IKON backoffice';
     $this->template->custom_class = 'special_page';
     $this->template->content = View::forge('welcome/login', $data);
 }
开发者ID:roine,项目名称:wawaw,代码行数:36,代码来源:welcome.php

示例4: action_password

 /**
  * Change user password
  * 
  * @access public
  * @return void
  */
 public function action_password()
 {
     \View::set_global('title', 'Forgot Password');
     if (\Input::post('forgot')) {
         $val = \User\Controller_Validate::forge('forgot_password');
         if ($val->run()) {
             // Get POST values
             $identity = \Input::post('identity', '');
             if (\Sentry::user_exists($identity)) {
                 try {
                     // reset the password
                     $reset = \Sentry::reset_password($identity);
                     if ($reset) {
                         $customer_email = $reset['email'];
                         // Load email package
                         \Package::load('email');
                         // Load email addresses from config (these will be bcc receivers)
                         \Config::load('auto_response_emails', true);
                         $bcc = \Config::get('autoresponders.forgot_password_emails');
                         if (!$bcc) {
                             $bcc = \Config::get('autoresponders.default_emails');
                         }
                         $settings = \Config::load('autoresponder.db');
                         $email_data = array('site_title' => $settings['company_name'], 'customer_identity' => $identity, 'reset_link' => \Uri::front_create('user/reset_password/' . $reset['link']));
                         $email = \Email::forge();
                         $email->to($customer_email);
                         $email->from(\Config::get('auto_response_emails.autoresponder_from_email'), $settings['company_name']);
                         if ($bcc) {
                             $email->bcc($bcc);
                         }
                         $email->subject($email_data['site_title'] . ' - Forgot Password');
                         $email_html = \Theme::instance()->view('views/_email/forgot_password')->set('email_data', $email_data, false);
                         $email->html_body($email_html);
                         try {
                             $email->send();
                             \Messages::success('You have been sent an email to reset your password.');
                         } catch (\EmailValidationFailedException $e) {
                             \Messages::error('Error while sending email.');
                         } catch (\EmailSendingFailedException $e) {
                             \Messages::error('Error while sending email.');
                         }
                         \Response::redirect(\Input::referrer(\Uri::front_create('/')));
                     } else {
                         \Messages::error('There was a problem while trying to change your password. Please try again.');
                     }
                 } catch (\Sentry\SentryException $e) {
                     // show validation errors
                     //\Messages::error('<h4>There was an error while trying to create user</h4>');
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             } else {
                 \Messages::error('There doesn`t appear to be an account associated with this email address. Try a different email address or register for a new account on the homepage.');
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 //\Messages::error('<h4>There was an error while trying to create user</h4>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     if (\Input::is_ajax()) {
         echo \Theme::instance()->view($this->view_dir . 'forgot_password');
     } else {
         if (isset($val)) {
             \View::set_global('validation', $val, false);
         }
         \Theme::instance()->set_partial('content', $this->view_dir . 'single_forgot_password');
     }
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:79,代码来源:user.php

示例5: add_credits

 /**
  * Add user credits depending of order
  *
  * @access public
  * @param  object	          $order = Order object
  * @param  array of objects   $products = Products from order
  * @return void
  */
 public function add_credits($order = false, $products = false)
 {
     if (!is_numeric($order->user_id)) {
         return false;
     }
     // Get user to edit
     if (!\Sentry::user_exists((int) $order->user_id)) {
         return false;
     }
     $user = new \Sentry_User((int) $order->user_id);
     // Add user credits
     $update = array('metadata' => array('seek_credits' => $user->get('metadata.seek_credits') + $order->seek, 'careerone_credits' => $user->get('metadata.careerone_credits') + $order->careerone));
     // Update user credits
     if ($user->update($update)) {
         return true;
     }
     return false;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:26,代码来源:public.php

示例6: action_update

 /**
  * Update user profile
  * 
  * @param int 
  * @access public
  * @return void
  */
 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/settings/user/list');
     }
     // Cast user id param to int
     $id = (int) $id;
     // Redirect if user don't exists
     if (!\Sentry::user_exists($id)) {
         \Response::redirect('admin/settings/user/list');
     }
     $user = \Sentry::user($id);
     $user_group = new \Sentry_User((int) $id);
     $user_group1 = $user_group->groups();
     $user_group2 = current($user_group1);
     $user_data = array('id' => $user->get('id'), 'first_name' => $user->get('metadata.first_name'), 'last_name' => $user->get('metadata.last_name'), 'email' => $user->get('email'), 'username' => $user->get('username'), 'user_group' => $user_group2['name']);
     if (\Input::post()) {
         // Validate input parameters
         $val = \Validation::forge('admin_details_validation');
         $val->add('first_name', 'First Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255);
         $val->add('last_name', 'Last Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255);
         $val->add('email', 'Email')->add_rule('required')->add_rule('valid_email');
         $val->add('password', 'Password')->add_rule('min_length', 8);
         $val->add('confirm_password', 'Confirm Password')->add_rule('required_with', 'password')->add_rule('match_field', 'password');
         $val->add('username', 'Username')->add_rule('required')->add_rule('unique', array('users', 'username', $id));
         if ($val->run()) {
             // Get Input parameters
             $post_data = \Input::post();
             try {
                 $fields = array('username' => $post_data['username'], 'email' => $post_data['email'], 'password' => $post_data['password'], 'user_group' => $post_data['user_group'], 'metadata' => array('first_name' => $post_data['first_name'], 'last_name' => $post_data['last_name']));
                 if (empty($post_data['password'])) {
                     unset($fields['password']);
                 }
                 $item = new \Sentry_User((int) $id);
                 $update = $item->update($fields);
                 // $item->remove_from_group((int)$fields['user_group']);
                 // $item->add_to_group((int)$fields['user_group']);
                 if ($update) {
                     $user_groups = $item->groups();
                     if (!empty($user_groups)) {
                         // Remove user from all other groups...
                         foreach ($user_groups as $value) {
                             $item->remove_from_group((int) $value['id']);
                         }
                     }
                     $item = new \Sentry_User((int) $id);
                     // ...and add it to selected one
                     $item->add_to_group((int) $fields['user_group']);
                     \Messages::success('User Details Successfully updated.');
                     \Response::redirect(\Uri::admin('current'));
                 } else {
                     \Messages::error('There was an error while trying to update User details.');
                 }
             } catch (Sentry\SentryException $e) {
                 \Messages::error($e->get_message());
             }
         } else {
             if ($val->error() != array()) {
                 // Show validation errors
                 \Messages::error('<strong>There was an error while trying to update User details</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     \View::set_global('title', 'Update User Details');
     \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('user_data', $user_data);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:76,代码来源:user.php

示例7: credit_account

 public static function credit_account($user_id = null, $new_amount = 0)
 {
     if (is_numeric($user_id) && \Sentry::user_exists((int) $user_id)) {
         $user = \Sentry::user((int) $user_id);
     } else {
         $user = \Sentry::user();
     }
     $out['credit'] = false;
     if ($user->get('metadata.credit_account') != 1) {
         return $out;
     }
     $out['credit'] = true;
     if ($month = $user->get('metadata.purchase_limit_period')) {
         $start = strtotime(date('m-01-Y', strtotime("-{$month} month")));
         $orders_total = 0;
         $orders = \Order\Model_Order::find(array('where' => array(array('created_at', '>', $start), 'user_id' => $user->get('id'), 'finished' => 1)));
         if ($orders) {
             foreach ($orders as $order) {
                 $orders_total += $order->total_price + $order->shipping_price;
             }
         }
         if ($orders_total + $new_amount > $user->get('metadata.purchase_limit_value')) {
             $out['over_limit'] = true;
             $out['over_limit_amount'] = $orders_total + $new_amount - $user->get('metadata.purchase_limit_value');
         } else {
             $out['over_limit'] = false;
             $out['over_limit_amount'] = 0;
         }
         $out['orders_total'] = $orders_total;
         $out['limit'] = $user->get('metadata.purchase_limit_value');
         $out['period'] = $user->get('metadata.purchase_limit_period');
     }
     if (is_numeric(\Session::get('order.id'))) {
         $order = \Order\Model_Order::find_one_by_id(\Session::get('order.id'));
         if (isset($order)) {
             $new_amount = $order->total_price + $order->shipping_price - $order->discount_amount;
         }
     }
     $out['current_total'] = $new_amount;
     return $out;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:41,代码来源:order.php

示例8: action_check_login

 public function action_check_login()
 {
     $user_not_exists = true;
     if (\Sentry::user_exists(\Input::get('fieldValue'))) {
         $user_not_exists = false;
     }
     $out = array(\Input::get('fieldId'), $user_not_exists);
     echo json_encode($out);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:9,代码来源:checkout+copy.php

示例9: get_user

 protected function get_user()
 {
     if (!\Sentry::user_exists((int) $this->user_id)) {
         return false;
     }
     return \Sentry::user((int) $this->user_id);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:7,代码来源:autoresponder.php

示例10: get_search_customer_products

 public function get_search_customer_products($user_id = false)
 {
     // Override group_id if its a search
     $user_id = \Input::get('user_id', $user_id);
     if ($user_id && \Sentry::user_exists((int) $user_id)) {
         $user = \Sentry::user((int) $user_id);
     }
     $items = \Order\Model_Order::find(function ($query) {
         if (isset($user)) {
             $query->where('user_id', $user->id);
         }
         //get customer only -- start
         $customer_list = \Sentry::user()->all('front');
         $customer_id_list = array();
         foreach ($customer_list as $customer) {
             array_push($customer_id_list, $customer['id']);
         }
         $query->where('user_id', 'in', $customer_id_list);
         //get customer only -- end
         $query->where('finished', '1');
         $query->order_by('id', 'desc');
     });
     foreach (\Input::get() as $key => $value) {
         if (!empty($value) || $value == '0') {
             switch ($key) {
                 case 'title':
                     if ($value != 'customer_order_select') {
                         foreach ($items as $number => $item) {
                             $full_name = $item->first_name . ' ' . $item->last_name;
                             if (stripos($item->company, $value) === false && stripos($item->id, $value) === false) {
                                 if (stripos($full_name, $value) === false) {
                                     unset($items[$number]);
                                 }
                             }
                         }
                     }
                     break;
                 case 'email':
                     foreach ($items as $number => $item) {
                         if (stripos($item->email, $value) === false) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'order_total_from':
                     is_numeric($value) or $value == 0;
                     foreach ($items as $number => $item) {
                         $item_details = \Order\Model_Order::order_info($item->id);
                         if (isset($item_details['total_price']) && $item_details['total_price'] < $value) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'order_total_to':
                     is_numeric($value) or $value == 0;
                     foreach ($items as $number => $item) {
                         $item_details = \Order\Model_Order::order_info($item->id);
                         if (isset($item_details['total_price']) && $item_details['total_price'] > $value) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'date_from':
                     // convert format date to m/d/Y
                     $parts = explode('/', $value);
                     $value = $parts[1] . '/' . $parts[0] . '/' . $parts[2];
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->created_at < $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'date_to':
                     // convert format date to m/d/Y
                     $parts = explode('/', $value);
                     $value = $parts[1] . '/' . $parts[0] . '/' . $parts[2];
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->created_at > $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'status':
                     foreach ($items as $number => $item) {
                         if ($value == 'false') {
                             break;
                         }
                         if (stripos($item->status, $value) === false) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'tracking_no':
                     foreach ($items as $number => $item) {
                         if (!$value != '') {
                             break;
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:reports.php

示例11: get_user

 public function get_user($user_id = false)
 {
     if (\Sentry::user_exists((int) $user_id)) {
         return \Sentry::user((int) $user_id);
     }
     return false;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:7,代码来源:order.php

示例12: get_search_items2

 public function get_search_items2($user_id = false)
 {
     // Override group_id if its a search
     $user_id = \Input::get('user_id', $user_id);
     if ($user_id && \Sentry::user_exists((int) $user_id)) {
         $user = \Sentry::user((int) $user_id);
     }
     $items = \Order\Model_Order::find(function ($query) {
         if (isset($user)) {
             $query->where('user_id', $user->id);
         }
         $query->order_by('main_number', 'desc');
         $query->order_by('id', 'asc');
     });
     foreach (\Input::get() as $key => $value) {
         if (!empty($value) || $value == '0') {
             switch ($key) {
                 case 'title':
                     foreach ($items as $number => $item) {
                         $full_name = $item->first_name . ' ' . $item->last_name;
                         if (stripos($item->company, $value) === false) {
                             if (stripos($full_name, $value) === false) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'email':
                     foreach ($items as $number => $item) {
                         if (stripos($item->email, $value) === false) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'custom_order_status':
                     if (array_key_exists($value, \Config::get('details.status', array()))) {
                         foreach ($items as $number => $item) {
                             if ($item->status != $value) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'order_total_from':
                     is_numeric($value) or $value = 0;
                     foreach ($items as $number => $item) {
                         $item_details = \Order\Model_Order::order_info($item->id);
                         if ($item_details['total_price'] < $value) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'order_total_to':
                     is_numeric($value) or $value = 0;
                     foreach ($items as $number => $item) {
                         $item_details = \Order\Model_Order::order_info($item->id);
                         if ($item_details['total_price'] > $value) {
                             unset($items[$number]);
                         }
                     }
                     break;
                 case 'date_from':
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->created_at < $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'date_to':
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->created_at > $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'sch_from':
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->sch_delivery < $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'sch_to':
                     if ($date = strtotime($value)) {
                         foreach ($items as $number => $item) {
                             if ($item->sch_delivery > $date) {
                                 unset($items[$number]);
                             }
                         }
                     }
                     break;
                 case 'status':
                     foreach ($items as $number => $item) {
                         if ($value == 'false') {
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:user.php


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