/** * This is a recursive function to copy the children from a parent. * * @todo shouldn't we recursively call copyDb here? instead of ourselves * * @param string $selector Selector * @param int $parent Parent ID * @param string $mode The mode we're in */ public function copyChildren($selector, $parent = '', $mode = 'copy') { $recordset = $this->select($selector)->mode($mode)->getAllRows(); if (count($recordset) > 0) { for ($i = 0; $i < count($recordset); ++$i) { $recordset[$i][$this->m_parent] = array('' => '', $this->m_primaryKey[0] => $parent); $oldrec = $recordset[$i]; parent::copyDb($recordset[$i], $mode); Tools::atkdebug('Child Record added'); $newparent = $recordset[$i][$this->m_primaryKey[0]]; Tools::atkdebug('CopyChildren(' . $this->m_parent . '=' . $oldrec[$this->m_primaryKey[0]] . ',' . $newparent . ')'); $this->copyChildren($this->m_table . '.' . $this->m_parent . '=' . $oldrec[$this->m_primaryKey[0]], $newparent); } } else { Tools::atkdebug("No records found with Selector: {$selector} - {$parent}"); } return ''; }