The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
checkMenu Page
#1
Hello!

I want to use a menu link, and instead of hard coding the permission levels that have access to that menu link, check the file and see if that permission level is in the users? Can this be coded into a function so I don't have to write the code out everytime and just call the function with the file name I want to check?

Thank you!
  Reply
#2
Ok. So you have access to a few things already.

You have
$currentPage
which gives you the page name and you have
$pagePermissions = fetchPagePermissions($id);
which gives you the permissions for that page if you have the id.

So all you need to do is to do a db query from the pages table to get the id of the current page.

Then you can run
$pagePermissions = fetchPagePermissions($id);

Then you can build an array of permission ids from that.

After that, the normal hasPerm function will work like it always has.

I hope that's a point in the right direction.
  Reply
#3
Sorry to ask for the work on this - but how can I built this into a function? Would I be using return true if in and return false if not in?

I will see if I can play around with it in a bit.

My issues is I won't be using $currentPage as I plan on using this for example in the navbar, so I'll be defining the page manually instead of using currentPage, but I want to do this so if I change permission levels, I don't have to make sure I do that in the nav.

Hope this makes sense.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)