ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPrgRestartAssignmentsCronJob Class Reference

Re-assign users (according to restart-date). More...

+ Inheritance diagram for ilPrgRestartAssignmentsCronJob:
+ Collaboration diagram for ilPrgRestartAssignmentsCronJob:

Public Member Functions

 __construct ()
 
 getTitle ()
 
 getDescription ()
 
 getId ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $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 (?int $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 Member Functions

 getStudyProgramme (int $prg_obj_id)
 
 getNow ()
 
 log (string $msg)
 

Protected Attributes

ilComponentLogger $log
 
ilLanguage $lng
 
ilPRGAssignmentDBRepository $assignment_repo
 
ilPrgCronJobAdapter $adapter
 
array $prgs = []
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

const ID = 'prg_restart_assignments_temporal_progress'
 
const ACTING_USR_ID = -1
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 This will be replaced with an ENUM in ILIAS 9 More...
 

Detailed Description

Re-assign users (according to restart-date).

This will result in a new/additional assignment

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

Constructor & Destructor Documentation

◆ __construct()

ilPrgRestartAssignmentsCronJob::__construct ( )

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

References $DIC, $dic, ilStudyProgrammeDIC\dic(), ILIAS\Repository\lng(), and log().

40  {
41  global $DIC;
42  $this->log = $DIC['ilLog'];
43  $this->lng = $DIC['lng'];
44  $this->lng->loadLanguageModule('prg');
45 
47  $this->assignment_repo = $dic['repo.assignment'];
48  $this->adapter = $dic['cron.restart'];
49  }
global $DIC
Definition: feed.php:28
$dic
Definition: result.php:32
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleType ( )

Definition at line 76 of file class.ilPrgRestartAssignmentsCronJob.php.

76  : int
77  {
78  return self::SCHEDULE_TYPE_IN_DAYS;
79  }

◆ getDefaultScheduleValue()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleValue ( )

Definition at line 81 of file class.ilPrgRestartAssignmentsCronJob.php.

81  : ?int
82  {
83  return 1;
84  }

◆ getDescription()

ilPrgRestartAssignmentsCronJob::getDescription ( )

Definition at line 56 of file class.ilPrgRestartAssignmentsCronJob.php.

References ILIAS\Repository\lng().

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

◆ getId()

ilPrgRestartAssignmentsCronJob::getId ( )

Definition at line 61 of file class.ilPrgRestartAssignmentsCronJob.php.

61  : string
62  {
63  return self::ID;
64  }

◆ getNow()

ilPrgRestartAssignmentsCronJob::getNow ( )
protected

Definition at line 153 of file class.ilPrgRestartAssignmentsCronJob.php.

Referenced by run().

154  {
155  return new DateTimeImmutable();
156  }
+ Here is the caller graph for this function:

◆ getStudyProgramme()

ilPrgRestartAssignmentsCronJob::getStudyProgramme ( int  $prg_obj_id)
protected

Definition at line 145 of file class.ilPrgRestartAssignmentsCronJob.php.

References ilObjStudyProgramme\getInstanceByObjId().

Referenced by run().

146  {
147  if (!array_key_exists($prg_obj_id, $this->prgs)) {
148  $this->prgs[$prg_obj_id] = ilObjStudyProgramme::getInstanceByObjId($prg_obj_id);
149  }
150  return $this->prgs[$prg_obj_id];
151  }
static getInstanceByObjId(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilPrgRestartAssignmentsCronJob::getTitle ( )

Definition at line 51 of file class.ilPrgRestartAssignmentsCronJob.php.

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilPrgRestartAssignmentsCronJob::hasAutoActivation ( )

Definition at line 66 of file class.ilPrgRestartAssignmentsCronJob.php.

66  : bool
67  {
68  return true;
69  }

◆ hasFlexibleSchedule()

ilPrgRestartAssignmentsCronJob::hasFlexibleSchedule ( )

Definition at line 71 of file class.ilPrgRestartAssignmentsCronJob.php.

71  : bool
72  {
73  return true;
74  }

◆ log()

ilPrgRestartAssignmentsCronJob::log ( string  $msg)
protected

Definition at line 158 of file class.ilPrgRestartAssignmentsCronJob.php.

Referenced by __construct(), and run().

158  : void
159  {
160  $this->log->write($msg);
161  }
+ Here is the caller graph for this function:

◆ run()

ilPrgRestartAssignmentsCronJob::run ( )

Definition at line 86 of file class.ilPrgRestartAssignmentsCronJob.php.

References getNow(), getStudyProgramme(), log(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

Referenced by ilPrgRestartAssignmentsCronJobTest\testRestartAssignmentsEvents().

87  {
88  $result = new ilCronJobResult();
89  $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
90 
91  $programmes_to_reassign = $this->adapter->getRelevantProgrammeIds();
92  if (count($programmes_to_reassign) === 0) {
93  return $result;
94  }
95 
96  $today = $this->getNow();
97  $programmes_and_due = [];
98 
99  foreach ($programmes_to_reassign as $programme_obj_id => $days_offset) {
100  $interval = new DateInterval('P' . $days_offset . 'D');
101  $due = $today->add($interval);
102  $programmes_and_due[$programme_obj_id] = $due;
103  }
104 
105  $assignments = $this->assignment_repo->getAboutToExpire($programmes_and_due, false);
106 
107  if (count($assignments) === 0) {
108  return $result;
109  }
110 
111  foreach ($assignments as $ass) {
112  if ($ass->getRestartedAssignmentId() < 0) {
113  $prg = $this->getStudyProgramme($ass->getRootId());
114 
115  $restart_settings = $prg->getSettings()->getValidityOfQualificationSettings();
116  if ($restart_settings->getRestartRecheck()
117  && !$ass->isManuallyAssigned()
118  && !$prg->getApplicableMembershipSourceForUser($ass->getUserId(), null)
119  ) {
120  continue;
121  }
122 
123  $this->log(
124  sprintf(
125  'PRG, RestartAssignments: user %s\'s assignment %s is being restarted (Programme %s)',
126  $ass->getUserId(),
127  $ass->getId(),
128  $ass->getRootId()
129  )
130  );
131 
132  $restarted = $prg->assignUser($ass->getUserId(), self::ACTING_USR_ID, false);
133  $ass = $ass->withRestarted($restarted->getId(), $today);
134  $this->assignment_repo->store($ass);
135 
136  $this->adapter->actOnSingleAssignment($restarted);
137 
138  $result->setStatus(ilCronJobResult::STATUS_OK);
139  }
140  }
141 
142  return $result;
143  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $adapter

ilPrgCronJobAdapter ilPrgRestartAssignmentsCronJob::$adapter
protected

◆ $assignment_repo

ilPRGAssignmentDBRepository ilPrgRestartAssignmentsCronJob::$assignment_repo
protected

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

◆ $lng

ilLanguage ilPrgRestartAssignmentsCronJob::$lng
protected

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

◆ $log

ilComponentLogger ilPrgRestartAssignmentsCronJob::$log
protected

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

◆ $prgs

array ilPrgRestartAssignmentsCronJob::$prgs = []
protected

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

◆ ACTING_USR_ID

const ilPrgRestartAssignmentsCronJob::ACTING_USR_ID = -1
private

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

◆ ID

const ilPrgRestartAssignmentsCronJob::ID = 'prg_restart_assignments_temporal_progress'
private

Definition at line 29 of file class.ilPrgRestartAssignmentsCronJob.php.


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