예제 #1
0
파일: Top.php 프로젝트: rganin/magelight
 /**
  * {@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();
 }
예제 #2
0
파일: Body.php 프로젝트: rganin/magelight
 /**
  * {@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();
 }
예제 #3
0
파일: Form.php 프로젝트: rganin/magelight
 /**
  * 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;
 }
예제 #4
0
 /**
  * Get session object
  *
  * @return Http\Session
  */
 public function session()
 {
     return \Magelight\Http\Session::getInstance();
 }
예제 #5
0
파일: App.php 프로젝트: rganin/magelight
 /**
  * Shutdown application handler
  * @codeCoverageIgnore
  */
 public function shutdown()
 {
     \Magelight\Http\Session::getInstance()->close();
 }
예제 #6
0
파일: Admin.php 프로젝트: rganin/magelight
 /**
  * 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);
 }
예제 #7
0
 /**
  * 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;
 }