23 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
24 include_once(
'Modules/Course/classes/class.ilCourseAgreement.php');
58 $this->lng->loadLanguageModule(
'ps');
62 $this->tabs_gui = $ilTabs;
64 $this->obj_id = $a_obj_id;
75 $cmd = $this->ctrl->getCmd();
77 switch($next_class = $this->ctrl->getNextClass($this))
97 unset(
$_SESSION[
'il_cdf_select_num_values']);
100 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_list.html',
'Modules/Course');
102 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
103 $this->tpl->setVariable(
'TABLE_TITLE',$this->lng->txt(
'ps_crs_user_fields'));
104 $this->tpl->setVariable(
'HEAD_NAME',$this->lng->txt(
'ps_cdf_name'));
105 $this->tpl->setVariable(
'HEAD_TYPE',$this->lng->txt(
'ps_cdf_type'));
106 $this->tpl->setVariable(
'HEAD_REQUIRED',$this->lng->txt(
'ps_cdf_required'));
108 $this->tpl->setVariable(
'ADD',$this->lng->txt(
'ps_cdf_add_field'));
109 $this->tpl->setVariable(
'LINK_ADD',$this->ctrl->getLinkTarget($this,
'fieldSelection'));
116 $this->tpl->setCurrentBlock(
'table_empty');
117 $this->tpl->setVariable(
'EMPTY_TXT',$this->lng->txt(
'ps_cdf_no_fields'));
118 $this->tpl->parseCurrentBlock();
122 $this->tpl->setCurrentBlock(
'warning_modify');
123 $this->tpl->setVariable(
'TXT_WARNING',$this->lng->txt(
'ps_cdf_warning_modify'));
124 $this->tpl->parseCurrentBlock();
127 foreach($fields as $field_obj)
131 $this->tpl->setCurrentBlock(
'show_edit');
133 $this->ctrl->setParameter($this,
'field_id',$field_obj->getId());
134 $this->tpl->setVariable(
'EDIT_LINK',$this->ctrl->getLinkTarget($this,
'editField'));
135 $this->ctrl->clearParameters($this);
137 $this->tpl->setVariable(
'EDIT',$this->lng->txt(
'edit'));
138 $this->tpl->parseCurrentBlock();
141 $this->tpl->setCurrentBlock(
'table_content');
144 $this->tpl->setVariable(
'NAME',$field_obj->getName());
146 $this->lng->txt(
'ps_type_select') :
147 $this->lng->txt(
'ps_type_text'));
148 $this->tpl->setVariable(
'REQUIRED',
ilUtil::formCheckbox((
int) $field_obj->isRequired(),
'required['.$field_obj->getId().
']',1));
149 $this->tpl->parseCurrentBlock();
152 $this->tpl->setVariable(
'BTN_DELETE',$this->lng->txt(
'delete'));
156 $this->tpl->setCurrentBlock(
'show_save');
157 $this->tpl->setVariable(
'BTN_SAVE',$this->lng->txt(
'save'));
158 $this->tpl->parseCurrentBlock();
171 if(!
$_GET[
'field_id'])
180 $required = isset($_POST[
'cmd']) ? $_POST[
'required'] :
$cdf->isRequired();
182 $this->ctrl->setParameter($this,
'field_id',(
int) $_GET[
'field_id']);
183 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_edit_select_field.html',
'Modules/Course');
184 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
187 $this->tpl->setVariable(
'TXT_FIELD_NAME',$this->lng->txt(
'ps_name_field'));
188 $this->tpl->setVariable(
'FIELD_NAME_VALUE',$name);
190 $this->tpl->setVariable(
'TXT_REQUIRED',$this->lng->txt(
'required_field'));
191 $this->tpl->setVariable(
'BTN_ADD',$this->lng->txt(
'save'));
192 $this->tpl->setVariable(
'BTN_PREVIOUS',$this->lng->txt(
'cancel'));
198 foreach(
$cdf->getValues() as $key => $value)
200 $this->ctrl->setParameter($this,
'del_field',$i - 1);
202 $this->tpl->setCurrentBlock(
'values');
204 $this->ctrl->setParameter($this,
'del_field',$i - 1);
205 $this->tpl->setVariable(
'DELETE',$this->lng->txt(
'delete'));
206 $this->tpl->setVariable(
'LINK_DELETE',$this->ctrl->getLinkTarget($this,
'deleteField'));
208 $this->tpl->setVariable(
"TXT_VALUES",$this->lng->txt(
'ps_cdf_value').
' '.($i++));
209 $this->tpl->parseCurrentBlock();
211 switch(
$cdf->getType())
214 $this->tpl->setVariable(
'TXT_SELECT_TYPE',$this->lng->txt(
'ps_edit_select_field'));
215 $this->tpl->setVariable(
'BTN_NEW_VALUE',$this->lng->txt(
'ps_btn_add_value'));
217 for($j = 0; $j <
$_SESSION[
'il_cdf_select_num_values'];$j++)
219 $this->tpl->setCurrentBlock(
'new_values');
220 $this->tpl->setVariable(
'COUNTER',$j);
221 $this->tpl->setVariable(
"TXT_NEW_VALUES",$this->lng->txt(
'ps_cdf_value').
' '.($i + $j));
222 $this->tpl->setVariable(
"NEW_FIELD_NAME",$_POST[
'new_field_values'][$j]);
223 $this->tpl->parseCurrentBlock();
228 $this->tpl->setVariable(
'TXT_SELECT_TYPE',$this->lng->txt(
'ps_edit_text_field'));
240 if(!
$_GET[
'field_id'])
247 $cdf->deleteValue((
int) $_GET[
'del_field']);
261 $_SESSION[
'il_cdf_select_num_values'] += 1;
273 if(!
$_GET[
'field_id'])
282 if(!strlen($_POST[
'field_name']))
289 switch(
$cdf->getType())
292 $values =
$cdf->prepareValues($_POST[
'new_field_values']);
293 $cdf->appendValues($values);
301 $cdf->enableRequired((
int) $_POST[
'required']);
322 if(!count($_POST[
'field_id']))
330 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_confirm_delete.html',
'Modules/Course');
331 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
332 $this->tpl->setVariable(
'TXT_NAME',$this->lng->txt(
'ps_cdf_name'));
333 $this->tpl->setVariable(
'TXT_TYPE',$this->lng->txt(
'ps_cdf_type'));
334 $this->tpl->setVariable(
'DELETE',$this->lng->txt(
'delete'));
335 $this->tpl->setVariable(
'CANCEL',$this->lng->txt(
'cancel'));
338 foreach($_POST[
'field_id'] as $field_id)
342 $this->tpl->setCurrentBlock(
'del_row');
344 $this->tpl->setVariable(
'DEL_NAME',$tmp_field->getName());
346 $this->lng->txt(
'ps_type_select') :
347 $this->lng->txt(
'ps_type_text'));
348 $this->tpl->parseCurrentBlock();
351 $_SESSION[
'il_cdf_delete'] = $_POST[
'field_id'];
359 public function delete()
367 foreach(
$_SESSION[
'il_cdf_delete'] as $field_id)
370 $tmp_field->delete();
394 foreach($fields as $field_obj)
396 $field_obj->enableRequired((
bool) isset($_POST[
'required'][$field_obj->getId()]));
397 $field_obj->update();
415 $_SESSION[
'il_cdf_select_num_values'] = 3;
418 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_selection.html',
'Modules/Course');
419 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
420 $this->tpl->setVariable(
'TXT_SELECT_TYPE',$this->lng->txt(
'ps_cdf_add_field'));
421 $this->tpl->setVariable(
'FIELD_TYPE',$this->lng->txt(
'ps_field_type'));
422 $this->tpl->setVariable(
'TXT_TEXT',$this->lng->txt(
'ps_type_txt_long'));
423 $this->tpl->setVariable(
'TXT_SELECT',$this->lng->txt(
'ps_type_select_long'));
424 $this->tpl->setVariable(
'BTN_MORE',$this->lng->txt(
'btn_next'));
425 $this->tpl->setVariable(
'BTN_CANCEL',$this->lng->txt(
'cancel'));
440 switch($field_type = (
int) $_REQUEST[
'field_type'])
459 $this->ctrl->setParameter($this,
'field_type',(
int) $_REQUEST[
'field_type']);
461 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_add_select.html',
'Modules/Course');
462 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
463 $this->tpl->setVariable(
'TXT_SELECT_TYPE',$this->lng->txt(
'ps_new_select_field'));
464 $this->tpl->setVariable(
'TXT_FIELD_NAME',$this->lng->txt(
'ps_name_field'));
465 $this->tpl->setVariable(
'TXT_REQUIRED',$this->lng->txt(
'required_field'));
466 $this->tpl->setVariable(
'BTN_ADD',$this->lng->txt(
'save'));
467 $this->tpl->setVariable(
'BTN_PREVIOUS',$this->lng->txt(
'btn_previous'));
468 $this->tpl->setVariable(
'BTN_NEW_VALUE',$this->lng->txt(
'ps_btn_add_value'));
470 $this->tpl->setVariable(
'REQUIRED',
ilUtil::formCheckbox($_POST[
'required'] ? 1 : 0,
'required',1));
471 $this->tpl->setVariable(
'FIELD_NAME_VALUE',$_POST[
'field_name']);
473 for($i = 0; $i <
$_SESSION[
'il_cdf_select_num_values'];$i++)
475 $this->tpl->setCurrentBlock(
"values");
476 $this->tpl->setVariable(
'COUNTER',$i);
477 $this->tpl->setVariable(
"TXT_VALUES",$this->lng->txt(
'ps_cdf_value').
' '.($i + 1));
478 $this->tpl->setVariable(
"FIELD_NAME",$_POST[
'field_values'][$i]);
479 $this->tpl->parseCurrentBlock();
491 $_SESSION[
'il_cdf_select_num_values'] += 1;
507 $this->ctrl->setParameter($this,
'field_type',(
int) $_REQUEST[
'field_type']);
509 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.user_fields_add_text.html',
'Modules/Course');
510 $this->tpl->setVariable(
'FORMACTION',$this->ctrl->getFormAction($this));
511 $this->tpl->setVariable(
'TXT_SELECT_TYPE',$this->lng->txt(
'ps_new_text_field'));
512 $this->tpl->setVariable(
'TXT_FIELD_NAME',$this->lng->txt(
'ps_name_field'));
513 $this->tpl->setVariable(
'TXT_REQUIRED',$this->lng->txt(
'required_field'));
514 $this->tpl->setVariable(
'BTN_ADD',$this->lng->txt(
'btn_add'));
515 $this->tpl->setVariable(
'BTN_PREVIOUS',$this->lng->txt(
'btn_previous'));
529 if(!strlen($_POST[
'field_name']))
542 $values =
$cdf->prepareValues($_POST[
'field_values']);
543 $cdf->setValues($values);
547 $cdf->enableRequired((
int) $_POST[
'required']);