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
/printthread.php 16 require_once



UserSpice
Suggested new function in US_helpers.php - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29)
+--- Thread: Suggested new function in US_helpers.php (/showthread.php?tid=239)



Suggested new function in US_helpers.php - plb - 09-04-2016

The current definition of
Code:
checkPermissions()
is somewhat special-purpose and (perhaps) obsolete.

I am suggesting a new function called
Code:
hasPermission()
which is a little more general-purpose and will change the definition of
Code:
checkPermissions()
to simply call
Code:
hasPermission()
with the appropriate parameter.

I will confess I am happy with the stability of
Code:
hasPermission()
(I have tested it) whereas I don't use
Code:
checkPermissions()
at all and so I haven't tested whether my change is backward compatible. [honesty strikes] OK, I haven't tested my definition of
Code:
checkPermission()
at all - I just typed it into the pastebin. Phew, conscience relieved. :-)

http://pastebin.com/cexD5maq

This provides a more generic way to check if a user (either the current user or someone else) has a given permission/group.


Suggested new function in US_helpers.php - mudmin - 09-06-2016

I like that. The old permission names and even what they do was somewhat setup like that for backwards compatibility, but I like having the more generic function.

Btw, technically you can still patch a usercake 2.0 project (from 2010 or something) all the way up to 4.1.4 if you're willing to do a little fiddling.