ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Settings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 class Settings implements SettingsInterface
24 {
25  protected const string STORAGE_IDENTIFIER = 'meta_oer';
26  protected const array ELIGIBLE_TYPES = [
27  'file',
28  'glo',
29  'copa',
30  'lm',
31  'htlm',
32  'sahs',
33  'qpl',
34  'spl',
35  'mep'
36  ];
37 
38  protected \ilSetting $settings;
39 
43  protected array $selected_obj_types;
44 
48  protected array $selected_cp_entry_ids;
51 
52  public function __construct()
53  {
54  $this->settings = new \ilSetting(self::STORAGE_IDENTIFIER);
55  }
56 
60  public function getObjectTypesEligibleForHarvesting(): array
61  {
62  return self::ELIGIBLE_TYPES;
63  }
64 
68  public function getObjectTypesSelectedForHarvesting(): array
69  {
70  if (isset($this->selected_obj_types)) {
72  }
73  $types_from_storage = unserialize(
74  $this->settings->get(
75  'collected_types',
76  serialize($this->getObjectTypesEligibleForHarvesting()),
77  ),
78  ['allowed_classes' => false]
79  );
80  return $this->selected_obj_types = array_intersect(
81  $types_from_storage,
83  );
84  }
85 
86  public function isObjectTypeSelectedForHarvesting(string $type): bool
87  {
88  $types = $this->getObjectTypesSelectedForHarvesting();
89  return in_array($type, $types);
90  }
91 
92  public function saveObjectTypesSelectedForHarvesting(string ...$types): void
93  {
94  $this->selected_obj_types = $types;
95  $this->settings->set('collected_types', serialize($types));
96  }
97 
102  {
103  if (isset($this->selected_cp_entry_ids)) {
105  }
106  $ids_from_storage = unserialize(
107  $this->settings->get('templates', serialize([])),
108  ['allowed_classes' => false]
109  );
110  $this->selected_cp_entry_ids = [];
111  foreach ($ids_from_storage as $id) {
112  $this->selected_cp_entry_ids[] = (int) $id;
113  }
115  }
116 
117  public function isCopyrightEntryIDSelectedForHarvesting(int $id): bool
118  {
119  $entry_ids = $this->getCopyrightEntryIDsSelectedForHarvesting();
120  return in_array($id, $entry_ids);
121  }
122 
123  public function saveCopyrightEntryIDsSelectedForHarvesting(int ...$ids): void
124  {
125  $this->selected_cp_entry_ids = $ids;
126  $this->settings->set('templates', serialize($ids));
127  }
128 
130  {
131  if (isset($this->target_for_harvesting_ref_id)) {
133  }
134  return $this->target_for_harvesting_ref_id = (int) $this->settings->get(
135  'target',
136  '0'
137  );
138  }
139 
140  public function saveContainerRefIDForHarvesting(int $ref_id): void
141  {
142  $this->target_for_harvesting_ref_id = $ref_id;
143  $this->settings->set('target', (string) $ref_id);
144  }
145 
147  {
148  if (isset($this->source_for_exposing_ref_id)) {
150  }
151  return $this->source_for_exposing_ref_id = (int) $this->settings->get(
152  'exposed_container',
153  '0'
154  );
155  }
156 
157  public function saveContainerRefIDForExposing(int $ref_id): void
158  {
159  $this->source_for_exposing_ref_id = $ref_id;
160  $this->settings->set('exposed_container', (string) $ref_id);
161  }
162 }
$ref_id
Definition: ltiauth.php:65
saveObjectTypesSelectedForHarvesting(string ... $types)
Definition: Settings.php:92
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23