ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 string CRON_JOB_IDENTIFIER = 'meta_oer_harvester'
 
const int DEFAULT_SCHEDULE_VALUE = 1
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $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 32 of file class.ilCronOerHarvester.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronOerHarvester::__construct ( )

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

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

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

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronOerHarvester::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

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

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

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

◆ getDefaultScheduleType()

ilCronOerHarvester::getDefaultScheduleType ( )

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

80  {
81  return JobScheduleType::DAILY;
82  }

◆ getDefaultScheduleValue()

ilCronOerHarvester::getDefaultScheduleValue ( )

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

84  : ?int
85  {
86  return self::DEFAULT_SCHEDULE_VALUE;
87  }

◆ getDescription()

ilCronOerHarvester::getDescription ( )

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

References ILIAS\Repository\lng().

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

◆ getId()

ilCronOerHarvester::getId ( )

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

64  : string
65  {
66  return self::CRON_JOB_IDENTIFIER;
67  }

◆ getTitle()

ilCronOerHarvester::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilCronOerHarvester::hasAutoActivation ( )

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

69  : bool
70  {
71  return false;
72  }

◆ hasCustomSettings()

ilCronOerHarvester::hasCustomSettings ( )

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

89  : bool
90  {
91  return true;
92  }

◆ hasFlexibleSchedule()

ilCronOerHarvester::hasFlexibleSchedule ( )

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

74  : bool
75  {
76  return true;
77  }

◆ run()

ilCronOerHarvester::run ( )

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

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

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

◆ saveCustomSettings()

ilCronOerHarvester::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

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

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

Field Documentation

◆ $initiator

Initiator ilCronOerHarvester::$initiator
private

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

◆ $lng

ilLanguage ilCronOerHarvester::$lng
private

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

◆ $logger

ilLogger ilCronOerHarvester::$logger
private

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

◆ $settings

SettingsInterface ilCronOerHarvester::$settings
private

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

◆ CRON_JOB_IDENTIFIER

const string ilCronOerHarvester::CRON_JOB_IDENTIFIER = 'meta_oer_harvester'
protected

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

◆ DEFAULT_SCHEDULE_VALUE

const int ilCronOerHarvester::DEFAULT_SCHEDULE_VALUE = 1
protected

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


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