ordersprinter/php/utilities/userrights.php

54 lines
1.1 KiB
PHP

<?php
// Datenbank-Verbindungsparameter
require_once ('globals.php');
class Userrights {
/*
* can the current call the currentCmd
*/
function canUserCallCommands($currentCmd, $cmdArray,$right) {
session_start();
if (!isset($_SESSION['angemeldet']) || !$_SESSION['angemeldet']) {
// no user logged in
return false;
} else {
// user is logged in
if (in_array($currentCmd, $cmdArray)) {
// yes, the current command is in the set of commands to test!
if ($_SESSION[$right]) {
return true;
}
}
return false;
}
}
function isCurrentUserAdmin() {
if(session_id() == '') {
session_start();
}
if (!isset($_SESSION['angemeldet']) || !$_SESSION['angemeldet']) {
// no user logged in
return false;
} else {
return ($_SESSION['is_admin']);
}
}
function hasCurrentUserRight($whichRight) {
if(session_id() == '') {
session_start();
}
if (!isset($_SESSION['angemeldet']) || !$_SESSION['angemeldet']) {
// no user logged in
return false;
} else {
return ($_SESSION[$whichRight]);
}
}
}
?>