ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMembershipCronNotifications Class Reference

Course/group notifications. More...

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

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 
 activationWasToggled ($a_currently_active)
 
- 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)

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

References $ilSetting.

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

◆ addToExternalSettingsForm()

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

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

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

233  {
234  global $lng;
235 
236  switch($a_form_id)
237  {
240  $a_fields["enable_course_group_notifications"] = $a_is_active ?
241  $lng->txt("enabled") :
242  $lng->txt("disabled");
243  break;
244  }
245  }
global $lng
Definition: privfeed.php:40

◆ getDefaultScheduleType()

ilMembershipCronNotifications::getDefaultScheduleType ( )

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

34  {
35  return self::SCHEDULE_TYPE_DAILY;
36  }

◆ getDefaultScheduleValue()

ilMembershipCronNotifications::getDefaultScheduleValue ( )

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

39  {
40  return;
41  }

◆ getDescription()

ilMembershipCronNotifications::getDescription ( )

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

References $lng.

27  {
28  global $lng;
29 
30  return $lng->txt("enable_course_group_notifications_desc");
31  }
global $lng
Definition: privfeed.php:40

◆ getId()

ilMembershipCronNotifications::getId ( )

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

15  {
16  return "mem_notification";
17  }

◆ getTitle()

ilMembershipCronNotifications::getTitle ( )

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

References $lng.

20  {
21  global $lng;
22 
23  return $lng->txt("enable_course_group_notifications");
24  }
global $lng
Definition: privfeed.php:40

◆ hasAutoActivation()

ilMembershipCronNotifications::hasAutoActivation ( )

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

44  {
45  return false;
46  }

◆ hasFlexibleSchedule()

ilMembershipCronNotifications::hasFlexibleSchedule ( )

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

49  {
50  return false;
51  }

◆ run()

ilMembershipCronNotifications::run ( )

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

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

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  }
113  }
114  }
115  }
116 
117  $lng = $old_lng;
118  }
119 
120  // save last run
121  $setting->set(get_class($this), date("Y-m-d"));
122 
123  if($counter)
124  {
125  $status = ilCronJobResult::STATUS_OK;
126  }
127  }
128 
129  $result = new ilCronJobResult();
130  $result->setStatus($status);
131 
132  if($status_details)
133  {
134  $result->setMessage($status_details);
135  }
136 
137  return $result;
138  }
ILIAS Setting Class.
$result
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
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
Cron job result data container.
+ 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 147 of file class.ilMembershipCronNotifications.php.

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

Referenced by run().

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