chg: [navigation] Breadcrumb generation is user aware
- moved the initialisation of the generation to be invoked from the appcontroller's beforefilter, after the user is loaded into the ACL component - Only show user setting edits when the user is editing themselvescli-modification-summary
parent
9a0ddef2af
commit
c186c88d5c
|
@ -110,6 +110,7 @@ class AppController extends Controller
|
||||||
}
|
}
|
||||||
unset($user['password']);
|
unset($user['password']);
|
||||||
$this->ACL->setUser($user);
|
$this->ACL->setUser($user);
|
||||||
|
$this->Navigation->genBreadcrumbs($user);
|
||||||
$this->request->getSession()->write('authUser', $user);
|
$this->request->getSession()->write('authUser', $user);
|
||||||
$this->isAdmin = $user['role']['perm_admin'];
|
$this->isAdmin = $user['role']['perm_admin'];
|
||||||
if (!$this->ParamHandler->isRest()) {
|
if (!$this->ParamHandler->isRest()) {
|
||||||
|
|
|
@ -24,7 +24,10 @@ class UsersNavigation extends BaseNavigation
|
||||||
$bcf = $this->bcf;
|
$bcf = $this->bcf;
|
||||||
$request = $this->request;
|
$request = $this->request;
|
||||||
$passedData = $this->request->getParam('pass');
|
$passedData = $this->request->getParam('pass');
|
||||||
$this->bcf->addLink('Users', 'view', 'UserSettings', 'index', function ($config) use ($bcf, $request, $passedData) {
|
$currentUser = $this->currentUser;
|
||||||
|
$ownUser = (!empty($passedData[0]) && $passedData[0] === $currentUser['id']);
|
||||||
|
if ($ownUser) {
|
||||||
|
$this->bcf->addLink('Users', 'view', 'UserSettings', 'index', function ($config) use ($bcf, $request, $passedData, $currentUser) {
|
||||||
if (!empty($passedData[0])) {
|
if (!empty($passedData[0])) {
|
||||||
$user_id = $passedData[0];
|
$user_id = $passedData[0];
|
||||||
$linkData = [
|
$linkData = [
|
||||||
|
@ -35,6 +38,7 @@ class UsersNavigation extends BaseNavigation
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
}
|
||||||
$this->bcf->addLink('Users', 'view', 'UserSettings', 'index', function ($config) use ($bcf, $request, $passedData) {
|
$this->bcf->addLink('Users', 'view', 'UserSettings', 'index', function ($config) use ($bcf, $request, $passedData) {
|
||||||
if (!empty($passedData[0])) {
|
if (!empty($passedData[0])) {
|
||||||
$user_id = $passedData[0];
|
$user_id = $passedData[0];
|
||||||
|
|
|
@ -5,6 +5,7 @@ class BaseNavigation
|
||||||
{
|
{
|
||||||
protected $bcf;
|
protected $bcf;
|
||||||
protected $request;
|
protected $request;
|
||||||
|
public $currentUser;
|
||||||
|
|
||||||
public function __construct($bcf, $request)
|
public function __construct($bcf, $request)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +13,11 @@ class BaseNavigation
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCurrentUser($currentUser)
|
||||||
|
{
|
||||||
|
$this->currentUser = $currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
public function addRoutes() {}
|
public function addRoutes() {}
|
||||||
public function addParents() {}
|
public function addParents() {}
|
||||||
public function addLinks() {}
|
public function addLinks() {}
|
||||||
|
|
Loading…
Reference in New Issue