ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAdvancedMDSettingsGUI Class Reference
+ Collaboration diagram for ilAdvancedMDSettingsGUI:

Public Member Functions

 __construct ($a_obj_id=null, $a_obj_type=null, $a_sub_type=null)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 showRecords ()
 show record list More...
 
 showPresentation ()
 
 updateSubstitutions ()
 Update substitution. More...
 
 exportRecords ()
 Export records. More...
 
 showFiles ()
 show export files More...
 
 downloadFile ()
 Download XML file. More...
 
 confirmDeleteFiles ()
 confirm delete files More...
 
 deleteFiles ()
 Delete files. More...
 
 confirmDeleteRecords ()
 Confirm delete. More...
 
 deleteRecords ()
 Permanently delete records. More...
 
 updateRecords ()
 Save records (assigned object typed) More...
 
 confirmDeleteFields ()
 show delete fields confirmation screen More...
 
 deleteFields ()
 delete fields More...
 
 editRecord ()
 Edit one record. More...
 
 editFields ()
 
 updateFields ()
 Update fields. More...
 
 updateRecord ()
 Update record. More...
 
 createRecord ()
 Show. More...
 
 importRecords ()
 
 importRecord ()
 import xml file More...
 
 saveRecord ()
 Save record. More...
 
 editField (ilPropertyFormGUI $a_form=null)
 Edit field. More...
 
 updateField ()
 Update field. More...
 
 createField (ilPropertyFormGUI $a_form=null)
 Show field type selection. More...
 
 saveField ()
 create field More...
 

Protected Member Functions

 getPermissions ()
 
 initImportForm ()
 show import form More...
 
 initFieldForm (ilAdvancedMDFieldDefinition $a_definition)
 init field form More...
 
 initForm ($a_mode)
 Init Form. More...
 
 getSubstitutionFieldPermissions ($a_obj_type, $a_field_id)
 
 initFormSubstitutions ()
 init form table 'substitutions' More...
 
 loadRecordFormData ()
 load record form data More...
 
 initRecordObject ()
 Init record object. More...
 
 setSubTabs ()
 Set sub tabs. More...
 
 getParsedRecordObjects ()
 Get and cache record objects. More...
 

Protected Attributes

 $lng
 
 $tpl
 
 $ctrl
 
 $tabs
 
 $permissions
 
 $obj_id
 
 $obj_type
 
 $sub_type
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDSettingsGUI::__construct (   $a_obj_id = null,
  $a_obj_type = null,
  $a_sub_type = null 
)

Constructor.

public

Definition at line 33 of file class.ilAdvancedMDSettingsGUI.php.

References $ilCtrl, $lng, $tpl, ilObject\_lookupType(), and ilClaimingPermissionHelper\getInstance().

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  }
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
global $ilCtrl
Definition: ilias.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteFields()

ilAdvancedMDSettingsGUI::confirmDeleteFields ( )

show delete fields confirmation screen

public

Definition at line 617 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, editFields(), ilAdvancedMDFieldDefinition\getInstance(), and ilUtil\sendFailure().

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  }
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ confirmDeleteFiles()

ilAdvancedMDSettingsGUI::confirmDeleteFiles ( )

confirm delete files

public

Definition at line 386 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, $files, $info, ilUtil\sendFailure(), and showFiles().

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  }
$files
Definition: add-vimline.php:18
$info
Definition: example_052.php:80
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ confirmDeleteRecords()

ilAdvancedMDSettingsGUI::confirmDeleteRecords ( )

Confirm delete.

public

Definition at line 451 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilUtil\sendFailure(), and showRecords().

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  }
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ createField()

ilAdvancedMDSettingsGUI::createField ( ilPropertyFormGUI  $a_form = null)

Show field type selection.

public

Definition at line 1085 of file class.ilAdvancedMDSettingsGUI.php.

References editFields(), ilAdvancedMDFieldDefinition\getInstance(), and initFieldForm().

Referenced by saveField().

1086  {
1087 
1088  if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1089  {
1090  return $this->editFields();
1091  }
1092 
1093  $this->ctrl->saveParameter($this,'record_id');
1094  $this->ctrl->saveParameter($this,'ftype');
1095 
1096  if(!$a_form)
1097  {
1098  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1099  $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1100  $field_definition->setRecordId($_REQUEST["record_id"]);
1101  $a_form = $this->initFieldForm($field_definition);
1102  }
1103  $this->tpl->setContent($a_form->getHTML());
1104  }
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createRecord()

ilAdvancedMDSettingsGUI::createRecord ( )

Show.

public

Parameters

Definition at line 873 of file class.ilAdvancedMDSettingsGUI.php.

References initForm(), and initRecordObject().

Referenced by importRecord(), and saveRecord().

874  {
875  $this->initRecordObject();
876  $this->initForm('create');
877  $this->tpl->setContent($this->form->getHTML());
878  return true;
879  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFields()

ilAdvancedMDSettingsGUI::deleteFields ( )

delete fields

public

Parameters

Definition at line 653 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, ilAdvancedMDPermissionHelper\ACTION_FIELD_DELETE, array, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteFiles()

ilAdvancedMDSettingsGUI::deleteFiles ( )

Delete files.

public

Parameters

Definition at line 425 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, $files, ilUtil\sendFailure(), ilUtil\sendSuccess(), and showFiles().

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  }
$files
Definition: add-vimline.php:18
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteRecords()

ilAdvancedMDSettingsGUI::deleteRecords ( )

Permanently delete records.

public

Definition at line 484 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_DELETE, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ downloadFile()

ilAdvancedMDSettingsGUI::downloadFile ( )

Download XML file.

public

Parameters

Definition at line 364 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, $files, ilUtil\deliverFile(), ilUtil\sendFailure(), and showFiles().

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  }
$files
Definition: add-vimline.php:18
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ editField()

ilAdvancedMDSettingsGUI::editField ( ilPropertyFormGUI  $a_form = null)

Edit field.

public

Definition at line 1014 of file class.ilAdvancedMDSettingsGUI.php.

References editFields(), ilAdvancedMDFieldDefinition\getInstance(), and initFieldForm().

Referenced by updateField().

1015  {
1016  if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1017  {
1018  return $this->editFields();
1019  }
1020 
1021  $this->ctrl->saveParameter($this,'record_id');
1022  $this->ctrl->saveParameter($this,'field_id');
1023 
1024  if(!$a_form)
1025  {
1026  $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1027  $a_form = $this->initFieldForm($field_definition);
1028  }
1029  $this->tpl->setContent($a_form->getHTML());
1030  }
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editFields()

ilAdvancedMDSettingsGUI::editFields ( )

Definition at line 708 of file class.ilAdvancedMDSettingsGUI.php.

References $options, ilAdvancedMDPermissionHelper\ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilSubmitButton\getInstance(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), ilAdvancedMDFieldDefinition\getValidTypes(), initRecordObject(), and ilUtil\sendInfo().

Referenced by confirmDeleteFields(), createField(), deleteFields(), editField(), saveField(), updateField(), and updateFields().

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  }
This class represents a selection list property in a property form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
if(!is_array($argv)) $options
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
static getValidTypes()
Get all valid types.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editRecord()

ilAdvancedMDSettingsGUI::editRecord ( )

Edit one record.

public

Parameters

Definition at line 699 of file class.ilAdvancedMDSettingsGUI.php.

References initForm(), and initRecordObject().

Referenced by updateRecord().

700  {
701  $this->ctrl->saveParameter($this,'record_id');
702  $this->initRecordObject();
703  $this->initForm('edit');
704  $this->tpl->setContent($this->form->getHTML());
705 
706  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilAdvancedMDSettingsGUI::executeCommand ( )

Execute command.

public

Parameters

Definition at line 70 of file class.ilAdvancedMDSettingsGUI.php.

References $cmd, and setSubTabs().

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  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ exportRecords()

ilAdvancedMDSettingsGUI::exportRecords ( )

Export records.

public

Definition at line 290 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EXPORT, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), showFiles(), and showRecords().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ getParsedRecordObjects()

ilAdvancedMDSettingsGUI::getParsedRecordObjects ( )
protected

Get and cache record objects.

protected

Definition at line 1651 of file class.ilAdvancedMDSettingsGUI.php.

References $res, ilAdvancedMDRecord\_getRecords(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_FIELDS, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDRecord\getObjRecSelection(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

Referenced by showRecords(), and updateRecords().

1652  {
1653  $res = array();
1654 
1655  if($this->obj_type)
1656  {
1657  $selected = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $this->sub_type);
1658  }
1659 
1660  foreach(ilAdvancedMDRecord::_getRecords() as $record)
1661  {
1662  $parent_id = $record->getParentObject();
1663 
1664  if(!$this->obj_type)
1665  {
1666  if($parent_id)
1667  {
1668  continue;
1669  }
1670  }
1671  else
1672  {
1673  // matching parent object?
1674  if($parent_id &&
1675  $parent_id != $this->obj_id)
1676  {
1677  continue;
1678  }
1679 
1680  // only globally activated records for object context
1681  if(!$parent_id &&
1682  !$record->isActive())
1683  {
1684  continue;
1685  }
1686  }
1687 
1688  $tmp_arr = array();
1689  $tmp_arr['id'] = $record->getRecordId();
1690  $tmp_arr['active'] = $record->isActive();
1691  $tmp_arr['title'] = $record->getTitle();
1692  $tmp_arr['description'] = $record->getDescription();
1693  $tmp_arr['fields'] = array();
1694  $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
1695 
1696  $tmp_arr['perm'] = $this->permissions->hasPermissions(
1698  $record->getRecordId(),
1699  array(
1705  ));
1706 
1707  if($this->obj_type)
1708  {
1709  $tmp_arr["readonly"] = !(bool)$parent_id;
1710  $tmp_arr["local"] = $parent_id;
1711 
1712  // local records are never optional
1713  $assigned = $optional = false;
1714  foreach($tmp_arr['obj_types'] as $idx => $item)
1715  {
1716  if($item["obj_type"] == $this->obj_type &&
1717  $item["sub_type"] == $this->sub_type)
1718  {
1719  $assigned = true;
1720  $optional = $item["optional"];
1721  $tmp_arr['obj_types'][$idx]['context'] = true;
1722  break;
1723  }
1724  }
1725  if(!$assigned)
1726  {
1727  continue;
1728  }
1729  $tmp_arr['optional'] = $optional;
1730  if($optional)
1731  {
1732  // in object context "active" means selected record
1733  $tmp_arr['active'] = in_array($record->getRecordId(), $selected);
1734  }
1735  }
1736 
1737  $res[] = $tmp_arr;
1738  }
1739 
1740  return $res;
1741  }
static _getRecords()
Get records.
Create styles array
The data for the language used.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPermissions()

◆ getSubstitutionFieldPermissions()

ilAdvancedMDSettingsGUI::getSubstitutionFieldPermissions (   $a_obj_type,
  $a_field_id 
)
protected

Definition at line 1321 of file class.ilAdvancedMDSettingsGUI.php.

References ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_SHOW_FIELD, array, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_CATEGORY, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_COURSE, getPermissions(), ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_BOLD, and ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_NEWLINE.

Referenced by initFormSubstitutions(), and updateSubstitutions().

1322  {
1323  if($a_obj_type == "crs")
1324  {
1325  $perm = $this->getPermissions()->hasPermissions(
1327  $a_field_id,
1328  array(
1334  ));
1335  return array(
1339  );
1340  }
1341  else if($a_obj_type == "cat")
1342  {
1343  $perm = $this->getPermissions()->hasPermissions(
1345  $a_field_id,
1346  array(
1352  ));
1353  return array(
1357  );
1358  }
1359  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importRecord()

ilAdvancedMDSettingsGUI::importRecord ( )

import xml file

public

Parameters

Definition at line 923 of file class.ilAdvancedMDSettingsGUI.php.

References $parser, createRecord(), initImportForm(), ilAdvancedMDRecordParser\MODE_INSERT, ilAdvancedMDRecordParser\MODE_INSERT_VALIDATION, ilUtil\sendFailure(), and ilUtil\sendSuccess().

924  {
925  $this->initImportForm();
926  if(!$this->import_form->checkInput())
927  {
928  $this->import_form->setValuesByPost();
929  $this->createRecord();
930  return false;
931  }
932 
933  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
934  $import_files = new ilAdvancedMDRecordImportFiles();
935  if(!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name']))
936  {
937  $this->createRecord();
938  return false;
939  }
940 
941  try
942  {
943  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
944  $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
945 
946  // local import?
947  if($this->obj_id)
948  {
949  $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
950  }
951 
952  // Validate
954  $parser->startParsing();
955 
956  // Insert
958  $parser->startParsing();
959  ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'), true);
960  $this->ctrl->redirect($this, "showRecords");
961  }
962  catch(ilSAXParserException $exc)
963  {
964  ilUtil::sendFailure($exc->getMessage(), true);
965  $this->ctrl->redirect($this, "importRecords");
966  }
967 
968  // Finally delete import file
969  $import_files->deleteFileByCreationDate($create_time);
970  return true;
971  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$parser
Definition: BPMN2Parser.php:24
SAX based XML parser for record import files.
+ Here is the call graph for this function:

◆ importRecords()

ilAdvancedMDSettingsGUI::importRecords ( )

Definition at line 881 of file class.ilAdvancedMDSettingsGUI.php.

References initImportForm().

882  {
883  // Import Table
884  $this->initImportForm();
885  $this->tpl->setContent($this->import_form->getHTML());
886  }
+ Here is the call graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

init field form

protected

Definition at line 1144 of file class.ilAdvancedMDSettingsGUI.php.

References ilAdvancedMDFieldDefinition\addToFieldDefinitionForm(), ilAdvancedMDFieldDefinition\getFieldId(), getPermissions(), ilAdvancedMDFieldDefinition\getTypeTitle(), and ilNonEditableValueGUI\setValue().

Referenced by createField(), editField(), saveField(), and updateField().

1145  {
1146  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1147 
1148  $form = new ilPropertyFormGUI();
1149  $form->setFormAction($this->ctrl->getFormAction($this));
1150 
1151  $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1152  $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1153  $form->addItem($type);
1154 
1155  $a_definition->addToFieldDefinitionForm($form, $this->getPermissions());
1156 
1157  if(!$a_definition->getFieldId())
1158  {
1159  $form->setTitle($this->lng->txt('md_adv_create_field'));
1160  $form->addCommandButton('saveField',$this->lng->txt('create'));
1161  }
1162  else
1163  {
1164  $form->setTitle($this->lng->txt('md_adv_edit_field'));
1165  $form->addCommandButton('updateField',$this->lng->txt('save'));
1166  }
1167 
1168  $form->addCommandButton('editFields',$this->lng->txt('cancel'));
1169 
1170  return $form;
1171  }
This class represents a property form user interface.
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Add input elements to definition form.
This class represents a non editable value in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilAdvancedMDSettingsGUI::initForm (   $a_mode)
protected

Init Form.

protected

Definition at line 1178 of file class.ilAdvancedMDSettingsGUI.php.

References $options, $section, $t, $title, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilCheckboxInputGUI\setChecked(), ilTextAreaInputGUI\setValue(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

Referenced by createRecord(), and editRecord().

1179  {
1180  if(is_object($this->form))
1181  {
1182  return true;
1183  }
1184 
1185  $perm = $this->getPermissions()->hasPermissions(
1187  $this->record->getRecordId(),
1188  array(
1196  ));
1197 
1198  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1199 
1200  $this->form = new ilPropertyFormGUI();
1201  $this->form->setFormAction($this->ctrl->getFormAction($this));
1202 
1203 
1204  // title
1205  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1206  $title->setValue($this->record->getTitle());
1207  $title->setSize(20);
1208  $title->setMaxLength(70);
1209  $title->setRequired(true);
1210  $this->form->addItem($title);
1211 
1213  {
1214  $title->setDisabled(true);
1215  }
1216 
1217  // desc
1218  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
1219  $desc->setValue($this->record->getDescription());
1220  $desc->setRows(3);
1221  $desc->setCols(50);
1222  $this->form->addItem($desc);
1223 
1225  {
1226  $desc->setDisabled(true);
1227  }
1228 
1229  // active
1230  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'),'active');
1231  $check->setChecked($this->record->isActive());
1232  $check->setValue(1);
1233  $this->form->addItem($check);
1234 
1236  {
1237  $check->setDisabled(true);
1238  }
1239 
1240  if(!$this->obj_type)
1241  {
1243  $section->setTitle($this->lng->txt('md_obj_types'));
1244  $this->form->addItem($section);
1245 
1246  // see ilAdvancedMDRecordTableGUI::fillRow()
1247  $options = array(
1248  0 => $this->lng->txt("meta_obj_type_inactive"),
1249  1 => $this->lng->txt("meta_obj_type_mandatory"),
1250  2 => $this->lng->txt("meta_obj_type_optional")
1251  );
1252 
1253 
1254  foreach(ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type)
1255  {
1256  $t = $type["obj_type"].":".$type["sub_type"];
1257  $this->lng->loadLanguageModule($type["obj_type"]);
1258 
1259  $type_options = $options;
1260  switch($type["obj_type"])
1261  {
1262  case "orgu":
1263  // currently only optional records for org unit (types)
1264  unset($type_options[1]);
1265  break;
1266  case "prg":
1267  // currently only optional records for study programme (types)
1268  unset($type_options[1]);
1269  break;
1270  case "rcrs":
1271  // optional makes no sense for ecs-courses
1272  unset($type_options[2]);
1273  break;
1274  }
1275 
1276  $value = 0;
1277  if($a_mode == "edit")
1278  {
1279  foreach($this->record->getAssignedObjectTypes() as $item)
1280  {
1281  if($item["obj_type"] == $type["obj_type"] &&
1282  $item["sub_type"] == $type["sub_type"])
1283  {
1284  $value = $item["optional"]
1285  ? 2
1286  : 1;
1287  }
1288  }
1289  }
1290 
1291  $check = new ilSelectInputGUI($type["text"],'obj_types['.$t.']');
1292  $check->setOptions($type_options);
1293  $check->setValue($value);
1294  $this->form->addItem($check);
1295 
1297  {
1298  $check->setDisabled(true);
1299  }
1300  }
1301  }
1302 
1303  switch($a_mode)
1304  {
1305  case 'create':
1306  $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1307  $this->form->addCommandButton('saveRecord',$this->lng->txt('add'));
1308  $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1309 
1310  return true;
1311 
1312  case 'edit':
1313  $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1314  $this->form->addCommandButton('updateRecord',$this->lng->txt('save'));
1315  $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1316 
1317  return true;
1318  }
1319  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
This class represents a section header in a property form.
setValue($a_value)
Set Value.
This class represents a checkbox property in a property form.
$section
Definition: Utf8Test.php:83
setChecked($a_checked)
Set Checked.
if(!is_array($argv)) $options
This class represents a text property in a property form.
Create styles array
The data for the language used.
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormSubstitutions()

ilAdvancedMDSettingsGUI::initFormSubstitutions ( )
protected

init form table 'substitutions'

protected

Definition at line 1366 of file class.ilAdvancedMDSettingsGUI.php.

References $counter, $obj_type, $records, $section, $title, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDRecord\_lookupTitle(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, array, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), getSubstitutionFieldPermissions(), and ilCheckboxInputGUI\setValue().

Referenced by showPresentation().

1367  {
1368  global $ilAccess;
1369 
1370  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1371 
1372  if(!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType())
1373  {
1374  return;
1375  }
1376 
1377  $this->form = new ilPropertyFormGUI();
1378  $this->form->setFormAction($this->ctrl->getFormAction($this));
1379  #$this->form->setTableWidth('100%');
1380 
1381  // substitution
1382  foreach($visible_records as $obj_type => $records)
1383  {
1384  $perm = null;
1385  // :TODO: hardwird ?
1386  if(in_array($obj_type, array("crs", "cat")))
1387  {
1388  $perm = $this->getPermissions()->hasPermissions(
1390  $obj_type,
1391  array(
1395  ));
1396  }
1397 
1398  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
1400 
1401  // Show section
1403  $section->setTitle($this->lng->txt('objs_'.$obj_type));
1404  $this->form->addItem($section);
1405 
1406  $check = new ilCheckboxInputGUI($this->lng->txt('description'),'enabled_desc_'.$obj_type);
1407  $check->setValue(1);
1408  $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1409  $check->setChecked($sub->isDescriptionEnabled() ? true : false);
1410  $this->form->addItem($check);
1411 
1413  {
1414  $check->setDisabled(true);
1415  }
1416 
1417  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'),'enabled_field_names_'.$obj_type);
1418  $check->setValue(1);
1419  $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1420  $check->setChecked($sub->enabledFieldNames() ? true : false);
1421  $this->form->addItem($check);
1422 
1424  {
1425  $check->setDisabled(true);
1426  }
1427 
1428  #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1429  #$area->setUseRte(true);
1430  #$area->setRteTagSet('standard');
1431  #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1432  #$area->setRows(5);
1433  #$area->setCols(80);
1434  #$this->form->addItem($area);
1435 
1436  if($perm)
1437  {
1439  }
1440 
1442  $definitions = $sub->sortDefinitions($definitions);
1443 
1444  $counter = 1;
1445  foreach($definitions as $def)
1446  {
1447  $definition_id = $def->getFieldId();
1448 
1449  $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1450 
1451  $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId());
1452  $title = $def->getTitle().' ('.$title.')';
1453 
1454  $check = new ilCheckboxInputGUI($title,'show['.$obj_type.']['.$definition_id.']');
1455  $check->setValue(1);
1456  $check->setOptionTitle($this->lng->txt('md_adv_show'));
1457  $check->setChecked($sub->isSubstituted($definition_id));
1458 
1459  if($perm && !$perm["show"])
1460  {
1461  $check->setDisabled(true);
1462  }
1463 
1464  $pos = new ilNumberInputGUI($this->lng->txt('position'),'position['.$obj_type.']['.$definition_id.']');
1465  $pos->setSize(3);
1466  $pos->setMaxLength(4);
1467  $pos->allowDecimals(true);
1468  $pos->setValue(sprintf('%.1f',$counter++));
1469  $check->addSubItem($pos);
1470 
1471  if($perm && !$perm_pos)
1472  {
1473  $pos->setDisabled(true);
1474  }
1475 
1476  $bold = new ilCheckboxInputGUI($this->lng->txt('bold'),'bold['.$obj_type.']['.$definition_id.']');
1477  $bold->setValue(1);
1478  $bold->setChecked($sub->isBold($definition_id));
1479  $check->addSubItem($bold);
1480 
1481  if($perm && !$perm["bold"])
1482  {
1483  $bold->setDisabled(true);
1484  }
1485 
1486  $bold = new ilCheckboxInputGUI($this->lng->txt('newline'),'newline['.$obj_type.']['.$definition_id.']');
1487  $bold->setValue(1);
1488  $bold->setChecked($sub->hasNewline($definition_id));
1489  $check->addSubItem($bold);
1490 
1491  if($perm && !$perm["newline"])
1492  {
1493  $bold->setDisabled(true);
1494  }
1495 
1496 
1497  $this->form->addItem($check);
1498  }
1499 
1500 
1501  // placeholder
1502  /*
1503  $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders'));
1504  $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData');
1505  foreach($records as $record)
1506  {
1507  foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition)
1508  {
1509  $tpl->setCurrentBlock('field');
1510  $tpl->setVariable('FIELD_NAME',$definition->getTitle());
1511  $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'.
1512  '[/IF_F_'.$definition->getFieldId().']');
1513  $tpl->parseCurrentBlock();
1514  }
1515 
1516  $tpl->setCurrentBlock('record');
1517  $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for'));
1518  $tpl->setVariable('TITLE',$record->getTitle());
1519  $tpl->parseCurrentBlock();
1520  }
1521  $custom->setHTML($tpl->get());
1522  $this->form->addItem($custom);
1523  */
1524  }
1525  $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1526 
1527  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
1528  {
1529  $this->form->addCommandButton('updateSubstitutions',$this->lng->txt('save'));
1530  }
1531 
1532  return true;
1533  }
This class represents a property form user interface.
This class represents a section header in a property form.
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
This class represents a checkbox property in a property form.
$records
Definition: simple_test.php:22
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
$counter
$section
Definition: Utf8Test.php:83
This class represents a number property in a property form.
static getInstancesByObjType($a_obj_type, $a_active_only=true)
setValue($a_value)
Set Value.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! public.
static _lookupTitle($a_record_id)
Lookup title.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initImportForm()

ilAdvancedMDSettingsGUI::initImportForm ( )
protected

show import form

protected

Definition at line 893 of file class.ilAdvancedMDSettingsGUI.php.

References $file, and array.

Referenced by importRecord(), and importRecords().

894  {
895  if(is_object($this->import_form))
896  {
897  return true;
898  }
899 
900  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
901  $this->import_form = new ilPropertyFormGUI();
902  $this->import_form->setMultipart(true);
903  $this->import_form->setFormAction($this->ctrl->getFormAction($this));
904 
905  // add file property
906  $file = new ilFileInputGUI($this->lng->txt('file'),'file');
907  $file->setSuffixes(array('xml'));
908  $file->setRequired(true);
909  $this->import_form->addItem($file);
910 
911  $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
912  $this->import_form->addCommandButton('importRecord',$this->lng->txt('import'));
913  $this->import_form->addCommandButton('showRecords',$this->lng->txt('cancel'));
914  }
This class represents a property form user interface.
This class represents a file property in a property form.
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the caller graph for this function:

◆ initRecordObject()

ilAdvancedMDSettingsGUI::initRecordObject ( )
protected

Init record object.

protected

Definition at line 1598 of file class.ilAdvancedMDSettingsGUI.php.

References $_GET, and ilAdvancedMDRecord\_getInstanceByRecordId().

Referenced by createRecord(), editFields(), editRecord(), saveRecord(), and updateRecord().

1599  {
1600  if(!is_object($this->record))
1601  {
1602  $record_id = isset($_GET['record_id'])
1603  ? $_GET['record_id']
1604  : 0;
1605  $this->record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
1606 
1607  // bind to parent object (aka local adv md)
1608  if(!$record_id &&
1609  $this->obj_id)
1610  {
1611  $this->record->setParentObject($this->obj_id);
1612  }
1613  }
1614 
1615  return $this->record;
1616  }
$_GET["client_id"]
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( )
protected

load record form data

protected

Definition at line 1540 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, $t, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\stripSlashes(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

Referenced by saveRecord(), and updateRecord().

1541  {
1542  $perm = $this->getPermissions()->hasPermissions(
1544  $this->record->getRecordId(),
1545  array(
1553  ));
1554 
1556  {
1557  $this->record->setActive(ilUtil::stripSlashes($_POST['active']));
1558  }
1560  {
1561  $this->record->setTitle(ilUtil::stripSlashes($_POST['title']));
1562  }
1564  {
1565  $this->record->setDescription(ilUtil::stripSlashes($_POST['desc']));
1566  }
1567 
1568  if(!$this->obj_type)
1569  {
1571  {
1572  $obj_types = array();
1573  if (is_array($_POST['obj_types']))
1574  {
1575  foreach ($_POST['obj_types'] as $t => $value)
1576  {
1577  if($value)
1578  {
1579  $t = explode(":", $t);
1580  $obj_types[] = array(
1581  "obj_type" => ilUtil::stripSlashes($t[0]),
1582  "sub_type" => ilUtil::stripSlashes($t[1]),
1583  "optional" => ($value > 1)
1584  );
1585  }
1586  }
1587  }
1588  $this->record->setAssignedObjectTypes($obj_types);
1589  }
1590  }
1591  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveField()

ilAdvancedMDSettingsGUI::saveField ( )

create field

public

Definition at line 1111 of file class.ilAdvancedMDSettingsGUI.php.

References createField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), initFieldForm(), and ilUtil\sendSuccess().

1112  {
1113  if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1114  {
1115  return $this->editFields();
1116  }
1117 
1118  $this->ctrl->saveParameter($this,'record_id');
1119  $this->ctrl->saveParameter($this,'ftype');
1120 
1121  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1122  $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1123  $field_definition->setRecordId($_REQUEST["record_id"]);
1124  $form = $this->initFieldForm($field_definition);
1125 
1126  if($form->checkInput())
1127  {
1128  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1129  $field_definition->save();
1130 
1131  ilUtil::sendSuccess($this->lng->txt('save_settings'), true);
1132  $this->ctrl->redirect($this, "editFields");
1133  }
1134 
1135  $form->setValuesByPost();
1136  $this->createField($form);
1137  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
+ Here is the call graph for this function:

◆ saveRecord()

ilAdvancedMDSettingsGUI::saveRecord ( )

Save record.

public

Parameters

Definition at line 981 of file class.ilAdvancedMDSettingsGUI.php.

References array, createRecord(), initRecordObject(), loadRecordFormData(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

982  {
983  $this->initRecordObject();
984  $this->loadRecordFormData();
985 
986  if($this->obj_type)
987  {
988  $this->record->setAssignedObjectTypes(array(
989  array(
990  "obj_type"=>$this->obj_type,
991  "sub_type"=>$this->sub_type,
992  "optional"=>false
993  )));
994  }
995 
996  if(!$this->record->validate())
997  {
998  ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
999  $this->createRecord();
1000  return false;
1001  }
1002  $this->record->save();
1003 
1004  ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'));
1005  $this->showRecords();
1006  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
loadRecordFormData()
load record form data
+ Here is the call graph for this function:

◆ setSubTabs()

ilAdvancedMDSettingsGUI::setSubTabs ( )
protected

Set sub tabs.

protected

Definition at line 1623 of file class.ilAdvancedMDSettingsGUI.php.

References ilAdvancedMDRecord\_getAllRecordsByObjectType().

Referenced by executeCommand().

1624  {
1625  $this->tabs_gui->clearSubTabs();
1626 
1627  $this->tabs_gui->addSubTabTarget("md_adv_record_list",
1628  $this->ctrl->getLinkTarget($this, "showRecords"),
1629  '',
1630  '',
1631  '',
1632  true);
1633 
1634 
1636  {
1637  $this->tabs_gui->addSubTabTarget("md_adv_presentation",
1638  $this->ctrl->getLinkTarget($this, "showPresentation"));
1639  }
1640 
1641  $this->tabs_gui->addSubTabTarget("md_adv_file_list",
1642  $this->ctrl->getLinkTarget($this, "showFiles"),
1643  "showFiles");
1644  }
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! public.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showFiles()

ilAdvancedMDSettingsGUI::showFiles ( )

show export files

public

Parameters

Definition at line 337 of file class.ilAdvancedMDSettingsGUI.php.

References $files.

Referenced by confirmDeleteFiles(), deleteFiles(), downloadFile(), and exportRecords().

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  }
$files
Definition: add-vimline.php:18
+ Here is the caller graph for this function:

◆ showPresentation()

ilAdvancedMDSettingsGUI::showPresentation ( )

Definition at line 157 of file class.ilAdvancedMDSettingsGUI.php.

References initFormSubstitutions(), and showRecords().

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  }
initFormSubstitutions()
init form table 'substitutions'
+ Here is the call graph for this function:

◆ showRecords()

ilAdvancedMDSettingsGUI::showRecords ( )

show record list

public

Parameters

Definition at line 98 of file class.ilAdvancedMDSettingsGUI.php.

References ilAdvancedMDPermissionHelper\ACTION_MD_CREATE_RECORD, ilAdvancedMDPermissionHelper\ACTION_MD_IMPORT_RECORDS, array, ilAdvancedMDPermissionHelper\CONTEXT_MD, ilLinkButton\getInstance(), getParsedRecordObjects(), and getPermissions().

Referenced by confirmDeleteRecords(), deleteRecords(), exportRecords(), saveRecord(), showPresentation(), and updateRecord().

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 
124  if($perm[ilAdvancedMDPermissionHelper::ACTION_MD_IMPORT_RECORDS])
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  }
getParsedRecordObjects()
Get and cache record objects.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateField()

ilAdvancedMDSettingsGUI::updateField ( )

Update field.

public

Definition at line 1038 of file class.ilAdvancedMDSettingsGUI.php.

References editField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), initFieldForm(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

1039  {
1040  if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1041  {
1042  return $this->editFields();
1043  }
1044 
1045  $this->ctrl->saveParameter($this,'record_id');
1046  $this->ctrl->saveParameter($this,'field_id');
1047 
1048  $confirm = false;
1049  $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1050  $form = $this->initFieldForm($field_definition);
1051  if($form->checkInput())
1052  {
1053  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1054  if(!$field_definition->importDefinitionFormPostValuesNeedsConfirmation())
1055  {
1056  $field_definition->update();
1057 
1058  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1059  $this->ctrl->redirect($this, "editFields");
1060  }
1061  else
1062  {
1063  $confirm = true;
1064  }
1065  }
1066 
1067  $form->setValuesByPost();
1068 
1069  // fields needs confirmation of updated settings
1070  if($confirm)
1071  {
1072  ilUtil::sendInfo($this->lng->txt("md_adv_confirm_definition"));
1073  $field_definition->prepareDefinitionFormConfirmation($form);
1074  }
1075 
1076  $this->editField($form);
1077  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
editField(ilPropertyFormGUI $a_form=null)
Edit field.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
+ Here is the call graph for this function:

◆ updateFields()

ilAdvancedMDSettingsGUI::updateFields ( )

Update fields.

public

Definition at line 783 of file class.ilAdvancedMDSettingsGUI.php.

References $_GET, $_POST, ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, editFields(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE.

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ updateRecord()

ilAdvancedMDSettingsGUI::updateRecord ( )

Update record.

public

Parameters

Definition at line 842 of file class.ilAdvancedMDSettingsGUI.php.

References $_GET, editRecord(), initRecordObject(), loadRecordFormData(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

843  {
844  if(!isset($_GET['record_id']) or !$_GET['record_id'])
845  {
846  ilUtil::sendFailure($this->lng->txt('select_one'));
847  $this->showRecords();
848  return false;
849  }
850  $this->initRecordObject();
851  $this->loadRecordFormData();
852 
853  if(!$this->record->validate())
854  {
855  ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
856  $this->editRecord();
857  return false;
858  }
859  $this->record->update();
860  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
861  $this->showRecords();
862  return true;
863  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
loadRecordFormData()
load record form data
+ Here is the call graph for this function:

◆ updateRecords()

ilAdvancedMDSettingsGUI::updateRecords ( )

Save records (assigned object typed)

public

Parameters

Definition at line 538 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, array, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getParsedRecordObjects(), getPermissions(), ilAdvancedMDRecord\saveObjRecSelection(), ilUtil\sendSuccess(), ilUtil\stripSlashes(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

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  }
584  else if($perm[ilAdvancedMDPermissionHelper::ACTION_RECORD_TOGGLE_ACTIVATION])
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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getParsedRecordObjects()
Get and cache record objects.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
$_POST["username"]
+ Here is the call graph for this function:

◆ updateSubstitutions()

ilAdvancedMDSettingsGUI::updateSubstitutions ( )

Update substitution.

public

Definition at line 176 of file class.ilAdvancedMDSettingsGUI.php.

References $_POST, $counter, $obj_type, $old, ilAdvancedMDRecord\_getActivatedObjTypes(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, array, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), getSubstitutionFieldPermissions(), ilUtil\sendSuccess(), and ilUtil\sortArray().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
$counter
static getInstancesByObjType($a_obj_type, $a_active_only=true)
$old
Create styles array
The data for the language used.
static _getActivatedObjTypes()
get activated obj types
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAdvancedMDSettingsGUI::$ctrl
protected

Definition at line 20 of file class.ilAdvancedMDSettingsGUI.php.

◆ $lng

ilAdvancedMDSettingsGUI::$lng
protected

Definition at line 18 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by __construct().

◆ $obj_id

ilAdvancedMDSettingsGUI::$obj_id
protected

Definition at line 23 of file class.ilAdvancedMDSettingsGUI.php.

◆ $obj_type

ilAdvancedMDSettingsGUI::$obj_type
protected

Definition at line 24 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by initFormSubstitutions(), and updateSubstitutions().

◆ $permissions

ilAdvancedMDSettingsGUI::$permissions
protected

Definition at line 22 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by getPermissions().

◆ $sub_type

ilAdvancedMDSettingsGUI::$sub_type
protected

Definition at line 25 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tabs

ilAdvancedMDSettingsGUI::$tabs
protected

Definition at line 21 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tpl

ilAdvancedMDSettingsGUI::$tpl
protected

Definition at line 19 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: