ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCronOerHarvester.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 {
16  const CRON_JOB_IDENTIFIER = 'meta_oer_harvester';
17 
22 
26  private $logger = null;
27 
31  private $lng = null;
32 
36  private $settings = null;
37 
38 
42  public function __construct()
43  {
44  global $DIC;
45 
46  $this->logger = $DIC->logger()->meta();
47  $this->lng = $DIC->language();
48  $this->lng->loadLanguageModule('meta');
49 
51  }
52 
56  public function getTitle()
57  {
58  return $this->lng->txt('meta_oer_harvester');
59  }
60 
64  public function getDescription()
65  {
66  return $this->lng->txt('meta_oer_harvester_desc');
67  }
68 
72  public function getId()
73  {
74  return self::CRON_JOB_IDENTIFIER;
75  }
76 
77 
81  public function hasAutoActivation()
82  {
83  return false;
84  }
85 
89  public function hasFlexibleSchedule()
90  {
91  return true;
92  }
93 
97  public function getDefaultScheduleType()
98  {
99  return self::SCHEDULE_TYPE_DAILY;
100  }
101 
105  public function getDefaultScheduleValue()
106  {
107  return self::DEFAULT_SCHEDULE_VALUE;
108  }
109 
110 
114  public function hasCustomSettings()
115  {
116  return true;
117  }
118 
123  {
124  // target selection
126  $this->lng->txt('meta_oer_target'),
127  'target',
128  false
129  );
130 
131  $explorer = $target->getExplorerGUI();
132  $explorer->setSelectMode('target', false);
133  $explorer->setRootId(ROOT_FOLDER_ID);
134  $explorer->setTypeWhiteList(['cat']);
135 
136  if ($this->settings->getTarget()) {
137  $explorer->setPathOpen($this->settings->getTarget());
138  $target->setValue($this->settings->getTarget());
139  }
140 
141  $target->setRequired(true);
142  $a_form->addItem($target);
143 
144 
145  // copyright selection
146  $checkbox_group = new ilCheckboxGroupInputGUI(
147  $this->lng->txt('meta_oer_copyright_selection'),
148  'copyright'
149  );
150  $checkbox_group->setRequired(true);
151  $checkbox_group->setValue($this->settings->getCopyrightTemplates());
152  $checkbox_group->setInfo(
153  $this->lng->txt('meta_oer_copyright_selection_info')
154  );
155 
156  foreach (ilMDCopyrightSelectionEntry::_getEntries() as $copyright_entry) {
157  $copyright_checkox = new ilCheckboxOption(
158  $copyright_entry->getTitle(),
159  $copyright_entry->getEntryId(),
160  $copyright_entry->getDescription()
161  );
162  $checkbox_group->addOption($copyright_checkox);
163  }
164  $a_form->addItem($checkbox_group);
165  return $a_form;
166  }
167 
168 
173  public function saveCustomSettings(ilPropertyFormGUI $a_form)
174  {
175  $this->settings->setTarget($a_form->getInput('target'));
176  $this->settings->setCopyrightTemplates($a_form->getInput('copyright'));
177  $this->settings->save();
178 
179  return true;
180  }
181 
185  public function run()
186  {
187  $this->logger->info('Started cron oer harvester.');
188  $harvester = new ilOerHarvester(new ilCronJobResult());
189  $res = $harvester->run();
190  $this->logger->info('cron oer harvester finished');
191 
192  return $res;
193  }
194 
202  public function addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
203  {
204  #23901
205  global $DIC;
206  $lng = $DIC->language();
207 
208  switch ($a_form_id) {
210 
211  $a_fields['meta_oer_harvester'] =
212  (
213  $a_is_active ?
214  $lng->txt('enabled') :
215  $lng->txt('disabled')
216  );
217  break;
218  }
219  }
220 }
settings()
Definition: settings.php:2
__construct()
ilOerHarvester constructor.
This class represents an option in a checkbox group.
This class represents a property form user interface.
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
global $DIC
Definition: saml.php:7
Cron job application base class.
Cron job for definition for oer harvesting.
Cron job for definition for oer harvesting.
addItem($a_item)
Add Item (Property, SectionHeader).
foreach($_POST as $key=> $value) $res
This class represents a property in a property form.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
saveCustomSettings(ilPropertyFormGUI $a_form)
addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
Provide external settings for presentation in MD settings.
Cron job result data container.
$target
Definition: test.php:19
setRequired($a_required)
Set Required.