private function parseMapJson($objectId, $mapName, $what) { global $AUTHORISATION; // Check if the user is permitted to view this if (!$AUTHORISATION->isPermitted('Map', 'view', $mapName)) { return null; } // If the parameter filterUser is set, filter the maps by the username // given in this parameter. This is a mechanism to be authed as generic // user but see the maps of another user. This feature is disabled by // default but could be enabled if you need it. if (cfg('global', 'user_filtering') && isset($_GET['filterUser']) && $_GET['filterUser'] != '') { $AUTHORISATION2 = new CoreAuthorisationHandler(); $AUTHORISATION2->parsePermissions($_GET['filterUser']); if (!$AUTHORISATION2->isPermitted('Map', 'view', $mapName)) { return null; } // Switch the auth cookie to this user global $SHANDLER; $SHANDLER->aquire(); $SHANDLER->set('authCredentials', array('user' => $_GET['filterUser'], 'password' => '')); $SHANDLER->set('authTrusted', true); $SHANDLER->commit(); } $map = array('object_id' => $objectId); $MAPCFG = new GlobalMapCfg($mapName); $MAPCFG->checkMapConfigExists(true); $MAPCFG->readMapConfig(); // Only perform this check with a valid config if ($MAPCFG->getValue(0, 'show_in_lists') != 1) { return null; } $MAP = new NagVisMap($MAPCFG, GET_STATE, !IS_VIEW); // Apply overview related configuration to object $MAP->MAPOBJ->setConfiguration($this->getMapDefaultOpts($mapName, $MAPCFG->getAlias())); if ($MAP->MAPOBJ->checkMaintenance(0)) { $map['overview_url'] = $this->htmlBase . '/index.php?mod=Map&act=view&show=' . $mapName; $map['overview_class'] = ''; } else { $map['overview_class'] = 'disabled'; $map['overview_url'] = 'javascript:alert(\'' . l('The map is in maintenance mode. Please be patient.') . '\');'; $map['summary_output'] = l('The map is in maintenance mode. Please be patient.'); $MAP->MAPOBJ->clearMembers(); $MAP->MAPOBJ->setSummaryState('UNKNOWN'); $MAP->MAPOBJ->fetchIcon(); } if (cfg('index', 'showmapthumbs') == 1) { $map['overview_image'] = $this->renderMapThumb($MAPCFG); } return array($MAP->MAPOBJ, $map); }
public function getListMaps() { $list = array(); $maps = $this->getPermittedMaps(); foreach ($maps as $mapName) { $MAPCFG = new GlobalMapCfg($mapName); $MAPCFG->checkMapConfigExists(true); try { $MAPCFG->readMapConfig(ONLY_GLOBAL); } catch (MapCfgInvalid $e) { continue; // skip configs with broken global sections } catch (NagVisException $e) { continue; // skip e.g. not read config files } if ($MAPCFG->getValue(0, 'show_in_lists') == 1) { $list[$mapName] = $MAPCFG->getAlias(); } } natcasesort($list); return array_keys($list); }