major refactoring of almost all files

This commit is contained in:
envoyr
2022-04-28 20:48:00 +02:00
parent a2e95b960f
commit 4f4c71d79b
285 changed files with 21716 additions and 18766 deletions

View File

@@ -1,5 +1,28 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
namespace Froxlor;
use Froxlor\Database\Database;
@@ -10,19 +33,9 @@ use Froxlor\Database\Database;
class CurrentUser
{
/**
* set the userinfo data to the session
*
* @param array $data
*/
public static function setData(array $data = []): void
{
$_SESSION['userinfo'] = $data;
}
/**
* returns whether there is an active session
*
*
* @return bool
*/
public static function hasSession(): bool
@@ -30,28 +43,6 @@ class CurrentUser
return !empty($_SESSION) && isset($_SESSION['userinfo']) && !empty($_SESSION['userinfo']);
}
/**
* returns whether user has an adminsession
*
* @return bool
*/
public static function isAdmin(): bool
{
return (self::getField('adminsession') == 1 && self::getField('adminid') > 0 && empty(self::getField('customerid')));
}
/**
* return content of a given field from userinfo-array
*
* @param string $index
*
* @return string|array
*/
public static function getField(string $index)
{
return isset($_SESSION['userinfo'][$index]) ? $_SESSION['userinfo'][$index] : "";
}
/**
* set userinfo field in session
*
@@ -66,16 +57,6 @@ class CurrentUser
return true;
}
/**
* Return userinfo array
*
* @return array
*/
public static function getData(): array
{
return $_SESSION['userinfo'] ?? [];
}
/**
* re-read in the user data if a valid session exists
*
@@ -103,4 +84,46 @@ class CurrentUser
self::setData([]);
return false;
}
/**
* returns whether user has an adminsession
*
* @return bool
*/
public static function isAdmin(): bool
{
return (self::getField('adminsession') == 1 && self::getField('adminid') > 0 && empty(self::getField('customerid')));
}
/**
* return content of a given field from userinfo-array
*
* @param string $index
*
* @return string|array
*/
public static function getField(string $index)
{
return isset($_SESSION['userinfo'][$index]) ? $_SESSION['userinfo'][$index] : "";
}
/**
* Return userinfo array
*
* @return array
*/
public static function getData(): array
{
return $_SESSION['userinfo'] ?? [];
}
/**
* set the userinfo data to the session
*
* @param array $data
*/
public static function setData(array $data = []): void
{
$_SESSION['userinfo'] = $data;
}
}