ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilCronOerHarvester Class Reference

Cron job for definition for oer harvesting. More...

+ Inheritance diagram for ilCronOerHarvester:
+ Collaboration diagram for ilCronOerHarvester:

Public Member Functions

 __construct ()
 
 getTitle ()
 
 getDescription ()
 
 getId ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 run ()
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?CronJobScheduleType $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Attributes

const CRON_JOB_IDENTIFIER = 'meta_oer_harvester'
 
const DEFAULT_SCHEDULE_VALUE = 1
 
- Protected Attributes inherited from ilCronJob
CronJobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ilLogger $logger
 
ilLanguage $lng
 
Initiator $initiator
 
SettingsInterface $settings
 

Detailed Description

Cron job for definition for oer harvesting.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 30 of file class.ilCronOerHarvester.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronOerHarvester::__construct ( )

Definition at line 40 of file class.ilCronOerHarvester.php.

References $DIC, ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

41  {
42  global $DIC;
43 
44  $this->logger = $DIC->logger()->meta();
45  $this->lng = $DIC->language();
46  $this->lng->loadLanguageModule('meta');
47 
48  $this->initiator = new Initiator($DIC);
49  $this->settings = $this->initiator->settings();
50  }
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronOerHarvester::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 92 of file class.ilCronOerHarvester.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ROOT_FOLDER_ID, ilFormPropertyGUI\setRequired(), ILIAS\Repository\settings(), ilCheckboxGroupInputGUI\setValue(), and ilExplorerSelectInputGUI\setValue().

92  : void
93  {
94  // target selection
95  $header = new ilFormSectionHeaderGUI();
96  $header->setTitle($this->lng->txt('meta_oer_categories'));
97  $a_form->addItem($header);
98 
99  $target = new ilRepositorySelector2InputGUI(
100  $this->lng->txt('meta_oer_target'),
101  'target',
102  false,
103  $a_form
104  );
105 
106  $explorer = $target->getExplorerGUI();
107  $explorer->setRootId(ROOT_FOLDER_ID);
108  $explorer->setTypeWhiteList(['cat']);
109 
110  $target_ref_id = $this->settings->getContainerRefIDForHarvesting();
111  if ($target_ref_id) {
112  $explorer->setPathOpen($target_ref_id);
113  $target->setValue($target_ref_id);
114  }
115 
116  $target->setRequired(true);
117  $a_form->addItem($target);
118 
119  // source for exposing
120  $ex_target = new ilRepositorySelector2InputGUI(
121  $this->lng->txt('meta_oer_exposed_source'),
122  'exposed_source',
123  false,
124  $a_form
125  );
126 
127  $ex_explorer = $ex_target->getExplorerGUI();
128  $ex_explorer->setRootId(ROOT_FOLDER_ID);
129  $ex_explorer->setTypeWhiteList(['cat']);
130 
131  $ex_target_ref_id = $this->settings->getContainerRefIDForExposing();
132  if ($ex_target_ref_id) {
133  $ex_explorer->setPathOpen($ex_target_ref_id);
134  $ex_target->setValue($ex_target_ref_id);
135  }
136 
137  $ex_target->setRequired(true);
138  $a_form->addItem($ex_target);
139 
140  // copyright selection
141  $header = new ilFormSectionHeaderGUI();
142  $header->setTitle($this->lng->txt('meta_oer_harvested_licences'));
143  $a_form->addItem($header);
144 
145  $checkbox_group = new ilCheckboxGroupInputGUI(
146  $this->lng->txt('meta_oer_copyright_selection'),
147  'copyright'
148  );
149  $checkbox_group->setValue($this->settings->getCopyrightEntryIDsSelectedForHarvesting());
150  $checkbox_group->setInfo(
151  $this->lng->txt('meta_oer_copyright_selection_info')
152  );
153 
154  foreach ($this->initiator->copyrightRepository()->getAllEntries() as $copyright_entry) {
155  $copyright_checkox = new ilCheckboxOption(
156  $copyright_entry->title(),
157  (string) $copyright_entry->id(),
158  $copyright_entry->description()
159  );
160  $checkbox_group->addOption($copyright_checkox);
161  }
162  $a_form->addItem($checkbox_group);
163 
164  // object type selection
165  $header = new ilFormSectionHeaderGUI();
166  $header->setTitle($this->lng->txt('meta_oer_harvested_types'));
167  $a_form->addItem($header);
168 
169  $checkbox_group = new ilCheckboxGroupInputGUI(
170  $this->lng->txt('meta_oer_object_type_selection'),
171  'object_type'
172  );
173  $checkbox_group->setRequired(true);
174  $checkbox_group->setValue($this->settings->getObjectTypesSelectedForHarvesting());
175 
176  foreach ($this->settings->getObjectTypesEligibleForHarvesting() as $type) {
177  $copyright_checkox = new ilCheckboxOption(
178  $this->lng->txt('objs_' . $type),
179  $type
180  );
181  $checkbox_group->addOption($copyright_checkox);
182  }
183  $a_form->addItem($checkbox_group);
184  }
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
+ Here is the call graph for this function:

◆ addToExternalSettingsForm()

ilCronOerHarvester::addToExternalSettingsForm ( int  $a_form_id,
array &  $a_fields,
bool  $a_is_active 
)

Definition at line 210 of file class.ilCronOerHarvester.php.

References ilAdministrationSettingsFormHandler\FORM_META_COPYRIGHT, and ILIAS\Repository\lng().

210  : void
211  {
212  switch ($a_form_id) {
214 
215  $a_fields['meta_oer_harvester'] =
216  (
217  $a_is_active ?
218  $this->lng->txt('enabled') :
219  $this->lng->txt('disabled')
220  );
221  break;
222  }
223  }
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilCronOerHarvester::getDefaultScheduleType ( )

Definition at line 77 of file class.ilCronOerHarvester.php.

78  {
79  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
80  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilCronOerHarvester::getDefaultScheduleValue ( )

Definition at line 82 of file class.ilCronOerHarvester.php.

82  : ?int
83  {
84  return self::DEFAULT_SCHEDULE_VALUE;
85  }

◆ getDescription()

ilCronOerHarvester::getDescription ( )

Definition at line 57 of file class.ilCronOerHarvester.php.

References ILIAS\Repository\lng().

57  : string
58  {
59  return $this->lng->txt('meta_oer_harvester_desc');
60  }
+ Here is the call graph for this function:

◆ getId()

ilCronOerHarvester::getId ( )

Definition at line 62 of file class.ilCronOerHarvester.php.

62  : string
63  {
64  return self::CRON_JOB_IDENTIFIER;
65  }

◆ getTitle()

ilCronOerHarvester::getTitle ( )

Definition at line 52 of file class.ilCronOerHarvester.php.

References ILIAS\Repository\lng().

52  : string
53  {
54  return $this->lng->txt('meta_oer_harvester');
55  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilCronOerHarvester::hasAutoActivation ( )

Definition at line 67 of file class.ilCronOerHarvester.php.

67  : bool
68  {
69  return false;
70  }

◆ hasCustomSettings()

ilCronOerHarvester::hasCustomSettings ( )

Definition at line 87 of file class.ilCronOerHarvester.php.

87  : bool
88  {
89  return true;
90  }

◆ hasFlexibleSchedule()

ilCronOerHarvester::hasFlexibleSchedule ( )

Definition at line 72 of file class.ilCronOerHarvester.php.

72  : bool
73  {
74  return true;
75  }

◆ run()

ilCronOerHarvester::run ( )

Definition at line 200 of file class.ilCronOerHarvester.php.

References $res, and ILIAS\Repository\logger().

201  {
202  $this->logger->info('Started cron oer harvester.');
203  $harvester = $this->initiator->harvester();
204  $res = $harvester->run(new ResultWrapper(new ilCronJobResult()));
205  $this->logger->info('cron oer harvester finished');
206 
207  return $res->get();
208  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilCronOerHarvester::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Definition at line 186 of file class.ilCronOerHarvester.php.

References $id, ilPropertyFormGUI\getInput(), ILIAS\Repository\int(), and ILIAS\Repository\settings().

186  : bool
187  {
188  $copyrights = [];
189  foreach ($a_form->getInput('copyright') as $id) {
190  $copyrights[] = (int) $id;
191  }
192 
193  $this->settings->saveContainerRefIDForHarvesting((int) $a_form->getInput('target'));
194  $this->settings->saveContainerRefIDForExposing((int) $a_form->getInput('exposed_source'));
195  $this->settings->saveCopyrightEntryIDsSelectedForHarvesting(...$copyrights);
196  $this->settings->saveObjectTypesSelectedForHarvesting(...$a_form->getInput('object_type'));
197  return true;
198  }
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-...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

Field Documentation

◆ $initiator

Initiator ilCronOerHarvester::$initiator
private

Definition at line 37 of file class.ilCronOerHarvester.php.

◆ $lng

ilLanguage ilCronOerHarvester::$lng
private

Definition at line 36 of file class.ilCronOerHarvester.php.

◆ $logger

ilLogger ilCronOerHarvester::$logger
private

Definition at line 35 of file class.ilCronOerHarvester.php.

◆ $settings

SettingsInterface ilCronOerHarvester::$settings
private

Definition at line 38 of file class.ilCronOerHarvester.php.

◆ CRON_JOB_IDENTIFIER

const ilCronOerHarvester::CRON_JOB_IDENTIFIER = 'meta_oer_harvester'
protected

Definition at line 32 of file class.ilCronOerHarvester.php.

◆ DEFAULT_SCHEDULE_VALUE

const ilCronOerHarvester::DEFAULT_SCHEDULE_VALUE = 1
protected

Definition at line 33 of file class.ilCronOerHarvester.php.


The documentation for this class was generated from the following file: