sessionStorage->user = $user; $this->sessionStorage->postAuth = array('validated' => false); } /** * Return true if the user has validated the 2FA key * * @access public * @return bool */ public function check2FA() { return isset($this->sessionStorage->postAuth['validated']) && $this->sessionStorage->postAuth['validated'] === true; } /** * Return true if the user has 2FA enabled * * @access public * @return bool */ public function has2FA() { return isset($this->sessionStorage->user['twofactor_activated']) && $this->sessionStorage->user['twofactor_activated'] === true; } /** * Disable 2FA for the current session * * @access public */ public function disable2FA() { $this->sessionStorage->user['twofactor_activated'] = false; } /** * Return true if the logged user is admin * * @access public * @return bool */ public function isAdmin() { return isset($this->sessionStorage->user['is_admin']) && $this->sessionStorage->user['is_admin'] === true; } /** * Return true if the logged user is project admin * * @access public * @return bool */ public function isProjectAdmin() { return isset($this->sessionStorage->user['is_project_admin']) && $this->sessionStorage->user['is_project_admin'] === true; } /** * Get the connected user id * * @access public * @return integer */ public function getId() { return isset($this->sessionStorage->user['id']) ? (int) $this->sessionStorage->user['id'] : 0; } /** * Get username * * @access public * @return integer */ public function getUsername() { return isset($this->sessionStorage->user['username']) ? $this->sessionStorage->user['username'] : ''; } /** * Check is the user is connected * * @access public * @return bool */ public function isLogged() { return isset($this->sessionStorage->user) && ! empty($this->sessionStorage->user); } /** * Get project filters from the session * * @access public * @param integer $project_id * @return string */ public function getFilters($project_id) { return ! empty($this->sessionStorage->filters[$project_id]) ? $this->sessionStorage->filters[$project_id] : 'status:open'; } /** * Save project filters in the session * * @access public * @param integer $project_id * @param string $filters */ public function setFilters($project_id, $filters) { $this->sessionStorage->filters[$project_id] = $filters; } /** * Is board collapsed or expanded * * @access public * @param integer $project_id * @return boolean */ public function isBoardCollapsed($project_id) { return ! empty($this->sessionStorage->boardCollapsed[$project_id]) ? $this->sessionStorage->boardCollapsed[$project_id] : false; } /** * Set board display mode * * @access public * @param integer $project_id * @param boolean $is_collapsed */ public function setBoardDisplayMode($project_id, $is_collapsed) { $this->sessionStorage->boardCollapsed[$project_id] = $is_collapsed; } /** * Set comments sorting * * @access public * @param string $order */ public function setCommentSorting($order) { $this->sessionStorage->commentSorting = $order; } /** * Get comments sorting direction * * @access public * @return string */ public function getCommentSorting() { return empty($this->sessionStorage->commentSorting) ? 'ASC' : $this->sessionStorage->commentSorting; } }