The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Permissions - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Permissions (/showthread.php?tid=213) |
Permissions - Sebastian - 08-23-2016 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 Permissions - mudmin - 08-23-2016 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. Permissions - Sebastian - 08-24-2016 Oh thanks, checkMenu is exactly what I need. So, no need to do it manually. Sebastian Permissions - mudmin - 08-24-2016 Absolutely. Glad it helped. |