5 include_once
"Services/Cron/classes/class.ilCronJob.php";
37 $this->lng = $DIC->language();
38 if (isset($DIC[
"ilAccess"])) {
39 $this->access = $DIC->access();
47 return "book_notification";
54 $lng->loadLanguageModule(
"book");
55 return $lng->txt(
"book_notification");
62 $lng->loadLanguageModule(
"book");
63 return $lng->txt(
"book_notification_info");
68 return self::SCHEDULE_TYPE_DAILY;
116 $log->debug(
"start");
127 $next_day_ts = mktime(0, 0, 0, date(
'n'), date(
'j') + 1);
128 $log->debug(
"next day ts: " . $next_day_ts);
129 $last_reminder_to_ts = $p[
"last_remind_ts"];
132 $log->debug(
"last_reminder ts: " . $last_reminder_to_ts);
133 $from_ts = max($next_day_ts, $last_reminder_to_ts);
134 $log->debug(
"from ts: " . $from_ts);
135 $to_ts = mktime(0, 0, 0, date(
'n'), date(
'j') + $p[
"reminder_day"] + 1);
144 $log->debug(
"pool id: " 145 . $p[
"booking_pool_id"]
148 . date(
"Y-m-d, H:i:s", $from_ts)
149 .
" to " . date(
"Y-m-d, H:i:s", $to_ts));
152 if ($to_ts > $from_ts) {
156 ], [$p[
"booking_pool_id"]]);
159 $log->debug(
"reservations: " . count(
$res));
166 $log->debug(
"users: " . count($user_ids));
172 $log->debug(
"check notification of user id: " . $r[
"user_id"]);
173 if (in_array($r[
"user_id"], $user_ids)) {
174 if ($this->
checkAccess(
"read", $r[
"user_id"], $p[
"booking_pool_id"])) {
175 $log->debug(
"got read");
176 $notifications[$r[
"user_id"]][
"personal"][$r[
"pool_id"]][] =
$r;
181 foreach ($user_ids as $uid) {
182 $log->debug(
"check write for user id: " . $uid .
", pool: " . $p[
"booking_pool_id"]);
184 if ($this->
checkAccess(
"write", $uid, $p[
"booking_pool_id"])) {
185 $log->debug(
"got write");
186 $notifications[$uid][
"admin"][$r[
"pool_id"]][] =
$r;
193 $log->debug(
"notifications to users: " . count($notifications));
198 return count($notifications);
208 foreach ($notifications as $uid =>
$n) {
209 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
211 $lng = $ntf->getUserLanguage($uid);
212 $lng->loadLanguageModule(
"book");
215 if (is_array(
$n[
"personal"])) {
216 $txt .=
"\n" .
$lng->txt(
"book_your_reservations") .
"\n";
217 $txt .=
"-----------------------------------------\n";
218 foreach (
$n[
"personal"] as $obj_id => $reservs) {
220 foreach ($reservs as
$r) {
221 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " .
228 if (is_array(
$n[
"admin"])) {
229 $txt .=
"\n" .
$lng->txt(
"book_reservation_overview") .
"\n";
230 $txt .=
"-----------------------------------------\n";
231 foreach (
$n[
"admin"] as $obj_id => $reservs) {
233 foreach ($reservs as
$r) {
234 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " . $r[
"user_name"] .
", " .
241 $ntf->setLangModules(array(
"book"));
242 $ntf->setSubjectLangId(
"book_booking_reminders");
243 $ntf->setIntroductionLangId(
"book_rem_intro");
244 $ntf->addAdditionalInfo(
"",
$txt);
245 $ntf->setReasonLangId(
"book_rem_reason");
246 $ntf->sendMail(array($uid));
261 if (
$access->checkAccessOfUser($uid, $perm,
"", $ref_id)) {
Cron job application base class.
static writeLastReminderTimestamp($a_obj_id, $a_ts)
Write last reminder timestamp.
static _lookupTitle($a_id)
lookup object title
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static getPoolsWithReminders()
Get poos with reminders.
static _getAllReferences($a_id)
get all reference ids of object
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
sendUserNotifications($res)
Send user notifications.
getDefaultScheduleValue()
foreach($_POST as $key=> $value) $res
Cron for booking manager notification.
static getListByDate( $a_has_schedule, array $a_object_ids=null, array $filter=null, array $a_pool_ids=null)
List all reservations by date.
sendMails($notifications)
Send mails.
sendNotifications()
Send notifications.
static getLogger($a_component_id)
Get component logger.
Cron job result data container.
checkAccess($perm, $uid, $obj_id)
check access on obj id
Wrapper classes for system notifications.
sendAdminNotifications($res)
Send admin notifications.
__construct()
Constructor.