ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 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 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 ILIAS\Cron\CronJob
JobScheduleType $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 = ilPRGAssignment::AUTO_ASSIGNED_BY_RESTART
 

Detailed Description

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

This will result in a new/additional assignment

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

Constructor & Destructor Documentation

◆ __construct()

ilPrgRestartAssignmentsCronJob::__construct ( )

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

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

42  {
43  global $DIC;
44  $this->log = $DIC['ilLog'];
45  $this->lng = $DIC['lng'];
46  $this->lng->loadLanguageModule('prg');
47 
49  $this->assignment_repo = $dic['repo.assignment'];
50  $this->adapter = $dic['cron.restart'];
51  }
global $DIC
Definition: shib_login.php:22
$dic
Definition: result.php:31
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleType ( )

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

79  {
80  return JobScheduleType::IN_DAYS;
81  }

◆ getDefaultScheduleValue()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleValue ( )

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

83  : ?int
84  {
85  return 1;
86  }

◆ getDescription()

ilPrgRestartAssignmentsCronJob::getDescription ( )

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

References ILIAS\Repository\lng().

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

◆ getId()

ilPrgRestartAssignmentsCronJob::getId ( )

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

63  : string
64  {
65  return self::ID;
66  }

◆ getNow()

ilPrgRestartAssignmentsCronJob::getNow ( )
protected

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

Referenced by run().

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

◆ getStudyProgramme()

ilPrgRestartAssignmentsCronJob::getStudyProgramme ( int  $prg_obj_id)
protected

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

References ilObjStudyProgramme\getInstanceByObjId().

Referenced by run().

148  {
149  if (!array_key_exists($prg_obj_id, $this->prgs)) {
150  $this->prgs[$prg_obj_id] = ilObjStudyProgramme::getInstanceByObjId($prg_obj_id);
151  }
152  return $this->prgs[$prg_obj_id];
153  }
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 53 of file class.ilPrgRestartAssignmentsCronJob.php.

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilPrgRestartAssignmentsCronJob::hasAutoActivation ( )

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

68  : bool
69  {
70  return true;
71  }

◆ hasFlexibleSchedule()

ilPrgRestartAssignmentsCronJob::hasFlexibleSchedule ( )

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

73  : bool
74  {
75  return true;
76  }

◆ log()

ilPrgRestartAssignmentsCronJob::log ( string  $msg)
protected

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

Referenced by __construct(), and run().

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

◆ run()

ilPrgRestartAssignmentsCronJob::run ( )

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

References getNow(), getStudyProgramme(), log(), and null.

Referenced by ilPrgRestartAssignmentsCronJobTest\testRestartAssignmentsEvents().

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

◆ $lng

ilLanguage ilPrgRestartAssignmentsCronJob::$lng
protected

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

◆ $log

ilComponentLogger ilPrgRestartAssignmentsCronJob::$log
protected

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

◆ $prgs

array ilPrgRestartAssignmentsCronJob::$prgs = []
protected

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

◆ ACTING_USR_ID

const ilPrgRestartAssignmentsCronJob::ACTING_USR_ID = ilPRGAssignment::AUTO_ASSIGNED_BY_RESTART
private

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

◆ ID

const ilPrgRestartAssignmentsCronJob::ID = 'prg_restart_assignments_temporal_progress'
private

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


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