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


PHP User::current方法代码示例

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


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

示例1: validate

 public function validate()
 {
     # Overloading validate method: http://programmers.stackexchange.com/a/274135
     list($old_field, $new_field, $confirm_field) = func_get_args();
     $user = User::current();
     $old_password = new PasswordValidator($this->request->post($old_field, ''), $user);
     $new_password = new PasswordValidator($this->request->post($new_field, ''), $user);
     $confirmation = new PasswordValidator($this->request->post($confirm_field, ''), $user);
     $this->fields = array($old_field => $old_password, $new_field => $new_password, $confirm_field => $confirmation);
     $old_password->validate_present();
     $new_password->validate_present();
     $confirmation->validate_present();
     if ($old_password->is_valid() && $new_password->is_valid()) {
         $old_password->authenticate_user_password();
         $new_password->validate_min_length();
         $new_password->validate_not_user_name();
         $this->validate_confirmation_match($new_field, $confirm_field);
     }
     if ($new_password->is_valid() && $confirmation->is_valid()) {
         $this->set_valid_field_value($new_field, $new_password->value);
         $this->set_valid_field_value($confirm_field, $confirmation->value);
     }
     $this->flatten_validator_errors();
     return $this->is_valid();
 }
开发者ID:klenwell,项目名称:neechy-app-engine,代码行数:25,代码来源:validator.php

示例2: current

 public static function current()
 {
     if (self::$current !== '') {
         return self::$current;
     }
     return self::$current = ($id = Session::getData('user_id')) ? User::find_by_id($id) : null;
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:7,代码来源:User.php

示例3: action_index

 public function action_index()
 {
     $id = intval($this->request->param('id'));
     $attachment = DB::select()->from('attachments')->where('id', '=', $id)->execute()->current();
     if (!preg_match('/^image\\/.*$/i', $attachment['mime']) || $attachment['folder'] == 'Signatures') {
         throw new HTTP_Exception_403('Forbidden');
     }
     $job = Database_Mongo::collection('jobs')->findOne(array('_id' => strval($attachment['job_id'])));
     if (!$job) {
         throw new HTTP_Exception_404('Not found');
     }
     if (!Group::current('show_all_jobs') && !in_array((int) User::current('company_id'), Arr::get($job, 'companies', array()), true) && !in_array((int) User::current('company_id'), Arr::get($job, 'ex', array()), true)) {
         throw new HTTP_Exception_403('Forbidden');
     }
     if (!file_exists(DOCROOT . 'storage/' . $id)) {
         throw new HTTP_Exception_404('Not found');
     }
     list(, $data) = explode(',', file_get_contents('php://input'), 2);
     $src = imagecreatefromstring(file_get_contents(DOCROOT . 'storage/' . $id));
     $image = imagecreatefromstring(base64_decode($data));
     imagealphablending($src, true);
     imagesavealpha($src, true);
     imagecopyresampled($src, $image, 0, 0, 0, 0, imagesx($src), imagesy($src), imagesx($image), imagesy($image));
     if ($attachment['mime'] == 'image/png') {
         imagepng($src, DOCROOT . 'storage/' . $id, 9);
     } else {
         imagejpeg($src, DOCROOT . 'storage/' . $id, 90);
     }
     if (file_exists(DOCROOT . 'storage/' . $id . '.thumb')) {
         unlink(DOCROOT . 'storage/' . $id . '.thumb');
     }
     imagedestroy($src);
     imagedestroy($image);
     die(json_encode(array('success' => true)));
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:35,代码来源:Update.php

示例4: before

 public function before()
 {
     parent::before();
     if (!User::current('is_admin')) {
         throw new HTTP_Exception_403('Forbidden');
     }
 }
开发者ID:Alex-AG,项目名称:exeltek-po,代码行数:7,代码来源:Address.php

示例5: load_current_user

 public static function load_current_user(){
     if (!isset(self::$current) && !empty($_SESSION['userid'])) {
         self::$current = new User($_SESSION['userid']);
         Logger::debug('Loading current user ' . self::$current->username);
     }
     return true;
 }
开发者ID:reddragon010,项目名称:RG-ServerPanel,代码行数:7,代码来源:User.php

示例6: handle

 public function handle()
 {
     #
     if ($this->is_console) {
         $this->params = $this->service->params;
         return $this->console();
     }
     # If not logged in, redirect to login page
     if (!User::is_logged_in()) {
         $this->t->flash('Please login to access that page.', 'warning');
         return $this->redirect('auth', 'login');
     }
     # Change password request
     if ($this->request->action_is('change-password')) {
         $form = new PasswordFormValidator($this->request);
         if ($form->validate('old-password', 'new-password', 'new-password-confirm')) {
             $user = User::current();
             $user->set_password($this->request->post('new-password'));
             if ($user->save()) {
                 $this->t->flash('Your password has been changed.', 'success');
             } else {
                 $this->t->flash('There was a problem saving your password.', 'danger');
             }
         } else {
             $this->t->data('form-validator', $form);
         }
         $content = $this->render_view('content');
     } else {
         $content = $this->render_view('content');
     }
     return $content;
 }
开发者ID:klenwell,项目名称:neechy-app-engine,代码行数:32,代码来源:handler.php

示例7: before

 public function before()
 {
     if (!User::current()) {
         $this->redirect('/login');
     }
     $url = str_replace('.', '_', URL::base() . $this->request->uri());
     if (isset($_GET[$url])) {
         unset($_GET[$url]);
     }
     if (isset($_GET[$url . '/'])) {
         unset($_GET[$url . '/']);
     }
     if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) {
         Pager::$counts[] = 2500;
     }
     if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) {
         DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (Arr::get($_GET, 'dismiss')) {
         DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (!Group::current('allow_assign')) {
         Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active';
     }
     View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute());
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:28,代码来源:Controller.php

示例8: action_fda

 public function action_fda()
 {
     $query = array();
     if (!Group::current('allow_assign')) {
         $query['$or'] = array(array('companies' => intval(User::current('company_id'))), array('ex' => intval(User::current('company_id'))));
     } else {
         if (Arr::get($_GET, 'company')) {
             $company = is_array($_GET['company']) ? $_GET['company'] : explode(',', $_GET['company']);
             $company = array_map('intval', $company);
             if (count($company) == 1) {
                 $company = array_shift($company);
             }
             $query['$or'] = array(array('companies' => is_array($company) ? array('$in' => $company) : $company), array('ex' => is_array($company) ? array('$in' => $company) : $company));
         }
         if (Arr::get($_GET, 'region')) {
             $query['region'] = strval($_GET['region']);
         }
     }
     if (Arr::get($_GET, 'fsam')) {
         $fsam = is_array($_GET['fsam']) ? array_map('strval', $_GET['fsam']) : explode(',', $_GET['fsam']);
         $query['data.13'] = count($fsam) == 1 ? array_shift($fsam) : array('$in' => $fsam);
     }
     $list = Database_Mongo::collection('jobs')->distinct('data.14', $query ?: NULL);
     sort($list);
     die(json_encode($list));
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:26,代码来源:Json.php

示例9: testShouldReturnLoggedInUser

 public function testShouldReturnLoggedInUser()
 {
     $user = User::find_by_name('NeechyUser');
     $user->login();
     $this->assertInstanceOf('User', User::current());
     $this->assertEquals($user->field('name'), User::current('name'));
     $this->assertEquals($user->field('name'), User::current()->field('name'));
 }
开发者ID:klenwell,项目名称:neechy-app-engine,代码行数:8,代码来源:UserTest.php

示例10: login

 public function login()
 {
     if (User::current() && User::current()->is_login()) {
         return redirect_message(array('admin'), array());
     } else {
         $this->load_view();
     }
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:8,代码来源:platform.php

示例11: test_current

 function test_current()
 {
     $user = User::$user;
     $u2 = User::current();
     $this->assertEquals($user, $u2);
     User::current($u2);
     $u3 = User::current();
     $this->assertEquals($user, $u3);
 }
开发者ID:Selwyn-b,项目名称:elefant,代码行数:9,代码来源:UserTest.php

示例12: testShouldRedirectUserWhenNotLoggedIn

 /**
  * Tests
  */
 public function testShouldRedirectUserWhenNotLoggedIn()
 {
     $request = new NeechyRequest();
     # Mock out redirect function (note: 3.7 syntax)
     $handler = $this->getMockBuilder('PasswordHandler')->setConstructorArgs(array($request))->setMethods(array('redirect'))->getMock();
     $handler->expects($this->any())->method('redirect')->will($this->returnValue('redirected'));
     $this->assertNull(User::current());
     $redirected = $handler->handle();
     $this->assertEquals('redirected', $redirected);
 }
开发者ID:klenwell,项目名称:neechy-app-engine,代码行数:13,代码来源:PasswordHandlerTest.php

示例13: action_delete

 public function action_delete()
 {
     if (!User::current('is_admin') && !Group::current('item_remove')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $id = $this->request->param('id');
     DB::delete('items')->where('id', '=', $id)->execute();
     Messages::save('Item was successfully deleted!', 'info');
     $this->redirect('/items');
 }
开发者ID:Alex-AG,项目名称:exeltek-po,代码行数:10,代码来源:Items.php

示例14: action_index

 public function action_index()
 {
     $items = DB::select(DB::expr('COUNT(*) as cnt'), DB::expr('COALESCE(`status`, "unattached") as status'))->from('unit_items')->join('tasks', 'left')->on('task_id', '=', 'tasks.id')->group_by('status');
     if (!User::current('is_admin') && !Group::current('all_projects')) {
         $items->where('company_id', '=', User::current('company_id'));
     }
     $items = $items->execute()->as_array('status', 'cnt');
     $view = View::factory('Dashboard')->bind('items', $items);
     $this->response->body($view);
 }
开发者ID:Alex-AG,项目名称:exeltek-mima,代码行数:10,代码来源:Dashboard.php

示例15: action_index

 public function action_index()
 {
     $id = $this->request->param('id');
     $location = Arr::get($_GET, 'location', '');
     $type = Arr::get($_GET, 'type', 'other');
     $title = Arr::get($_GET, 'title', 'other');
     $job = Database_Mongo::collection('jobs')->findOne(array('_id' => strval($id)));
     if (!$job) {
         throw new HTTP_Exception_404('Not found');
     }
     if (!Group::current('show_all_jobs') && !in_array((int) User::current('company_id'), Arr::get($job, 'companies', array()), true) && !in_array((int) User::current('company_id'), Arr::get($job, 'ex', array()), true)) {
         throw new HTTP_Exception_403('Forbidden');
     }
     switch ($type) {
         case 'photo-before':
             $type = 'Photos';
             $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.before.%NUM%';
             $title = '';
             break;
         case 'photo-after':
             $type = 'Photos';
             $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.after.%NUM%';
             $title = '';
             break;
         case 'jsa':
             $type = 'JSA-forms';
             $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.JSA.%NUM%';
             $title = '';
             break;
         case 'waiver':
             $type = 'Waiver';
             $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.Waiver.%NUM%';
             $title = '';
             break;
         case 'odtr':
             $title = '';
             $type = 'otdr-traces';
             $filename = '';
             break;
         default:
             $type = 'Other';
             $filename = '';
             break;
     }
     $number = DB::select('numbering')->from('attachments')->where('job_id', '=', $id)->and_where('folder', '=', $type)->order_by('numbering', 'desc')->limit(1)->execute()->get('numbering');
     $data = array('filename' => $filename, 'mime' => '', 'uploaded' => 0, 'user_id' => User::current('id'), 'job_id' => $id, 'folder' => $type, 'fda_id' => Arr::path($job, 'data.14'), 'address' => trim(preg_replace('/-{2,}/', '-', preg_replace('/[^0-9a-z\\-]/i', '-', Arr::path($job, 'data.8'))), '-'), 'title' => $title, 'numbering' => intval($number) + 1);
     $result = Arr::get(DB::insert('attachments', array_keys($data))->values(array_values($data))->execute(), 0);
     if (file_exists(DOCROOT . 'storage/' . $result)) {
         unlink(DOCROOT . 'storage/' . $result);
     }
     die(json_encode(array('success' => true, 'id' => $result)));
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:52,代码来源:Prepare.php


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