ILIAS  release_8 Revision v8.23
class.ilOerHarvesterSettings.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
14 {
15  public const CRON_JOB_IDENTIFIER = 'meta_oer_harvester';
16  public const STORAGE_IDENTIFIER = 'meta_oer';
17  public const COLLECTED_TYPES = [
18  'file'
19  ];
20 
21  private static ?ilOerHarvesterSettings $instance = null;
22 
23  protected ilSetting $storage;
24  protected ilSetting $settings;
25 
26  private int $target = 0;
27 
31  private array $copyright_templates = [];
32 
33  private ?ilCronOerHarvester $cronjob = null;
34 
35  protected function __construct()
36  {
37  global $DIC;
38 
39  $this->storage = new ilSetting(self::STORAGE_IDENTIFIER);
40  $this->settings = $DIC->settings();
41 
42  $this->read();
43  }
44 
45  public static function getInstance(): self
46  {
47  if (!self::$instance instanceof self) {
48  self::$instance = new self();
49  }
50  return self::$instance;
51  }
52 
53  public function supportsHarvesting(string $a_type): bool
54  {
55  return in_array($a_type, self::COLLECTED_TYPES);
56  }
57 
61  public function getHarvestingTypes(): array
62  {
63  return self::COLLECTED_TYPES;
64  }
65 
66  public function setTarget(int $a_target): void
67  {
68  $this->target = $a_target;
69  }
70 
71  public function getTarget(): int
72  {
73  return $this->target;
74  }
75 
79  public function setCopyrightTemplates(array $a_template_ids): void
80  {
81  $this->copyright_templates = $a_template_ids;
82  }
83 
87  public function getCopyrightTemplates(): array
88  {
90  }
91 
92  public function isActiveCopyrightTemplate(int $a_id): bool
93  {
94  return in_array($a_id, $this->getCopyrightTemplates());
95  }
96 
101  public function getCopyRightTemplatesInLomFormat(): array
102  {
103  $lom_entries = [];
104  foreach ($this->getCopyrightTemplates() as $copyright_id) {
105  $lom_entries[] = 'il_copyright_entry__' . $this->settings->get('inst_id', '0') . '__' . $copyright_id;
106  }
107  return $lom_entries;
108  }
109 
110  public function save(): void
111  {
112  $this->storage->set('target', (string) $this->getTarget());
113  $this->storage->set('templates', serialize($this->copyright_templates));
114  }
115 
116  public function read(): void
117  {
118  $this->setTarget((int) $this->storage->get('target', '0'));
119  $this->setCopyrightTemplates(unserialize($this->storage->get('templates', serialize([])), ['allowed_classes' => false]));
120  }
121 }
Cron job for definition for oer harvesting.
setCopyrightTemplates(array $a_template_ids)
global $DIC
Definition: feed.php:28
getCopyRightTemplatesInLomFormat()
Get copyright entries in LOM format: "il_copyright_entry_INST_ID_ID".
Cron job for definition for oer harvesting.
static ilOerHarvesterSettings $instance