/** * Clone fields * * @access public * @static * * @param int source obj id * @param int target obj_id */ public static function _clone($a_source_id, $a_target_id) { foreach (ilCourseDefinedFieldDefinition::_getFields($a_source_id) as $field_obj) { $cdf = new ilCourseDefinedFieldDefinition($a_target_id); $cdf->setName($field_obj->getName()); $cdf->setType($field_obj->getType()); $cdf->setValues($field_obj->getValues()); $cdf->enableRequired($field_obj->isRequired()); $cdf->save(); } }
/** * Update field definition * @return */ protected function updateField() { $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($_POST, true)); $this->initFieldForm(self::MODE_UPDATE); if ($this->form->checkInput()) { $udf = new ilCourseDefinedFieldDefinition($this->getObjId(), (int) $_REQUEST['field_id']); $udf->setName($this->form->getInput('na')); $udf->setType($this->form->getInput('ty')); $udf->setValues($udf->prepareValues($this->form->getInput('va'))); $udf->setValueOptions($this->form->getItemByPostVar('va')->getOpenAnswerIndexes()); $udf->enableRequired($this->form->getInput('re')); $udf->update(); // Finally reset member agreements ilMemberAgreement::_deleteByObjId($this->getObjId()); ilUtil::sendSuccess($this->lng->txt('settings_saved')); $this->listFields(); return true; } ilUtil::sendFailure($this->lng->txt('err_check_input')); $this->form->setValuesByPost(); $this->tpl->setContent($this->form->getHTML()); return false; }