From: <sy...@us...> - 2007-09-05 17:49:42
|
Update of /cvsroot/tikiwiki/tiki/lib/structures In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1894/lib/structures Modified Files: structlib.php Log Message: [MOD]structure: be able to move a sub-structure to another structure Index: structlib.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/structures/structlib.php,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- structlib.php 16 Jun 2007 16:01:54 -0000 1.87 +++ structlib.php 5 Sep 2007 17:49:44 -0000 1.88 @@ -881,6 +881,23 @@ } return $pages; } + 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 `parent_id`=?, `pos`=? where `page_ref_id`=?"; + $this->query($query, array($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 `parent_id`=?, `pos`=? where `page_ref_id`=?"; + $this->query($query, array($structure_id, $pos+1, $page_ref_id)); + } + } } global $dbTiki; $structlib = new StructLib($dbTiki); |