ILIAS  release_8 Revision v8.24
class.ilCronOerHarvester.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6
12{
13 public const CRON_JOB_IDENTIFIER = 'meta_oer_harvester';
14 public const DEFAULT_SCHEDULE_VALUE = 1;
15
18
20
21 public function __construct()
22 {
23 global $DIC;
24
25 $this->logger = $DIC->logger()->meta();
26 $this->lng = $DIC->language();
27 $this->lng->loadLanguageModule('meta');
28
30 }
31
32 public function getTitle(): string
33 {
34 return $this->lng->txt('meta_oer_harvester');
35 }
36
37 public function getDescription(): string
38 {
39 return $this->lng->txt('meta_oer_harvester_desc');
40 }
41
42 public function getId(): string
43 {
45 }
46
47 public function hasAutoActivation(): bool
48 {
49 return false;
50 }
51
52 public function hasFlexibleSchedule(): bool
53 {
54 return true;
55 }
56
57 public function getDefaultScheduleType(): int
58 {
60 }
61
62 public function getDefaultScheduleValue(): ?int
63 {
65 }
66
67 public function hasCustomSettings(): bool
68 {
69 return true;
70 }
71
72 public function addCustomSettingsToForm(ilPropertyFormGUI $a_form): void
73 {
74 // target selection
76 $this->lng->txt('meta_oer_target'),
77 'target',
78 false,
79 $a_form
80 );
81
82 $explorer = $target->getExplorerGUI();
83 $explorer->setSelectMode('target', false);
84 $explorer->setRootId(ROOT_FOLDER_ID);
85 $explorer->setTypeWhiteList(['cat']);
86
87 if ($this->settings->getTarget()) {
88 $explorer->setPathOpen($this->settings->getTarget());
89 $target->setValue($this->settings->getTarget());
90 }
91
92 $target->setRequired(true);
93 $a_form->addItem($target);
94
95 // copyright selection
96 $checkbox_group = new ilCheckboxGroupInputGUI(
97 $this->lng->txt('meta_oer_copyright_selection'),
98 'copyright'
99 );
100 $checkbox_group->setRequired(true);
101 $checkbox_group->setValue($this->settings->getCopyrightTemplates());
102 $checkbox_group->setInfo(
103 $this->lng->txt('meta_oer_copyright_selection_info')
104 );
105
106 foreach (ilMDCopyrightSelectionEntry::_getEntries() as $copyright_entry) {
107 $copyright_checkox = new ilCheckboxOption(
108 $copyright_entry->getTitle(),
109 (string) $copyright_entry->getEntryId(),
110 $copyright_entry->getDescription()
111 );
112 $checkbox_group->addOption($copyright_checkox);
113 }
114 $a_form->addItem($checkbox_group);
115 }
116
117 public function saveCustomSettings(ilPropertyFormGUI $a_form): bool
118 {
119 $this->settings->setTarget((int) $a_form->getInput('target'));
120 $this->settings->setCopyrightTemplates($a_form->getInput('copyright'));
121 $this->settings->save();
122
123 return true;
124 }
125
126 public function run(): ilCronJobResult
127 {
128 $this->logger->info('Started cron oer harvester.');
129 $harvester = new ilOerHarvester(new ilCronJobResult());
130 $res = $harvester->run();
131 $this->logger->info('cron oer harvester finished');
132
133 return $res;
134 }
135
136 public function addToExternalSettingsForm(int $a_form_id, array &$a_fields, bool $a_is_active): void
137 {
138 switch ($a_form_id) {
140
141 $a_fields['meta_oer_harvester'] =
142 (
143 $a_is_active ?
144 $this->lng->txt('enabled') :
145 $this->lng->txt('disabled')
146 );
147 break;
148 }
149 }
150}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
Cron job for definition for oer harvesting.
ilOerHarvesterSettings $settings
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
addToExternalSettingsForm(int $a_form_id, array &$a_fields, bool $a_is_active)
saveCustomSettings(ilPropertyFormGUI $a_form)
language handling
Component logger with individual log levels by component id.
Cron job for definition for oer harvesting.
Cron job for definition for oer harvesting.
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69