Moving a node in structure to another structure does not change structure ID of the moved node's children.
- Status
- Open
- Subject
- Moving a node in structure to another structure does not change structure ID of the moved node's children.
- Version
- 16.x
- Category
- Release Blocker
- Feature
- Wiki Structure (book & table of content)
- Resolution status
- New
- Submitted by
- flamenco
- Lastmod by
- flamenco
- Rating
- Description
The method
Copy to clipboardpublic function move_to_structure($page_ref_id, $structure_id, $begin=true)changes the moved node's structure_id, but not the children's structure_id. The target structure will still show the children, but will not allow them to be moved. (Pressing save will have no effect, basically causing a read-only structure, with no warnings or errors ouptut)
Here's your fix:Copy to clipboardpublic function move_to_structure($page_ref_id, $structure_id, $begin=true) { $page_info = $this->s_get_page_info($page_ref_id); $query = "update `tiki_structures` set `pos`=`pos`-1 where `pos`>? and `parent_id`=?"; $this->query($query, array((int) $page_info["pos"], (int) $page_info["parent_id"])); if ($begin) { $query = "update `tiki_structures` set `pos`=`pos`+1 where `parent_id`=?"; $this->query($query, array($structure_id)); $pos = 1; $query = "update `tiki_structures` set `structure_id`=?, `parent_id`=?, `pos`=? where `page_ref_id`=?"; $this->query($query, array($structure_id, $structure_id, $pos+1, $page_ref_id)); } else { $query = "select max(`pos`) from `tiki_structures` where `parent_id`=?"; $pos = $this->getOne($query, array($structure_id)); $query = "update `tiki_structures` set `structure_id`=?, `parent_id`=?, `pos`=? where `page_ref_id`=?"; $this->query($query, array($structure_id, $structure_id, $pos+1, $page_ref_id)); } // get the page_ref_ids of all child pages of the moved page $child_ref_ids = array(); $result = $this->query("select child.page_ref_id from tiki_structures p inner join tiki_structures child on child.parent_id = p.page_ref_id where p.page_ref_id=" . $page_ref_id); while ($row = $result->fetchRow()){ array_push($child_ref_ids, $row['page_ref_id']); } // update the structure ids of the child pages $this->query("update tiki_structures set structure_id=" . $structure_id . " where page_ref_id in (" . implode(',',$child_ref_ids) . ")"); }- Files
- Importance
- 10 high
- Easy to solve?
- 5
- Priority
- 50
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 6047
- Created
- Sunday 24 July, 2016 13:24:44 UTC
by flamenco - LastModif
- Saturday 06 July, 2024 10:21:44 UTC