private function handleAddModify() { $perm = get_checkbox('perm'); $perm_user = get_checkbox('perm_user'); $show_dialog = false; // Modification/Creation? // The object_id is known on modification. When it is not known 'type' is set // to create new objects if ($this->object_id !== null) { // The handler has been called in "view_params" mode. In this case the user has // less options and the options to // 1. modify these parameters only for the current open view // 2. Save the changes for himselfs // 3. Save the changes to the map config (-> Use default code below) if ($this->mode == 'view_params' && !$perm && !$perm_user) { // This is the 1. case -> redirect the user to a well formated url $attrs = array_merge($this->attrs, $this->attrs_filtered); unset($attrs['object_id']); js('document.getElementById("_submit").disabled = true;' . 'window.location.href = makeuri(' . json_encode($attrs) . ');'); $show_dialog = true; } elseif ($this->mode == 'view_params' && !$perm && $perm_user) { // This is the 2. case -> saving the options only for the user $USERCFG = new CoreUserCfg(); $attrs = $this->attrs; unset($attrs['object_id']); $USERCFG->doSet(array('params-' . $this->MAPCFG->getName() => $attrs)); scroll_up(); // On success, always scroll to top of page success(l('Personal settings saved.')); js('document.getElementById("_submit").disabled = true;' . 'window.setTimeout(function() { window.location.reload(); }, 2000);'); $show_dialog = true; } else { if (!$this->MAPCFG->objExists($this->object_id)) { throw new NagVisException(l('The object does not exist.')); } $this->validateAttributes(); // Update the map configuration if ($this->mode == 'view_params') { // Only modify/add the given attributes. Don't remove any // set options in the array foreach ($this->attrs as $key => $val) { $this->MAPCFG->setValue($this->object_id, $key, $val); } $this->MAPCFG->storeUpdateElement($this->object_id); } else { // add/modify case: Rewrite whole object with the given attributes $this->MAPCFG->updateElement($this->object_id, $this->attrs, true); } $t = $this->object_type == 'global' ? l('map configuration') : $this->object_type; $result = array(2, null, l('The [TYPE] has been modified. Reloading in 2 seconds.', array('TYPE' => $t))); js('popupWindowClose();' . 'refreshMapObject(null, "' . $this->object_id . '", false);'); } } else { // Create the new object $this->validateAttributes(); // append a new object definition to the map configuration $obj_id = $this->MAPCFG->addElement($this->object_type, $this->attrs, true); js('popupWindowClose();' . 'refreshMapObject(null, "' . $obj_id . '", false);'); } // delete map lock if (!$this->MAPCFG->deleteMapLock()) { throw new NagVisException(l('mapLockNotDeleted')); } return $show_dialog; }
protected function doSet($a) { $CFG = new CoreUserCfg(); return $CFG->doSet($a['opts']); }