Esempio n. 1
0
 public function beforeAction($actionName)
 {
     $key = Config::value('FORUM_SECTION_ID_KEY');
     switch (Config::value('FORUM_SECTION_ID_SOURCE')) {
         case 'get':
             if (isset($_GET[$key])) {
                 $this->sectionId = $_GET[$key];
             }
             break;
         case 'post':
             if (isset($_POST[$key])) {
                 $this->sectionId = $_POST[$key];
             }
             break;
         case 'session':
             if (Session::get()->exists($key)) {
                 $this->sectionId = Session::get()->value($key);
             }
             break;
     }
     if (!in_array($actionName, ['notFound', 'accesDenied'])) {
         $section = ForumSection::findByPk($this->sectionId);
         if (!$section) {
             $this->goToPage('special', 'notFound');
         }
         $this->forumTitle = str_replace('__SECTION__', 'Main' == $section->name ? '' : $section->name . ' ', $this->forumTitle);
     }
     return parent::beforeAction($actionName);
 }
Esempio n. 2
0
 public function setLimitPerPage($limit)
 {
     $this->perPage = $limit;
     if ($this->perPageSessionKey) {
         Session::get()->set($this->perPageSessionKey, $limit);
     }
     if ($this->perPageCookieKey) {
         Cookie::get()->set($this->perPageCookieKey, $limit);
     }
 }
Esempio n. 3
0
 public function updateViews()
 {
     if (Session::get()->exists($this->sessionViewsTempKey)) {
         $threads = Session::get()->value($this->sessionViewsTempKey);
     } else {
         $threads = [];
     }
     if (!isset($threads[$this->id])) {
         $this->views++;
         $this->save();
         $threads[$this->id] = true;
         Session::get()->set($this->sessionViewsTempKey, $threads);
     }
 }
Esempio n. 4
0
 public function init($config)
 {
     if (Session::get()->exists($this->sessionKey)) {
         $session = Session::get()->value($this->sessionKey);
         if (isset($session['userId']) && $session['userId'] == (WebApp::get()->user()->isConnected() ? WebApp::get()->user()->id : 0)) {
             // handle logout + login
             $this->user2Sections = $session['user2Sections'];
         } else {
             $this->reloadRights();
         }
     } else {
         $this->reloadRights();
     }
     parent::init($config);
 }
Esempio n. 5
0
 /**
  * Get csrf token value
  * @return string
  */
 public function getCsrfValue()
 {
     return md5($this->getUserAgent() . Session::get()->id() . $this->csrfSalt);
 }
Esempio n. 6
0
 /**
  * Set a new set of rights for active user.
  * @param $rights
  * @return $this
  */
 public function setRights($rights)
 {
     $this->_rights = $rights;
     Session::get()->updateListItem(App::get()->shortName . $this->sessionKey, 'rights', $this->_rights, array('vars' => array(), 'rights' => array()));
     return $this;
 }