protected function doModifyObject($a) { $MAPCFG = new GlobalMapCfg($a['map']); try { $MAPCFG->readMapConfig(); } catch (MapCfgInvalid $e) { } // Give the sources the chance to load the object $MAPCFG->handleSources('load_obj', $a['id']); if (!$MAPCFG->objExists($a['id'])) { throw new NagVisException(l('The object does not exist.')); } // set options in the array foreach ($a['opts'] as $key => $val) { $MAPCFG->setValue($a['id'], $key, $val); } // write element to file $MAPCFG->storeUpdateElement($a['id']); // delete map lock if (!$MAPCFG->deleteMapLock()) { throw new NagVisException(l('mapLockNotDeleted')); } return json_encode(array('status' => 'OK', 'message' => '')); }
private function doRename($name, $new_name) { global $CORE, $AUTHORISATION; $files = array(); // loop all map configs to replace mapname in all map configs foreach ($CORE->getAvailableMaps() as $mapName) { try { $MAPCFG1 = new GlobalMapCfg($mapName); $MAPCFG1->readMapConfig(); $i = 0; // loop definitions of type map foreach ($MAPCFG1->getDefinitions('map') as $key => $obj) { // check if old map name is linked... if ($obj['map_name'] == $name) { $MAPCFG1->setValue('map', $i, 'map_name', $new_name); $MAPCFG1->writeElement('map', $i); } $i++; } } catch (Exception $e) { // Do nothing. Siletly pass config errors here... } } // And also remove the permission $AUTHORISATION->renameMapPermissions($name, $new_name); // rename config file rename(cfg('paths', 'mapcfg') . $name . '.cfg', cfg('paths', 'mapcfg') . $new_name . '.cfg'); }