Skip to content

Commit

Permalink
Fixed cloning of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsMichelsen committed Jun 20, 2015
1 parent 7120b41 commit 55bad99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions share/server/core/classes/ViewMapAddModify.php
Expand Up @@ -190,7 +190,7 @@ private function handleAddModify() {
}

private function getAttr($default_value, $attr, $must, $only_inherited = false) {
$update = !is_action();
$update = !is_action() && is_update();
// update is true during view repaint
// only_inherited is true when only asking for inherited value
$val = '';
Expand All @@ -207,15 +207,15 @@ private function getAttr($default_value, $attr, $must, $only_inherited = false)
// the shown values
$val = $this->MAPCFG->getSourceParam($attr, true, true);

} elseif(($this->mode == 'view_params' || !$only_inherited) && $this->object_id !== null
} elseif(!$update && ($this->mode == 'view_params' || !$only_inherited) && $this->object_id !== null
&& $this->MAPCFG->getValue($this->object_id, $attr, true) !== false) {
// Get the value set in this object if there is some set
$val = $this->MAPCFG->getValue($this->object_id, $attr, true);
// In view_param mode this is inherited
if($this->mode == 'view_params')
$isInherited = true;

} elseif(!$only_inherited && $this->clone_id !== null && $attr !== 'object_id'
} elseif(!$update && !$only_inherited && $this->clone_id !== null && $attr !== 'object_id'
&& $this->MAPCFG->getValue($this->clone_id, $attr, true) !== false) {
// Get the value set in the object to be cloned if there is some set
// But don't try this when running in "update" mode
Expand Down Expand Up @@ -313,7 +313,7 @@ private function drawField($propname, $prop, $properties) {
// Add a checkbox to toggle the usage of an attribute. But only add it for
// non-must attributes.
if (!$prop['must'] && $fieldType != 'readonly') {
checkbox('toggle_'.$propname, $isInherited === false, '', 'toggle_option(\''.$propname.'\');');
checkbox('toggle_'.$propname, $isInherited === false, '', 'toggle_option(\''.$propname.'\');'.$onChange);
}

echo '</td><td class=tdfield>';
Expand Down
5 changes: 5 additions & 0 deletions share/server/core/functions/html.php
Expand Up @@ -92,6 +92,10 @@ function is_action() {
return (submitted() || (bool)get('_action')) && post('_update', '0') == '0';
}

function is_update() {
return post('_update', '0') == '1';
}

function js($code) {
echo '<script>'.$code.'</script>'.N;
}
Expand Down Expand Up @@ -134,6 +138,7 @@ function form_start($name, $target, $type = 'POST', $multipart = false) {
}

function form_end($keep_context=true) {
global $form_name;
if ($keep_context)
hidden_vars();
echo '</form>'.N;
Expand Down

0 comments on commit 55bad99

Please sign in to comment.