ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAdvancedMDSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
5 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
6 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDPermissionHelper.php');
7 
17 {
18  protected $lng;
19  protected $tpl;
20  protected $ctrl;
21  protected $tabs;
22  protected $permissions; // [ilAdvancedMDPermissionHelper]
23  protected $obj_id; // [int]
24  protected $obj_type; // [string]
25  protected $sub_type; // [string]
26 
33  public function __construct($a_obj_id = null, $a_obj_type = null, $a_sub_type = null)
34  {
35  global $tpl,$lng,$ilCtrl,$ilTabs;
36 
37  $this->ctrl = $ilCtrl;
38  $this->lng = $lng;
39  $this->lng->loadLanguageModule('meta');
40  $this->tpl = $tpl;
41  $this->tabs_gui = $ilTabs;
42 
43  $this->obj_id = $a_obj_id;
44  $this->obj_type = $a_obj_type;
45  $this->sub_type = $a_sub_type
46  ? $a_sub_type
47  : "-";
48 
49  if($this->obj_id &&
50  !$this->obj_type)
51  {
52  $this->obj_type = ilObject::_lookupType($this->obj_id);
53  }
54 
55  $this->permissions = ilAdvancedMDPermissionHelper::getInstance();
56  }
57 
58  protected function getPermissions()
59  {
60  return $this->permissions;
61  }
62 
70  public function executeCommand()
71  {
72  $next_class = $this->ctrl->getNextClass($this);
73  $cmd = $this->ctrl->getCmd();
74 
75  if(!$this->obj_id)
76  {
77  $this->setSubTabs();
78  }
79 
80  switch($next_class)
81  {
82  default:
83  if(!$cmd)
84  {
85  $cmd = 'showRecords';
86  }
87  $this->$cmd();
88  }
89  }
90 
98  public function showRecords()
99  {
100  global $ilToolbar, $ilAccess;
101 
102  $perm = $this->getPermissions()->hasPermissions(
104  $_REQUEST["ref_id"],
105  array(
108  ));
109 
111  {
112  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
113  $button = ilLinkButton::getInstance();
114  $button->setCaption("add");
115  $button->setUrl($this->ctrl->getLinkTarget($this, "createRecord"));
116  $ilToolbar->addButtonInstance($button);
117 
119  {
120  $ilToolbar->addSeparator();
121  }
122  }
123 
125  {
126  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
127  $button = ilLinkButton::getInstance();
128  $button->setCaption("import");
129  $button->setUrl($this->ctrl->getLinkTarget($this, "importRecords"));
130  $ilToolbar->addButtonInstance($button);
131  }
132 
133  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.show_records.html','Services/AdvancedMetaData');
134 
135  include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
136  $table_gui = new ilAdvancedMDRecordTableGUI($this, "showRecords", $this->getPermissions(), (bool)$this->obj_id);
137  $table_gui->setTitle($this->lng->txt("md_record_list_table"));
138  $table_gui->setData($this->getParsedRecordObjects());
139 
140  // permissions?
141  //$table_gui->addCommandButton('createRecord',$this->lng->txt('add'));
142  $table_gui->addMultiCommand("exportRecords",$this->lng->txt('export'));
143  $table_gui->setSelectAllCheckbox("record_id");
144 
145  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
146  {
147  $table_gui->addMultiCommand("confirmDeleteRecords", $this->lng->txt("delete"));
148  $table_gui->addCommandButton("updateRecords", $this->lng->txt("save"));
149  }
150 
151 
152  $this->tpl->setVariable('RECORD_TABLE',$table_gui->getHTML());
153 
154  return true;
155  }
156 
157  public function showPresentation()
158  {
159  if($this->initFormSubstitutions())
160  {
161  if (is_object($this->form))
162  {
163  $this->tabs_gui->setSubTabActive('md_adv_presentation');
164  return $this->tpl->setContent($this->form->getHTML());
165  }
166  }
167  return $this->showRecords();
168  }
169 
176  public function updateSubstitutions()
177  {
178  global $ilAccess;
179 
180  if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
181  {
182  $this->ctrl->redirect($this, "showPresentation");
183  }
184 
186  {
187  $perm = null;
188  // :TODO: hardwired?
189  if(in_array($obj_type, array("crs", "cat")))
190  {
191  $perm = $this->getPermissions()->hasPermissions(
193  $obj_type,
194  array(
198  ));
199  }
200 
201  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
203 
205  {
206  $sub->enableDescription($_POST['enabled_desc_'.$obj_type]);
207  }
208 
210  {
211  $sub->enableFieldNames((int) $_POST['enabled_field_names_'.$obj_type]);
212  }
213 
214  $definitions = ilAdvancedMDFieldDefinition::getInstancesByObjType($obj_type);
215  $definitions = $sub->sortDefinitions($definitions);
216 
217  // gather existing data
218  $counter = 1;
219  $old_sub = array();
220  foreach($definitions as $def)
221  {
222  $field_id = $def->getFieldId();
223  $old_sub[$field_id] = array(
224  "active" => $sub->isSubstituted($field_id),
225  "pos" => $counter++,
226  "bold" => $sub->isBold($field_id),
227  "newline" => $sub->hasNewline($field_id)
228  );
229  }
230 
231  $sub->resetSubstitutions(array());
232 
233  $new_sub = array();
234  foreach($definitions as $def)
235  {
236  $field_id = $def->getFieldId();
237  $old = $old_sub[$field_id];
238 
239  $perm_def = $this->getSubstitutionFieldPermissions($obj_type, $field_id);
240  if($perm_def["show"])
241  {
242  $active = (isset($_POST['show'][$obj_type][$field_id]) && $_POST['show'][$obj_type][$field_id]);
243  }
244  else
245  {
246  $active = $old["active"];
247  }
248 
249  if($active)
250  {
251  $new_sub[$field_id] = $old;
252 
254  {
255  $new_sub[$field_id]["pos"] = (int)$_POST['position'][$obj_type][$field_id];
256  }
257  if($perm_def["bold"])
258  {
259  $new_sub[$field_id]["bold"] = (isset($_POST['bold'][$obj_type][$field_id]) && $_POST['bold'][$obj_type][$field_id]);
260  }
261  if($perm_def["newline"])
262  {
263  $new_sub[$field_id]["newline"] = (isset($_POST['newline'][$obj_type][$field_id]) && $_POST['newline'][$obj_type][$field_id]);
264  }
265  }
266  }
267 
268  if(sizeof($new_sub))
269  {
270  $new_sub = ilUtil::sortArray($new_sub, "pos", "asc", true, true);
271  foreach($new_sub as $field_id => $field)
272  {
273  $sub->appendSubstitution($field_id, $field["bold"], $field["newline"]);
274  }
275  }
276 
277  $sub->update();
278  }
279 
280 
281  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
282  $this->ctrl->redirect($this, "showPresentation");
283  }
284 
290  public function exportRecords()
291  {
292  if(!isset($_POST['record_id']))
293  {
294  ilUtil::sendFailure($this->lng->txt('select_one'));
295  $this->showRecords();
296  return false;
297  }
298 
299  // all records have to be exportable
300  $fail = array();
301  foreach($_POST['record_id'] as $record_id)
302  {
303  if(!$this->getPermissions()->hasPermission(
305  $record_id,
307  {
308  $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
309  $fail[] = $record->getTitle();
310  }
311  }
312  if($fail)
313  {
314  ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy')." ".implode(", ", $fail), true);
315  $this->ctrl->redirect($this, "showRecords");
316  }
317 
318  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
319  $xml_writer = new ilAdvancedMDRecordXMLWriter($_POST['record_id']);
320  $xml_writer->write();
321 
322  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
323  $export_files = new ilAdvancedMDRecordExportFiles($this->obj_id);
324  $export_files->create($xml_writer->xmlDumpMem());
325 
326  ilUtil::sendSuccess($this->lng->txt('md_adv_records_exported'));
327  $this->showFiles();
328  }
329 
337  public function showFiles()
338  {
339  $this->tabs_gui->setSubTabActive('md_adv_file_list');
340 
341  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
342  $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
343  $file_data = $files->readFilesInfo();
344 
345  include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
346  $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
347  $table_gui->setTitle($this->lng->txt("md_record_export_table"));
348  $table_gui->parseFiles($file_data);
349  $table_gui->addMultiCommand("downloadFile",$this->lng->txt('download'));
350  $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
351  $table_gui->addCommandButton('showFiles',$this->lng->txt('cancel'));
352  $table_gui->setSelectAllCheckbox("file_id");
353 
354  $this->tpl->setContent($table_gui->getHTML());
355  }
356 
364  public function downloadFile()
365  {
366  if(!isset($_POST['file_id']) or count($_POST['file_id']) != 1)
367  {
368  ilUtil::sendFailure($this->lng->txt('md_adv_select_one_file'));
369  $this->showFiles();
370  return false;
371  }
372 
373  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
374  $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
375  $abs_path = $files->getAbsolutePathByFileId((int) $_POST['file_id'][0]);
376 
377  ilUtil::deliverFile($abs_path,'ilias_meta_data_record.xml','application/xml');
378  }
379 
386  public function confirmDeleteFiles()
387  {
388  if(!isset($_POST['file_id']))
389  {
390  ilUtil::sendFailure($this->lng->txt('select_one'));
391  $this->showFiles();
392  return false;
393  }
394 
395  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
396  $c_gui = new ilConfirmationGUI();
397 
398  // set confirm/cancel commands
399  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
400  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
401  $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
402  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
403 
404  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
405  $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
406  $file_data = $files->readFilesInfo();
407 
408 
409  // add items to delete
410  foreach($_POST["file_id"] as $file_id)
411  {
412  $info = $file_data[$file_id];
413  $c_gui->addItem("file_id[]", $file_id, is_array($info['name']) ? implode(',',$info['name']) : 'No Records');
414  }
415  $this->tpl->setContent($c_gui->getHTML());
416  }
417 
425  public function deleteFiles()
426  {
427  if(!isset($_POST['file_id']))
428  {
429  ilUtil::sendFailure($this->lng->txt('select_one'));
430  $this->editFiles();
431  return false;
432  }
433 
434  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
435  $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
436 
437  foreach($_POST['file_id'] as $file_id)
438  {
439  $files->deleteByFileId((int) $file_id);
440  }
441  ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_files'));
442  $this->showFiles();
443  }
444 
451  public function confirmDeleteRecords()
452  {
453  if(!isset($_POST['record_id']))
454  {
455  ilUtil::sendFailure($this->lng->txt('select_one'));
456  $this->showRecords();
457  return false;
458  }
459 
460  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
461  $c_gui = new ilConfirmationGUI();
462 
463  // set confirm/cancel commands
464  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
465  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
466  $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
467  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
468 
469  // add items to delete
470  foreach($_POST["record_id"] as $record_id)
471  {
472  $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
473  $c_gui->addItem("record_id[]", $record_id, $record->getTitle() ? $record->getTitle() : 'No Title');
474  }
475  $this->tpl->setContent($c_gui->getHTML());
476  }
477 
484  public function deleteRecords()
485  {
486  if(!isset($_POST['record_id']))
487  {
488  ilUtil::sendFailure($this->lng->txt('select_one'));
489  $this->showRecords();
490  return false;
491  }
492 
493  // all records have to be deletable
494  $fail = array();
495  foreach($_POST['record_id'] as $record_id)
496  {
497  // must not delete global records in local context
498  if($this->obj_id)
499  {
500  $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
501  if(!$record->getParentObject())
502  {
503  $fail[] = $record->getTitle();
504  }
505  }
506 
507  if(!$this->getPermissions()->hasPermission(
509  $record_id,
511  {
512  $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
513  $fail[] = $record->getTitle();
514  }
515  }
516  if($fail)
517  {
518  ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete')." ".implode(", ", $fail), true);
519  $this->ctrl->redirect($this, "showRecords");
520  }
521 
522  foreach($_POST['record_id'] as $record_id)
523  {
524  $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
525  $record->delete();
526  }
527  ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_records'), true);
528  $this->ctrl->redirect($this, "showRecords");
529  }
530 
538  public function updateRecords()
539  {
540  $selected_global = array();
541  foreach($this->getParsedRecordObjects() as $item)
542  {
543  $perm = $this->getPermissions()->hasPermissions(
545  $item['id'],
546  array(
550  ));
551 
552  if(!$this->obj_type)
553  {
554  $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
555 
557  {
558  $obj_types = array();
559  if (is_array($_POST['obj_types'][$record_obj->getRecordId()]))
560  {
561  foreach ($_POST['obj_types'][$record_obj->getRecordId()] as $type => $status)
562  {
563  if($status)
564  {
565  $type = explode(":", $type);
566  $obj_types[] = array(
567  "obj_type" => ilUtil::stripSlashes($type[0]),
568  "sub_type" => ilUtil::stripSlashes($type[1]),
569  "optional" => ((int)$status == 2)
570  );
571  }
572  }
573  }
574  $record_obj->setAssignedObjectTypes($obj_types);
575  }
576 
578  {
579  $record_obj->setActive(isset($_POST['active'][$record_obj->getRecordId()]));
580  }
581 
582  $record_obj->update();
583  }
585  {
586  // global, optional record
587  if($item['readonly'] &&
588  $item['optional'] &&
589  $_POST['active'][$item['id']])
590  {
591  $selected_global[] = $item['id'];
592  }
593  else if($item['local'])
594  {
595  $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
596  $record_obj->setActive(isset($_POST['active'][$item['id']]));
597  $record_obj->update();
598  }
599  }
600  }
601 
602  if($this->obj_type)
603  {
604  ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $this->sub_type, $selected_global);
605  }
606 
607  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
608  $this->ctrl->redirect($this, "showRecords");
609  }
610 
617  public function confirmDeleteFields()
618  {
619  if(!isset($_POST['field_id']))
620  {
621  ilUtil::sendFailure($this->lng->txt('select_one'));
622  $this->editFields();
623  return false;
624  }
625 
626  $this->ctrl->saveParameter($this,'record_id');
627 
628  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
629  $c_gui = new ilConfirmationGUI();
630 
631  // set confirm/cancel commands
632  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
633  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
634  $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
635  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
636 
637  // add items to delete
638  foreach($_POST["field_id"] as $field_id)
639  {
640  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
641  $c_gui->addItem("field_id[]", $field_id, $field->getTitle() ? $field->getTitle() : 'No Title');
642  }
643  $this->tpl->setContent($c_gui->getHTML());
644  }
645 
653  public function deleteFields()
654  {
655  $this->ctrl->saveParameter($this,'record_id');
656 
657  if(!isset($_POST['field_id']))
658  {
659  ilUtil::sendFailure($this->lng->txt('select_one'));
660  $this->editFields();
661  return false;
662  }
663 
664  // all fields have to be deletable
665  $fail = array();
666  foreach($_POST['field_id'] as $field_id)
667  {
668  if(!$this->getPermissions()->hasPermission(
670  $field_id,
672  {
673  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
674  $fail[] = $field->getTitle();
675  }
676  }
677  if($fail)
678  {
679  ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete')." ".implode(", ", $fail), true);
680  $this->ctrl->redirect($this, "editFields");
681  }
682 
683  foreach($_POST["field_id"] as $field_id)
684  {
685  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
686  $field->delete();
687  }
688  ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_fields'), true);
689  $this->ctrl->redirect($this, "editFields");
690  }
691 
699  public function editRecord()
700  {
701  $this->ctrl->saveParameter($this,'record_id');
702  $this->initRecordObject();
703  $this->initForm('edit');
704  $this->tpl->setContent($this->form->getHTML());
705 
706  }
707 
708  public function editFields()
709  {
710  global $ilToolbar;
711 
712  $this->ctrl->saveParameter($this,'record_id');
713  $this->initRecordObject();
714 
715  $perm = $this->getPermissions()->hasPermissions(
717  $this->record->getRecordId(),
718  array(
721  ));
722 
723  $filter_warn = array();
725  {
726  // type selection
727  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
728  $types = new ilSelectInputGUI("", "ftype");
729  $options = array();
731  {
732  $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
733  $options[$type] = $this->lng->txt($field->getTypeTitle());
734 
735  if(!$field->isFilterSupported())
736  {
737  $filter_warn[] = $this->lng->txt($field->getTypeTitle());
738  }
739  }
740  $types->setOptions($options);
741  $ilToolbar->addInputItem($types);
742 
743  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "createField"));
744 
745  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
746  $button = ilSubmitButton::getInstance();
747  $button->setCaption("add");
748  $button->setCommand("createField");
749  $ilToolbar->addButtonInstance($button);
750  }
751 
752  // #17092
753  if(sizeof($filter_warn))
754  {
755  ilUtil::sendInfo(sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
756  }
757 
758  // show field table
759  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
760  $fields = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record->getRecordId());
761 
762  include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
763  $table_gui = new ilAdvancedMDFieldTableGUI($this, "editRecord", $this->getPermissions(), $perm[ilAdvancedMDPermissionHelper::ACTION_RECORD_FIELD_POSITIONS]);
764  $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
765  $table_gui->parseDefinitions($fields);
766  if(sizeof($fields))
767  {
768  $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
769  }
770  $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
771  $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
772  $table_gui->setSelectAllCheckbox("field_id");
773 
774  $this->tpl->setContent($table_gui->getHTML());
775  }
776 
783  public function updateFields()
784  {
785  $this->ctrl->saveParameter($this,'record_id');
786 
787  if(!isset($_GET['record_id']) or !$_GET['record_id'])
788  {
789  ilUtil::sendFailure($this->lng->txt('select_one'));
790  $this->editFields();
791  return false;
792  }
793 
794  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
796 
797  if($this->getPermissions()->hasPermission(
799  $_GET['record_id'],
801  {
802  if(!isset($_POST['position']) or !is_array($_POST['position']))
803  {
804  $this->editFields();
805  return false;
806  }
807  // sort by position
808  asort($_POST['position'],SORT_NUMERIC);
809  $positions = array_flip(array_keys($_POST['position']));
810  foreach($fields as $field)
811  {
812  $field->setPosition($positions[$field->getFieldId()]);
813  $field->update();
814  }
815  }
816 
817  foreach($fields as $field)
818  {
819  if($this->getPermissions()->hasPermission(
821  $field->getFieldId(),
824  {
825  $field->setSearchable(isset($_POST['searchable'][$field->getFieldId()]) ? true : false);
826  $field->update();
827  }
828  }
829 
830 
831  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
832  $this->ctrl->redirect($this, "editFields");
833  }
834 
842  public function updateRecord()
843  {
844  global $ilErr;
845 
846  if(!isset($_GET['record_id']) or !$_GET['record_id'])
847  {
848  ilUtil::sendFailure($this->lng->txt('select_one'));
849  $this->showRecords();
850  return false;
851  }
852  $this->initRecordObject();
853  $this->loadRecordFormData();
854 
855  if(!$this->record->validate())
856  {
857  ilUtil::sendFailure($this->lng->txt($ilErr->getMessage()));
858  $this->editRecord();
859  return false;
860  }
861  $this->record->update();
862  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
863  $this->showRecords();
864  return true;
865  }
866 
867 
875  public function createRecord()
876  {
877  $this->initRecordObject();
878  $this->initForm('create');
879  $this->tpl->setContent($this->form->getHTML());
880  return true;
881  }
882 
883  public function importRecords()
884  {
885  // Import Table
886  $this->initImportForm();
887  $this->tpl->setContent($this->import_form->getHTML());
888  }
889 
895  protected function initImportForm()
896  {
897  if(is_object($this->import_form))
898  {
899  return true;
900  }
901 
902  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
903  $this->import_form = new ilPropertyFormGUI();
904  $this->import_form->setMultipart(true);
905  $this->import_form->setFormAction($this->ctrl->getFormAction($this));
906 
907  // add file property
908  $file = new ilFileInputGUI($this->lng->txt('file'),'file');
909  $file->setSuffixes(array('xml'));
910  $file->setRequired(true);
911  $this->import_form->addItem($file);
912 
913  $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
914  $this->import_form->addCommandButton('importRecord',$this->lng->txt('import'));
915  $this->import_form->addCommandButton('showRecords',$this->lng->txt('cancel'));
916  }
917 
925  public function importRecord()
926  {
927  $this->initImportForm();
928  if(!$this->import_form->checkInput())
929  {
930  $this->import_form->setValuesByPost();
931  $this->createRecord();
932  return false;
933  }
934 
935  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
936  $import_files = new ilAdvancedMDRecordImportFiles();
937  if(!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name']))
938  {
939  $this->createRecord();
940  return false;
941  }
942 
943  try
944  {
945  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
946  $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
947 
948  // local import?
949  if($this->obj_id)
950  {
951  $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
952  }
953 
954  // Validate
956  $parser->startParsing();
957 
958  // Insert
959  $parser->setMode(ilAdvancedMDRecordParser::MODE_INSERT);
960  $parser->startParsing();
961  ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'), true);
962  $this->ctrl->redirect($this, "showRecords");
963  }
964  catch(ilSAXParserException $exc)
965  {
966  ilUtil::sendFailure($exc->getMessage(), true);
967  $this->ctrl->redirect($this, "importRecords");
968  }
969 
970  // Finally delete import file
971  $import_files->deleteFileByCreationDate($create_time);
972  return true;
973  }
974 
975 
983  public function saveRecord()
984  {
985  global $ilErr;
986 
987  $this->initRecordObject();
988  $this->loadRecordFormData();
989 
990  if($this->obj_type)
991  {
992  $this->record->setAssignedObjectTypes(array(
993  array(
994  "obj_type"=>$this->obj_type,
995  "sub_type"=>$this->sub_type,
996  "optional"=>false
997  )));
998  }
999 
1000  if(!$this->record->validate())
1001  {
1002  ilUtil::sendFailure($this->lng->txt($ilErr->getMessage()));
1003  $this->createRecord();
1004  return false;
1005  }
1006  $this->record->save();
1007 
1008  ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'));
1009  $this->showRecords();
1010  }
1011 
1018  public function editField(ilPropertyFormGUI $a_form = null)
1019  {
1020  if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1021  {
1022  return $this->editFields();
1023  }
1024 
1025  $this->ctrl->saveParameter($this,'record_id');
1026  $this->ctrl->saveParameter($this,'field_id');
1027 
1028  if(!$a_form)
1029  {
1030  $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1031  $a_form = $this->initFieldForm($field_definition);
1032  }
1033  $this->tpl->setContent($a_form->getHTML());
1034  }
1035 
1042  public function updateField()
1043  {
1044  global $ilErr;
1045 
1046  if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1047  {
1048  return $this->editFields();
1049  }
1050 
1051  $this->ctrl->saveParameter($this,'record_id');
1052  $this->ctrl->saveParameter($this,'field_id');
1053 
1054  $confirm = false;
1055  $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1056  $form = $this->initFieldForm($field_definition);
1057  if($form->checkInput())
1058  {
1059  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1060  if(!$field_definition->importDefinitionFormPostValuesNeedsConfirmation())
1061  {
1062  $field_definition->update();
1063 
1064  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1065  $this->ctrl->redirect($this, "editFields");
1066  }
1067  else
1068  {
1069  $confirm = true;
1070  }
1071  }
1072 
1073  $form->setValuesByPost();
1074 
1075  // fields needs confirmation of updated settings
1076  if($confirm)
1077  {
1078  ilUtil::sendInfo($this->lng->txt("md_adv_confirm_definition"));
1079  $field_definition->prepareDefinitionFormConfirmation($form);
1080  }
1081 
1082  $this->editField($form);
1083  }
1084 
1091  public function createField(ilPropertyFormGUI $a_form = null)
1092  {
1093 
1094  if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1095  {
1096  return $this->editFields();
1097  }
1098 
1099  $this->ctrl->saveParameter($this,'record_id');
1100  $this->ctrl->saveParameter($this,'ftype');
1101 
1102  if(!$a_form)
1103  {
1104  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1105  $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1106  $field_definition->setRecordId($_REQUEST["record_id"]);
1107  $a_form = $this->initFieldForm($field_definition);
1108  }
1109  $this->tpl->setContent($a_form->getHTML());
1110  }
1111 
1117  public function saveField()
1118  {
1119  global $ilErr;
1120 
1121  if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1122  {
1123  return $this->editFields();
1124  }
1125 
1126  $this->ctrl->saveParameter($this,'record_id');
1127  $this->ctrl->saveParameter($this,'ftype');
1128 
1129  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1130  $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1131  $field_definition->setRecordId($_REQUEST["record_id"]);
1132  $form = $this->initFieldForm($field_definition);
1133 
1134  if($form->checkInput())
1135  {
1136  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1137  $field_definition->save();
1138 
1139  ilUtil::sendSuccess($this->lng->txt('save_settings'), true);
1140  $this->ctrl->redirect($this, "editFields");
1141  }
1142 
1143  $form->setValuesByPost();
1144  $this->createField($form);
1145  }
1146 
1152  protected function initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
1153  {
1154  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1155 
1156  $form = new ilPropertyFormGUI();
1157  $form->setFormAction($this->ctrl->getFormAction($this));
1158 
1159  $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1160  $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1161  $form->addItem($type);
1162 
1163  $a_definition->addToFieldDefinitionForm($form, $this->getPermissions());
1164 
1165  if(!$a_definition->getFieldId())
1166  {
1167  $form->setTitle($this->lng->txt('md_adv_create_field'));
1168  $form->addCommandButton('saveField',$this->lng->txt('create'));
1169  }
1170  else
1171  {
1172  $form->setTitle($this->lng->txt('md_adv_edit_field'));
1173  $form->addCommandButton('updateField',$this->lng->txt('save'));
1174  }
1175 
1176  $form->addCommandButton('editFields',$this->lng->txt('cancel'));
1177 
1178  return $form;
1179  }
1180 
1186  protected function initForm($a_mode)
1187  {
1188  if(is_object($this->form))
1189  {
1190  return true;
1191  }
1192 
1193  $perm = $this->getPermissions()->hasPermissions(
1195  $this->record->getRecordId(),
1196  array(
1204  ));
1205 
1206  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1207 
1208  $this->form = new ilPropertyFormGUI();
1209  $this->form->setFormAction($this->ctrl->getFormAction($this));
1210 
1211 
1212  // title
1213  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1214  $title->setValue($this->record->getTitle());
1215  $title->setSize(20);
1216  $title->setMaxLength(70);
1217  $title->setRequired(true);
1218  $this->form->addItem($title);
1219 
1221  {
1222  $title->setDisabled(true);
1223  }
1224 
1225  // desc
1226  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
1227  $desc->setValue($this->record->getDescription());
1228  $desc->setRows(3);
1229  $desc->setCols(50);
1230  $this->form->addItem($desc);
1231 
1233  {
1234  $desc->setDisabled(true);
1235  }
1236 
1237  // active
1238  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'),'active');
1239  $check->setChecked($this->record->isActive());
1240  $check->setValue(1);
1241  $this->form->addItem($check);
1242 
1244  {
1245  $check->setDisabled(true);
1246  }
1247 
1248  if(!$this->obj_type)
1249  {
1251  $section->setTitle($this->lng->txt('md_obj_types'));
1252  $this->form->addItem($section);
1253 
1254  // see ilAdvancedMDRecordTableGUI::fillRow()
1255  $options = array(
1256  0 => $this->lng->txt("meta_obj_type_inactive"),
1257  1 => $this->lng->txt("meta_obj_type_mandatory"),
1258  2 => $this->lng->txt("meta_obj_type_optional")
1259  );
1260 
1261 
1262  foreach(ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type)
1263  {
1264  $t = $type["obj_type"].":".$type["sub_type"];
1265  $this->lng->loadLanguageModule($type["obj_type"]);
1266 
1267  $type_options = $options;
1268  switch($type["obj_type"])
1269  {
1270  case "orgu":
1271  // currently only optional records for org unit (types)
1272  unset($type_options[1]);
1273  break;
1274  case "prg":
1275  // currently only optional records for study programme (types)
1276  unset($type_options[1]);
1277  break;
1278  case "rcrs":
1279  // optional makes no sense for ecs-courses
1280  unset($type_options[2]);
1281  break;
1282  }
1283 
1284  $value = 0;
1285  if($a_mode == "edit")
1286  {
1287  foreach($this->record->getAssignedObjectTypes() as $item)
1288  {
1289  if($item["obj_type"] == $type["obj_type"] &&
1290  $item["sub_type"] == $type["sub_type"])
1291  {
1292  $value = $item["optional"]
1293  ? 2
1294  : 1;
1295  }
1296  }
1297  }
1298 
1299  $check = new ilSelectInputGUI($type["text"],'obj_types['.$t.']');
1300  $check->setOptions($type_options);
1301  $check->setValue($value);
1302  $this->form->addItem($check);
1303 
1305  {
1306  $check->setDisabled(true);
1307  }
1308  }
1309  }
1310 
1311  switch($a_mode)
1312  {
1313  case 'create':
1314  $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1315  $this->form->addCommandButton('saveRecord',$this->lng->txt('add'));
1316  $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1317 
1318  return true;
1319 
1320  case 'edit':
1321  $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1322  $this->form->addCommandButton('updateRecord',$this->lng->txt('save'));
1323  $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1324 
1325  return true;
1326  }
1327  }
1328 
1329  protected function getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
1330  {
1331  if($a_obj_type == "crs")
1332  {
1333  $perm = $this->getPermissions()->hasPermissions(
1335  $a_field_id,
1336  array(
1342  ));
1343  return array(
1347  );
1348  }
1349  else if($a_obj_type == "cat")
1350  {
1351  $perm = $this->getPermissions()->hasPermissions(
1353  $a_field_id,
1354  array(
1360  ));
1361  return array(
1365  );
1366  }
1367  }
1368 
1374  protected function initFormSubstitutions()
1375  {
1376  global $ilAccess;
1377 
1378  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1379 
1380  if(!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType())
1381  {
1382  return;
1383  }
1384 
1385  $this->form = new ilPropertyFormGUI();
1386  $this->form->setFormAction($this->ctrl->getFormAction($this));
1387  #$this->form->setTableWidth('100%');
1388 
1389  // substitution
1390  foreach($visible_records as $obj_type => $records)
1391  {
1392  $perm = null;
1393  // :TODO: hardwird ?
1394  if(in_array($obj_type, array("crs", "cat")))
1395  {
1396  $perm = $this->getPermissions()->hasPermissions(
1398  $obj_type,
1399  array(
1403  ));
1404  }
1405 
1406  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
1408 
1409  // Show section
1411  $section->setTitle($this->lng->txt('objs_'.$obj_type));
1412  $this->form->addItem($section);
1413 
1414  $check = new ilCheckboxInputGUI($this->lng->txt('description'),'enabled_desc_'.$obj_type);
1415  $check->setValue(1);
1416  $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1417  $check->setChecked($sub->isDescriptionEnabled() ? true : false);
1418  $this->form->addItem($check);
1419 
1421  {
1422  $check->setDisabled(true);
1423  }
1424 
1425  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'),'enabled_field_names_'.$obj_type);
1426  $check->setValue(1);
1427  $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1428  $check->setChecked($sub->enabledFieldNames() ? true : false);
1429  $this->form->addItem($check);
1430 
1432  {
1433  $check->setDisabled(true);
1434  }
1435 
1436  #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1437  #$area->setUseRte(true);
1438  #$area->setRteTagSet('standard');
1439  #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1440  #$area->setRows(5);
1441  #$area->setCols(80);
1442  #$this->form->addItem($area);
1443 
1444  if($perm)
1445  {
1447  }
1448 
1450  $definitions = $sub->sortDefinitions($definitions);
1451 
1452  $counter = 1;
1453  foreach($definitions as $def)
1454  {
1455  $definition_id = $def->getFieldId();
1456 
1457  $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1458 
1459  $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId());
1460  $title = $def->getTitle().' ('.$title.')';
1461 
1462  $check = new ilCheckboxInputGUI($title,'show['.$obj_type.']['.$definition_id.']');
1463  $check->setValue(1);
1464  $check->setOptionTitle($this->lng->txt('md_adv_show'));
1465  $check->setChecked($sub->isSubstituted($definition_id));
1466 
1467  if($perm && !$perm["show"])
1468  {
1469  $check->setDisabled(true);
1470  }
1471 
1472  $pos = new ilNumberInputGUI($this->lng->txt('position'),'position['.$obj_type.']['.$definition_id.']');
1473  $pos->setSize(3);
1474  $pos->setMaxLength(4);
1475  $pos->allowDecimals(true);
1476  $pos->setValue(sprintf('%.1f',$counter++));
1477  $check->addSubItem($pos);
1478 
1479  if($perm && !$perm_pos)
1480  {
1481  $pos->setDisabled(true);
1482  }
1483 
1484  $bold = new ilCheckboxInputGUI($this->lng->txt('bold'),'bold['.$obj_type.']['.$definition_id.']');
1485  $bold->setValue(1);
1486  $bold->setChecked($sub->isBold($definition_id));
1487  $check->addSubItem($bold);
1488 
1489  if($perm && !$perm["bold"])
1490  {
1491  $bold->setDisabled(true);
1492  }
1493 
1494  $bold = new ilCheckboxInputGUI($this->lng->txt('newline'),'newline['.$obj_type.']['.$definition_id.']');
1495  $bold->setValue(1);
1496  $bold->setChecked($sub->hasNewline($definition_id));
1497  $check->addSubItem($bold);
1498 
1499  if($perm && !$perm["newline"])
1500  {
1501  $bold->setDisabled(true);
1502  }
1503 
1504 
1505  $this->form->addItem($check);
1506  }
1507 
1508 
1509  // placeholder
1510  /*
1511  $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders'));
1512  $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData');
1513  foreach($records as $record)
1514  {
1515  foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition)
1516  {
1517  $tpl->setCurrentBlock('field');
1518  $tpl->setVariable('FIELD_NAME',$definition->getTitle());
1519  $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'.
1520  '[/IF_F_'.$definition->getFieldId().']');
1521  $tpl->parseCurrentBlock();
1522  }
1523 
1524  $tpl->setCurrentBlock('record');
1525  $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for'));
1526  $tpl->setVariable('TITLE',$record->getTitle());
1527  $tpl->parseCurrentBlock();
1528  }
1529  $custom->setHTML($tpl->get());
1530  $this->form->addItem($custom);
1531  */
1532  }
1533  $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1534 
1535  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
1536  {
1537  $this->form->addCommandButton('updateSubstitutions',$this->lng->txt('save'));
1538  }
1539 
1540  return true;
1541  }
1542 
1548  protected function loadRecordFormData()
1549  {
1550  $perm = $this->getPermissions()->hasPermissions(
1552  $this->record->getRecordId(),
1553  array(
1561  ));
1562 
1564  {
1565  $this->record->setActive(ilUtil::stripSlashes($_POST['active']));
1566  }
1568  {
1569  $this->record->setTitle(ilUtil::stripSlashes($_POST['title']));
1570  }
1572  {
1573  $this->record->setDescription(ilUtil::stripSlashes($_POST['desc']));
1574  }
1575 
1576  if(!$this->obj_type)
1577  {
1579  {
1580  $obj_types = array();
1581  if (is_array($_POST['obj_types']))
1582  {
1583  foreach ($_POST['obj_types'] as $t => $value)
1584  {
1585  if($value)
1586  {
1587  $t = explode(":", $t);
1588  $obj_types[] = array(
1589  "obj_type" => ilUtil::stripSlashes($t[0]),
1590  "sub_type" => ilUtil::stripSlashes($t[1]),
1591  "optional" => ($value > 1)
1592  );
1593  }
1594  }
1595  }
1596  $this->record->setAssignedObjectTypes($obj_types);
1597  }
1598  }
1599  }
1600 
1606  protected function initRecordObject()
1607  {
1608  if(!is_object($this->record))
1609  {
1610  $record_id = isset($_GET['record_id'])
1611  ? $_GET['record_id']
1612  : 0;
1613  $this->record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
1614 
1615  // bind to parent object (aka local adv md)
1616  if(!$record_id &&
1617  $this->obj_id)
1618  {
1619  $this->record->setParentObject($this->obj_id);
1620  }
1621  }
1622 
1623  return $this->record;
1624  }
1625 
1631  protected function setSubTabs()
1632  {
1633  $this->tabs_gui->clearSubTabs();
1634 
1635  $this->tabs_gui->addSubTabTarget("md_adv_record_list",
1636  $this->ctrl->getLinkTarget($this, "showRecords"),
1637  '',
1638  '',
1639  '',
1640  true);
1641 
1642 
1644  {
1645  $this->tabs_gui->addSubTabTarget("md_adv_presentation",
1646  $this->ctrl->getLinkTarget($this, "showPresentation"));
1647  }
1648 
1649  $this->tabs_gui->addSubTabTarget("md_adv_file_list",
1650  $this->ctrl->getLinkTarget($this, "showFiles"),
1651  "showFiles");
1652  }
1653 
1659  protected function getParsedRecordObjects()
1660  {
1661  $res = array();
1662 
1663  if($this->obj_type)
1664  {
1665  $selected = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $this->sub_type);
1666  }
1667 
1668  foreach(ilAdvancedMDRecord::_getRecords() as $record)
1669  {
1670  $parent_id = $record->getParentObject();
1671 
1672  if(!$this->obj_type)
1673  {
1674  if($parent_id)
1675  {
1676  continue;
1677  }
1678  }
1679  else
1680  {
1681  // matching parent object?
1682  if($parent_id &&
1683  $parent_id != $this->obj_id)
1684  {
1685  continue;
1686  }
1687 
1688  // only globally activated records for object context
1689  if(!$parent_id &&
1690  !$record->isActive())
1691  {
1692  continue;
1693  }
1694  }
1695 
1696  $tmp_arr = array();
1697  $tmp_arr['id'] = $record->getRecordId();
1698  $tmp_arr['active'] = $record->isActive();
1699  $tmp_arr['title'] = $record->getTitle();
1700  $tmp_arr['description'] = $record->getDescription();
1701  $tmp_arr['fields'] = array();
1702  $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
1703 
1704  $tmp_arr['perm'] = $this->permissions->hasPermissions(
1706  $record->getRecordId(),
1707  array(
1713  ));
1714 
1715  if($this->obj_type)
1716  {
1717  $tmp_arr["readonly"] = !(bool)$parent_id;
1718  $tmp_arr["local"] = $parent_id;
1719 
1720  // local records are never optional
1721  $assigned = $optional = false;
1722  foreach($tmp_arr['obj_types'] as $idx => $item)
1723  {
1724  if($item["obj_type"] == $this->obj_type &&
1725  $item["sub_type"] == $this->sub_type)
1726  {
1727  $assigned = true;
1728  $optional = $item["optional"];
1729  $tmp_arr['obj_types'][$idx]['context'] = true;
1730  break;
1731  }
1732  }
1733  if(!$assigned)
1734  {
1735  continue;
1736  }
1737  $tmp_arr['optional'] = $optional;
1738  if($optional)
1739  {
1740  // in object context "active" means selected record
1741  $tmp_arr['active'] = in_array($record->getRecordId(), $selected);
1742  }
1743  }
1744 
1745  $res[] = $tmp_arr;
1746  }
1747 
1748  return $res;
1749  }
1750 
1751 }
1752 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
print $file
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
$_POST['username']
Definition: cron.php:12
This class represents a selection list property in a property form.
static _getRecords()
Get records.
This class represents a property form user interface.
deleteRecords()
Permanently delete records.
$_GET["client_id"]
updateRecords()
Save records (assigned object typed)
This class represents a section header in a property form.
This class represents a file property in a property form.
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
$cmd
Definition: sahs_server.php:35
setValue($a_value)
Set Value.
This class represents a checkbox property in a property form.
getParsedRecordObjects()
Get and cache record objects.
$records
Definition: simple_test.php:17
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:84
setChecked($a_checked)
Set Checked.
$info
Definition: example_052.php:80
confirmDeleteFiles()
confirm delete files
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
if(!is_array($argv)) $options
This class represents a number property in a property form.
static getInstancesByObjType($a_obj_type, $a_active_only=true)
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Add input elements to definition form.
setValue($a_value)
Set Value.
This class represents a text property in a property form.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! public.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static _lookupTitle($a_record_id)
Lookup title.
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.
static getValidTypes()
Get all valid types.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
editField(ilPropertyFormGUI $a_form=null)
Edit field.
setContext($a_obj_id, $a_obj_type, $a_sub_type=null)
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
updateSubstitutions()
Update substitution.
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
initFormSubstitutions()
init form table &#39;substitutions&#39;
static _getActivatedObjTypes()
get activated obj types
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
SAX based XML parser for record import files.
setValue($a_value)
Set Value.
__construct($a_obj_id=null, $a_obj_type=null, $a_sub_type=null)
Constructor.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
loadRecordFormData()
load record form data
confirmDeleteFields()
show delete fields confirmation screen
Confirmation screen class.