diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2012-12-15 14:10:04 -0500 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2012-12-15 14:10:04 -0500 |
commit | 4d360c11d14768c8a0229b8b2b1f02622f17c48a (patch) | |
tree | ae7f01685a08c16a49b551925631c7401dbb79d0 /mod/pages/actions | |
parent | cd3839cfec814c191ff664faeaf9e9360118d6bf (diff) | |
parent | 21eb7616a11906a19260a081070a6b1c51820fa3 (diff) | |
download | elgg-4d360c11d14768c8a0229b8b2b1f02622f17c48a.tar.gz elgg-4d360c11d14768c8a0229b8b2b1f02622f17c48a.tar.bz2 |
Merge branch 'pr-316' into 1.8
Diffstat (limited to 'mod/pages/actions')
-rw-r--r-- | mod/pages/actions/pages/edit.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php index fe5754d76..29fbf022b 100644 --- a/mod/pages/actions/pages/edit.php +++ b/mod/pages/actions/pages/edit.php @@ -60,6 +60,9 @@ if (sizeof($input) > 0) { if (($name == 'access_id' || $name == 'write_access_id') && !$can_change_access) { continue; } + if ($name == 'parent_guid') { + continue; + } $page->$name = $value; } @@ -68,7 +71,27 @@ if (sizeof($input) > 0) { // need to add check to make sure user can write to container $page->container_guid = $container_guid; -if ($parent_guid) { +if ($parent_guid && $parent_guid != $page_guid) { + // Check if parent isn't below of the page in the tree + if ($page_guid) { + $tree_page = get_entity($parent_guid); + while ($tree_page->parent_guid > 0 && $page_guid != $tree_page->guid) { + $tree_page = get_entity($tree_page->parent_guid); + } + // If is below, bring all child elements forward + if ($page_guid == $tree_page->guid) { + $previous_parent = $page->parent_guid; + $children = elgg_get_entities_from_metadata(array( + 'metadata_name' => 'parent_guid', + 'metadata_value' => $page->getGUID() + )); + if ($children) { + foreach ($children as $child) { + $child->parent_guid = $previous_parent; + } + } + } + } $page->parent_guid = $parent_guid; } |