boka3/include/Responder.php
Erik Thuning 45f80a0855 Moved entitlement handling into the application.
Any user who can log in via SSO but doesn't have one of the required
entitlements will only ever see a listing of their own loans.
2024-02-29 15:44:19 +01:00

61 lines
1.7 KiB
PHP

<?php
abstract class Responder {
protected $fragments = array();
protected $ldap = null;
public function __construct() {
global $language, $required_entitlements;
$this->authorized = false;
$entitlements = explode(';', $_SERVER['entitlement']);
foreach($entitlements as $entitlement) {
if(in_array($entitlement, $required_entitlements)) {
$this->authorized = true;
}
}
$this->fragments = get_fragments("./html/$language/fragments.html");
$this->ldap = new Ldap();
}
public function respond() {
if(!$this->authorized) {
die("Unauthorized.");
}
return $this->render();
}
abstract public function render();
final protected function escape_tags($tags) {
foreach($tags as $key => $tag) {
$tags[$key] = $this->escape_string(strtolower($tag));
}
return $tags;
}
final protected function unescape_tags($tags) {
foreach($tags as $key => $tag) {
$tags[$key] = $this->unescape_string(strtolower($tag));
}
return $tags;
}
final protected function escape_string($string) {
return str_replace(array("'",
'"'),
array('&#39;',
'&#34;'),
$string);
}
final protected function unescape_string($string) {
return str_replace(array('&#39;',
'&#34;'),
array("'",
'"'),
$string);
}
}
?>