ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPrgUserNotRestartedCronJob.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5declare(strict_types=1);
6
7
9{
10 const ID = 'prg_user_not_restarted';
11
16
20 protected $log;
21
25 protected $lng;
26
27 public function __construct()
28 {
29 global $DIC;
30
31 $this->user_assignments_db = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserAssignmentDB'];
32 $this->log = $DIC['ilLog'];
33 $this->lng = $DIC['lng'];
34 }
35
41 public function getTitle()
42 {
43 return $this->lng->txt('prg_user_not_restarted_title');
44 }
45
51 public function getDescription()
52 {
53 return $this->lng->txt('prg_user_not_restarted_desc');
54 }
55
61 public function getId()
62 {
63 return self::ID;
64 }
65
71 public function hasAutoActivation()
72 {
73 return true;
74 }
75
81 public function hasFlexibleSchedule()
82 {
83 return true;
84 }
85
91 public function getDefaultScheduleType()
92 {
94 }
95
101 public function getDefaultScheduleValue()
102 {
103 return 1;
104 }
105
112 public function run()
113 {
114 $result = new ilCronJobResult();
116 foreach ($this->user_assignments_db->getDueToRestartAndMail() as $assignment) {
117 try {
118 $prg = $assignment->getStudyProgramme();
119 $validity_of_qualification = $prg->getValidityOfQualificationSettings();
120 $auto_re_assign = $validity_of_qualification->getRestartPeriod();
121 if ($auto_re_assign == -1) {
122 continue;
123 }
124
125 $auto_mail_settings = $prg->getAutoMailSettings();
126 $inform_by_days = $auto_mail_settings->getReminderNotRestartedByUserDays();
127 if (is_null($inform_by_days)) {
128 continue;
129 }
130 $restart_date = $assignment->getRestartDate();
131 $restart_date->sub(new DateInterval(('P' . $inform_by_days . 'D')));
132
133 $assignment->informUserByMailToRestart();
134 } catch (ilException $e) {
135 $this->log->write('an error occured: ' . $e->getMessage());
136 }
137 }
138 return $result;
139 }
140}
$result
An exception for terminatinating execution or to throw for unit testing.
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_IN_DAYS
Base class for ILIAS Exception handling.
hasAutoActivation()
Is to be activated on "installation".
hasFlexibleSchedule()
Can the schedule be configured?
$DIC
Definition: xapitoken.php:46