+ private $session;
+
+ /**
+ * Set the user ID
+ *
+ * @param int $user_id
+ * @return void
+ */
+ public function setLoggedInUserId(int $user_id)
+ {
+ $this->user_id = $user_id;
+ }
+
+ /**
+ * Set the nickname
+ *
+ * @param int $user_id
+ * @return void
+ */
+ public function setLoggedInUserNickname(string $nickname)
+ {
+ $this->nickname = $nickname;
+ }
+
+ public function isLoggedIn(): bool
+ {
+ return $this->session->getLocalUserId() && $this->user_id && ($this->user_id == $this->session->getLocalUserId());
+ }
+
+ /**
+ * Check if current user has admin role.
+ *
+ * @return bool true if user is an admin
+ * @throws Exception
+ */
+ public function isSiteAdmin(): bool
+ {
+ return
+ $this->session->getLocalUserId()
+ && $this->database->exists('user', [
+ 'uid' => $this->getLoggedInUserId(),
+ 'email' => User::getAdminEmailList()
+ ]);
+ }
+
+ /**
+ * Fetch the user id
+ * @return int User id
+ */
+ public function getLoggedInUserId(): int
+ {
+ return $this->user_id;
+ }
+
+ /**
+ * Fetch the user nick name
+ * @return string User's nickname
+ */
+ public function getLoggedInUserNickname(): string
+ {
+ return $this->nickname;
+ }