X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSession.php;h=0af4d344b11337c019bc27ea3bdba480aa09ab86;hb=f97a358a9b0d73e96c6dd52ea304574d0bbff039;hp=ef26cd929edc1dfd69f73b1f7f7004c8d6ee470e;hpb=555513e4b48e948bdfd64bba833e0ccf222c0b2b;p=friendica.git diff --git a/src/Core/Session.php b/src/Core/Session.php index ef26cd929e..0af4d344b1 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -5,9 +5,8 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; -use Friendica\Core\Session\ISession; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Util\Strings; @@ -16,39 +15,39 @@ use Friendica\Util\Strings; * * @author Hypolite Petovan */ -class Session extends BaseObject +class Session { public static $exists = false; public static $expire = 180000; public static function exists($name) { - return self::getClass(ISession::class)->exists($name); + return DI::session()->exists($name); } public static function get($name, $defaults = null) { - return self::getClass(ISession::class)->get($name, $defaults); + return DI::session()->get($name, $defaults); } public static function set($name, $value) { - self::getClass(ISession::class)->set($name, $value); + DI::session()->set($name, $value); } public static function setMultiple(array $values) { - self::getClass(ISession::class)->setMultiple($values); + DI::session()->setMultiple($values); } public static function remove($name) { - self::getClass(ISession::class)->remove($name); + DI::session()->remove($name); } public static function clear() { - self::getClass(ISession::class)->clear(); + DI::session()->clear(); } /** @@ -59,11 +58,13 @@ class Session extends BaseObject */ public static function getRemoteContactID($uid) { - if (empty($_SESSION['remote'][$uid])) { - return false; + $session = DI::session(); + + if (empty($session->get('remote')[$uid])) { + return 0; } - return $_SESSION['remote'][$uid]; + return $session->get('remote')[$uid]; } /** @@ -74,11 +75,13 @@ class Session extends BaseObject */ public static function getUserIDForVisitorContactID($cid) { - if (empty($_SESSION['remote'])) { + $session = DI::session(); + + if (empty($session->get('remote'))) { return false; } - return array_search($cid, $_SESSION['remote']); + return array_search($cid, $session->get('remote')); } /** @@ -88,15 +91,17 @@ class Session extends BaseObject */ public static function setVisitorsContacts() { - $_SESSION['remote'] = []; + $session = DI::session(); - $remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => Strings::normaliseLink($_SESSION['my_url']), 'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'self' => false]); + $session->set('remote', []); + + $remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => Strings::normaliseLink($session->get('my_url')), 'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'self' => false]); while ($contact = DBA::fetch($remote_contacts)) { if (($contact['uid'] == 0) || Contact::isBlockedByUser($contact['id'], $contact['uid'])) { continue; } - $_SESSION['remote'][$contact['uid']] = $contact['id']; + $session->set('remote', [$contact['uid'] => $contact['id']]); } DBA::close($remote_contacts); } @@ -108,15 +113,8 @@ class Session extends BaseObject */ public static function isAuthenticated() { - if (empty($_SESSION['authenticated'])) { - return false; - } - - return $_SESSION['authenticated']; - } + $session = DI::session(); - public static function delete() - { - self::getClass(ISession::class)->delete(); + return $session->get('authenticated', false); } }