ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateCron Class Reference
+ Inheritance diagram for ilCertificateCron:
+ Collaboration diagram for ilCertificateCron:

Public Member Functions

 __construct (ilCertificateQueueRepository $queueRepository=null, ilCertificateTemplateRepository $templateRepository=null, ilUserCertificateRepository $userRepository=null, ilCertificateValueReplacement $valueReplacement=null, ilLogger $logger=null, \ILIAS\DI\Container $dic=null, ilLanguage $language=null, ilCertificateObjectHelper $objectHelper=null, ilSetting $setting=null)
 
 getTitle ()
 
 getDescription ()
 
 init ()
 
 run ()
 
 getId ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $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...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Data Fields

const DEFAULT_SCHEDULE_HOURS = 1
 
- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Protected Attributes

 $lng
 

Private Attributes

 $queueRepository
 @var ilCertificateQueueRepository More...
 
 $templateRepository
 
 $userRepository
 
 $logger
 
 $valueReplacement
 
 $objectHelper
 
 $dic
 
 $settings
 

Additional Inherited Members

- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 7 of file class.ilCertificateCron.php.

Constructor & Destructor Documentation

◆ __construct()

ilCertificateCron::__construct ( ilCertificateQueueRepository  $queueRepository = null,
ilCertificateTemplateRepository  $templateRepository = null,
ilUserCertificateRepository  $userRepository = null,
ilCertificateValueReplacement  $valueReplacement = null,
ilLogger  $logger = null,
\ILIAS\DI\Container  $dic = null,
ilLanguage  $language = null,
ilCertificateObjectHelper  $objectHelper = null,
ilSetting  $setting = null 
)
Parameters
ilCertificateQueueRepository$queueRepository
ilCertificateTemplateRepository$templateRepository
ilUserCertificateRepository$userRepository
ilCertificateValueReplacement | null$valueReplacement
ilLogger | null$logger
\ILIAS\DI\Container | null$dic
ilLanguage | null$language
ilCertificateObjectHelper | null$objectHelper
ilSetting | null$setting

Definition at line 49 of file class.ilCertificateCron.php.

References $DIC, $dic, $language, $logger, $objectHelper, $queueRepository, $templateRepository, $userRepository, $valueReplacement, and settings().

59  {
60  if (null === $dic) {
61  global $DIC;
62  $dic = $DIC;
63  }
64  $this->dic = $dic;
65 
66  $this->queueRepository = $queueRepository;
67  $this->templateRepository = $templateRepository;
68  $this->userRepository = $userRepository;
69  $this->valueReplacement = $valueReplacement;
70  $this->logger = $logger;
71  $this->objectHelper = $objectHelper;
72  $this->settings = $setting;
73 
74  if ($dic) {
75  if (isset($dic['lng'])) {
76  $language = $dic->language();
77  $language->loadLanguageModule('certificate');
78  }
79  }
80 
81  $this->lng = $language;
82  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
$queueRepository
@var ilCertificateQueueRepository
loadLanguageModule($a_module)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilCertificateCron::getDefaultScheduleType ( )

Definition at line 230 of file class.ilCertificateCron.php.

231  {
232  return self::SCHEDULE_TYPE_IN_MINUTES;
233  }

◆ getDefaultScheduleValue()

◆ getDescription()

ilCertificateCron::getDescription ( )

Definition at line 95 of file class.ilCertificateCron.php.

96  {
97  return $this->lng->txt('cert_cron_task_desc');
98  }

◆ getId()

ilCertificateCron::getId ( )

Definition at line 206 of file class.ilCertificateCron.php.

Referenced by getDefaultScheduleValue().

207  {
208  return 'certificate';
209  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCertificateCron::getTitle ( )

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

88  {
89  return $this->lng->txt('cert_cron_task_title');
90  }

◆ hasAutoActivation()

ilCertificateCron::hasAutoActivation ( )

Definition at line 214 of file class.ilCertificateCron.php.

215  {
216  return true;
217  }

◆ hasFlexibleSchedule()

ilCertificateCron::hasFlexibleSchedule ( )

Definition at line 222 of file class.ilCertificateCron.php.

223  {
224  return true;
225  }

◆ init()

ilCertificateCron::init ( )

Definition at line 100 of file class.ilCertificateCron.php.

References $DIC, and settings().

Referenced by run().

101  {
102  if (null === $this->dic) {
103  global $DIC;
104  $this->dic = $DIC;
105  }
106 
107  $database = $this->dic->database();
108 
109  if (null === $this->logger) {
110  $this->logger = $this->dic->logger()->cert();
111  }
112 
113  if (null === $this->queueRepository) {
114  $this->queueRepository = new ilCertificateQueueRepository($database, $this->logger);
115  }
116 
117  if (null === $this->templateRepository) {
118  $this->templateRepository = new ilCertificateTemplateRepository($database, $this->logger);
119  }
120 
121  if (null === $this->userRepository) {
122  $this->userRepository = new ilUserCertificateRepository($database, $this->logger);
123  }
124 
125  if (null === $this->valueReplacement) {
126  $this->valueReplacement = new ilCertificateValueReplacement();
127  }
128 
129  if (null === $this->objectHelper) {
130  $this->objectHelper = new ilCertificateObjectHelper();
131  }
132 
133  if (null === $this->settings) {
134  $this->settings = new ilSetting('certificate');
135  }
136  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCertificateCron::run ( )

Exceptions
ilDatabaseException

Definition at line 142 of file class.ilCertificateCron.php.

References $result, init(), settings(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

143  {
144  $this->init();
145 
146  $result = new ilCronJobResult();
148 
149  $currentMode = $this->settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
150  if ($currentMode !== 'persistent_certificate_mode_cron') {
151  $this->logger->warning(sprintf('Will not start cron job, because the mode is not set as cron job. Current Mode in settings: "%s"', $currentMode));
152  return $result;
153  }
154 
155  $this->logger->info('START - Begin with cron job to create user certificates from templates');
156 
157  $entries = $this->queueRepository->getAllEntriesFromQueue();
158 
159  $status = ilCronJobResult::STATUS_OK;
160 
161  $entryCounter = 0;
162  $succeededGenerations = [];
163  foreach ($entries as $entry) {
164  try {
165  $succeededGenerations = $this->processEntry(
166  $entryCounter,
167  $entry,
168  $succeededGenerations
169  );
170 
171  ++$entryCounter;
172  } catch (ilInvalidCertificateException $exception) {
173  $this->logger->warning($exception->getMessage());
174  $this->logger->warning('The user MAY not be able to achieve the certificate based on the adapters settings');
175  $this->logger->warning('Due the error, the entry will now be removed from the queue.');
176 
177  $this->queueRepository->removeFromQueue($entry->getId());
178 
179  continue;
180  } catch (ilException $exception) {
181  $this->logger->warning($exception->getMessage());
182  $this->logger->warning('Due the error, the entry will now be removed from the queue.');
183 
184  $this->queueRepository->removeFromQueue($entry->getId());
185  continue;
186  }
187  }
188 
189  $result->setStatus($status);
190  if (count($succeededGenerations) > 0) {
191  $result->setMessage(sprintf(
192  'Generated %s certificate(s) in run. Result: %s',
193  count($succeededGenerations),
194  implode(' | ', $succeededGenerations)
195  ));
196  } else {
197  $result->setMessage('0 certificates generated in current run.');
198  }
199 
200  return $result;
201  }
settings()
Definition: settings.php:2
$result
Cron job result data container.
+ Here is the call graph for this function:

Field Documentation

◆ $dic

ilCertificateCron::$dic
private

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

Referenced by __construct().

◆ $lng

ilCertificateCron::$lng
protected

Definition at line 12 of file class.ilCertificateCron.php.

◆ $logger

ilCertificateCron::$logger
private

Definition at line 24 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $objectHelper

ilCertificateCron::$objectHelper
private

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

Referenced by __construct().

◆ $queueRepository

ilCertificateCron::$queueRepository
private

@var ilCertificateQueueRepository

Definition at line 15 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $settings

ilCertificateCron::$settings
private

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

◆ $templateRepository

ilCertificateCron::$templateRepository
private

Definition at line 18 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $userRepository

ilCertificateCron::$userRepository
private

Definition at line 21 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $valueReplacement

ilCertificateCron::$valueReplacement
private

Definition at line 27 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ DEFAULT_SCHEDULE_HOURS

const ilCertificateCron::DEFAULT_SCHEDULE_HOURS = 1

Definition at line 9 of file class.ilCertificateCron.php.


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