Your IP : 216.73.216.240
<?php
/**
* @copyright
* @package Easybook Reloaded - EBR for Joomla! 3.x
* @author Viktor Vogel <admin@kubik-rubik.de>
* @version 3.4.1.1-FREE - 2021-08-29
* @link https://kubik-rubik.de/ebr-easybook-reloaded
*
* @license GNU/GPL
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
namespace EasybookReloaded;
defined('_JEXEC') || die('Restricted access');
use Joomla\CMS\{Factory, Access\Access};
/**
* Class Acl
*
* @package EasybookReloaded
*
* @since 3.4.0-FREE
* @version 3.4.1.0-FREE
*/
class Acl
{
/**
* This code segment sets the correct permission rights of the user
*
* @since 3.4.0-FREE
* @version 3.4.1.0-FREE
*/
public static function setAclConstants(): void
{
$canAdd = false;
$canEdit = false;
// Get all groups which are associated with the user
$user = Factory::getUser();
$userGroup = Access::getGroupsByUser($user->id);
// Get the specified groups from the parameters
$addAclArray = array_map('intval', Helper::getParams('addAcl', [1]));
$adminAclArray = array_map('intval', Helper::getParams('adminAcl', [8]));
foreach ($userGroup as $value) {
foreach ($addAclArray as $addAclValue) {
if ($value === $addAclValue) {
$canAdd = true;
break;
}
}
foreach ($adminAclArray as $adminAclValue) {
if ($value === $adminAclValue) {
$canEdit = true;
break;
}
}
}
// Defines constants for adding and editing permission rights
define('EASYBOOK_CANADD', $canAdd);
define('EASYBOOK_CANEDIT', $canEdit);
}
}