4 include_once
"Services/Cron/classes/class.ilCronJob.php";
28 return "frm_notification";
35 return $lng->txt(
"cron_forum_notification");
42 return $lng->txt(
"cron_forum_notification_crob_desc");
47 return self::SCHEDULE_TYPE_IN_HOURS;
79 $lng->loadLanguageModule(
'forum');
81 if(!($last_run_datetime = $ilSetting->get(
'cron_forum_notification_last_date')))
83 $last_run_datetime = null;
90 if($last_run_datetime != null &&
91 checkDate(date(
'm', strtotime($last_run_datetime)), date(
'd', strtotime($last_run_datetime)), date(
'Y', strtotime($last_run_datetime))))
93 $threshold = max(strtotime($last_run_datetime), strtotime(
'-' . (
int)$this->settings->get(
'max_notification_age', 30) .
' days', time()));
97 $threshold = strtotime(
'-' . (
int)$this->settings->get(
'max_notification_age', 30) .
' days', time());
100 $date_condition =
' frm_posts.pos_date >= %s AND ';
101 $types[] =
'timestamp';
102 $values[] = date(
'Y-m-d H:i:s', $threshold);
104 $cj_start_date = date(
'Y-m-d H:i:s');
107 $res = $ilDB->queryf(
' 108 SELECT frm_threads.thr_subject thr_subject, 109 frm_data.top_name top_name, 110 frm_data.top_frm_fk obj_id, 111 frm_notification.user_id user_id, 113 FROM frm_notification, frm_posts, frm_threads, frm_data 114 WHERE '.$date_condition.
' frm_posts.pos_thr_fk = frm_threads.thr_pk 115 AND frm_threads.thr_top_fk = frm_data.top_pk 116 AND frm_data.top_frm_fk = frm_notification.frm_id 117 ORDER BY frm_posts.pos_date ASC',
125 $res = $ilDB->queryf(
' 126 SELECT frm_threads.thr_subject thr_subject, 127 frm_data.top_name top_name, 128 frm_data.top_frm_fk obj_id, 129 frm_notification.user_id user_id, 131 FROM frm_notification, frm_posts, frm_threads, frm_data 132 WHERE '.$date_condition.
' frm_posts.pos_thr_fk = frm_threads.thr_pk 133 AND frm_threads.thr_pk = frm_notification.thread_id 134 AND frm_data.top_pk = frm_threads.thr_top_fk 135 ORDER BY frm_posts.pos_date ASC',
142 $ilSetting->set(
'cron_forum_notification_last_date', $cj_start_date);
144 $mess =
'Send '.$numRows.
' messages.';
145 $ilLog->write(__METHOD__.
': '.$mess);
161 static $cache = array();
162 static $attachments_cache = array();
164 include_once
'Modules/Forum/classes/class.ilObjForum.php';
165 include_once
'Services/Mail/classes/class.ilMail.php';
166 include_once
'Services/User/classes/class.ilObjUser.php';
167 include_once
'Services/Language/classes/class.ilLanguage.php';
170 $frm = $forumObj->Forum;
173 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
174 $mail_obj->enableSOAP(
false);
175 while(
$row = $ilDB->fetchAssoc(
$res))
178 if(
$row[
'pos_display_user_id'] !=
$row[
'user_id'])
181 if(
$row[
'pos_display_user_id'])
185 else if(strlen(
$row[
'pos_usr_alias']))
187 $row[
'pos_usr_name'] =
$row[
'pos_usr_alias'].
' ('.$lng->txt(
'frm_pseudonym').
')';
190 if(
$row[
'pos_usr_name'] ==
'')
192 $row[
'pos_usr_name'] = $lng->txt(
'forums_anonymous');
196 if(!isset($cache[
$row[
'obj_id']]))
200 $has_attachments =
false;
201 if(!isset($attachments_cache[$row[
'obj_id']][$row[
'pos_pk']]))
204 $filesOfPost = $fileDataForum->getFilesOfPost();
205 foreach($filesOfPost as $attachment)
207 $attachments_cache[$row[
'obj_id']][$row[
'pos_pk']][] = $attachment[
'name'];
208 $has_attachments =
true;
213 $has_attachments =
true;
218 foreach((array)$cache[$row[
'obj_id']] as
$ref_id)
220 if($ilAccess->checkAccessOfUser($row[
'user_id'],
'read',
'', $ref_id))
227 $attached_files = array();
228 if($has_attachments ==
true)
230 $attached_files = $attachments_cache[$row[
'obj_id']][$row[
'pos_pk']];
238 $frm->formatNotificationSubject($row),
239 $frm->formatNotification($row, 1, $attached_files, $row[
'user_id']),
261 $a_fields[
'cron_forum_notification'] = $a_is_active ?
262 $lng->txt(
'enabled') :
263 $lng->txt(
'disabled');
273 if((
bool)$a_currently_active)
275 $ilSetting->set(
'forum_notification', 2);
279 $ilSetting->set(
'forum_notification', 1);
293 $lng->loadLanguageModule(
'forum');
295 $max_notification_age =
new ilNumberInputGUI($lng->txt(
'frm_max_notification_age'),
'max_notification_age');
296 $max_notification_age->
setSize(5);
297 $max_notification_age->setSuffix($lng->txt(
'frm_max_notification_age_unit'));
298 $max_notification_age->setRequired(
true);
299 $max_notification_age->allowDecimals(
false);
300 $max_notification_age->setMinValue(1);
301 $max_notification_age->setInfo($lng->txt(
'frm_max_notification_age_info'));
302 $max_notification_age->setValue($this->settings->get(
'max_notification_age', 30));
304 $a_form->
addItem($max_notification_age);
312 $this->settings->set(
'max_notification_age', $a_form->
getInput(
'max_notification_age'));
addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
Add external settings to form.
Cron job application base class.
static _getAllReferences($a_id)
get all reference ids of object
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
Add custom settings to form.
getDefaultScheduleValue()
Class Mail this class handles base functions for mail handling.
_lookupLogin($a_user_id)
lookup login
saveCustomSettings(ilPropertyFormGUI $a_form)
activationWasToggled($a_currently_active)
This class handles all operations on files for the forum object.
Cron job result data container.
static _getLanguageInstanceByUsrId($usr_id)
Get the ilLanguage instance for the passed user id.