1<?php 2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5 * @author Nadia Matuschek <nmatuschek@databay.de> 6 * Class ilForumPostsTree 7 */ 8class ilForumPostsTree 9{ 10 private $thr_fk = 0; 11 private $pos_fk = 0; 12 private $parent_pos = 0; 13 private $lft = 0; 14 private $rgt = 0; 15 private $depth = 0; 16 17 private $source_thread_id = 0; 18 private $target_thread_id = 0; 19 20 private $db; 21 22 public function setDepth($depth) 23 { 24 $this->depth = $depth; 25 } 26 27 public function getDepth() 28 { 29 return $this->depth; 30 } 31 32 public function setLft($lft) 33 { 34 $this->lft = $lft; 35 } 36 37 public function getLft() 38 { 39 return $this->lft; 40 } 41 42 public function setParentPos($parent_pos) 43 { 44 $this->parent_pos = $parent_pos; 45 } 46 47 public function getParentPos() 48 { 49 return $this->parent_pos; 50 } 51 52 public function setPosFk($pos_fk) 53 { 54 $this->pos_fk = $pos_fk; 55 } 56 57 public function getPosFk() 58 { 59 return $this->pos_fk; 60 } 61 62 public function setRgt($rgt) 63 { 64 $this->rgt = $rgt; 65 } 66 67 public function getRgt() 68 { 69 return $this->rgt; 70 } 71 72 public function setThrFk($thr_fk) 73 { 74 $this->thr_fk = $thr_fk; 75 } 76 77 public function getThrFk() 78 { 79 return $this->thr_fk; 80 } 81 82 public function setSourceThreadId($source_thread_id) 83 { 84 $this->source_thread_id = $source_thread_id; 85 } 86 87 public function getSourceThreadId() 88 { 89 return $this->source_thread_id; 90 } 91 92 public function setTargetThreadId($target_thread_id) 93 { 94 $this->target_thread_id = $target_thread_id; 95 } 96 97 public function getTargetThreadId() 98 { 99 return $this->target_thread_id; 100 } 101 102 public function __construct() 103 { 104 global $DIC; 105 $this->db = $DIC->database(); 106 } 107 108 public function merge() 109 { 110 $this->db->update( 111 'frm_posts_tree', 112 [ 113 'lft' => array('integer', $this->getLft()), 114 'rgt' => array('integer', $this->getRgt()), 115 'depth' => array('integer', $this->getDepth()), 116 'thr_fk' => array('integer', $this->getTargetThreadId()), 117 'parent_pos' => array('integer', $this->getParentPos()), 118 ], 119 [ 120 'pos_fk' => array('integer', $this->getPosFk()), 121 'thr_fk' => array('integer', $this->getSourceThreadId()) 122 ] 123 ); 124 } 125 126 /*** 127 * @param integer $root_node_id 128 * @param integer $rgt 129 */ 130 public static function updateTargetRootRgt($root_node_id, $rgt) 131 { 132 global $DIC; 133 $ilDB = $DIC->database(); 134 135 $ilDB->update( 136 'frm_posts_tree', 137 array( 138 'rgt' => array('integer', $rgt)), 139 array( 140 'parent_pos' => array('integer', 0), 141 'pos_fk' => array('integer', $root_node_id) 142 ) 143 ); 144 } 145} 146