/** * Check validity of form and pass values from form to object * * @return bool */ protected function fillObject() { $this->setValuesByPost(); if (!$this->checkInput()) { return false; } $file_data = (array) $this->getInput('icon'); /** @var ilImageFileInputGUI $item */ $item = $this->getItemByPostVar('icon'); try { if (isset($file_data['name']) && $file_data['name']) { $this->type->removeIconFile(); $this->type->setIcon($file_data['name']); $this->type->processAndStoreIconFile($file_data); } else { if ($item->getDeletionFlag()) { $this->type->removeIconFile(); $this->type->setIcon(''); } } } catch (ilException $e) { ilUtil::sendFailure($this->lng->txt('orgu_type_msg_error_custom_icon')); return false; } return true; }
/** * 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 a text and textarea input per language * * @param $a_lang_code */ protected function addTranslationInputs($a_lang_code) { $section = new ilFormSectionHeaderGUI(); $section->setTitle($this->lng->txt("meta_l_{$a_lang_code}")); $this->addItem($section); $item = new ilTextInputGUI($this->lng->txt('title'), "title_{$a_lang_code}"); $item->setValue($this->type->getTitle($a_lang_code)); $this->addItem($item); $item = new ilTextAreaInputGUI($this->lng->txt('description'), "description_{$a_lang_code}"); $item->setValue($this->type->getDescription($a_lang_code)); $this->addItem($item); }
/** * Build and set data for table. */ protected function buildData() { $types = ilOrgUnitType::getAllTypes(); $data = array(); /** @var $type ilOrgUnitType */ foreach ($types as $type) { $row = array(); $row['id'] = $type->getId(); $row['title'] = $type->getTitle($type->getDefaultLang()); $row['default_language'] = $type->getDefaultLang(); $row['description'] = $type->getDescription($type->getDefaultLang()); $row['icon'] = $type->getIcon(); $data[] = $row; } $this->setData($data); }
/** * Check validity of form and pass values from form to object * * @return bool */ protected function fillObject() { $this->setValuesByPost(); if (!$this->checkInput()) { return false; } try { // Assign and deassign amd records. A plugin could prevent those actions. $record_ids_selected = (array) $this->getInput('amd_records'); $record_ids = $this->type->getAssignedAdvancedMDRecordIds(true); $record_ids_removed = array_diff($record_ids, $record_ids_selected); $record_ids_added = array_diff($record_ids_selected, $record_ids); foreach ($record_ids_added as $record_id) { $this->type->assignAdvancedMDRecord($record_id); } foreach ($record_ids_removed as $record_id) { $this->type->deassignAdvancedMdRecord($record_id); } return true; } catch (ilException $e) { ilUtil::sendFailure($e->getMessage()); return false; } }
/** * Delete a type */ protected function delete() { $type = new ilOrgUnitType((int) $_GET['type_id']); try { $type->delete(); ilUtil::sendSuccess($this->lng->txt('orgu_type_msg_deleted'), true); $this->ctrl->redirect($this); } catch (ilException $e) { ilUtil::sendFailure($e->getMessage(), true); $this->ctrl->redirect($this); } }
/** * Returns an array that maps from OrgUnit object IDs to its icon defined by the assigned OrgUnit type. * Keys = OrgUnit object IDs, values = Path to the icon * This allows to get the Icons of OrgUnits without loading the object (e.g. used in the tree explorer) * * @return array */ public static function getIconsCache() { if (is_array(self::$icons_cache)) { return self::$icons_cache; } global $ilDB; /** @var ilDB $ilDB */ $sql = 'SELECT orgu_id, ot.id AS type_id FROM orgu_data INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) WHERE ot.icon IS NOT NULL'; $set = $ilDB->query($sql); $icons_cache = array(); while ($row = $ilDB->fetchObject($set)) { $type = ilOrgUnitType::getInstance($row->type_id); if ($type && is_file($type->getIconPath(true))) { $icons_cache[$row->orgu_id] = $type->getIconPath(true); } } self::$icons_cache = $icons_cache; return $icons_cache; }
/** * Get all available AdvancedMDRecord objects for OrgUnits/Types * * @return array */ public static function getAvailableAdvancedMDRecords() { if (is_array(self::$amd_records_available)) { return self::$amd_records_available; } self::$amd_records_available = ilAdvancedMDRecord::_getActivatedRecordsByObjectType('orgu', 'orgu_type'); return self::$amd_records_available; }