/**
  * Add all fields to the form
  */
 protected function initForm()
 {
     $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
     $this->setTitle($this->lng->txt('orgu_settings'));
     $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
     $item->setRequired(true);
     $item->setValue($this->obj_orgu->getTitle());
     $this->addItem($item);
     $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
     $item->setValue($this->obj_orgu->getDescription());
     $this->addItem($item);
     $item = new ilFormSectionHeaderGUI();
     $item->setTitle($this->lng->txt('orgu_type'));
     $this->addItem($item);
     $types = ilOrgUnitType::getAllTypes();
     $options = array(0 => '');
     /** @var ilOrgUnitType $type */
     foreach ($types as $type) {
         $options[$type->getId()] = $type->getTitle();
     }
     asort($options);
     $item = new ilSelectInputGUI($this->lng->txt('orgu_type'), 'orgu_type');
     $item->setOptions($options);
     $item->setValue($this->obj_orgu->getOrgUnitTypeId());
     $this->addItem($item);
     $item = new ilFormSectionHeaderGUI();
     $item->setTitle($this->lng->txt('ext_id'));
     $this->addItem($item);
     $item = new ilTextInputGUI($this->lng->txt('ext_id'), 'ext_id');
     $item->setValue($this->obj_orgu->getImportId());
     $this->addItem($item);
     $this->addCommandButton('updateSettings', $this->lng->txt('save'));
 }
 /**
  * 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());
             }
         }
     }
 }