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
Permissions
#1
Hi,

I've added some Permission Levels and wanted to use these permissions to allow or disallow users access to sites/functions etc. I found that the permissions are saved in the database in the table "user_permission_matches".
So, is it the way to have access to the permissions to query this table, like
Code:
$query = $db->query("SELECT * FROM user_permission_matches WHERE user_id = ?", array($num));
?
Or does UserSpice offers some functions for that?
Thanks,
Sebastian
  Reply
#2
There are not built in functions for doing that, but I could definitely see the use case for it. By default those permissions are designed only to control access to particular pages, but there is no reason why that functionality could not be extended.

Just fyi, you can always get the id of the logged in user by putting
Code:
$user->data()->id;

You'll notice that we also do something similar with the menus. The menu looks at the permission level of the logged in user. In fact, there is a function for that.

Code:
if (checkMenu(2,$user->data()->id)){  //Links for permission level 2 (default admin) ?>

You may want to play with that checkMenu function. It might be a slightly faster (but less flexible) way to do that rather than querying manually.
  Reply
#3
Oh thanks, checkMenu is exactly what I need. So, no need to do it manually.
Sebastian
  Reply
#4
Absolutely. Glad it helped.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)