The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
DB-dynamic NavBar - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27) +--- Thread: DB-dynamic NavBar (/showthread.php?tid=1301) |
DB-dynamic NavBar - zyan - 01-10-2019 Hello, I am trying to build a dynamic NavBar depending on the permission level of the logged in user. My first approach was something like: PHP Code: $db = DB::getInstance(); But the problem is, that the list element doesn't even show up for the admin. When I echoed $permission it always showed "1" for all users I tried. To me it looks like, that "$user->data()->permissions" outputs the permissions level of the user, that is necessary to access the current the page. So when my page requires access level 1 and the admin has access levels 1 and 2, "$user->data()->permissions" outputs 1. Does anyone know a solution or am I just on the wrong path? PS: I started using UserSpice about a week ago and want to thank developers very much for this great tool! RE: DB-dynamic NavBar - mudmin - 01-10-2019 (01-10-2019, 02:37 PM)zyan Wrote: Hello, The term "permissions" in the db is actually an old thing that basically is whether the user is locked out or not. What you can do instead is use the hasPerm function which takes an array of permissions to be more flexible. PHP Code: if(hasPerm([2,3,4],$user->data()->id)){ Glad you're enjoying it! RE: DB-dynamic NavBar - zyan - 01-10-2019 Thank you very much! Works perfectly! RE: DB-dynamic NavBar - mudmin - 01-10-2019 Awesome. Happy to help. |