/** * Function to add the organisation switcher to the sidebar. * * @global type $translate * @global type $ENTRADA_USER */ function add_organisation_sidebar() { global $translate, $ENTRADA_USER; $temp_router = new Entrada_Router(); $temp_router->setBasePath(ENTRADA_CORE . DIRECTORY_SEPARATOR . "modules" . (defined("IN_ADMIN") && IN_ADMIN ? DIRECTORY_SEPARATOR . "admin" : DIRECTORY_SEPARATOR . "public")); $temp_router->initRoute(); /** * Create the Organisation side bar. * If the org request attribute is set then change the current org id for this user. */ if ($ENTRADA_USER->getAllOrganisations() && count($ENTRADA_USER->getAllOrganisations()) > 1 || $ENTRADA_USER->getOrganisationGroupRole() && max(array_map('count', $ENTRADA_USER->getOrganisationGroupRole())) > 1) { $org_group_role = $ENTRADA_USER->getOrganisationGroupRole(); $sidebar_html = "<ul class=\"nav nav-list\">\n"; foreach ($ENTRADA_USER->getAllOrganisations() as $key => $organisation_title) { $sidebar_html .= "<li class=\"nav-header\">" . html_encode($organisation_title) . "</li>\n"; if ($org_group_role && !empty($org_group_role)) { foreach ($org_group_role[$key] as $group_role) { $sidebar_html .= "<li><a href=\"" . ENTRADA_RELATIVE . "/" . (defined("IN_ADMIN") && IN_ADMIN ? "admin/" : "") . (isset($temp_router) && $temp_router ? implode("/", $temp_router->getModules()) : "") . "?" . replace_query(array("organisation_id" => $key, "ua_id" => $group_role["access_id"])) . "\"" . ($group_role["access_id"] == $ENTRADA_USER->getAccessId() ? " style=\"font-weight: bold\"" : "") . ">" . html_encode(ucfirst($group_role["group"]) . " / " . ucfirst($group_role["role"])) . "</a></li>\n"; } } } $sidebar_html .= "</ul>\n"; new_sidebar_item($translate->_("My Organisations"), $sidebar_html, "org-switch", "open", SIDEBAR_PREPEND); } }
} define("PARENT_INCLUDED", true); require_once ENTRADA_ABSOLUTE . "/templates/" . $ENTRADA_TEMPLATE->activeTemplate() . "/layouts/public/header.tpl.php"; switch ($MODULE) { case "confirm_observership": case "password_reset": case "privacy_policy": case "help": case "login": require_once ENTRADA_ABSOLUTE . DIRECTORY_SEPARATOR . "default-pages" . DIRECTORY_SEPARATOR . $MODULE . ".inc.php"; break; default: /** * Initialize Entrada_Router so it can load the requested modules. */ $router = new Entrada_Router(); $router->setBasePath(ENTRADA_CORE . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "public"); $router->setSection($SECTION); if ($router && ($route = $router->initRoute($MODULE))) { /** * Responsible for displaying the permission masks sidebar item * if they have more than their own permission set available. */ if (isset($_SESSION["permissions"]) && is_array($_SESSION["permissions"]) && count($_SESSION["permissions"]) > 1) { $sidebar_html = "<form id=\"masquerade-form\" action=\"" . ENTRADA_URL . "\" method=\"get\">\n"; $sidebar_html .= "<label for=\"permission-mask\">Available permission masks:</label><br />"; $sidebar_html .= "<select id=\"permission-mask\" name=\"mask\" style=\"width: 100%\" onchange=\"window.location='" . ENTRADA_URL . "/" . $MODULE . "/?" . str_replace("'", "'", replace_query(array("mask" => "'+this.options[this.selectedIndex].value"))) . "\">\n"; $display_masks = false; $added_users = array(); foreach ($_SESSION["permissions"] as $access_id => $result) { if ($result["organisation_id"] == $ENTRADA_USER->getActiveOrganisation() && is_int($access_id) && (isset($result["mask"]) && $result["mask"] || $access_id == $ENTRADA_USER->getDefaultAccessId() || $result["id"] == $ENTRADA_USER->getID() && $ENTRADA_USER->getDefaultAccessId() != $access_id) && array_search($result["id"], $added_users) === false) {