The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
checkMenu Page - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10)
+--- Thread: checkMenu Page (/showthread.php?tid=610)



checkMenu Page - Brandin - 06-24-2017

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!


checkMenu Page - mudmin - 06-24-2017

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.



checkMenu Page - Brandin - 06-24-2017

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.