Rework permission handling

Add a new function has_credential() that checks whether the currently
logged in user is allowed to perform a given action. Moving all
permission handling to this central place makes adding new user groups
and adjusting permissions much more convenient.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-07-15 20:52:54 +02:00
parent 9e6b861b6f
commit 03c6304e19
24 changed files with 187 additions and 237 deletions

View file

@ -16,6 +16,7 @@ include_once("routing.inc.php");
include_once("version.inc.php");
include_once("acctfuncs.inc.php");
include_once("cachefuncs.inc.php");
include_once("credentials.inc.php");
/**
* Check if a visitor is logged in
@ -406,16 +407,6 @@ function uid_from_email($email) {
return $row[0];
}
/**
* Determine if a user has TU or Developer privileges
*
* @return bool Return true if the user is a TU or developer, otherwise false
*/
function check_user_privileges() {
$type = account_from_sid($_COOKIE['AURSID']);
return ($type == 'Trusted User' || $type == 'Developer');
}
/**
* Generate clean url with edited/added user values
*