/** * Recover a corrupted tree * * The mode parameter is used to specify the source of info that is valid/correct. The opposite source of data * will be populated based upon that source of info. E.g. if the MPTT fields are corrupt or empty, with the $mode * 'parent' the values of the parent_id field will be used to populate the left and right fields. The missingParentAction * parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present. * * @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB. * @param AppModel $Model Model instance * @param string $mode parent or tree * @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to * delete, or the id of the parent to set as the parent_id * @param string $scope The scopeField to select which tree to recover * @return boolean true on success, false on failure * @access public * @link http://book.cakephp.org/view/1628/Recover */ public function recover($Model, $mode = 'parent', $missingParentAction = null, $scope = null) { if ($this->scoped($Model)) { if (empty($scope)) { return false; } $this->__setScope($Model, $scope); } return parent::recover($Model, $mode, $missingParentAction); }