function display_page($page, $submod, $mod) { if ($page->getDescription() && $page->isVisible()) { $url = urlStr($mod->getName() . "/" . $submod->getName() . "/" . $page->_action); if (hasCorrectAcl($mod->getName(), $submod->getName(), $page->_action)) { echo "<li><a href=\"{$url}\">" . $page->getDescription() . "</a></li>"; } else { echo "<li style=\"color: #BBB;\">" . $page->getDescription() . "</li>"; } } }
function modIsActive($action) { $modActionAssoc = array("img" => "imaging", "inv" => "inventory", "vnc" => "msc", "msc" => "msc"); $action = strtolower($action); foreach ($modActionAssoc as $key => $value) { $mod = ''; if (strpos($action, $key) !== false) { $mod = $value; } if (in_array($mod, $_SESSION["supportModList"])) { if (strpos($action, "vnc") !== false) { // if VNC icon, check if "Take control of this computer" ACL // is True or not return hasCorrectAcl('base', 'computers', "index&vnc="); } return True; } } return False; }
function modIsActive($action) { $modActionAssoc = array("img" => "imaging", "inv" => "inventory", "vnc" => "msc", "msc" => "msc", "hos" => "backuppc", "cre" => "extticket"); $modList = $_SESSION['supportModList']; if (in_array('glpi', $modList)) { $modList[] = 'inventory'; } $action = strtolower($action); foreach ($modActionAssoc as $key => $value) { $mod = ''; if (strpos($action, $key) !== false) { $mod = $value; } if (in_array($mod, $modList)) { if (strpos($action, "vnc") !== false) { // if VNC icon, check if "Take control of this computer" ACL // is True or not return hasCorrectAcl('base', 'computers', "vnc_client"); } return True; } } return False; }
function RenderedMSCActions($script_list, $qa_on_name, $params) { $this->list = array(); $this->qa_on_name = $qa_on_name; $this->params = $params; $this->name = "mscactions"; $this->url = $_SERVER["REQUEST_URI"]; $this->module = "base"; $this->submod = "computers"; $this->action = "start_quick_action"; $this->enabled = hasCorrectAcl("base", "computers", "start_quick_action"); $this->error = !$script_list[0]; if (!$this->error) { foreach ($script_list[1] as $script) { array_push($this->list, new RenderedMSCAction($script)); } } else { $this->errmsg = msg_err_qa($script_list); } }
$_GET['part'] = 'Summary'; } if (isset($_GET['groupname'])) { $groupname = $_GET['groupname']; } else { $groupname = ""; } if (isset($_GET['gid'])) { $gid = $_GET['gid']; } else { $gid = ""; } $p = new TabbedPageGenerator(); $p->setSideMenu($sidemenu); if (isset($_SESSION['pull_targets']) && in_array($_GET['uuid'], $_SESSION['pull_targets'])) { if (hasCorrectAcl('base', 'computers', 'remove_from_pull')) { $remove_pull_id = uniqid(); $_SESSION['remove_pull_id'] = $remove_pull_id; $p->setDescription(sprintf('%s <a class="btn btn-primary" href="%s">%s</a>', _T('This client has been registered in pull mode', 'inventory'), urlStrRedirect('base/computers/remove_from_pull', array('uuid' => $_GET['uuid'], 'remove_pull_id' => $remove_pull_id)), _T('Leave pull mode', 'inventory'))); } else { $p->setDescription(sprintf('%s', _T('This client has been registered in pull mode', 'inventory'))); } } $prefix = ''; if ($_GET['hostname'] != '') { $p->addTop(sprintf(_T("%s's inventory", 'inventory'), $_GET['hostname']), "modules/inventory/inventory/header.php"); } else { $p->addTop(sprintf(_T("%s's content inventory", 'inventory'), $groupname), "modules/inventory/inventory/header.php"); $prefix = 'group'; } // TODO get the list with trads from agent (conf file...)
function getButtonString($name, $value, $klass = "btnPrimary", $extra = "", $type = "submit") { if (hasCorrectAcl($this->module, $this->submod, $this->action)) { return $this->getButtonStringWithRight($name, $value, $klass, $extra, $type); } else { return $this->getButtonStringWithNoRight($name, $value, $klass, $extra, $type); } }
/** * Add the submodule icon and the URL link to the top navigation bar */ function generateNavBar() { if ($this->_visibility == False || !hasCorrectModuleAcl($this->_parentname)) { return; } list($module, $submod, $action) = split('/', $this->_defaultpage, 3); /* If the user has no right to access the default page, try to find another page. */ if (!hasCorrectAcl($module, $submod, $action)) { $found = False; foreach ($this->getPages() as $page) { if ($page->isVisible() && hasCorrectAcl($module, $submod, $page->getAction())) { $found = True; $action = $page->getAction(); break; } } /* No page found, so don't display the submodule icon */ if (!$found) { return; } } global $root; print "<li id=\"navbar" . $this->getName() . "\"><a href=\"" . $root . "main.php?module={$module}&submod={$submod}&action={$action}\">\n"; print $this->_desc . "</a></li>\n"; }
function getDefaultPage() { if ($_SESSION["login"] == "root") { $url = urlStrRedirect("base/main/default"); } elseif (hasCorrectAcl('dashboard', 'main', 'default')) { $url = urlStrRedirect("dashboard/main/default"); } else { $MMCApp =& MMCApp::getInstance(); # get first page in acl list which is not a popup if (isset($_SESSION["acl"])) { foreach ($_SESSION["acl"] as $module => $modinfo) { foreach ($modinfo as $submod => $submodinfo) { foreach ($submodinfo as $page => $pageinfo) { # check page is not a popup if (isset($MMCApp->_modules[$module]->_submod[$submod]->_pages[$page]) && $MMCApp->_modules[$module]->_submod[$submod]->_pages[$page]->_options['noHeader'] != 1 && $MMCApp->_modules[$module]->_submod[$submod]->_pages[$page]->_options['AJAX'] != true) { # get url $url = urlStrRedirect("{$module}/{$submod}/{$page}"); # stop foreach loops break 3; } } } } } } if (!isset($url)) { return "index.php?error=" . urlencode(_("You do not have required rights")); } return $url; }
$_SESSION['request'] = $request; print "<form method='POST' action='" . urlStr("base/computers/save", array('request' => 'stored_in_session', 'id' => $id, 'is_group' => $is_group, 'imaging_server' => $imaging_server)) . "' >" . "<td>" . _T('Name :', 'dyngroup') . " <input name='name' type='text' value=\"" . htmlspecialchars($name) . "\" /></td>"; if ($is_group) { print "<td>" . _T('save as', 'dyngroup') . " <select name='save_type'><option value='1' " . ($save_type == 1 ? 'selected' : '') . ">" . _T("query", "dyngroup") . "</option><option value='2' " . ($save_type == 2 ? 'selected' : '') . ">" . _T('result', 'dyngroup') . "</option></select></td>"; } else { print "<td><input name='save_type' type='hidden' value='2'/></td>"; } print "<td colspan='2'>" . _T("it should be", "dyngroup") . " <select name='visible'><option value='2' " . ($visible == 2 ? 'selected' : '') . ">" . _T("hidden", "dyngroup") . "</option><option value='1' " . ($visible == 1 ? 'selected' : '') . ">" . _T("visible", "dyngroup") . "</option></select></td>"; } if ($r->countPart() > 0) { drawBoolEquation($bool); } if (hasCorrectAcl("base", "computers", "tmpdisplay")) { drawTemporaryButton(); } if (hasCorrectAcl("base", "computers", "save")) { print "<td><input name='btnPrimary' value='" . _T('Save', 'dyngroup') . "' class='btnPrimary' type='submit'/></td>"; } print "</tr></form></table>"; if ($name_exists && !isset($_POST['displayTmp'])) { new NotifyWidgetFailure(sprintf(_T("A group already exists with name '%s'", "dyngroup"), $name)); } elseif ($name == '' && $check && $id) { new NotifyWidgetFailure(_T("You must specify a group name", "dyngroup")); } elseif (isset($_POST['btnPrimary']) && $check) { new NotifyWidgetFailure(_T("You must specify a group name", "dyngroup")); } } else { if ($id) { $group = getPGobject($id, true); $group->setVisibility($visible); $group->setName($name);
/** Lookup and load all MMC modules */ function autoInclude() { global $redirArray; global $redirAjaxArray; global $conf; global $filter; $modules = fetchModulesList($conf["global"]["rootfsmodules"]); includeInfoPackage($modules); includePublicFunc($modules); if (isset($_GET["module"])) { $__module = $_GET["module"]; } else { $__module = "default"; } if (isset($_GET["submod"])) { $__submod = $_GET["submod"]; } else { $__submod = "default"; } if (isset($_GET["action"])) { $__action = $_GET["action"]; } else { $__action = "default"; } /* Check filter info */ // we must be in a ajax call if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" and isset($_GET['filter'])) { // get the page who called us preg_match('/module=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches); if (isset($matches[1])) { $module = $matches[1]; } else { $module = "default"; } preg_match('/submod=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches); if (isset($matches[1])) { $submod = $matches[1]; } else { $submod = "default"; } preg_match('/action=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches); if (isset($matches[1])) { $action = $matches[1]; } else { $action = "default"; } preg_match('/tab=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches); if (isset($matches[1])) { $tab = $matches[1]; } else { $tab = "default"; } // extra arguments of the request so we don't cache filters for another // page $extra = ""; foreach ($_GET as $key => $value) { if (!in_array($key, array('module', 'submod', 'tab', 'action', 'filter', 'start', 'end', 'maxperpage'))) { $extra .= $key . "_" . $value; } } // store the filter if (isset($_GET['filter'])) { $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_filter_" . $extra] = $_GET['filter']; } // store pagination info if (isset($_GET['maxperpage'])) { $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_max_" . $extra] = $_GET['maxperpage']; } if (isset($_GET['start'])) { $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_start_" . $extra] = $_GET['start']; } if (isset($_GET['end'])) { $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_end_" . $extra] = $_GET['end']; } unset($module); unset($submod); unset($action); unset($tab); } /* Redirect user to a default page. */ if (!isset($redirArray[$__module][$__submod][$__action]) && !isset($redirAjaxArray[$__module][$__submod][$__action])) { header("Location: " . getDefaultPage()); exit; } if (!isNoHeader($__module, $__submod, $__action)) { require_once "graph/header.inc.php"; /* Include specific module CSS if there is one */ require "graph/dynamicCss.php"; } /* ACL check */ if (!hasCorrectAcl($__module, $__submod, $__action)) { header("Location: " . getDefaultPage()); exit; } /* Warn user once at login if her account is expired. */ if (in_array("ppolicy", $_SESSION["supportModList"])) { require_once "modules/ppolicy/default/warnuser.php"; } if (!empty($redirArray[$__module][$__submod][$__action])) { require $redirArray[$__module][$__submod][$__action]; } else { if (!empty($redirAjaxArray[$__module][$__submod][$__action])) { require $redirAjaxArray[$__module][$__submod][$__action]; } } require_once "includes/check_notify.inc.php"; if (!isNoHeader($__module, $__submod, $__action)) { require_once "graph/footer.inc.php"; } }