function postSave() { $this->StartTransaction(); $this->getFastTreeObject()->setTree($this->getCompany()); if ($this->getDeleted() == TRUE) { //FIXME: Get parent of this object, and re-parent all groups to it. $parent_id = $this->getFastTreeObject()->getParentId($this->getId()); //Get items by group id. $ulf = new UserListFactory(); $ulf->getByCompanyIdAndGroupId($this->getCompany(), $this->getId()); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $obj) { Debug::Text(' Re-Grouping Item: ' . $obj->getId(), __FILE__, __LINE__, __METHOD__, 10); $obj->setGroup($parent_id); $obj->Save(); } } $this->getFastTreeObject()->delete($this->getId()); $this->CommitTransaction(); return TRUE; } else { $retval = TRUE; //if ( $this->getId() === FALSE ) { if ($this->insert_tree === TRUE) { Debug::Text(' Adding Node ', __FILE__, __LINE__, __METHOD__, 10); //echo "Current ID: ". $this->getID() ."<br>\n"; //echo "Parent ID: ". $this->getParent() ."<br>\n"; //Add node to tree if ($this->getFastTreeObject()->add($this->getID(), $this->getParent()) === FALSE) { Debug::Text(' Failed adding Node ', __FILE__, __LINE__, __METHOD__, 10); $this->Validator->isTrue('name', FALSE, TTi18n::gettext('Name is already in use')); $retval = FALSE; } } else { Debug::Text(' Editing Node ', __FILE__, __LINE__, __METHOD__, 10); //Edit node. $retval = $this->getFastTreeObject()->move($this->getID(), $this->getParent()); } if ($retval === TRUE) { $this->CommitTransaction(); } else { $this->FailTransaction(); } return $retval; } }