/** * save Field * * @param string $a_mode values: create | update */ public function save($a_mode = "create") { global $ilCtrl, $lng, $tpl; //check access if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) { $this->accessDenied(); return; } $this->initForm($a_mode == "update" ? "edit" : "create"); if ($this->checkInput($a_mode)) { $title = $this->form->getInput("title"); if ($a_mode != "create" && $title != $this->field_obj->getTitle()) { ilUtil::sendInfo($lng->txt("dcl_field_title_change_warning"), true); } $this->field_obj->setTitle($title); $this->field_obj->setDescription($this->form->getInput("description")); $this->field_obj->setDatatypeId($this->form->getInput("datatype")); $this->field_obj->setRequired($this->form->getInput("required")); $this->field_obj->setUnique($this->form->getInput("unique")); if ($a_mode == "update") { $this->field_obj->doUpdate(); } else { $this->field_obj->setVisible(true); $this->field_obj->setOrder($this->table->getNewOrder()); $this->field_obj->doCreate(); } // Get possible properties and save them include_once "./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php"; foreach (ilDataCollectionDatatype::getProperties($this->field_obj->getDatatypeId()) as $property) { $fieldprop_obj = new ilDataCollectionFieldProp(); $fieldprop_obj->setDatatypePropertyId($property['id']); $fieldprop_obj->setFieldId($this->field_obj->getId()); $fieldprop_obj->setValue($this->form->getInput("prop_" . $property['id'])); if ($a_mode == "update") { $fieldprop_obj->doUpdate(); } else { $fieldprop_obj->doCreate(); } } $ilCtrl->setParameter($this, "field_id", $this->field_obj->getId()); if ($a_mode == "update") { ilUtil::sendSuccess($lng->txt("dcl_msg_field_modified"), true); } else { $this->table->addField($this->field_obj); $this->table->buildOrderFields(); ilUtil::sendSuccess($lng->txt("msg_field_created"), false); } $ilCtrl->redirectByClass(strtolower("ilDataCollectionFieldListGUI"), "listFields"); } else { $this->form->setValuesByPost(); $tpl->setContent($this->form->getHTML()); } }
/** * Export DC as Excel sheet * */ public function exportExcel() { global $ilCtrl, $lng; if (!($this->table_obj->getExportEnabled() || $this->table_obj->hasPermissionToFields($this->parent_obj->ref_id))) { echo $lng->txt("access_denied"); exit; } require_once './Modules/DataCollection/classes/class.ilDataCollectionRecordListTableGUI.php'; $list = new ilDataCollectionRecordListTableGUI($this, $ilCtrl->getCmd(), $this->table_obj); $list->setRecordData($this->table_obj->getRecordsByFilter($list->getFilter())); $list->setExternalSorting(true); if (!$list->dataExists()) { $this->ctrl->redirect($this->parent_obj); } $list->exportData(ilTable2GUI::EXPORT_EXCEL, true); }