本文整理汇总了PHP中Environment::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getUser方法的具体用法?PHP Environment::getUser怎么用?PHP Environment::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* @return User
*/
public function getUser()
{
if ($this->user === null) {
$this->user = Environment::getUser();
}
return $this->user;
}
示例2: beforeRender
public function beforeRender()
{
$filters = $this->getUniqueValues(array('works' => array('year', 'award', 'type'), 'authors' => array('class')));
$temp = $filters['authors'];
unset($filters['authors']);
//$filters['works']['category'] = Model::palicky();// + array(5=>'palice'); // 'category'=>'Kategorie',
$filters['works']['grade'] = Model::rocniky();
$filters['palicka']['category'] = Model::palicky();
$filters['authors'] = $temp;
//{link :Front:Default:works "category"=>palicka}
$this->template->filters = $filters;
$this->template->schoolYear = Model::getSchoolYear();
$newest = dibi::query('SELECT
url,
title,
CONCAT_WS(" ", name, surname) as authorName
FROM [works]
join [authors] on author = authorId', 'ORDER BY %by', array('added' => 'desc'), 'LIMIT %i', 2)->fetchAll();
$this->template->newest = $newest;
$mostread = dibi::query('SELECT
url,
title,
CONCAT_WS(" ", name, surname) as authorName
FROM [works]
join [authors] on author = authorId', 'ORDER BY %by', array('read' => 'desc'), 'LIMIT %i', 3)->fetchAll();
$this->template->mostread = $mostread;
$user = Environment::getUser();
if ($user->isLoggedIn()) {
$this->template->adminMode = true;
}
}
示例3: handleLogout
public function handleLogout()
{
$user = Environment::getUser();
// odhlášení
$user->signOut();
$this->redirect(':Front:Default:');
}
示例4: formLoginAjaxSubmitted
public function formLoginAjaxSubmitted($form)
{
$values = $form->getValues();
if ($form->isValid()) {
$login = $values['login'];
$password = $values['password'];
$user = Environment::getUser();
$user->setAuthenticationHandler(new Admin_UserModel());
try {
$user->authenticate($login, $password);
$session_conf = Environment::getVariable('session');
$user->setExpiration($session_conf['expiration'], true);
//$session = $this->getSession('backlink');
//$session->in_application = true;
//$this->getApplication()->restoreRequest($session['backlink']);
//$this->redirect('Dashboard:default');
$this->payload->cmds = array();
$this->payload->cmds[] = 'login_ok';
$this->flash('Login OK');
if ($this->isAjax()) {
$this->sendPayload();
$this->terminate();
}
} catch (AuthenticationException $e) {
$form->setValues($values);
$this->invalidateControl('frmLogin');
if ($this->isAjax()) {
$this->invalidateControl('formLoginAjax');
}
//$this->flash('Error: '. $e->getMessage());
$this->payload->error = $e - getMessage();
}
}
}
示例5: actionDefault
public function actionDefault()
{
if (Environment::getUser()->getIdentity()->role == 'super admin') {
$this->config_data = ConfigAdapterIni::load(APP_DIR . '/config/admin.ini', 'admin');
$this->profile_data = $this->config_data['admin'];
$this->mode = 'superadmin';
}
$this->view = 'profile';
}
示例6: startup
public function startup()
{
parent::startup();
$user = Environment::getUser();
if ($user->isAuthenticated()) {
$roles = Environment::getUser()->getIdentity()->getRoles();
$role = $roles[0];
$this->redirect(":{$role}:Default:default");
}
}
示例7: startup
protected function startup()
{
parent::startup();
$this->model = new Model();
$this->fileModel = new FileModel();
$user = Environment::getUser();
if (!$user->isLoggedIn()) {
// je uživatel přihlášen?
$this->redirect(':Admin:Login:');
}
}
示例8: loginFormSubmitted
public function loginFormSubmitted($form)
{
try {
$user = Environment::getUser();
$user->authenticate($form['username']->getValue(), $form['password']->getValue());
$this->getApplication()->restoreRequest($this->backlink);
$this->redirect('Dashboard:');
} catch (AuthenticationException $e) {
$form->addError($e->getMessage());
}
}
示例9: beforeRender
public function beforeRender()
{
// curly brackets
$this->template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke');
// texy
$texy = new Texy();
$this->template->registerHelper('texy', array($texy, 'process'));
// user
$this->template->user = Environment::getUser();
// order statuses
$this->template->order_statuses = mapper::order_statuses()->findAll();
// date
$this->template->registerHelper('date', array(__CLASS__, 'date'));
}
示例10: onLoginFormSubmit
public function onLoginFormSubmit(Form $form)
{
$user = Environment::getUser();
$user->setAuthenticationHandler(new SimpleAuthenticator(array(ADMIN_USERNAME => ADMIN_PASSWORD)));
$values = $form->getValues();
try {
$user->authenticate($values['username'], $values['password']);
adminlog::log(__('Successfully logged in as "%s"'), Environment::getUser()->getIdentity()->getName());
$this->redirect('Dashboard:default');
$this->terminate();
} catch (AuthenticationException $e) {
adminlog::log(__('Unsuccessful log in (username: "%s", password: "%s")'), $values['username'], $values['password']);
$this->template->error = $e;
}
}
示例11: login
private function login($username, $password)
{
$user = Environment::getUser();
if (!$user->isAuthenticated()) {
$user->setAuthenticationHandler(new Admin_UserModel());
try {
$user->authenticate($username, $password);
$session_conf = Environment::getVariable('session');
$user->setExpiration($session_conf['expiration'], true);
return $user;
} catch (AuthenticationException $e) {
$this->error = new IXR_Error(403, $e->getMessage());
return false;
}
}
return $user;
}
示例12: checkAuthorization
private function checkAuthorization()
{
$presenter = String::lower($this->getReflection()->getName());
$user = Environment::getUser();
$user->setAuthorizationHandler(MokujiServiceLocator::getService('UserAuthorizator'));
//if(Environment::getServiceLocator()->hasService('UserAuthorizator')) $user->setAuthorizationHandler(Environment::getService('UserAuthorizator'));
//else $user->setAuthorizationHandler(new Admin_UserModel());
if ($this->formatActionMethod($this->action) == 'actiondeny') {
return;
}
if ($user->isAllowed($presenter, $this->formatActionMethod($this->action)) === true) {
if ($user->isAllowed($presenter, $this->formatSignalMethod($this->signal)) === false) {
throw new AuthenticationException('This action is not allowed');
}
} else {
throw new AuthenticationException('This action is not allowed');
}
}
示例13: isAllowed
public function isAllowed($role = self::ALL, $resource = self::ALL, $privilege = self::ALL)
{
if ($privilege == 'actionDeny') {
return true;
}
$data = Environment::getUser()->getIdentity()->permissions;
if (isset($data[String::lower($resource)])) {
if ($privilege == null) {
return true;
}
foreach ($data[String::lower($resource)] as $user_privilege) {
if (String::lower($privilege) == String::lower($user_privilege)) {
return true;
}
}
return false;
} else {
return false;
}
}
示例14: formLoginSubmitted
public function formLoginSubmitted($form)
{
$modul = explode(':', $this->getName());
$module = $modul[0];
$user = Environment::getUser();
$user->setAuthenticationHandler(new Authenticator());
$values = $form->getValues();
if ($form->isValid()) {
$email = $values['email'];
$password = $values['password'];
try {
$user->authenticate($email, $password, $module);
$user->setExpiration('+ 30 minutes');
$this->redirect(":{$module}:default:default");
} catch (AuthenticationException $e) {
$this->flashMessage('Error: ' . $e->getMessage(), 'error');
$this->invalidateControl('flash');
if (!$this->isAjax()) {
$this->redirect('this');
}
}
}
}
示例15: actionLogout
public function actionLogout()
{
Environment::getUser()->signOut();
$this->flashMessage('You have been logged off.');
$this->redirect('Auth:login');
}