ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilMembershipCronNotifications Class Reference

Course/group notifications. More...

+ Inheritance diagram for ilMembershipCronNotifications:
+ Collaboration diagram for ilMembershipCronNotifications:

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 run ()
 Run job. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 sendMail ($a_user_id, $a_ref_id, array $news)
 Send news mail for 1 object and 1 user. More...
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Detailed Description

Course/group notifications.

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 12 of file class.ilMembershipCronNotifications.php.

Member Function Documentation

◆ activationWasToggled()

ilMembershipCronNotifications::activationWasToggled (   $a_currently_active)

Cron job status was changed.

Parameters
bool$a_currently_active

Reimplemented from ilCronJob.

Definition at line 250 of file class.ilMembershipCronNotifications.php.

251 {
252 global $ilSetting;
253
254 // propagate cron-job setting to object setting
255 $ilSetting->set("crsgrp_ntf", (bool)$a_currently_active);
256 }
global $ilSetting
Definition: privfeed.php:40

References $ilSetting.

◆ addToExternalSettingsForm()

ilMembershipCronNotifications::addToExternalSettingsForm (   $a_form_id,
array &  $a_fields,
  $a_is_active 
)

Add external settings to form.

Parameters
int$a_form_id
array$a_fields
bool$a_is_active

Reimplemented from ilCronJob.

Definition at line 235 of file class.ilMembershipCronNotifications.php.

236 {
237 global $lng;
238
239 switch($a_form_id)
240 {
243 $a_fields["enable_course_group_notifications"] = $a_is_active ?
244 $lng->txt("enabled") :
245 $lng->txt("disabled");
246 break;
247 }
248 }
global $lng
Definition: privfeed.php:40

References $lng, ilAdministrationSettingsFormHandler\FORM_COURSE, and ilAdministrationSettingsFormHandler\FORM_GROUP.

◆ getDefaultScheduleType()

ilMembershipCronNotifications::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

34 {
36 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilMembershipCronNotifications::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 38 of file class.ilMembershipCronNotifications.php.

39 {
40 return;
41 }

◆ getDescription()

ilMembershipCronNotifications::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 26 of file class.ilMembershipCronNotifications.php.

27 {
28 global $lng;
29
30 return $lng->txt("enable_course_group_notifications_desc");
31 }

References $lng.

◆ getId()

ilMembershipCronNotifications::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 14 of file class.ilMembershipCronNotifications.php.

15 {
16 return "mem_notification";
17 }

Referenced by run().

+ Here is the caller graph for this function:

◆ getTitle()

ilMembershipCronNotifications::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

Definition at line 19 of file class.ilMembershipCronNotifications.php.

20 {
21 global $lng;
22
23 return $lng->txt("enable_course_group_notifications");
24 }

References $lng.

◆ hasAutoActivation()

ilMembershipCronNotifications::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

44 {
45 return false;
46 }

◆ hasFlexibleSchedule()

ilMembershipCronNotifications::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

49 {
50 return false;
51 }

◆ run()

ilMembershipCronNotifications::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

54 {
55 global $lng, $ilDB;
56
58 $status_details = null;
59
60 $setting = new ilSetting("cron");
61 $last_run = $setting->get(get_class($this));
62
63 // #10284 - we already did send today, do nothing
64 if($last_run == date("Y-m-d"))
65 {
66 // #14005
67 $status_details = "Did already run today.";
68 }
69 else
70 {
71 // gather objects and participants with notification setting
72 $objects = array();
73 $set = $ilDB->query("SELECT usr_id,keyword FROM usr_pref".
74 " WHERE ".$ilDB->like("keyword", "text", "grpcrs_ntf_%").
75 " AND value = ".$ilDB->quote("1", "text"));
76 while($row = $ilDB->fetchAssoc($set))
77 {
78 $ref_id = substr($row["keyword"], 11);
79 $type = ilObject::_lookupType($ref_id, true);
80 if($type)
81 {
82 $objects[$type][$ref_id][] = $row["usr_id"];
83 }
84 }
85
86 $counter = 0;
87 if(sizeof($objects))
88 {
89 $old_lng = $lng;
90
91 include_once "Services/News/classes/class.ilNewsItem.php";
92 foreach($objects as $type => $ref_ids)
93 {
94 // type is not needed for now
95 foreach($ref_ids as $ref_id => $user_ids)
96 {
97 // gather news per object
98 $news_item = new ilNewsItem();
99 if($news_item->checkNewsExistsForGroupCourse($ref_id))
100 {
101 foreach($user_ids as $user_id)
102 {
103 // gather news for user
104 $user_news = $news_item->getNewsForRefId($ref_id,
105 false, false, 1, false, false, false, false,
106 $user_id);
107 if($user_news)
108 {
109 $this->sendMail($user_id, $ref_id, $user_news);
110 $counter++;
111
112 // #17928
113 ilCronManager::ping($this->getId());
114 }
115 }
116 }
117 }
118 }
119
120 $lng = $old_lng;
121 }
122
123 // save last run
124 $setting->set(get_class($this), date("Y-m-d"));
125
126 if($counter)
127 {
129 }
130 }
131
132 $result = new ilCronJobResult();
133 $result->setStatus($status);
134
135 if($status_details)
136 {
137 $result->setMessage($status_details);
138 }
139
140 return $result;
141 }
$result
Cron job result data container.
static ping($a_job_id)
Keep cron job alive.
sendMail($a_user_id, $a_ref_id, array $news)
Send news mail for 1 object and 1 user.
static _lookupType($a_id, $a_reference=false)
lookup object type
ILIAS Setting Class.
$ref_id
Definition: sahs_server.php:39
global $ilDB

References $ilDB, $lng, $ref_id, $result, $row, ilObject\_lookupType(), getId(), ilCronManager\ping(), sendMail(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

◆ sendMail()

ilMembershipCronNotifications::sendMail (   $a_user_id,
  $a_ref_id,
array  $news 
)
protected

Send news mail for 1 object and 1 user.

Parameters
int$a_user_id
int$a_ref_id
array$news

Definition at line 150 of file class.ilMembershipCronNotifications.php.

151 {
152 global $lng, $ilUser;
153
154 $obj_id = ilObject::_lookupObjId($a_ref_id);
155 $obj_type = ilObject::_lookupType($obj_id);
156
157 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
158 $ntf = new ilSystemNotification();
159 $ntf->setLangModules(array("crs", "news"));
160 $ntf->setRefId($a_ref_id);
161 $ntf->setGotoLangId('url');
162 $ntf->setSubjectLangId('crs_subject_course_group_notification');
163
164 // user specific language
165 $lng = $ntf->getUserLanguage($a_user_id);
166
167 $obj_title = $lng->txt($obj_type)." \"".ilObject::_lookupTitle($obj_id)."\"";
168 $ntf->setIntroductionDirect(sprintf($lng->txt("crs_intro_course_group_notification_for"), $obj_title));
169
170 $subject = sprintf($lng->txt("crs_subject_course_group_notification"), $obj_title);
171
172 // news summary
173 $counter = 1;
174 $txt = "";
175 foreach($news as $item)
176 {
177 $title = ilNewsItem::determineNewsTitle($item["context_obj_type"],
178 $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"],
179 $item["aggregation"]);
180 $content = ilNewsItem::determineNewsContent($item["context_obj_type"],
181 $item["content"], $item["content_text_is_lang_var"]);
182
183 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
184 $obj_title = ilObject::_lookupTitle($obj_id);
185
186 // path
187 include_once './Services/Locator/classes/class.ilLocatorGUI.php';
188 $cont_loc = new ilLocatorGUI();
189 $cont_loc->addContextItems($item["ref_id"], true);
190 $cont_loc->setTextOnly(true);
191
192 // #9954/#10044
193 // see ilInitialisation::requireCommonIncludes()
194 @include_once "HTML/Template/ITX.php"; // new implementation
195 if (class_exists("HTML_Template_ITX"))
196 {
197 include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php";
198 }
199 else
200 {
201 include_once "HTML/ITX.php"; // old implementation
202 include_once "./Services/UICore/classes/class.ilTemplateITX.php";
203 }
204 require_once "./Services/UICore/classes/class.ilTemplate.php";
205 $loc = "[".$cont_loc->getHTML()."]";
206
207 if($counter > 1)
208 {
209 $txt .= $ntf->getBlockBorder();
210 }
211 $txt .= '#'.$counter." - ".$loc." ".$obj_title."\n\n";
212 $txt .= $title;
213 if($content)
214 {
215 $txt .= "\n".$content;
216 }
217 $txt .= "\n\n";
218
219 ++$counter;
220 }
221 $ntf->addAdditionalInfo("news", $txt, true);
222
223 // #10044
224 $mail = new ilMail($ilUser->getId());
225 $mail->enableSOAP(false); // #10410
226 $mail->sendMail(ilObjUser::_lookupLogin($a_user_id),
227 null,
228 null,
229 $subject,
230 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
231 null,
232 array("system"));
233 }
locator handling class
Class Mail this class handles base functions for mail handling.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
static determineNewsTitle($a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
_lookupLogin($a_user_id)
lookup login
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
Wrapper classes for system notifications.
$txt
Definition: error.php:10
global $ilUser
Definition: imgupload.php:15

References $ilUser, $lng, $txt, ilObjUser\_lookupLogin(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\determineNewsContent(), and ilNewsItem\determineNewsTitle().

Referenced by run().

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

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