/**
  * Get xml representation
  *
  * @param	string		entity
  * @param	string		schema version
  * @param	string		id
  * @return	string		xml string
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $parts = explode(":", $a_id);
     if (sizeof($parts) != 2) {
         return;
     }
     $obj_id = $parts[0];
     $rec_id = $parts[1];
     // any data for current record and object?
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $raw = ilAdvancedMDValues::findByObjectId($obj_id);
     if (!$raw) {
         return;
     }
     // gather sub-item data from value entries
     $sub_items = array();
     foreach ($raw as $item) {
         $sub_items[$item["sub_type"]][] = $item["sub_id"];
     }
     // gather all relevant data
     $items = array();
     foreach ($sub_items as $sub_type => $sub_ids) {
         foreach (array_unique($sub_ids) as $sub_id) {
             $values_record = new ilAdvancedMDValues($rec_id, $obj_id, $sub_type, $sub_id);
             $defs = $values_record->getDefinitions();
             $values_record->read();
             foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
                 if (!$element->isNull()) {
                     $def = $defs[$element_id];
                     $items[$rec_id][] = array('id' => $def->getImportId(), 'sub_type' => $sub_type, 'sub_id' => $sub_id, 'value' => $def->getValueForXML($element));
                 }
             }
         }
     }
     // we only want non-empty fields
     if (sizeof($items)) {
         $xml = new ilXmlWriter();
         foreach ($items as $record_id => $record_items) {
             // no need to state record id here
             $xml->xmlStartTag('AdvancedMetaData');
             foreach ($record_items as $item) {
                 $xml->xmlElement('Value', array('id' => $item['id'], 'sub_type' => $item['sub_type'], 'sub_id' => $item['sub_id']), $item['value']);
             }
             $xml->xmlEndTag('AdvancedMetaData');
         }
         return $xml->xmlDumpMem(false);
     }
 }
 public function preload()
 {
     global $objDefinition, $tree, $ilObjDataCache, $ilUser, $rbacsystem;
     if (!$this->obj_ids) {
         return;
     }
     $this->obj_ids = array_unique($this->obj_ids);
     $this->types = array_unique($this->types);
     if ($this->ref_ids) {
         $this->ref_ids = array_unique($this->ref_ids);
     }
     // type specific preloads
     include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
     foreach ($this->types as $type) {
         $this->obj_ids_by_type[$type] = array_unique($this->obj_ids_by_type[$type]);
         if (is_array($this->ref_ids_by_type[$type])) {
             $this->ref_ids_by_type[$type] = array_unique($this->ref_ids_by_type[$type]);
         }
         if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY || $this->context == ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP || $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
             ilConditionHandler::preloadConditionsForTargetRecords($type, $this->obj_ids_by_type[$type]);
         }
         $class = $objDefinition->getClassName($type);
         $location = $objDefinition->getLocation($type);
         if ($class && $location) {
             $full_class = "ilObj" . $class . "Access";
             include_once $location . "/class." . $full_class . ".php";
             if (class_exists($full_class)) {
                 call_user_func(array($full_class, "_preloadData"), $this->obj_ids_by_type[$type], $this->ref_ids_by_type[$type]);
             }
         }
     }
     if ($this->ref_ids) {
         $tree->preloadDeleted($this->ref_ids);
         $tree->preloadDepthParent($this->ref_ids);
         $ilObjDataCache->preloadReferenceCache($this->ref_ids, false);
         $rbacsystem->preloadRbacPaCache($this->ref_ids, $ilUser->getId());
         if ($ilUser->getId != ANONYMOUS_USER_ID && $this->context != ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP) {
             ilObjUser::preloadIsDesktopItem($ilUser->getId(), $this->ref_ids);
         }
         include_once "./Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::preloadData($this->ref_ids);
     }
     include_once "./Services/Object/classes/class.ilObjectListGUI.php";
     ilObjectListGUI::preloadCommonProperties($this->obj_ids, $this->context);
     if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY) {
         include_once "./Services/Rating/classes/class.ilRating.php";
         include_once "./Services/Rating/classes/class.ilRatingGUI.php";
         ilRating::preloadListGUIData($this->obj_ids);
         include_once "./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
         ilAdvancedMDValues::preloadByObjIds($this->obj_ids);
     }
     if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY || $this->context == ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP || $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
         include_once "./Services/Tracking/classes/class.ilLPStatus.php";
         ilLPStatus::preloadListGUIData($this->obj_ids);
     }
 }
 private function parseInfoPage()
 {
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
     include_once 'Services/ADT/classes/class.ilADTFactory.php';
     foreach (ilAdvancedMDValues::getInstancesForObjectId($this->obj_id, $this->obj_type) as $record_id => $a_values) {
         // this correctly binds group and definitions
         $a_values->read();
         $this->info->addSection(ilAdvancedMDRecord::_lookupTitle($record_id));
         $defs = $a_values->getDefinitions();
         foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
             if (!$element->isNull()) {
                 $this->info->addProperty($defs[$element_id]->getTitle(), ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getHTML());
             }
         }
     }
 }
Пример #4
0
 /**
  * Build advanced meta data
  *
  * @access private
  * 
  */
 private function __buildAdvancedMetaData()
 {
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     ilAdvancedMDValues::_appendXMLByObjId($this, $this->course_obj->getId());
 }
Пример #5
0
 /**
  * Get all terms for given set of glossary ids.
  * 
  * @param 	integer/array	array of glossary ids for meta glossaries
  * @param	string			searchstring
  * @param	string			first letter
  * @return	array			array of terms 
  */
 static function getTermList($a_glo_id, $searchterm = "", $a_first_letter = "", $a_def = "", $a_tax_node = 0, $a_add_amet_fields = false, $a_amet_filter = "")
 {
     global $ilDB;
     $terms = array();
     // get all term ids under taxonomy node (if given)
     if ($a_tax_node > 1) {
         include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
         $tax_ids = ilObjTaxonomy::getUsageOfObject($a_glo_id);
         if (count($tax_ids) > 0) {
             $items = ilObjTaxonomy::getSubTreeItems("glo", $a_glo_id, "term", $tax_ids[0], $a_tax_node);
             $sub_tree_ids = array();
             foreach ($items as $i) {
                 $sub_tree_ids[] = $i["item_id"];
             }
             $in = " AND " . $ilDB->in("gt.id", $sub_tree_ids, false, "integer");
         }
     }
     if ($a_def != "") {
         $join = " JOIN glossary_definition gd ON (gd.term_id = gt.id)" . " JOIN page_object ON (" . "page_object.parent_id = " . $ilDB->quote($a_glo_id, "integer") . " AND page_object.parent_type = " . $ilDB->quote("gdf", "text") . " AND page_object.page_id = gd.id" . " AND " . $ilDB->like("page_object.content", "text", "%" . $a_def . "%") . ")";
     }
     $searchterm = !empty($searchterm) ? " AND " . $ilDB->like("term", "text", "%" . $searchterm . "%") . " " : "";
     if ($a_first_letter != "") {
         $searchterm .= " AND " . $ilDB->upper($ilDB->substr("term", 1, 1)) . " = " . $ilDB->upper($ilDB->quote($a_first_letter, "text")) . " ";
     }
     // meta glossary
     if (is_array($a_glo_id)) {
         $where = $ilDB->in("glo_id", $a_glo_id, false, "integer");
     } else {
         $where = " glo_id = " . $ilDB->quote($a_glo_id, "integer") . " ";
     }
     $where .= $in;
     $q = "SELECT gt.term, gt.id, gt.glo_id, gt.language FROM glossary_term gt " . $join . " WHERE " . $where . $searchterm . " ORDER BY term";
     $term_set = $ilDB->query($q);
     //var_dump($q);
     while ($term_rec = $ilDB->fetchAssoc($term_set)) {
         $terms[] = array("term" => $term_rec["term"], "language" => $term_rec["language"], "id" => $term_rec["id"], "glo_id" => $term_rec["glo_id"]);
     }
     // add advanced metadata
     if ($a_add_amet_fields || is_array($a_amet_filter)) {
         include_once "./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
         $terms = ilAdvancedMDValues::queryForRecords($a_glo_id, "term", $terms, "glo_id", "id", $a_amet_filter);
     }
     return $terms;
 }
 /**
  * Start element handler
  *
  * @access public
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  * @param	array		$a_attribs			element attributes array
  * 
  */
 public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
 {
     switch ($a_name) {
         case 'AdvancedMetaData':
             $this->values_records = ilAdvancedMDValues::getInstancesForObjectId($this->obj_id);
             foreach ($this->values_records as $values_record) {
                 // init ADTGroup before definitions to bind definitions to group
                 $values_record->getADTGroup();
                 foreach ($values_record->getDefinitions() as $def) {
                     $this->values[$def->getImportId()] = $def;
                 }
             }
             break;
         case 'Value':
             $this->initValue($a_attribs['id']);
             break;
     }
 }
 /**
  * export released
  *
  * @access protected
  * @return
  */
 protected function exportReleased()
 {
     global $ilObjDataCache;
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     $exported = ilECSExport::getExportedIds();
     $ilObjDataCache->preloadObjectCache($exported);
     include_once 'Services/Utilities/classes/class.ilCSVWriter.php';
     $writer = new ilCSVWriter();
     $writer->addColumn($this->lng->txt('title'));
     $writer->addColumn($this->lng->txt('description'));
     $writer->addColumn($this->lng->txt('ecs_field_courseID'));
     $writer->addColumn($this->lng->txt('ecs_field_term'));
     $writer->addColumn($this->lng->txt('ecs_field_lecturer'));
     $writer->addColumn($this->lng->txt('ecs_field_courseType'));
     $writer->addColumn($this->lng->txt('ecs_field_semester_hours'));
     $writer->addColumn($this->lng->txt('ecs_field_credits'));
     $writer->addColumn($this->lng->txt('ecs_field_room'));
     $writer->addColumn($this->lng->txt('ecs_field_cycle'));
     $writer->addColumn($this->lng->txt('ecs_field_begin'));
     $writer->addColumn($this->lng->txt('ecs_field_end'));
     $writer->addColumn($this->lng->txt('last_update'));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::_getInstance();
     foreach ($exported as $obj_id) {
         include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
         $values = ilAdvancedMDValues::_getValuesByObjId($obj_id);
         $writer->addRow();
         $writer->addColumn(ilObject::_lookupTitle($obj_id));
         $writer->addColumn(ilObject::_lookupDescription($obj_id));
         $field = $settings->getMappingByECSName('courseID');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('term');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('lecturer');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('courseType');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('semester_hours');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('credits');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('room');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('cycle');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('begin');
         $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : '');
         $field = $settings->getMappingByECSName('end');
         $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : '');
         $writer->addColumn($ilObjDataCache->lookupLastUpdate($obj_id));
     }
     ilUtil::deliverData($writer->getCSVString(), date("Y_m_d") . "_ecs_export.csv", "text/csv");
 }
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  */
 protected function addMetadataToJson(&$a_json, ilECSSetting $a_server, array $a_definition)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     $values = ilAdvancedMDValues::_getValuesByObjId($this->content_obj->getId());
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
             $value = isset($values[$field]) ? $values[$field] : '';
             switch ($type) {
                 case ilECSUtils::TYPE_ARRAY:
                     $a_json->{$target} = explode(',', $value);
                     break;
                 case ilECSUtils::TYPE_INT:
                     $a_json->{$target} = (int) $value;
                     break;
                 case ilECSUtils::TYPE_STRING:
                     $a_json->{$target} = (string) $value;
                     break;
                 case ilECSUtils::TYPE_TIMEPLACE:
                     if (!isset($a_json->{$target})) {
                         include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                         $a_json->{$target} = new ilECSTimePlace();
                     }
                     $a_json->{$target}->{'set' . ucfirst($id)}($value);
                     break;
             }
         }
     }
 }
 /**
  * Substitute
  *
  * @access public
  * @param int ref_id
  * @param int obj_id
  * @param string description
  * 
  */
 public function getParsedSubstitutions($a_ref_id, $a_obj_id)
 {
     if (!count($this->getSubstitutions())) {
         return array();
     }
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($a_obj_id);
     $counter = 0;
     foreach ($this->getSubstitutions() as $field_id) {
         if (!isset($this->active_fields[$field_id])) {
             continue;
         }
         if (!isset($values[$field_id]) or !$values[$field_id]) {
             if ($this->hasNewline($field_id) and $counter) {
                 $substituted[$counter - 1]['newline'] = true;
             }
             continue;
         }
         $value = $this->parseValue($field_id, $values);
         $substituted[$counter]['name'] = $this->active_fields[$field_id];
         $substituted[$counter]['value'] = $value;
         $substituted[$counter]['bold'] = $this->isBold($field_id);
         if ($this->hasNewline($field_id)) {
             $substituted[$counter]['newline'] = true;
         } else {
             $substituted[$counter]['newline'] = false;
         }
         $substituted[$counter]['show_field'] = $this->enabledFieldNames();
         $counter++;
     }
     return $substituted ? $substituted : array();
 }
Пример #10
0
 /**
  * Get advanced metadata values for object id
  * 
  * @param int $a_obj_id
  * @return array
  */
 public static function getAdvancedMDValuesForObjId($a_obj_id)
 {
     $res = array();
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     // getting all records
     foreach (ilAdvancedMDValues::getInstancesForObjectId($a_obj_id) as $a_values) {
         // this correctly binds group and definitions
         $a_values->read();
         // getting elements for record
         $defs = $a_values->getDefinitions();
         foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
             if (!$element->isNull()) {
                 // :TODO: using this for a "flat" presentation
                 $res[$element_id] = $defs[$element_id]->getValueForXML($element);
             } else {
                 // :TODO: is this needed?
                 $res[$element_id] = null;
             }
         }
     }
     return $res;
 }
 /**
  * Fill row
  *
  * @access public
  * @param array row data
  * 
  */
 public function fillRow($a_set)
 {
     include_once './Services/Link/classes/class.ilLink.php';
     $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
     $this->tpl->setVariable('VAL_LINK', ilLink::_getLink($a_set['ref_id'], 'rcrs'));
     $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
     $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
     $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
     $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
     $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
     $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
     $this->tpl->setVariable('VAL_LAST_UPDATE', $a_set['last_update']);
     $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
     $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
     $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
     $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
     $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
     $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
     $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
     $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
     $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
     $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
     $sid = array_pop($a_set['sids']);
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::getInstanceByServerId($sid);
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($a_set['obj_id']);
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'lecturer')) {
         $this->tpl->setVariable('VAL_LECTURER', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'term')) {
         $this->tpl->setVariable('VAL_TERM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'courseID')) {
         $this->tpl->setVariable('VAL_CRS_ID', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'courseType')) {
         $this->tpl->setVariable('VAL_CRS_TYPE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'credits')) {
         $this->tpl->setVariable('VAL_CREDITS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'semester_hours')) {
         $this->tpl->setVariable('VAL_SWS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'room')) {
         $this->tpl->setVariable('VAL_ROOM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'cycle')) {
         $this->tpl->setVariable('VAL_CYCLE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'begin')) {
         $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'end')) {
         $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
 }
Пример #12
0
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  * @param int $a_mapping_mode
  */
 protected function importMetadataFromJson($a_json, ilECSSetting $a_server, array $a_definition, $a_mapping_mode)
 {
     global $ilLog;
     $ilLog->write("importing metadata from json: " . print_r($a_json, true));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     $values_records = ilAdvancedMDValues::getInstancesForObjectId($this->getId(), $this->getType());
     foreach ($values_records as $values_record) {
         // this correctly binds group and definitions
         $values_record->read();
     }
     $do_save = false;
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         $timePlace = null;
         if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
             // find element in records
             $adv_md_def = null;
             foreach ($values_records as $values_record) {
                 $adv_md_defs = $values_record->getDefinitions();
                 if (isset($adv_md_defs[$field])) {
                     $adv_md_def = $adv_md_defs[$field];
                     break;
                 }
             }
             if (!$adv_md_def) {
                 continue;
             }
             $raw_value = $a_json->{$target};
             if ($type == ilECSUtils::TYPE_TIMEPLACE) {
                 if (!is_object($timePlace)) {
                     include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                     if (is_object($raw_value)) {
                         $timePlace = new ilECSTimePlace();
                         $timePlace->loadFromJSON($raw_value);
                     } else {
                         $timePlace = new ilECSTimePlace();
                     }
                 }
                 $raw_value = $timePlace;
             }
             if ($adv_md_def->importFromECS($type, $raw_value, $id)) {
                 $do_save = true;
             }
         }
     }
     if ($do_save) {
         foreach ($values_records as $values_record) {
             $additional = array();
             foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
                 if (!$element->isNull()) {
                     $additional[$element_id] = array("disabled" => array("integer", 1));
                 }
             }
             $values_record->write($additional);
         }
     }
 }
Пример #13
0
 /**
  * Create new wiki page
  *
  * @param string $a_page_title page title
  * @param int $a_template_page template page id
  * @return ilWikiPage new wiki page
  */
 function createWikiPage($a_page_title, $a_template_page = 0)
 {
     // check if template has to be used
     if ($a_template_page == 0) {
         if (!$this->getEmptyPageTemplate()) {
             include_once "./Modules/Wiki/classes/class.ilWikiPageTemplate.php";
             $wt = new ilWikiPageTemplate($this->getId());
             $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES);
             if (count($ts) == 1) {
                 $t = current($ts);
                 $a_template_page = $t["wpage_id"];
             }
         }
     }
     // create the page
     $page = new ilWikiPage();
     $page->setWikiId($this->getId());
     $page->setTitle(ilWikiUtil::makeDbTitle($a_page_title));
     if ($this->getRating() && $this->getRatingForNewPages()) {
         $page->setRating(true);
     }
     // needed for notification
     $page->setWikiRefId($this->getRefId());
     $page->create();
     // copy template into new page
     if ($a_template_page > 0) {
         $orig = new ilWikiPage($a_template_page);
         $orig->copy($page->getId());
         // #15718
         include_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
         ilAdvancedMDValues::_cloneValues($this->getId(), $this->getId(), "wpg", $a_template_page, $page->getId());
     }
     return $page;
 }
Пример #14
0
 /**
  * Clone object permissions, put in tree ...
  *
  * @access public
  * @param int target id
  * @param int copy id for class.ilCopyWizardOptions()
  * @return object new object
  *  
  */
 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
 {
     global $objDefinition, $ilUser, $rbacadmin, $ilDB;
     $location = $objDefinition->getLocation($this->getType());
     $class_name = 'ilObj' . $objDefinition->getClassName($this->getType());
     if (!$a_omit_tree) {
         $title = $this->appendCopyInfo($a_target_id, $a_copy_id);
     } else {
         $title = $this->getTitle();
     }
     // create instance
     include_once $location . "/class." . $class_name . ".php";
     $new_obj = new $class_name(0, false);
     $new_obj->setOwner($ilUser->getId());
     $new_obj->setTitle($title);
     $new_obj->setDescription($this->getLongDescription());
     $new_obj->setType($this->getType());
     // Choose upload mode to avoid creation of additional settings, db entries ...
     $new_obj->create(true);
     if (!$a_omit_tree) {
         $new_obj->createReference();
         $new_obj->putInTree($a_target_id);
         $new_obj->setPermissions($a_target_id);
         // when copying from personal workspace we have no current ref id
         if ($this->getRefId()) {
             // copy local roles
             $rbacadmin->copyLocalRoles($this->getRefId(), $new_obj->getRefId());
         }
     }
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     ilAdvancedMDValues::_cloneValues($this->getId(), $new_obj->getId());
     // BEGIN WebDAV: Clone WebDAV properties
     $query = "INSERT INTO dav_property (obj_id,node_id,ns,name,value) " . "SELECT " . $ilDB->quote($new_obj->getId(), 'integer') . ",node_id,ns,name,value " . "FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
     $res = $ilDB->manipulate($query);
     // END WebDAV: Clone WebDAV properties
     return $new_obj;
 }
 /**
  * Delete field entry 
  */
 public function delete()
 {
     global $ilDB;
     if (!$this->getFieldId()) {
         return;
     }
     // delete all values
     include_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
     ilAdvancedMDValues::_deleteByFieldId($this->getFieldId(), $this->getADT());
     $query = "DELETE FROM adv_mdf_definition" . " WHERE field_id = " . $ilDB->quote($this->getFieldId(), "integer");
     $ilDB->manipulate($query);
 }
Пример #16
0
 /**
  * Preload list gui data
  * 
  * @param array $a_obj_ids
  */
 public static function preloadByObjIds(array $a_obj_ids)
 {
     global $ilDB;
     // preload values
     ilADTFactory::getInstance()->initActiveRecordByType();
     ilADTActiveRecordByType::preloadByPrimary("adv_md_values", array("obj_id" => array("integer", $a_obj_ids)));
     // preload record ids for object types
     self::$preload_obj_records = array();
     // get active records for object types
     $query = "SELECT amro.*" . " FROM adv_md_record_objs amro" . " JOIN adv_md_record amr ON (amr.record_id = amro.record_id)" . " WHERE active = " . $ilDB->quote(1, "integer");
     $set = $ilDB->query($query);
     while ($row = $ilDB->fetchAssoc($set)) {
         self::$preload_obj_records[$row["obj_type"]][] = $row["record_id"];
     }
 }
Пример #17
0
 /**
  * Get the assigned AMD Values.
  * If a record_id is given, returns an array with all Elements (instances of ilADT objects) belonging to this record.
  * If no record_id is given, returns an associative array with record-IDs as keys and ilADT objects as values
  *
  * @param int $a_record_id
  *
  * @return array
  */
 public function getAdvancedMDValues($a_record_id = 0)
 {
     if (!$this->getOrgUnitTypeId()) {
         return array();
     }
     // Serve from cache?
     if (is_array($this->amd_data)) {
         if ($a_record_id) {
             return isset($this->amd_data[$a_record_id]) ? $this->amd_data[$a_record_id] : array();
         } else {
             return $this->amd_data;
         }
     }
     /** @var ilAdvancedMDValues $amd_values */
     foreach (ilAdvancedMDValues::getInstancesForObjectId($this->getId(), 'orgu') as $record_id => $amd_values) {
         $amd_values = new ilAdvancedMDValues($record_id, $this->getId(), 'orgu_type', $this->getOrgUnitTypeId());
         $amd_values->read();
         $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
     }
     if ($a_record_id) {
         return isset($this->amd_data[$a_record_id]) ? $this->amd_data[$a_record_id] : array();
     } else {
         return $this->amd_data;
     }
 }
 /**
  * Fill row
  *
  * @access public
  * @param array row data
  * 
  */
 public function fillRow($a_set)
 {
     global $tree;
     include_once './Services/Link/classes/class.ilLink.php';
     $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
     #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
     $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
     $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
     $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
     $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
     $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
     $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
     $this->tpl->setVariable('VAL_LAST_UPDATE', ilDatePresentation::formatDate(new ilDateTime($a_set['last_update'], IL_CAL_DATETIME)));
     // Links
     foreach (ilObject::_getAllReferences($a_set['obj_id']) as $ref_id) {
         $parent = $tree->getParentId($ref_id);
         $p_obj_id = ilObject::_lookupObjId($parent);
         $p_title = ilObject::_lookupTitle($p_obj_id);
         $p_type = ilObject::_lookupType($p_obj_id);
         $this->tpl->setCurrentBlock('link');
         $this->tpl->setVariable('LINK_IMG', ilUtil::getTypeIconPath($p_type, $p_obj_id, 'tiny'));
         $this->tpl->setVariable('LINK_CONTAINER', $p_title);
         $this->tpl->setVariable('LINK_LINK', ilLink::_getLink($parent, $p_type));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
     $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
     $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
     $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
     $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
     $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
     $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
     $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
     $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
     $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::getInstanceByServerId($a_set['sid']);
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($a_set['obj_id']);
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'lecturer')) {
         $this->tpl->setVariable('VAL_LECTURER', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'term')) {
         $this->tpl->setVariable('VAL_TERM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseID')) {
         $this->tpl->setVariable('VAL_CRS_ID', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseType')) {
         $this->tpl->setVariable('VAL_CRS_TYPE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'credits')) {
         $this->tpl->setVariable('VAL_CREDITS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'semester_hours')) {
         $this->tpl->setVariable('VAL_SWS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room')) {
         $this->tpl->setVariable('VAL_ROOM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle')) {
         $this->tpl->setVariable('VAL_CYCLE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin')) {
         $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end')) {
         $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
 }
Пример #19
0
 /**
  * Add Advanced Meta Data Information to the Info Screen
  *
  * @param ilInfoScreenGUI $info
  */
 protected function parseInfoScreen(ilInfoScreenGUI $info)
 {
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
     include_once 'Services/ADT/classes/class.ilADTFactory.php';
     $type = $this->object->getOrgUnitType();
     if (!$type) {
         return;
     }
     $assigned_record_ids = $type->getAssignedAdvancedMDRecordIds();
     foreach (ilAdvancedMDValues::getInstancesForObjectId($this->object->getId(), 'orgu') as $record_id => $a_values) {
         // Skip record ids not assigned to the type
         if (!in_array($record_id, $assigned_record_ids)) {
             continue;
         }
         // Note that we have to do this because with the instances above the sub-type and sub-id are missing...
         $a_values = new ilAdvancedMDValues($record_id, $this->object->getId(), 'orgu_type', $this->object->getOrgUnitTypeId());
         // this correctly binds group and definitions
         $a_values->read();
         $info->addSection(ilAdvancedMDRecord::_lookupTitle($record_id));
         $defs = $a_values->getDefinitions();
         foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
             if (!$element->isNull()) {
                 $info->addProperty($defs[$element_id]->getTitle(), ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getHTML());
             }
         }
     }
 }
 /**
  * Fill data section
  */
 function fillDataSection()
 {
     global $lng;
     $btpl = new ilTemplate("tpl.wiki_advmd_block.html", true, true, "Modules/Wiki");
     // see ilAdvancedMDRecordGUI::parseInfoPage()
     $old_dt = ilDatePresentation::useRelativeDates();
     ilDatePresentation::setUseRelativeDates(false);
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once 'Services/ADT/classes/class.ilADTFactory.php';
     $values = new ilAdvancedMDValues($this->record->getRecordId(), $this->obj_id, "wpg", $this->page_id);
     // this correctly binds group and definitions
     $values->read();
     $defs = $values->getDefinitions();
     foreach ($values->getADTGroup()->getElements() as $element_id => $element) {
         $btpl->setCurrentBlock("item");
         $btpl->setVariable("CAPTION", $defs[$element_id]->getTitle());
         if ($element->isNull()) {
             $value = "-";
         } else {
             $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
             if ($element instanceof ilADTLocation) {
                 $value->setSize("100%", "200px");
             }
             $value = $value->getHTML();
         }
         $btpl->setVariable("VALUE", $value);
         $btpl->parseCurrentBlock();
     }
     /*
     if ($this->isHidden())
     {
     	$btpl->setVariable("HIDDEN_INFO", $lng->txt("wiki_adv_md_hidden"));			
     }
     */
     $this->setDataSection($btpl->get());
     ilDatePresentation::setUseRelativeDates($old_dt);
     return;
 }
 /**
  * delete field
  *
  * @access public
  */
 public function delete()
 {
     global $ilDB;
     $query = "DELETE FROM adv_mdf_definition " . "WHERE field_id = " . $this->db->quote($this->getFieldId(), 'integer') . " ";
     $res = $ilDB->manipulate($query);
     // Also delete all values
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     ilAdvancedMDValues::_deleteByFieldId($this->getFieldId());
     return true;
 }