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


PHP Sentry::user方法代码示例

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


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

示例1: Check_User_Cart

function Check_User_Cart()
{
    $Identifier = '';
    if (!Sentry::check()) {
        return false;
    } else {
        $Identifier = Sentry::user()->id;
        if (Cookie::has('Anon_Cart_Extension')) {
            $AnonIdentifier = Cookie::get('Anon_Cart_Extension');
            $dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
            if (Cache::has('user_cart.' . $Identifier)) {
                $dataUser = Cache::get('user_cart.' . $Identifier);
                if ($dataAnon != null && $dataUser != null) {
                    foreach ($dataAnon as $key => $value) {
                        if (!isset($dataUser[$key])) {
                            $dataUser[$key] = $value;
                        }
                    }
                    Cache::forever('user_cart.' . $Identifier, $dataUser);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            } else {
                if ($dataAnon != null) {
                    Cache::forever('user_cart.' . $Identifier, $dataAnon);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            }
        }
    }
}
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:30,代码来源:helpers.php

示例2: before

 /**
  * @param   none
  * @throws  none
  * @returns	void
  */
 public function before()
 {
     $result = array();
     // users need to be logged in to access this controller
     if (!\Sentry::check()) {
         $result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
         // Don't show this message if url is just 'admin'
         if (\Uri::string() == 'admin/admin/index') {
             unset($result['message']);
         }
         \Session::set('redirect_to', \Uri::admin('current'));
     } else {
         if (!\Sentry::user()->is_admin()) {
             $result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
             \Session::set('redirect_to', \Uri::admin('current'));
         }
     }
     if (!empty($result)) {
         if (\Input::is_ajax()) {
             \Messages::error('You need to be logged in to complete this action.');
             echo \Messages::display('left', false);
             exit;
         } else {
             if (isset($result['message'])) {
                 \Messages::warning($result['message']);
             }
             \Response::redirect($result['url']);
         }
     }
     parent::before();
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:36,代码来源:admin.php

示例3: post_create

 public function post_create()
 {
     $posts = Input::all();
     $title = $posts['thread_name'];
     $contentRaw = $posts['inputarea'];
     if ($title != '' && strlen($contentRaw) > 10) {
         $alias = Str::slug($title, '-');
         $exist = Thread::where('alias', '=', $alias)->first();
         if ($exist != null) {
             return Redirect::to($exist->id);
         }
         $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
         $thread = Thread::create($threadData);
         if ($thread != null) {
             $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
             $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
             $pst = Post::create($postData);
             if ($pst != null) {
                 return Redirect::to($thread->id);
             }
         }
     } else {
         return Redirect::to(URL::full());
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:25,代码来源:thread.php

示例4: before

 public function before()
 {
     $this->nocversion = 'none';
     $path = $this->request->route->path;
     if ($path != 'auth/login') {
         $this->check_license($path);
     }
     parent::before();
     //$auth = Auth::instance();
     //Auth::instance()->login('hrvoje','hajduk81');
     /*
     if(!$this->check_license())
     \Response::redirect(\Config::get('base_url').'/ajax/license');
     */
     $uri_string = explode('/', Uri::string());
     if (count($uri_string) > 1 and $uri_string[0] == 'auth' and $uri_string[1] == 'login') {
         return;
     }
     if ($path != '_root_') {
         if (\Sentry::check()) {
             $this->user = Sentry::user()->get('id');
             $this->username = Sentry::user()->get('username');
             return;
         } else {
             $this->user = false;
             $this->username = '';
             \Response::redirect(\Config::get('base_url') . 'auth/login');
         }
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:30,代码来源:login.php

示例5: post_register

 /**
  * Do register
  *
  * @return void
  */
 public function post_register()
 {
     // data pass to the view
     $data = array();
     // do valiation
     $rules = array('email' => 'required|email', 'password' => 'required|confirmed', 'password_confirmation' => 'required');
     $input = Input::get();
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to('user/register')->with_input()->with_errors($validation);
     }
     // add user
     try {
         $user = Sentry::user()->register(array('email' => Input::get('email'), 'password' => Input::get('password')));
         if (!$user) {
             $data['errors'] = 'There was an issue when add user to database';
         }
     } catch (Sentry\SentryException $e) {
         $data['errors'] = $e->getMessage();
     }
     if (array_key_exists('errors', $data)) {
         return Redirect::to('user/register')->with_input()->with('errors', $data['errors']);
     } else {
         return Redirect::to('user/login')->with('hash_link', URL::base() . '/user/activate/' . $user['hash']);
     }
 }
开发者ID:imbrj,项目名称:laravel-sentry-tutorial,代码行数:31,代码来源:user.php

示例6: action_edit

 public function action_edit($id = null)
 {
     if (!Sentry::user()->has_access('groups_edit')) {
         self::no_access();
     }
     $groups = Model_Group::access(intval($id));
     $group['permissions'] = json_decode($groups[0]['permissions'], true);
     $group['groupName'] = $groups[0]['name'];
     if (Input::method() == 'POST') {
         if (!Input::post('groupName')) {
             Session::set_flash('error', 'Please choose a name for the group');
         } else {
             $post = Input::post();
             $groupName = $post['groupName'];
             unset($post['groupName']);
             // JSON_NUMERIC_CHECK to keep the int
             $permissions = json_encode($post, JSON_NUMERIC_CHECK);
             $updated = Model_Group::editGroup(intval($id), $groupName, $permissions);
             if ($updated) {
                 Session::set_flash('success', 'The group ' . $groupName . ' has been successfully edited');
                 Response::redirect('groups');
             }
         }
     }
     $var = self::access();
     // all the access
     View::set_global('var', $var);
     // all the needed informations about the current group
     View::set_global('group', $group);
     $this->template->h2 = 'Edit Group';
     $this->template->title = 'Groups » Edit';
     $this->template->js .= Asset::js(array('mylibs/jquery.validate.js', 'script.js'));
     $this->template->content = View::forge('groups/edit');
 }
开发者ID:roine,项目名称:wawaw,代码行数:34,代码来源:groups.php

示例7: action_to

 public function action_to($id = null)
 {
     // redirect if no id
     if ($id == null) {
         Response::redirect('message');
     }
     // redirect if no right access
     if (!Sentry::user()->has_access('message_send')) {
         Session::set_flash('error', "You are not allowed to send message");
         Response::redirect('');
     }
     $data['user'] = Sentry::user(intval($id));
     $data['messages'] = Model_Message::messageWith($data['user'], $this->current_user);
     if (Input::method() == 'POST') {
         $message = Model_Message::forge(array('subject' => Input::post('subject'), 'content' => Input::post('content'), 'to' => $data['user']->id, 'from' => $this->current_user->id, 'parent_id' => '', 'read' => 0, 'from_delete' => 0, 'to_delete' => 0));
         if ($message and $message->save()) {
             Session::set_flash('success', 'Message successfuly sent to ' . $data['user']->username);
             Response::redirect('message');
         } else {
             Session::set_flash('error', 'Could not send the message.');
         }
     }
     $this->template->h2 = 'Send Message to ' . $data['user']->username;
     $this->template->title = 'Message » to';
     $this->template->content = View::forge('message/to', $data);
 }
开发者ID:roine,项目名称:wawaw,代码行数:26,代码来源:message.php

示例8: check_logged

 public static function check_logged()
 {
     $logged = true;
     if (!(\Sentry::check() && !\Sentry::user()->is_admin())) {
         $logged = false;
     }
     return $logged;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:8,代码来源:base.php

示例9: get_checkperm

 public function get_checkperm()
 {
     if (Sentry::user()->has_access('can_edit')) {
         return json_encode(array('result' => true));
     } else {
         return json_encode(array('result' => false));
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:8,代码来源:moderator.php

示例10: action_index

 public function action_index()
 {
     $view = View::make('dashboard');
     $view->user = Sentry::user();
     $view->title = 'Kullanıcı Paneli';
     $count = DB::table('threads')->where('last_message_at', '=', DB::Raw('NOW()'))->count();
     $view->count = $count;
     return $view;
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:9,代码来源:dashboard.php

示例11: before

 public function before()
 {
     parent::before();
     $this->template->js = Asset::js(array('mylibs/jquery.jgrowl.js', 'mylibs/jquery.validate.js', 'plugins.js', 'script.js', 'mylibs/jquery.chosen.js', 'mylibs/jquery.ui.touch-punch.js'));
     if (!Sentry::user()->has_access('forms_index')) {
         Session::set_flash('error', "You cannot access that section");
         Response::redirect('');
     }
 }
开发者ID:roine,项目名称:wawaw,代码行数:9,代码来源:forms.php

示例12: before

 public function before()
 {
     parent::before();
     \Theme::instance()->active('admin');
     \Theme::instance()->set_template($this->template);
     // Assign current_user to the instance so controllers can use it
     $this->current_user = \Sentry::check() ? \Sentry::user() : null;
     // Set a global variable so views can use it
     \View::set_global('current_user', $this->current_user);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:10,代码来源:base.php

示例13: prep_values

 /**
  * Save users that commited insert/update operations
  * 
  * @param $vars
  */
 protected function prep_values($vars)
 {
     // Set user who is created/updated item
     if ($this->is_new()) {
         $vars['user_created'] = \Sentry::user()->id;
     } else {
         $vars['user_updated'] = \Sentry::user()->id;
     }
     return $vars;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:15,代码来源:history.php

示例14: check_logged_type

 /**
  * After controller method has run, render the theme template
  *
  * @return  mixed:  false, user, guest
  */
 public function check_logged_type()
 {
     if (!$this->check_logged()) {
         return false;
     }
     $user = \Sentry::user();
     if (!empty($user['metadata']) && $user['metadata']['guest'] == 1) {
         return 'guest';
     }
     return 'user';
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:16,代码来源:user.php

示例15: locate

 private function locate($sub)
 {
     $this->user = \Sentry::user()->get('id');
     $ips = \Basic\Model_Network_Ip::find()->where('addrint', '<=', $sub['range_to'])->where('addrint', '>=', $sub['range_from'])->get();
     foreach ($ips as $ip) {
         $device = $ip->network->device;
         if ($this->user == $device->meta_update_user) {
             $this->update_device($ip);
         }
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:11,代码来源:subnet.php


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