45f80a0855
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.
61 lines
1.7 KiB
PHP
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(''',
|
|
'"'),
|
|
$string);
|
|
}
|
|
|
|
final protected function unescape_string($string) {
|
|
return str_replace(array(''',
|
|
'"'),
|
|
array("'",
|
|
'"'),
|
|
$string);
|
|
}
|
|
}
|
|
?>
|