Add option to restrict Page view to logged user

$logged_access = 0 -> not logged in
$logged_access = 1 -> logged in
This commit is contained in:
slawkens 2023-11-11 12:52:26 +01:00
parent 193e18523d
commit ada1e391d4
5 changed files with 14 additions and 4 deletions

View File

@ -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'));

View File

@ -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()

8
system/migrations/37.php Normal file
View File

@ -0,0 +1,8 @@
<?php
// 2023-11-11
// Add Guest page access
use MyAAC\Models\Pages;
Pages::query()->where('access', 1)->update(['access' => 0]);

View File

@ -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();
}

View File

@ -21,10 +21,12 @@
<div class="form-group row">
<label for="access">Access</label>
<select class="form-control" id="access" name="access">
<option value="0" {% if access == 0 %}selected{% endif %}>Guest*</option>
{% for id, group in groups %}
<option value="{{ group.getId() }}"{% if access == group.getId() %} selected{% endif %}>{{ group.getName() }}</option>
<option value="{{ group.getId() }}"{% if access == group.getId() %} selected{% endif %}>{{ group.getName()|title }}</option>
{% endfor %}
</select>
<br>* Guest means everyone will have access to this page. Player means registered and logged in user.
</div>
<div class="form-group row">
<label for="php">PHP