ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilMembershipCronMinMembers Class Reference

Cron for course/group minimum members. More...

+ Inheritance diagram for ilMembershipCronMinMembers:
+ Collaboration diagram for ilMembershipCronMinMembers:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 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

 getCourses (array &$a_recipients_map)
 
 getGroups (array &$a_recipients_map)
 
 sendMessage (int $a_reci_id, array $a_items)
 

Protected Attributes

ilLanguage $lng
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Cron for course/group minimum members.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilMembershipCronMinMembers::__construct ( )

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

35 {
36 global $DIC;
37
38 $this->lng = $DIC->language();
39 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getCourses()

ilMembershipCronMinMembers::getCourses ( array &  $a_recipients_map)
protected

Definition at line 101 of file class.ilMembershipCronMinMembers.php.

101 : void
102 {
103 foreach (ilObjCourse::findCoursesWithNotEnoughMembers() as $obj_id => $item) {
104 $too_few = (bool) $item[0];
105
106
107 if ($too_few) {
108 // not enough members: notifiy course admins
109 foreach ($item[1] as $reci_id) {
110 $a_recipients_map[$reci_id][] = array("crs", $obj_id, $item[0]);
111 }
112 }
113 }
114 }
static findCoursesWithNotEnoughMembers()

References ilObjCourse\findCoursesWithNotEnoughMembers().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilMembershipCronMinMembers::getDefaultScheduleType ( )

Reimplemented from ILIAS\Cron\CronJob.

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

57 {
58 return JobScheduleType::DAILY;
59 }

◆ getDefaultScheduleValue()

ilMembershipCronMinMembers::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

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

61 : ?int
62 {
63 return null;
64 }

◆ getDescription()

ilMembershipCronMinMembers::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

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

51 : string
52 {
53 return $this->lng->txt("mem_cron_min_members_info");
54 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getGroups()

ilMembershipCronMinMembers::getGroups ( array &  $a_recipients_map)
protected

Definition at line 116 of file class.ilMembershipCronMinMembers.php.

116 : void
117 {
118 foreach (ilObjGroup::findGroupsWithNotEnoughMembers() as $obj_id => $item) {
119 $too_few = (bool) $item[0];
120
121
122 if ($too_few) {
123 // not enough members: notifiy group admins
124 foreach ($item[1] as $reci_id) {
125 $a_recipients_map[$reci_id][] = array("grp", $obj_id, $item[0]);
126 }
127 }
128 }
129 }
static findGroupsWithNotEnoughMembers()

References ilObjGroup\findGroupsWithNotEnoughMembers().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilMembershipCronMinMembers::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

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

41 : string
42 {
43 return "mem_min_members";
44 }

◆ getTitle()

ilMembershipCronMinMembers::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 46 of file class.ilMembershipCronMinMembers.php.

46 : string
47 {
48 return $this->lng->txt("mem_cron_min_members");
49 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilMembershipCronMinMembers::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ILIAS\Cron\CronJob.

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

66 : bool
67 {
68 return true;
69 }

◆ hasFlexibleSchedule()

ilMembershipCronMinMembers::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

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

71 : bool
72 {
73 return false;
74 }

◆ run()

ilMembershipCronMinMembers::run ( )

Reimplemented from ILIAS\Cron\CronJob.

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

76 : JobResult
77 {
78 $status = JobResult::STATUS_NO_ACTION;
79 $message = '';
80
81 $recipients_map = array();
82
83 $this->getCourses($recipients_map);
84 $this->getGroups($recipients_map);
85
86 if (count($recipients_map)) {
87 foreach ($recipients_map as $reci_id => $items) {
88 $this->sendMessage($reci_id, $items);
89 }
90 $status = JobResult::STATUS_OK;
91 $message = count($recipients_map) . " notifications sent";
92 }
93
94 $result = new JobResult();
95 $result->setStatus($status);
96 $result->setMessage($message);
97
98 return $result;
99 }
sendMessage(int $a_reci_id, array $a_items)

References getCourses(), getGroups(), and sendMessage().

+ Here is the call graph for this function:

◆ sendMessage()

ilMembershipCronMinMembers::sendMessage ( int  $a_reci_id,
array  $a_items 
)
protected

Definition at line 131 of file class.ilMembershipCronMinMembers.php.

131 : void
132 {
133 $ntf = new ilSystemNotification();
134 $ntf->setLangModules(array("crs"));
135
136 // #17097
137 $ntf->setReasonLangId("mem_cron_min_members_reason");
138
139 // user specific language
140 $lng = $ntf->getUserLanguage($a_reci_id);
141
142 $list = array();
143 foreach ($a_items as $item) {
144 $obj_type = (string) $item[0];
145 $obj_id = (int) $item[1];
146 $ref_ids = ilObject::_getAllReferences($obj_id);
147 $ref_id = array_pop($ref_ids);
148 $title = ilObject::_lookupTitle($obj_id);
149 $url = ilLink::_getLink($ref_id, $obj_type);
150
151 $list[] = $title . "\n" . $url . "\n";
152 }
153 $list = implode($ntf->getBlockBorder() . "\n", $list);
154
155 $ntf->addAdditionalInfo("mem_cron_min_members_intro", $list, true);
156 $ntf->addAdditionalInfo("mem_cron_min_members_task", "");
157
158 $mail = new ilMail(ANONYMOUS_USER_ID);
159 $mail->enqueue(
160 ilObjUser::_lookupLogin($a_reci_id),
161 '',
162 '',
163 $lng->txt("mem_cron_min_members_subject"),
164 $ntf->composeAndGetMessage($a_reci_id, null, "read", true),
165 []
166 );
167 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getUserLanguage()
Return language of user.
static _lookupLogin(int $a_user_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
$ref_id
Definition: ltiauth.php:66
$url
Definition: shib_logout.php:70

References $lng, $ref_id, $url, ilObject\_getAllReferences(), ilObjUser\_lookupLogin(), ilObject\_lookupTitle(), ANONYMOUS_USER_ID, ilLanguage\getUserLanguage(), ILIAS\Repository\int(), and ilLanguage\txt().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilLanguage ilMembershipCronMinMembers::$lng
protected

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

Referenced by sendMessage().


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