Exemplo n.º 1
0
 public function handleAction()
 {
     $sReturn = '';
     if ($this->offersAction($this->sAction)) {
         switch ($this->sAction) {
             case 'getOptions':
                 $CFG = new CoreUserCfg();
                 $sReturn = json_encode($CFG->doGet());
                 break;
             case 'setOption':
                 $this->handleResponse('handleResponseSet', 'doSet');
                 break;
         }
     }
     return $sReturn;
 }
Exemplo n.º 2
0
 /**
  * PRIVATE getMacros()
  *
  * Returns all macros for the header template
  *
  * @author	Lars Michelsen <*****@*****.**>
  */
 private function getMacros()
 {
     global $CORE, $AUTH, $AUTHORISATION, $UHANDLER;
     // First get all static macros
     $this->aMacros = $this->getStaticMacros();
     // Save the page
     $this->aMacros['mod'] = $UHANDLER->get('mod');
     $this->aMacros['act'] = $UHANDLER->get('act');
     // In rotation?
     $this->aMacros['bRotation'] = $this->bRotation;
     $this->aMacros['permittedOverview'] = $AUTHORISATION->isPermitted('Overview', 'view', '*');
     // Check if the user is permitted to edit the current map
     $this->aMacros['permittedView'] = $AUTHORISATION->isPermitted($this->aMacros['mod'], 'view', $UHANDLER->get('show'));
     $this->aMacros['permittedEdit'] = $AUTHORISATION->isPermitted($this->aMacros['mod'], 'edit', $UHANDLER->get('show'));
     // Permissions for the option menu
     $this->aMacros['permittedSearch'] = $AUTHORISATION->isPermitted('Search', 'view', '*');
     $this->aMacros['permittedEditMainCfg'] = $AUTHORISATION->isPermitted('MainCfg', 'edit', '*');
     $this->aMacros['permittedManageShapes'] = $AUTHORISATION->isPermitted('ManageShapes', 'manage', '*');
     $this->aMacros['permittedManageBackgrounds'] = $AUTHORISATION->isPermitted('ManageBackgrounds', 'manage', '*');
     $this->aMacros['permittedManageBackgrounds'] = $AUTHORISATION->isPermitted('ManageBackgrounds', 'manage', '*');
     $this->aMacros['permittedManageMaps'] = $AUTHORISATION->isPermitted('Map', 'add', '*') && $AUTHORISATION->isPermitted('Map', 'edit', '*');
     $this->aMacros['currentUser'] = $AUTH->getUser();
     $this->aMacros['permittedChangePassword'] = $AUTHORISATION->isPermitted('ChangePassword', 'change', '*');
     $this->aMacros['permittedLogout'] = $AUTH->logoutSupported() & $AUTHORISATION->isPermitted('Auth', 'logout', '*');
     // Replace some special macros for maps
     if ($this->OBJ !== null && $this->aMacros['mod'] == 'Map') {
         $this->aMacros['currentMap'] = $this->OBJ->getName();
         $this->aMacros['currentMapAlias'] = $this->OBJ->getValue(0, 'alias');
         $this->aMacros['usesSources'] = count($this->OBJ->getValue(0, 'sources')) > 0;
         $this->aMacros['zoombar'] = $this->OBJ->getValue(0, 'zoombar');
         $this->aMacros['canAddObjects'] = !in_array('automap', $this->OBJ->getValue(0, 'sources')) && !in_array('geomap', $this->OBJ->getValue(0, 'sources'));
         $this->aMacros['canEditObjects'] = !in_array('automap', $this->OBJ->getValue(0, 'sources'));
         $this->aMacros['canMoveObjects'] = !in_array('automap', $this->OBJ->getValue(0, 'sources')) && !in_array('geomap', $this->OBJ->getValue(0, 'sources'));
         $this->aMacros['isWorldmap'] = in_array('worldmap', $this->OBJ->getValue(0, 'sources'));
     } else {
         $this->aMacros['currentMap'] = '';
         $this->aMacros['currentMapAlias'] = '';
         $this->aMacros['usesSources'] = false;
         $this->aMacros['zoombar'] = false;
         $this->aMacros['canAddObjects'] = false;
         $this->aMacros['canEditObjects'] = false;
         $this->aMacros['canMoveObjects'] = false;
         $this->aMacros['isWorldmap'] = true;
     }
     // Add permitted rotations
     $this->aMacros['rotations'] = array();
     foreach ($CORE->getDefinedRotationPools() as $poolName) {
         if ($AUTHORISATION->isPermitted('Rotation', 'view', $poolName)) {
             $this->aMacros['rotations'][] = $poolName;
         }
     }
     list($this->aMacros['maps'], $this->aMacros['permittedEditAnyMap']) = $this->getMapList();
     $this->aMacros['langs'] = $this->getLangList();
     // Specific information for special templates
     if ($this->templateName == 'on-demand-filter') {
         global $_BACKEND;
         $this->aMacros['hostgroups'] = $_BACKEND->getBackend($_GET['backend_id'])->getObjects('hostgroup', '', '');
         usort($this->aMacros['hostgroups'], array($this, 'sortHostgroups'));
         array_unshift($this->aMacros['hostgroups'], array('name1' => '', 'name2' => ''));
         $default = '';
         $USERCFG = new CoreUserCfg();
         $cfg = $USERCFG->doGet();
         if (isset($cfg['params-']) && isset($cfg['params-']['filter_group'])) {
             $default = $cfg['params-']['filter_group'];
         }
         $this->aMacros['filter_group'] = isset($_GET['filter_group']) ? htmlspecialchars($_GET['filter_group']) : $default;
     }
     $this->aMacros['mapNames'] = json_encode($CORE->getListMaps());
 }