mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-02-13 15:28:41 +00:00
Minor nav permission check improvements
This commit is contained in:
parent
bd23899bf9
commit
169d357ff8
|
|
@ -46,11 +46,16 @@ class BackendController extends Controller
|
||||||
*/
|
*/
|
||||||
public function createNavigationMid(int $pageId, RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
public function createNavigationMid(int $pageId, RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
||||||
{
|
{
|
||||||
$nav = Navigation::getInstance($request, $this->app->accountManager->get($request->getHeader()->getAccount()), $this->app->dbPool);
|
$nav = Navigation::getInstance($request,
|
||||||
|
$this->app->accountManager->get($request->getHeader()->getAccount()),
|
||||||
|
$this->app->dbPool,
|
||||||
|
$this->app->orgId,
|
||||||
|
$this->app->appName
|
||||||
|
);
|
||||||
|
|
||||||
$navView = new NavigationView($this->app, $request, $response);
|
$navView = new NavigationView($this->app, $request, $response);
|
||||||
$navView->setTemplate('/Modules/Navigation/Theme/Backend/mid');
|
$navView->setTemplate('/Modules/Navigation/Theme/Backend/mid');
|
||||||
$navView->setNav($nav->getNav());
|
$navView->setNav($nav->getNav());
|
||||||
$navView->setLanguage($request->getHeader()->getL11n()->getLanguage());
|
|
||||||
$navView->setParent($pageId);
|
$navView->setParent($pageId);
|
||||||
|
|
||||||
return $navView;
|
return $navView;
|
||||||
|
|
@ -68,10 +73,16 @@ class BackendController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getView(RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
public function getView(RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
||||||
{
|
{
|
||||||
$navObj = \Modules\Navigation\Models\Navigation::getInstance($request, $this->app->accountManager->get($request->getHeader()->getAccount()), $this->app->dbPool);
|
$navObj = \Modules\Navigation\Models\Navigation::getInstance(
|
||||||
$nav = new \Modules\Navigation\Views\NavigationView($this->app, $request, $response);
|
$request,
|
||||||
|
$this->app->accountManager->get($request->getHeader()->getAccount()),
|
||||||
|
$this->app->dbPool,
|
||||||
|
$this->app->orgId,
|
||||||
|
$this->app->appName
|
||||||
|
);
|
||||||
|
|
||||||
|
$nav = new \Modules\Navigation\Views\NavigationView($this->app, $request, $response);
|
||||||
$nav->setNav($navObj->getNav());
|
$nav->setNav($navObj->getNav());
|
||||||
$nav->setLanguage($request->getHeader()->getL11n()->getLanguage());
|
|
||||||
|
|
||||||
$unread = [];
|
$unread = [];
|
||||||
foreach ($this->receiving as $receiving) {
|
foreach ($this->receiving as $receiving) {
|
||||||
|
|
@ -107,6 +118,7 @@ class BackendController extends Controller
|
||||||
|
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$lang = include $path;
|
$lang = include $path;
|
||||||
|
|
||||||
$this->app->l11nManager->loadLanguage($response->getHeader()->getL11n()->getLanguage(), 'Navigation', $lang);
|
$this->app->l11nManager->loadLanguage($response->getHeader()->getL11n()->getLanguage(), 'Navigation', $lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,12 +134,17 @@ class BackendController extends Controller
|
||||||
*/
|
*/
|
||||||
public function createNavigationSplash(int $pageId, RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
public function createNavigationSplash(int $pageId, RequestAbstract $request, ResponseAbstract $response) : NavigationView
|
||||||
{
|
{
|
||||||
$nav = Navigation::getInstance($request, $this->app->accountManager->get($request->getHeader()->getAccount()), $this->app->dbPool);
|
$nav = Navigation::getInstance($request,
|
||||||
|
$this->app->accountManager->get($request->getHeader()->getAccount()),
|
||||||
|
$this->app->dbPool,
|
||||||
|
$this->app->orgId,
|
||||||
|
$this->app->appName
|
||||||
|
);
|
||||||
|
|
||||||
$navView = new NavigationView($this->app, $request, $response);
|
$navView = new NavigationView($this->app, $request, $response);
|
||||||
|
|
||||||
$navView->setTemplate('/Modules/Navigation/Theme/Backend/splash');
|
$navView->setTemplate('/Modules/Navigation/Theme/Backend/splash');
|
||||||
$navView->setNav($nav->getNav());
|
$navView->setNav($nav->getNav());
|
||||||
$navView->setLanguage($request->getHeader()->getL11n()->getLanguage());
|
|
||||||
$navView->setParent($pageId);
|
$navView->setParent($pageId);
|
||||||
|
|
||||||
return $navView;
|
return $navView;
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,15 @@ class Navigation
|
||||||
* @param RequestAbstract $request Request hashes
|
* @param RequestAbstract $request Request hashes
|
||||||
* @param Account $account Account
|
* @param Account $account Account
|
||||||
* @param DatabasePool $dbPool Database pool
|
* @param DatabasePool $dbPool Database pool
|
||||||
|
* @param int $unit Unit
|
||||||
|
* @param string $appName App name
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function __construct(RequestAbstract $request, Account $account, DatabasePool $dbPool)
|
private function __construct(RequestAbstract $request, Account $account, DatabasePool $dbPool, int $unit, string $appName)
|
||||||
{
|
{
|
||||||
$this->dbPool = $dbPool;
|
$this->dbPool = $dbPool;
|
||||||
$this->load($request->getHash(), $account);
|
$this->load($request->getHash(), $account, $unit, $appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,12 +79,14 @@ class Navigation
|
||||||
*
|
*
|
||||||
* @param string[] $hashes Request hashes
|
* @param string[] $hashes Request hashes
|
||||||
* @param Account $account Account
|
* @param Account $account Account
|
||||||
|
* @param int $unit Unit
|
||||||
|
* @param string $app App name
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function load(array $hashes, Account $account)
|
private function load(array $hashes, Account $account, int $unit, string $app)
|
||||||
{
|
{
|
||||||
if (empty($this->nav)) {
|
if (empty($this->nav)) {
|
||||||
$this->nav = [];
|
$this->nav = [];
|
||||||
|
|
@ -102,8 +106,8 @@ class Navigation
|
||||||
foreach ($tempNav as $id => $link) {
|
foreach ($tempNav as $id => $link) {
|
||||||
$isReadable = $account->hasPermission(
|
$isReadable = $account->hasPermission(
|
||||||
PermissionType::READ,
|
PermissionType::READ,
|
||||||
null,
|
$unit,
|
||||||
null,
|
$app,
|
||||||
(string) $link[0]['nav_from'],
|
(string) $link[0]['nav_from'],
|
||||||
(int) $link[0]['nav_permission_type'],
|
(int) $link[0]['nav_permission_type'],
|
||||||
(int) $link[0]['nav_permission_element']
|
(int) $link[0]['nav_permission_element']
|
||||||
|
|
@ -154,6 +158,8 @@ class Navigation
|
||||||
* @param RequestAbstract $hashes Request hashes
|
* @param RequestAbstract $hashes Request hashes
|
||||||
* @param Account $account Account
|
* @param Account $account Account
|
||||||
* @param DatabasePool $dbPool Database pool
|
* @param DatabasePool $dbPool Database pool
|
||||||
|
* @param int $unit Unit
|
||||||
|
* @param string $appName App name
|
||||||
*
|
*
|
||||||
* @return \Modules\Navigation\Models\Navigation
|
* @return \Modules\Navigation\Models\Navigation
|
||||||
*
|
*
|
||||||
|
|
@ -161,14 +167,14 @@ class Navigation
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getInstance(RequestAbstract $hashes = null, Account $account, DatabasePool $dbPool)
|
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) || !isset($dbPool)) {
|
||||||
throw new \Exception('Invalid parameters');
|
throw new \Exception('Invalid parameters');
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$instance = new self($hashes, $account, $dbPool);
|
self::$instance = new self($hashes, $account, $dbPool, $unit, $appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,6 @@ class NavigationView extends View
|
||||||
*/
|
*/
|
||||||
protected $nav = [];
|
protected $nav = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Language used for the navigation.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected $language = 'en';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent element used for navigation.
|
* Parent element used for navigation.
|
||||||
*
|
*
|
||||||
|
|
@ -62,14 +54,6 @@ class NavigationView extends View
|
||||||
*/
|
*/
|
||||||
protected $parent = 0;
|
protected $parent = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __construct($app, $request, $response)
|
|
||||||
{
|
|
||||||
parent::__construct($app, $request, $response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get navigation Id.
|
* Get navigation Id.
|
||||||
*
|
*
|
||||||
|
|
@ -118,28 +102,6 @@ class NavigationView extends View
|
||||||
$this->nav = $nav;
|
$this->nav = $nav;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getLanguage() : string
|
|
||||||
{
|
|
||||||
return $this->language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $language
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function setLanguage(string $language)
|
|
||||||
{
|
|
||||||
$this->language = $language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user