/**
  * Copy a term to a glossary
  *
  * @param
  * @return
  */
 function _copyTerm($a_term_id, $a_glossary_id)
 {
     $old_term = new ilGlossaryTerm($a_term_id);
     // copy the term
     $new_term = new ilGlossaryTerm();
     $new_term->setTerm($old_term->getTerm());
     $new_term->setLanguage($old_term->getLanguage());
     $new_term->setGlossaryId($a_glossary_id);
     $new_term->create();
     // copy the definitions
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id);
     foreach ($def_list as $def) {
         $old_def = new ilGlossaryDefinition($def["id"]);
         $new_def = new ilGlossaryDefinition();
         $new_def->setShortText($old_def->getShortText());
         $new_def->setNr($old_def->getNr());
         $new_def->setTermId($new_term->getId());
         $new_def->create();
         // copy meta data
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($old_term->getGlossaryId(), $old_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         $new_md = $md->cloneMD($a_glossary_id, $new_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         // page content
         $new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true));
         $new_def->getPageObject()->buildDom();
         $new_def->getPageObject()->update();
     }
     return $new_term->getId();
 }
 /**
  * add definition
  */
 function addDefinition()
 {
     global $ilCtrl;
     $term_id = (int) $_GET["term_id"];
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
     if ($term_glo_id != $this->object->getId()) {
         ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
         $ilCtrl->redirect($this, "listTerms");
     }
     // add term
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     $term = new ilGlossaryTerm($term_id);
     // add first definition
     $def = new ilGlossaryDefinition();
     $def->setTermId($term->getId());
     $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
     $def->create();
     $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
     $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
     $this->ctrl->redirectByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
 }