Loading...
 
Skip to main content

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
(0)
Description

The method

Copy to clipboard
public 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 clipboard
public 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
  1. Screen Shot 2016 07 24 At 10.14.41 AM
Importance
10 high
Easy to solve?
5
Priority
50
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
6047
Created
Sunday 24 July, 2016 13:24:44 UTC
by flamenco
LastModif
Saturday 06 July, 2024 10:21:44 UTC


Show PHP error messages