本文整理汇总了PHP中Registry::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::getCurrentUser方法的具体用法?PHP Registry::getCurrentUser怎么用?PHP Registry::getCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::getCurrentUser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_logout
/**
*
*/
public function action_logout()
{
if (!\Registry::getCurrentUser()->isGuest()) {
\Auth\Base::destroy();
}
\HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'Login']), 302);
}
示例2: before
/**
*
*/
public function before()
{
$is_guest = \Registry::getCurrentUser()->isGuest();
// Дополнительные функции
$this->InitEnvironment();
if (!Request::current()->is_ajax()) {
// Add Google Font
Assets::css('Google_Font', 'https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic&subset=latin,cyrillic-ext,cyrillic');
/*ADD google maps JS*/
Assets::js('google_maps_api', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=drawing&places&geometry');
Assets::js('jQuery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']);
Assets::js('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js');
//GMAP Plugin js
Assets::js('cluster', base_UI . 'js/plugins/gmap/marker.js');
Assets::js('gmap', base_UI . 'js/plugins/gmap/gmaps.js');
/*Базовые стили шаблона*/
//Global Assets
Assets::js('globalJS', base_UI . 'js/pages/global.js');
Assets::css('awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');
Assets::css('stl', base_UI . 'css/style.css');
/*BootBox Js file*/
Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
/*Login Js file*/
Assets::js('LoginJs', base_UI . 'js/Auth/login.js');
/*Register Js file*/
Assets::js('RegisterJs', base_UI . 'js/Auth/register.js');
//Zopim Helper js
Assets::js('zopim', base_UI . 'js/index/zopim.js');
//MAP js
Assets::js('map1', base_UI . 'js/map/map.js');
Assets::js('map2', base_UI . 'js/pages/map.js');
Assets::js('map3', base_UI . 'js/map/catalog.js');
$this->template = \smarty\View::init();
$this->renderULogin();
if (!$is_guest) {
$access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
$user_id = \Registry::getCurrentUser()->iduser;
$this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]);
} else {
$this->template->assign(['current_user' => \Registry::getCurrentUser()]);
}
$this->template->assign(['localis' => $this->localis, 'local' => $this->i18n]);
} else {
$this->setJSONHeader();
// Mobile API
if (!isset($_POST)) {
$error = array('status' => 'error', 'message' => 'No Data', 'code' => '2');
echo json_encode($error);
return;
}
/** @var $dbSession UserSession */
if ($_POST['token']) {
$condition = (new \DBCriteria())->addColumnCondition(['token' => $_POST['token']])->addCondition('`expired`>=UNIX_TIMESTAMP(NOW())');
/** @var $dbSession UserSession */
$sessionData = UserSession::model()->with('user')->find($condition);
\Registry::setCurrentUser($sessionData->user);
}
}
}
示例3: action_index
public function action_index()
{
$user_id = \Registry::getCurrentUser()->iduser;
$services = $this->getServices();
$this->template->assign(['services' => $services]);
$this->response->body($this->template->fetch('main.tpl'));
}
示例4: findImages
public function findImages($search)
{
$user_id = \Registry::getCurrentUser()->iduser;
$user = \Model\User::model()->findByPk($user_id);
$criteria = new \DBCriteria(array('condition' => " description LIKE :match OR\n main_text LIKE :match OR\n title LIKE :match OR ", 'params' => array(':match' => "%{$search}%")));
$criteria->limit = $this->limit;
$data = \Model\Pages::model()->with('idpageType')->findAll($criteria);
$this->template->assign(['results' => $data, 'count_find' => count($data)]);
}
示例5: action_index
public function action_index()
{
\Assets::css('page2', base_UI . 'css/rangeslider.css');
\Assets::js('page1', base_UI . 'js/plugins/range/rangeslider.min.js');
\Assets::js('page2', base_UI . 'js/plugins/range/range_script.js');
\Assets::js('attr', base_UI . 'js/pages/attr.js');
\Assets::js('jumper', base_UI . 'js/index/recovery_pass_jumper.js');
$user_id = \Registry::getCurrentUser()->iduser;
$data_formula = $this->dataFormula();
$this->template->assign(['data_formula' => $data_formula]);
$this->response->body($this->template->fetch('main.tpl'));
}
示例6: action_display
public function action_display()
{
$user_id = \Registry::getCurrentUser()->iduser;
if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
\Assets::js('page1', base_UI . 'js/pages/page.js');
$page = \Model\Pages::model()->findByPk($item_id);
$this->template->assign(['page' => $page]);
$this->response->body($this->template->fetch('pages.tpl'));
} else {
if ($alias = \Utils\Protect::Validate($this->request->param('alias'), 'string')) {
/**@var \Model\Item $data*/
\Assets::js('page1', base_UI . 'js/pages/page.js');
$page = \Model\Pages::model()->findByAttributes(['alias' => $alias]);
$this->template->assign(['page' => $page]);
$this->response->body($this->template->fetch('pages.tpl'));
}
}
}
示例7: before
/**
*
*/
public function before()
{
if (\Registry::getCurrentUser()->isGuest()) {
if ($this->request->controller() != 'Main' && $this->request->action() != 'login') {
#todo Fix it!
if (!\Request::current()->is_ajax()) {
\HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'login']), 302);
}
}
}
if (!Request::current()->is_ajax()) {
// Add Google Font
Assets::css('Google_Font', 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,300italic,400italic,700italic|Lustria');
Assets::js('jQuery', base_UI . 'libs/jquery-2.1.1.js');
Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']);
Assets::js('bootstrap', 'http:////netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js');
Assets::css('font-awesome', 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', ['media' => 'screen']);
/*Базовые стили шаблона*/
Assets::css('stl', base_UI . 'AdminLTE/css/style.css');
Assets::css('lightbox', base_UI . 'libs/lightbox/css/lightbox.css');
/*BootBox Js file*/
Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
/*Login Js file*/
Assets::js('LoginJs', base_UI . 'js/Auth/login.js');
/*Register Js file*/
Assets::js('RegisterJs', base_UI . 'js/Auth/register.js');
//uLogin js
Assets::js('uLogin', 'http://ulogin.ru/js/ulogin.js');
//Add notification plugin
Assets::js('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.js');
Assets::css('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.css');
Assets::css('AdminLTE', base_UI . 'AdminLTE/css/AdminLTE.css');
Assets::js('AdminLTE_App', base_UI . 'AdminLTE/js/AdminLTE/app.js');
$this->template = \Smarty\View::init();
if (!Request::current()->is_ajax()) {
$access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
$this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]);
}
}
}
示例8: _save_image
protected function _save_image($image)
{
$user_id = \Registry::getCurrentUser()->id;
if (!Upload::valid($image) or !Upload::type($image, array('jpg', 'jpeg', 'png', 'gif'))) {
return FALSE;
}
$directory = $_SERVER['DOCUMENT_ROOT'] . '/Uploads/Photo/' . $user_id . '/';
$thumbnail = $_SERVER['DOCUMENT_ROOT'] . '/Uploads/Photo/' . $user_id . '/thumbnail/';
$this->create_dir($directory, '');
$this->create_dir($directory, 'thumbnail');
$file = Upload::save($image, NULL, $directory);
$file_clear = str_replace('\\', '/', $file);
$filename = str_replace($directory, '', $file_clear);
// -- Resize
if (file_exists($file)) {
Image::factory($file)->resize(100, 100, Image::AUTO)->save($thumbnail . $filename);
return $filename;
}
return FALSE;
}
示例9: chatInit
public function chatInit()
{
// Init Current Chat Session
$sender_id = \Registry::getCurrentUser()->id;
$receiver_id = $this->request->post('receiver_id');
$user = \Model\User::model()->findByPk($sender_id);
if (!$user) {
$this->response->body(json_encode(['status' => -777, 'error' => 'Access Denied!']));
return true;
}
if ($receiver_id) {
if ($receiver_id > $sender_id) {
$this->chat_session = $receiver_id . "#" . $sender_id;
} else {
$this->chat_session = $sender_id . "#" . $receiver_id;
}
}
}
示例10: action_GetJson
public function action_GetJson()
{
$data = User::model()->findAll();
$access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
if ($access->get(\Auth\Access::User_Is_Admin)) {
$aoColumnsData = [];
/** @var $item User */
foreach ($data as $item) {
$currentUserAccess = new \Auth\Access($item->access_level);
$tmp = ['id' => $item->iduser, 'fio' => $item->first_name, 'email' => $item->email, 'Access' => $currentUserAccess->get(\Auth\Access::User_Login) ? 'Yes' : 'No'];
$aoColumnsData[] = $tmp;
}
$this->response->body(json_encode(['aaData' => $aoColumnsData]));
} else {
throw new \HTTP_Exception_403('Admin Only');
}
}
示例11: action_GetJson
public function action_GetJson()
{
$data = \Model\UserPayment::model()->with('iduser0', 'iduserCredit')->findAll();
$access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
if ($access->get(\Auth\Access::User_Is_Admin)) {
$aoColumnsData = [];
if (!$data) {
$this->response->body(json_encode(['aaData' => $aoColumnsData]));
return;
}
/** @var $item User */
foreach ($data as $key => $item) {
$tmp = ['id' => $item->iduser_payment, 'price' => $item->price, 'date' => date("Y-m-d H:i", $item->date_pay), 'remaining' => $item->iduserCredit->price_remaining, 'user' => $item->iduser0->first_name . " " . $item->iduser0->last_name];
$aoColumnsData[] = $tmp;
}
$this->response->body(json_encode(['aaData' => $aoColumnsData]));
} else {
throw new \HTTP_Exception_403('Admin Only');
}
}
示例12: shortHistory
public function shortHistory($limit)
{
$user_id = \Registry::getCurrentUser()->id;
$criteria = new \DBCriteria();
$criteria->select = ' cht.sendtime, cht.message, usr1.fio as sender_fio, usr2.fio as receiver_fio,
usr1.id as sender_id, usr2.id as receiver_id, usr1.photo as sender_photo, usr2.photo as receiver_photo ';
$criteria->condition = ' cht.sender_id = "' . $user_id . '"
OR cht.receiver_id = "' . $user_id . '" ';
$criteria->group = ' cht.session';
$criteria->mergeWith(array('join' => 'INNER JOIN user AS usr1 ON usr1.id = cht.sender_id
INNER JOIN user AS usr2 ON usr2.id = cht.receiver_id'));
$criteria->limit = $limit;
$data = \Model\Chat::model()->findAll($criteria);
return $data;
}
示例13: action_GetJson
public function action_GetJson()
{
$data = \Model\Pages::model()->with('idpageType')->findAll();
$access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
if ($access->get(\Auth\Access::User_Is_Admin)) {
$aoColumnsData = [];
if (!$data) {
$this->response->body(json_encode(['aaData' => $aoColumnsData]));
return;
}
/** @var $item User */
foreach ($data as $key => $item) {
$tmp = ['id' => $item->idpages, 'title' => $item->title, 'description' => $item->description, 'type' => $item->idpageType->name];
$aoColumnsData[] = $tmp;
}
$this->response->body(json_encode(['aaData' => $aoColumnsData]));
} else {
throw new \HTTP_Exception_403('Admin Only');
}
}