ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 ()
 
 hasFlexibleSchedule ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $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 (?CronJobScheduleType $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

 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 ilCronJob
CronJobScheduleType $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.

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

35  {
36  global $DIC;
37 
38  $this->lng = $DIC->language();
39  }
global $DIC
Definition: shib_login.php:25
+ 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.

References ilObjCourse\findCoursesWithNotEnoughMembers().

Referenced by run().

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()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilMembershipCronMinMembers::getDefaultScheduleType ( )

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

57  {
58  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
59  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilMembershipCronMinMembers::getDefaultScheduleValue ( )

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

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

◆ getDescription()

ilMembershipCronMinMembers::getDescription ( )

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

References ILIAS\Repository\lng().

51  : string
52  {
53  return $this->lng->txt("mem_cron_min_members_info");
54  }
+ 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.

References ilObjGroup\findGroupsWithNotEnoughMembers().

Referenced by run().

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()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilMembershipCronMinMembers::getId ( )

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

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

◆ getTitle()

ilMembershipCronMinMembers::getTitle ( )

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

References ILIAS\Repository\lng().

46  : string
47  {
48  return $this->lng->txt("mem_cron_min_members");
49  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilMembershipCronMinMembers::hasAutoActivation ( )

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

66  : bool
67  {
68  return true;
69  }

◆ hasFlexibleSchedule()

ilMembershipCronMinMembers::hasFlexibleSchedule ( )

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

71  : bool
72  {
73  return false;
74  }

◆ run()

ilMembershipCronMinMembers::run ( )

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

References getCourses(), getGroups(), sendMessage(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

77  {
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  }
91  $message = count($recipients_map) . " notifications sent";
92  }
93 
94  $result = new ilCronJobResult();
95  $result->setStatus($status);
96  $result->setMessage($message);
97 
98  return $result;
99  }
sendMessage(int $a_reci_id, array $a_items)
final const STATUS_NO_ACTION
+ 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.

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

Referenced by run().

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(), $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  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
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 _getAllReferences(int $id)
get all reference ids for object ID
$url
Definition: shib_logout.php:63
$ref_id
Definition: ltiauth.php:66
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupLogin(int $a_user_id)
+ 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.


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