mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-02-12 06:48:40 +00:00
Update permission handling
This commit is contained in:
parent
243355f4c4
commit
bd42cd6ac1
|
|
@ -52,6 +52,7 @@ class Installer extends InstallerAbstract
|
||||||
`nav_from` varchar(255) DEFAULT NULL,
|
`nav_from` varchar(255) DEFAULT NULL,
|
||||||
`nav_order` smallint(3) DEFAULT NULL,
|
`nav_order` smallint(3) DEFAULT NULL,
|
||||||
`nav_parent` int(11) DEFAULT NULL,
|
`nav_parent` int(11) DEFAULT NULL,
|
||||||
|
`nav_permission_permission` int(11) DEFAULT NULL,
|
||||||
`nav_permission_type` int(11) DEFAULT NULL,
|
`nav_permission_type` int(11) DEFAULT NULL,
|
||||||
`nav_permission_element` int(11) DEFAULT NULL,
|
`nav_permission_element` int(11) DEFAULT NULL,
|
||||||
PRIMARY KEY (`nav_id`)
|
PRIMARY KEY (`nav_id`)
|
||||||
|
|
@ -97,8 +98,8 @@ class Installer extends InstallerAbstract
|
||||||
private static function installLink($dbPool, $data) : void
|
private static function installLink($dbPool, $data) : void
|
||||||
{
|
{
|
||||||
$sth = $dbPool->get()->con->prepare(
|
$sth = $dbPool->get()->con->prepare(
|
||||||
'INSERT INTO `' . $dbPool->get()->prefix . 'nav` (`nav_id`, `nav_pid`, `nav_name`, `nav_type`, `nav_subtype`, `nav_icon`, `nav_uri`, `nav_target`, `nav_from`, `nav_order`, `nav_parent`, `nav_permission_type`, `nav_permission_element`) VALUES
|
'INSERT INTO `' . $dbPool->get()->prefix . 'nav` (`nav_id`, `nav_pid`, `nav_name`, `nav_type`, `nav_subtype`, `nav_icon`, `nav_uri`, `nav_target`, `nav_from`, `nav_order`, `nav_parent`, `nav_permission_permission`, `nav_permission_type`, `nav_permission_element`) VALUES
|
||||||
(:id, :pid, :name, :type, :subtype, :icon, :uri, :target, :from, :order, :parent, :perm_type, :perm_element);'
|
(:id, :pid, :name, :type, :subtype, :icon, :uri, :target, :from, :order, :parent, :perm_perm, :perm_type, :perm_element);'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT);
|
$sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT);
|
||||||
|
|
@ -112,6 +113,7 @@ class Installer extends InstallerAbstract
|
||||||
$sth->bindValue(':from', $data['from'] ?? 0, \PDO::PARAM_STR);
|
$sth->bindValue(':from', $data['from'] ?? 0, \PDO::PARAM_STR);
|
||||||
$sth->bindValue(':order', $data['order'] ?? 1, \PDO::PARAM_INT);
|
$sth->bindValue(':order', $data['order'] ?? 1, \PDO::PARAM_INT);
|
||||||
$sth->bindValue(':parent', $data['parent'], \PDO::PARAM_INT);
|
$sth->bindValue(':parent', $data['parent'], \PDO::PARAM_INT);
|
||||||
|
$sth->bindValue(':perm_perm', $data['permission']['permission'] ?? null, \PDO::PARAM_INT);
|
||||||
$sth->bindValue(':perm_type', $data['permission']['type'] ?? null, \PDO::PARAM_INT);
|
$sth->bindValue(':perm_type', $data['permission']['type'] ?? null, \PDO::PARAM_INT);
|
||||||
$sth->bindValue(':perm_element', $data['permission']['element'] ?? null, \PDO::PARAM_INT);
|
$sth->bindValue(':perm_element', $data['permission']['element'] ?? null, \PDO::PARAM_INT);
|
||||||
|
|
||||||
|
|
@ -121,7 +123,7 @@ class Installer extends InstallerAbstract
|
||||||
|
|
||||||
foreach ($data['children'] as $link) {
|
foreach ($data['children'] as $link) {
|
||||||
$parent = ($link['parent'] == null ? $lastInsertID : $link['parent']);
|
$parent = ($link['parent'] == null ? $lastInsertID : $link['parent']);
|
||||||
self::installLink($dbPool, $link, $parent);
|
self::installLink($dbPool, $link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class Navigation
|
||||||
|
|
||||||
foreach ($tempNav as $id => $link) {
|
foreach ($tempNav as $id => $link) {
|
||||||
$isReadable = $account->hasPermission(
|
$isReadable = $account->hasPermission(
|
||||||
PermissionType::READ,
|
(int) $link[0]['nav_permission_permission'],
|
||||||
$unit,
|
$unit,
|
||||||
$app,
|
$app,
|
||||||
(string) $link[0]['nav_from'],
|
(string) $link[0]['nav_from'],
|
||||||
|
|
@ -170,7 +170,7 @@ class Navigation
|
||||||
public static function getInstance(RequestAbstract $hashes = null, Account $account, DatabasePool $dbPool, int $unit, string $appName)
|
public static function getInstance(RequestAbstract $hashes = null, Account $account, DatabasePool $dbPool, int $unit, string $appName)
|
||||||
{
|
{
|
||||||
if (!isset(self::$instance)) {
|
if (!isset(self::$instance)) {
|
||||||
if (!isset($hashes) || !isset($dbPool)) {
|
if (!isset($hashes)) {
|
||||||
throw new \Exception('Invalid parameters');
|
throw new \Exception('Invalid parameters');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,13 @@ if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE])) : ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?= $this->getHtml($parent['nav_name']) ?><label for="nav-<?= $this->printHtml($parent['nav_name']); ?>"><i class="fa fa-chevron-down min"></i>
|
<?= $this->getHtml($parent['nav_name']) ?><label for="nav-<?= $this->printHtml($parent['nav_name']); ?>"><i class="fa fa-chevron-down min"></i>
|
||||||
<i class="fa fa-chevron-up max"></i></label>
|
<i class="fa fa-chevron-up max"></i></label>
|
||||||
<?php foreach ($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::LINK] as $key2 => $link) :
|
<?php if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::LINK])) :
|
||||||
|
foreach ($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::LINK] as $key2 => $link) :
|
||||||
if ($link['nav_parent'] === $key) : ?>
|
if ($link['nav_parent'] === $key) : ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= \phpOMS\Uri\UriFactory::build($link['nav_uri']); ?>"><?= $this->getHtml($link['nav_name']) ?></a>
|
<a href="<?= \phpOMS\Uri\UriFactory::build($link['nav_uri']); ?>"><?= $this->getHtml($link['nav_name']) ?></a>
|
||||||
<?php endif;
|
<?php endif;
|
||||||
endforeach; ?>
|
endforeach; endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user