2013-05-10 17:25:51 +02:00
|
|
|
<?php
|
2013-05-16 03:16:56 +02:00
|
|
|
/**
|
2014-05-12 18:26:17 +02:00
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2014, Block 8 Limited.
|
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
|
|
|
* @link https://www.phptesting.org/
|
|
|
|
*/
|
2013-05-10 17:25:51 +02:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace PHPCensor\Helper;
|
2013-05-10 17:25:51 +02:00
|
|
|
|
2013-05-16 03:30:48 +02:00
|
|
|
/**
|
|
|
|
* User Helper - Provides access to logged in user information in views.
|
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
* @package PHPCI
|
|
|
|
* @subpackage Web
|
|
|
|
*/
|
2013-05-10 17:25:51 +02:00
|
|
|
class User
|
|
|
|
{
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* Proxies method calls through to the current active user model.
|
|
|
|
* @param $method
|
|
|
|
* @param array $params
|
|
|
|
* @return mixed|null
|
|
|
|
*/
|
2016-04-20 17:39:48 +02:00
|
|
|
public function __call($method, $params = [])
|
2013-05-16 16:40:40 +02:00
|
|
|
{
|
2016-12-24 10:58:38 +01:00
|
|
|
if (empty($_SESSION['php-censor-user'])) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-07-21 19:02:11 +02:00
|
|
|
$user = $_SESSION['php-censor-user'];
|
2014-07-29 16:51:53 +02:00
|
|
|
|
|
|
|
if (!is_object($user)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-04-20 17:39:48 +02:00
|
|
|
return call_user_func_array([$user, $method], $params);
|
2013-05-16 16:40:40 +02:00
|
|
|
}
|
|
|
|
}
|