function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping) { include_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDParser.php"; include_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php"; $parser = new ilAdvancedMDParser($a_id, $a_mapping); $parser->setXMLContent($a_xml); $parser->startParsing(); // select records for object foreach ($parser->getRecordIds() as $obj_id => $sub_types) { // currently only supported for wikis and glossary if (!in_array(ilObject::_lookupType($obj_id), array("glo", "wiki"))) { continue; } foreach ($sub_types as $sub_type => $rec_ids) { ilAdvancedMDRecord::saveObjRecSelection($obj_id, $sub_type, array_unique($rec_ids), false); } } }
public function update() { global $ilDB; parent::update(); $sql = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE orgu_id = ' . $ilDB->quote($this->getId(), 'integer'); $set = $ilDB->query($sql); if ($ilDB->numRows($set)) { $ilDB->update(self::TABLE_NAME, array('orgu_type_id' => array('integer', $this->getOrgUnitTypeId())), array('orgu_id' => array('integer', $this->getId()))); } else { $ilDB->insert(self::TABLE_NAME, array('orgu_type_id' => array('integer', $this->getOrgUnitTypeId()), 'orgu_id' => array('integer', $this->getId()))); } // Update selection for advanced meta data of the type if ($this->getOrgUnitTypeId()) { ilAdvancedMDRecord::saveObjRecSelection($this->getId(), 'orgu_type', $this->getOrgUnitType()->getAssignedAdvancedMDRecordIds()); } else { // If no type is assigned, delete relations by passing an empty array ilAdvancedMDRecord::saveObjRecSelection($this->getId(), 'orgu_type', array()); } }
/** * Save selection per object * * @param * @return */ function saveSelection() { $sel = ilUtil::stripSlashesArray($_POST["amet_use_rec"]); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $this->sub_type, $sel); }
/** * Deassign a given AdvancedMD record from this type. * * @param int $a_record_id * * @throws ilOrgUnitTypePluginException */ public function deassignAdvancedMdRecord($a_record_id) { $record_ids = $this->getAssignedAdvancedMDRecordIds(); $key = array_search($a_record_id, $record_ids); if ($key !== false) { /** @var ilOrgUnitTypeHookPlugin $plugin */ $disallowed = array(); $titles = array(); foreach ($this->getActivePlugins() as $plugin) { if (!$plugin->allowDeassignAdvancedMDRecord($this->getId(), $a_record_id)) { $disallowed[] = $plugin; $titles[] = $plugin->getPluginName(); } } if (count($disallowed)) { $msg = sprintf($this->lng->txt('orgu_type_msg_deassign_amd_prevented'), implode(', ', $titles)); throw new ilOrgUnitTypePluginException($msg, $disallowed); } unset($record_ids[$key]); $sql = 'DELETE FROM orgu_types_adv_md_rec WHERE type_id = ' . $this->db->quote($this->getId(), 'integer') . ' AND rec_id = ' . $this->db->quote($a_record_id, 'integer'); $this->db->query($sql); // We need to update each OrgUnit from this type and map the selected records to object_id foreach ($this->getOrgUnitIds() as $orgu_id) { ilAdvancedMDRecord::saveObjRecSelection($orgu_id, 'orgu_type', $record_ids); } $this->amd_records_assigned = NULL; // Force reload of assigned objects } }