ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOerHarvesterSettings.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13  const CRON_JOB_IDENTIFIER = 'meta_oer_harvester';
14 
15  const STORAGE_IDENTIFIER = 'meta_oer';
16 
17  const COLLECTED_TYPES = [
18  'file'
19  ];
20 
24  private static $instance = null;
25 
29  private $storage = null;
30 
34  private $target = 0;
35 
36 
40  private $copyright_templates = [];
41 
45  private $cronjob = null;
46 
47 
48 
53  protected function __construct()
54  {
55  $this->storage = new ilSetting(self::STORAGE_IDENTIFIER);
56  /*
57  $this->cronjob = ilCronManager::getJobInstanceById(self::CRON_JOB_IDENTIFIER);
58  if(!$this->cronjob instanceof ilCronJob) {
59 
60  throw new \LogicException(
61  'Cannot create cron job instance'
62  );
63  }
64  */
65  $this->read();
66  }
67 
68 
69 
73  public static function getInstance()
74  {
75  if (!self::$instance instanceof ilOerHarvesterSettings) {
76  self::$instance = new self();
77  }
78  return self::$instance;
79  }
80 
85  public function supportsHarvesting($a_type)
86  {
87  return in_array($a_type, self::COLLECTED_TYPES);
88  }
89 
93  public function getHarvestingTypes()
94  {
95  return self::COLLECTED_TYPES;
96  }
97 
101  public function setTarget($a_target)
102  {
103  $this->target = $a_target;
104  }
105 
109  public function getTarget()
110  {
111  return $this->target;
112  }
113 
117  public function setCopyrightTemplates(array $a_template_ids)
118  {
119  $this->copyright_templates = $a_template_ids;
120  }
121 
125  public function getCopyrightTemplates()
126  {
128  }
129 
134  public function isActiveCopyrightTemplate($a_id)
135  {
136  return in_array($a_id, $this->getCopyrightTemplates());
137  }
138 
144  {
145  global $DIC;
146 
147  $settings = $DIC->settings();
148 
149  $lom_entries = [];
150  foreach ($this->getCopyrightTemplates() as $copyright_id) {
151  $lom_entries[] = 'il_copyright_entry__' . $settings->get('inst_id', 0) . '__' . $copyright_id;
152  }
153  return $lom_entries;
154  }
155 
156 
160  public function save()
161  {
162  $this->storage->set('target', $this->getTarget());
163  $this->storage->set('templates', serialize($this->copyright_templates));
164  }
165 
169  public function read()
170  {
171  $this->setTarget($this->storage->get('target', 0));
172  $this->setCopyrightTemplates(unserialize($this->storage->get('templates', serialize([]))));
173  }
174 }
global $DIC
Definition: saml.php:7
getHarvestingTypes()
Get obj types that support harvesing.
setCopyrightTemplates(array $a_template_ids)
$a_type
Definition: workflow.php:92
getCopyRightTemplatesInLomFormat()
Get copyright entries in LOM format: "il_copyright_entry_INST_ID_ID" return string[].
Cron job for definition for oer harvesting.
__construct()
ilOerHarvesterSettings constructor.