From ada1e391d4581543af7d22736d15c6f5001e9501 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 11 Nov 2023 12:52:26 +0100 Subject: [PATCH] Add option to restrict Page view to logged user $logged_access = 0 -> not logged in $logged_access = 1 -> logged in --- common.php | 2 +- system/libs/pot/OTS_Account.php | 2 +- system/migrations/37.php | 8 ++++++++ system/router.php | 2 +- system/templates/admin.pages.form.html.twig | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 system/migrations/37.php diff --git a/common.php b/common.php index b2147460..7a40466c 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.0', '<')) die('PHP version 8.0 or higher is const MYAAC = true; const MYAAC_VERSION = '1.0-dev'; -const DATABASE_VERSION = 36; +const DATABASE_VERSION = 37; const TABLE_PREFIX = 'myaac_'; define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/system/libs/pot/OTS_Account.php b/system/libs/pot/OTS_Account.php index 366dccdf..067c418d 100644 --- a/system/libs/pot/OTS_Account.php +++ b/system/libs/pot/OTS_Account.php @@ -952,7 +952,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable return $query['group_id']; } - return 0; + return 1; } public function getAccGroupId() diff --git a/system/migrations/37.php b/system/migrations/37.php new file mode 100644 index 00000000..dd12f35a --- /dev/null +++ b/system/migrations/37.php @@ -0,0 +1,8 @@ +where('access', 1)->update(['access' => 0]); diff --git a/system/router.php b/system/router.php index ca5454ff..1f0b1306 100644 --- a/system/router.php +++ b/system/router.php @@ -79,7 +79,7 @@ $ignore = false; /** @var boolean $logged */ /** @var OTS_Account $account_logged */ -$logged_access = 1; +$logged_access = 0; if($logged && $account_logged && $account_logged->isLoaded()) { $logged_access = $account_logged->getAccess(); } diff --git a/system/templates/admin.pages.form.html.twig b/system/templates/admin.pages.form.html.twig index 28274dac..267f0a40 100644 --- a/system/templates/admin.pages.form.html.twig +++ b/system/templates/admin.pages.form.html.twig @@ -21,10 +21,12 @@
+
* Guest means everyone will have access to this page. Player means registered and logged in user.