/** * {@inheritdoc} */ public function initBlock() { $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id', false); if ($currentUserId && ($userData = \Magelight\Auth\Models\User::find($currentUserId)->asArray())) { $this->set('user_id', $currentUserId); $this->set('user_data', $userData); } return parent::initBlock(); }
/** * {@inheritdoc} */ public function initBlock() { $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id'); if (!empty($currentUserId)) { if ($user = \Magelight\Auth\Models\User::find($currentUserId)) { $userData = $user->asArray(); $this->setGlobal('user_data', $userData); } } $document = \Magelight\Core\Blocks\Document::getInstance(); $document->addMeta(['http-equiv' => "content-type", 'content' => "text/html; charset=utf-8"]); $document->addCss('Magelight/Core/static/css/bootstrap.css'); $document->addCss('Magelight/Core/static/css/hint.css'); $document->addJs('Magelight/Core/static/js/jquery.js'); $document->addJs('Magelight/Core/static/js/bootstrap.min.js'); return parent::initBlock(); }
/** * Load user data from session * * @return Form */ public function loadFromSession() { $data = \Magelight\Http\Session::getInstance()->get('forms-' . $this->getAttribute('name'), []); if (!empty($data)) { $this->requestFields = $data; } return $this; }
/** * Get session object * * @return Http\Session */ public function session() { return \Magelight\Http\Session::getInstance(); }
/** * Shutdown application handler * @codeCoverageIgnore */ public function shutdown() { \Magelight\Http\Session::getInstance()->close(); }
/** * Check is current user admin user * * @return bool */ public function isCurrentUserAdmin() { $userId = \Magelight\Http\Session::getInstance()->get('user_id'); $model = \Magelight\Admin\Models\AdminUser::findBy('user_id', $userId); return !empty($model); }
/** * Check is captcha correct * * @param string $code * @return bool */ public function check($code) { if ($this->case_sensitive) { return $code === \Magelight\Http\Session::getInstance()->get($this->session_code, null); } $check = \Magelight\Http\Session::getInstance()->get($this->session_code, null); $result = strtolower($code) == strtolower($check); \Magelight\Http\Session::getInstance()->unsetData($this->session_code); return $result; }