/**
* Get the child nodes of the current model
*
* If the direct parameter is set to true, only the direct children are returned (based upon the parent_id field)
* If false is passed for the id parameter, top level, or all (depending on direct parameter appropriate) are counted.
*
* Scoped behavior:
*
* If the model is scoped and the id parameter is given it will automatically set the scope. For no id parameter
* you will have to pass the scope.
*
* Example: array('scope' => 5) or array('id' => false, 'scope' => 5)
*
* @param AppModel $Model Model instance
* @param mixed $id The ID of the record to read
* @param boolean $direct whether to return only the direct, or all, children
* @param mixed $fields Either a single string of a field name, or an array of field names
* @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") defaults to the tree order
* @param integer $limit SQL LIMIT clause, for calculating items per page.
* @param integer $page Page number, for accessing paged data
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of child nodes
* @access public
* @link http://book.cakephp.org/view/1346/Children
*/
public function children($Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null)
{
if ($this->scoped($Model)) {
if (empty($id)) {
return false;
}
$id = $this->__setScopeFromId($Model, $id);
}
return parent::children($Model, $id, $direct, $fields, $order, $limit, $page, $recursive);
}