Ejemplo n.º 1
0
 /**
  * Save export id
  *
  * @param
  * @return
  */
 public static function saveExportId($a_lm_id, $a_lmobj_id, $a_exp_id, $a_type = "pg")
 {
     global $ilDB;
     include_once "Services/MetaData/classes/class.ilMDIdentifier.php";
     if (trim($a_exp_id) == "") {
         // delete export ids, if existing
         $entries = ilMDIdentifier::_getEntriesForObj($a_lm_id, $a_lmobj_id, $a_type);
         foreach ($entries as $id => $e) {
             if ($e["catalog"] == "ILIAS_NID") {
                 $identifier = new ilMDIdentifier();
                 $identifier->setMetaId($id);
                 $identifier->delete();
             }
         }
     } else {
         // update existing entry
         $entries = ilMDIdentifier::_getEntriesForObj($a_lm_id, $a_lmobj_id, $a_type);
         $updated = false;
         foreach ($entries as $id => $e) {
             if ($e["catalog"] == "ILIAS_NID") {
                 $identifier = new ilMDIdentifier();
                 $identifier->setMetaId($id);
                 $identifier->read();
                 $identifier->setEntry($a_exp_id);
                 $identifier->update();
                 $updated = true;
             }
         }
         // nothing updated? create a new one
         if (!$updated) {
             include_once "./Services/MetaData/classes/class.ilMD.php";
             $md = new ilMD($a_lm_id, $a_lmobj_id, $a_type);
             $md_gen = $md->getGeneral();
             $identifier = $md_gen->addIdentifier();
             $identifier->setEntry($a_exp_id);
             $identifier->setCatalog("ILIAS_NID");
             $identifier->save();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * test Identifier
  * @group IL_Init
  * @return
  */
 public function testIdentifier()
 {
     include_once './Services/MetaData/classes/class.ilMDIdentifier.php';
     include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
     $con = new ilMDIdentifier(1, 2, 'xxx');
     $con->setCatalog('Easy');
     $ret = $con->save();
     $this->assertGreaterThan(0, $ret);
     $con->setCatalog('Medium');
     $con->update();
     $con->read();
     $desc = $con->getCatalog();
     $this->assertEquals('Medium', $desc);
     $con->delete();
 }