ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 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 32 of file class.ilMembershipCronMinMembers.php.

Constructor & Destructor Documentation

◆ __construct()

ilMembershipCronMinMembers::__construct ( )

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

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

37  {
38  global $DIC;
39 
40  $this->lng = $DIC->language();
41  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getCourses()

ilMembershipCronMinMembers::getCourses ( array &  $a_recipients_map)
protected

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

References ilObjCourse\findCoursesWithNotEnoughMembers().

Referenced by run().

103  : void
104  {
105  foreach (ilObjCourse::findCoursesWithNotEnoughMembers() as $obj_id => $item) {
106  $too_few = (bool) $item[0];
107 
108 
109  if ($too_few) {
110  // not enough members: notifiy course admins
111  foreach ($item[1] as $reci_id) {
112  $a_recipients_map[$reci_id][] = array("crs", $obj_id, $item[0]);
113  }
114  }
115  }
116  }
static findCoursesWithNotEnoughMembers()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilMembershipCronMinMembers::getDefaultScheduleType ( )

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

59  {
60  return JobScheduleType::DAILY;
61  }

◆ getDefaultScheduleValue()

ilMembershipCronMinMembers::getDefaultScheduleValue ( )

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

References null.

63  : ?int
64  {
65  return null;
66  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilMembershipCronMinMembers::getDescription ( )

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

References ILIAS\Repository\lng().

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

◆ getGroups()

ilMembershipCronMinMembers::getGroups ( array &  $a_recipients_map)
protected

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

References ilObjGroup\findGroupsWithNotEnoughMembers().

Referenced by run().

118  : void
119  {
120  foreach (ilObjGroup::findGroupsWithNotEnoughMembers() as $obj_id => $item) {
121  $too_few = (bool) $item[0];
122 
123 
124  if ($too_few) {
125  // not enough members: notifiy group admins
126  foreach ($item[1] as $reci_id) {
127  $a_recipients_map[$reci_id][] = array("grp", $obj_id, $item[0]);
128  }
129  }
130  }
131  }
static findGroupsWithNotEnoughMembers()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilMembershipCronMinMembers::getId ( )

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

43  : string
44  {
45  return "mem_min_members";
46  }

◆ getTitle()

ilMembershipCronMinMembers::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilMembershipCronMinMembers::hasAutoActivation ( )

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

68  : bool
69  {
70  return true;
71  }

◆ hasFlexibleSchedule()

ilMembershipCronMinMembers::hasFlexibleSchedule ( )

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

73  : bool
74  {
75  return false;
76  }

◆ run()

ilMembershipCronMinMembers::run ( )

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

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

78  : JobResult
79  {
80  $status = JobResult::STATUS_NO_ACTION;
81  $message = '';
82 
83  $recipients_map = array();
84 
85  $this->getCourses($recipients_map);
86  $this->getGroups($recipients_map);
87 
88  if (count($recipients_map)) {
89  foreach ($recipients_map as $reci_id => $items) {
90  $this->sendMessage($reci_id, $items);
91  }
92  $status = JobResult::STATUS_OK;
93  $message = count($recipients_map) . " notifications sent";
94  }
95 
96  $result = new JobResult();
97  $result->setStatus($status);
98  $result->setMessage($message);
99 
100  return $result;
101  }
sendMessage(int $a_reci_id, array $a_items)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ sendMessage()

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

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

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

Referenced by run().

133  : void
134  {
135  $ntf = new ilSystemNotification();
136  $ntf->setLangModules(array("crs"));
137 
138  // #17097
139  $ntf->setReasonLangId("mem_cron_min_members_reason");
140 
141  // user specific language
142  $lng = $ntf->getUserLanguage($a_reci_id);
143 
144  $list = array();
145  foreach ($a_items as $item) {
146  $obj_type = (string) $item[0];
147  $obj_id = (int) $item[1];
148  $ref_ids = ilObject::_getAllReferences($obj_id);
149  $ref_id = array_pop($ref_ids);
150  $title = ilObject::_lookupTitle($obj_id);
151  $url = ilLink::_getLink($ref_id, $obj_type);
152 
153  $list[] = $title . "\n" . $url . "\n";
154  }
155  $list = implode($ntf->getBlockBorder(), $list);
156 
157  $ntf->addAdditionalInfo("mem_cron_min_members_intro", $list, true);
158  $ntf->addAdditionalInfo("mem_cron_min_members_task", "");
159 
160  $mail = new ilMail(ANONYMOUS_USER_ID);
161  $mail->enqueue(
162  ilObjUser::_lookupLogin($a_reci_id),
163  '',
164  '',
165  $lng->txt("mem_cron_min_members_subject"),
166  $ntf->composeAndGetMessage($a_reci_id, null, "read", true),
167  []
168  );
169  }
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:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
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 34 of file class.ilMembershipCronMinMembers.php.


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