]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Session/Model/UserSession.php
API: Accept "redirect_uris" as both array and string
[friendica.git] / src / Core / Session / Model / UserSession.php
index 9d7d5c091e9ec5b65f6a504affcd1a93aa4105eb..a544487bd223fd5125fe7bc1c1ec46a4b75b4801 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,7 +24,11 @@ namespace Friendica\Core\Session\Model;
 use Friendica\Core\Session\Capability\IHandleSessions;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Model\Contact;
+use Friendica\Model\User;
 
+/**
+ * This class handles user sessions, which is directly extended from regular session
+ */
 class UserSession implements IHandleUserSessions
 {
        /** @var IHandleSessions */
@@ -47,6 +51,16 @@ class UserSession implements IHandleUserSessions
                return false;
        }
 
+       /** {@inheritDoc} */
+       public function getLocalUserNickname()
+       {
+               if ($this->isAuthenticated()) {
+                       return $this->session->get('nickname');
+               }
+
+               return false;
+       }
+
        /** {@inheritDoc} */
        public function getPublicContactId()
        {
@@ -107,12 +121,24 @@ class UserSession implements IHandleUserSessions
                return array_search($cid, $this->session->get('remote'));
        }
 
+       /** {@inheritDoc} */
+       public function getMyUrl(): string
+       {
+               return $this->session->get('my_url', '');
+       }
+
        /** {@inheritDoc} */
        public function isAuthenticated(): bool
        {
                return $this->session->get('authenticated', false);
        }
 
+       /** {@inheritDoc} */
+       public function isSiteAdmin(): bool
+       {
+               return User::isSiteAdmin($this->getLocalUserId());
+       }
+
        /** {@inheritDoc} */
        public function setVisitorsContacts()
        {
@@ -130,4 +156,52 @@ class UserSession implements IHandleUserSessions
        {
                $this->session->set('submanage', $managed_uid);
        }
+
+       /** {@inheritDoc} */
+       public function start(): IHandleSessions
+       {
+               return $this;
+       }
+
+       /** {@inheritDoc} */
+       public function exists(string $name): bool
+       {
+               return $this->session->exists($name);
+       }
+
+       /** {@inheritDoc} */
+       public function get(string $name, $defaults = null)
+       {
+               return $this->session->get($name, $defaults);
+       }
+
+       /** {@inheritDoc} */
+       public function pop(string $name, $defaults = null)
+       {
+               return $this->session->pop($name, $defaults);
+       }
+
+       /** {@inheritDoc} */
+       public function set(string $name, $value)
+       {
+               $this->session->set($name, $value);
+       }
+
+       /** {@inheritDoc} */
+       public function setMultiple(array $values)
+       {
+               $this->session->setMultiple($values);
+       }
+
+       /** {@inheritDoc} */
+       public function remove(string $name)
+       {
+               $this->session->remove($name);
+       }
+
+       /** {@inheritDoc} */
+       public function clear()
+       {
+               $this->session->clear();
+       }
 }