//============================================================================================ // Session, configuration file, localization constructor //============================================================================================ require '../includes/php/bootstrap.php'; $SESSION = new \Zend_Session_Namespace('internal', true); if (!isset($SESSION->lang)) { $SESSION->lang = DEFAULT_LANGUAGE; } \Locale::setDefault($SESSION->lang); $l10n->setLanguage($SESSION->lang); //============================================================================================ // Model //============================================================================================ $profile = new Profile($dbo); $summary = new CaseSummary($dbo); $emp_profile = new \Ventus\Profile\MyProfile($dbo); if (isset($_GET['student_num']) && ctype_digit($_GET['student_num'])) { $studentProfile = $profile->getProfile($_GET['student_num']); } //============================================================================================ // Load the content //============================================================================================ if (!isset($_GET['page'])) { $render = true; $thisPage = 'summary'; if (!empty($studentProfile)) { $emp_signature = nl2br($emp_profile->getEmpSignature($SESSION->user_name)); $triage_list = $summary->listTriage($_GET['student_num']); $casedata = $summary->listCaseSummaries($_GET['student_num']); $l10n->addResource(__DIR__ . '/l10n/case-summary.json'); $viewFile = 'views/case-summary.php';
/** * Checks whether a user has privileges to access a given module * @param string $username The username * @param string $module The module name * @return boolean */ private static function checkUserPrivileges($username, $module) { global $dbo; $pro = new \Ventus\Profile\MyProfile($dbo); // Function to filter modules based on path returned from database $filterByModule = function ($mod) use($module) { return $mod['path'] === $module; }; // Function to filter modules based on global availability and path returned from database $filterByGlobal = function ($mod) use($module) { return $mod['globally_available'] === '1' && $mod['path'] === $module; }; /** * The user has priviliges if * (1) the module is "profile" * (2) the user modules contains the module, or * (3) the module is globally available */ return $module === 'profile' || sizeof(array_filter($pro->getEmpModules($username), $filterByModule)) || sizeof(array_filter($pro->getAllModules(), $filterByGlobal)); }