mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
Avoid globals where possible
$logged => logged() $account_logged => accountLogged()
This commit is contained in:
@@ -6,11 +6,9 @@ use MyAAC\Services\StatusService;
|
||||
// few things we'll need
|
||||
require '../common.php';
|
||||
|
||||
const ADMIN_PANEL = true;
|
||||
const MYAAC_ADMIN = true;
|
||||
|
||||
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
|
||||
{
|
||||
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) {
|
||||
header('Location: ' . BASE_URL . 'install/');
|
||||
exit;
|
||||
}
|
||||
@@ -32,8 +30,11 @@ require __DIR__ . '/includes/debugbar.php';
|
||||
|
||||
$loginService = new LoginService();
|
||||
$checkLogin = $loginService->checkLogin();
|
||||
|
||||
$logged = $checkLogin['logged'];
|
||||
$account_logged = $checkLogin['account'];
|
||||
|
||||
app()->setLoggedIn($logged);
|
||||
app()->setAccountLogged($account_logged);
|
||||
|
||||
$statusService = new StatusService();
|
||||
@@ -49,7 +50,7 @@ if (ACTION == 'logout') {
|
||||
}
|
||||
|
||||
// if we're not logged in - show login box
|
||||
if(!$logged || !admin()) {
|
||||
if(!logged() || !admin()) {
|
||||
$page = 'login';
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ $title = 'Login';
|
||||
csrfProtect();
|
||||
|
||||
require PAGES . 'account/login.php';
|
||||
if ($logged) {
|
||||
if (logged()) {
|
||||
header('Location: ' . (admin() ? ADMIN_URL : BASE_URL));
|
||||
return;
|
||||
}
|
||||
|
@@ -57,13 +57,14 @@ function admin_give_coins($coins)
|
||||
|
||||
function admin_give_premdays($days)
|
||||
{
|
||||
global $db, $freePremium;
|
||||
global $freePremium;
|
||||
|
||||
if ($freePremium) {
|
||||
displayMessage('Premium days not supported. Free Premium enabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
$db = app()->get('database');
|
||||
$value = $days * 86400;
|
||||
$now = time();
|
||||
// othire
|
||||
@@ -174,10 +175,12 @@ else {
|
||||
}
|
||||
|
||||
function displayMessage($message, $success = false) {
|
||||
global $twig, $hasCoinsColumn, $hasPointsColumn, $freePremium;
|
||||
global $hasCoinsColumn, $hasPointsColumn, $freePremium;
|
||||
|
||||
$success ? success($message): error($message);
|
||||
|
||||
$twig = app()->get('twig');
|
||||
|
||||
$twig->display('admin.tools.account.html.twig', array(
|
||||
'hasCoinsColumn' => $hasCoinsColumn,
|
||||
'hasPointsColumn' => $hasPointsColumn,
|
||||
|
@@ -99,9 +99,9 @@ else {
|
||||
}
|
||||
|
||||
|
||||
function displayMessage($message, $success = false) {
|
||||
global $twig;
|
||||
|
||||
function displayMessage($message, $success = false)
|
||||
{
|
||||
$twig = app()->get('twig');
|
||||
$success ? success($message): error($message);
|
||||
$twig->display('admin.tools.teleport.html.twig', array());
|
||||
}
|
||||
|
@@ -203,7 +203,7 @@ if (isset($_POST['template'])) {
|
||||
|
||||
function onTemplateMenusChange(): void
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
$cache = app()->get('cache');
|
||||
if ($cache->enabled()) {
|
||||
$cache->delete('template_menus');
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@
|
||||
</head>
|
||||
<body class="sidebar-mini ">
|
||||
<?php $hooks->trigger(HOOK_ADMIN_BODY_START); ?>
|
||||
<?php if ($logged && admin()) { ?>
|
||||
<?php if (logged() && admin()) { ?>
|
||||
<div class="wrapper">
|
||||
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
|
||||
<ul class="navbar-nav">
|
||||
@@ -177,7 +177,7 @@
|
||||
<div id="sidebar-overlay"></div>
|
||||
</div>
|
||||
|
||||
<?php } else if (!$logged && !admin()) {
|
||||
<?php } else if (!logged() && !admin()) {
|
||||
echo $content;
|
||||
}
|
||||
?>
|
||||
@@ -185,7 +185,7 @@
|
||||
/**
|
||||
* @var OTS_Account $account_logged
|
||||
*/
|
||||
if ($logged && admin()) {
|
||||
if (logged() && admin()) {
|
||||
$twig->display('admin-bar.html.twig', [
|
||||
'username' => USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()
|
||||
]);
|
||||
|
Reference in New Issue
Block a user