/** * Saves into the DB all the intrenal links between nodes. * Before adding the row to the DB, it maps the exported * id nodes to the imported ones. That's the reason why * this must be execute AFTER all nodes have been imported. * * @param int $courseNewID */ private function _saveLinks($courseNewID) { if (is_array($this->_linksArray)) { $this->_logMessage(__METHOD__ . ' Saving internal links for course'); foreach ($this->_linksArray as $num => $linkArray) { if (isset($this->_courseNodeIDMapping[$linkArray['id_nodo']]) && isset($this->_courseNodeIDMapping[$linkArray['id_nodo_to']])) { $linkArray['id_nodo'] = $this->_courseNodeIDMapping[$linkArray['id_nodo']]; $linkArray['id_nodo_to'] = $this->_courseNodeIDMapping[$linkArray['id_nodo_to']]; $res = $this->_dh->add_link($linkArray); if (!AMA_DB::isError($res)) { if (!isset($this->_recapArray[$courseNewID]['links'])) { $this->_recapArray[$courseNewID]['links'] = 1; } else { $this->_recapArray[$courseNewID]['links']++; } $this->_logMessage(__METHOD__ . ' link # ' . $num . ' successfully saved. id_nodo=' . $linkArray['id_nodo'] . ' id_nodo_to=' . $linkArray['id_nodo_to']); } else { $this->_logMessage(__METHOD__ . ' link # ' . $num . ' FAILED! id_nodo=' . $linkArray['id_nodo'] . ' id_nodo_to=' . $linkArray['id_nodo_to']); } } else { $this->_logMessage(__METHOD__ . ' could not find a match in the mapping array. id_nodo=' . $linkArray['id_nodo'] . ' id_nodo_to=' . $linkArray['id_nodo_to']); } } } else { $this->_logMessage(__METHOD__ . ' No links to be saved this time'); } $this->_linksArray = null; }