33 $this->
lng = $DIC->language();
34 if (isset($DIC[
"ilAccess"])) {
35 $this->
access = $DIC->access();
43 return "book_notification";
51 return $lng->
txt(
"book_notification");
59 return $lng->
txt(
"book_notification_info");
64 return self::SCHEDULE_TYPE_DAILY;
93 $result->setStatus($status);
102 $log->debug(
"start");
113 $next_day_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + 1);
114 $log->debug(
"next day ts: " . $next_day_ts);
115 $last_reminder_to_ts = $p[
"last_remind_ts"];
118 $log->debug(
"last_reminder ts: " . $last_reminder_to_ts);
119 $from_ts = max($next_day_ts, $last_reminder_to_ts);
120 $log->debug(
"from ts: " . $from_ts);
121 $to_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + $p[
"reminder_day"] + 1);
130 $log->debug(
"pool id: " 131 . $p[
"booking_pool_id"]
134 . date(
"Y-m-d, H:i:s", $from_ts)
135 .
" to " . date(
"Y-m-d, H:i:s", $to_ts));
138 if ($to_ts > $from_ts) {
140 $repo =
$f->getRepo();
141 $res = $repo->getListByDate(
true, null, [
144 ], [$p[
"booking_pool_id"]]);
147 $log->debug(
"reservations: " . count(
$res));
153 $log->debug(
"users: " . count($user_ids));
156 foreach (
$res as $r) {
159 $log->debug(
"check notification of user id: " . $r[
"user_id"]);
160 if (in_array($r[
"user_id"], $user_ids)) {
161 if ($this->
checkAccess(
"read", $r[
"user_id"], $p[
"booking_pool_id"])) {
162 $log->debug(
"got read");
163 $notifications[$r[
"user_id"]][
"personal"][$r[
"pool_id"]][] = $r;
168 foreach ($user_ids as $uid) {
169 $log->debug(
"check write for user id: " . $uid .
", pool: " . $p[
"booking_pool_id"]);
171 if ($this->
checkAccess(
"write", $uid, $p[
"booking_pool_id"])) {
172 $log->debug(
"got write");
173 $notifications[$uid][
"admin"][$r[
"pool_id"]][] = $r;
183 return count($notifications);
189 foreach ($notifications as $uid => $n) {
195 if (is_array($n[
"personal"] ?? null)) {
196 $txt .=
"\n" . $lng->
txt(
"book_your_reservations") .
"\n";
197 $txt .=
"-----------------------------------------\n";
198 foreach ($n[
"personal"] as $obj_id => $reservs) {
200 foreach ($reservs as $r) {
201 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " .
208 if (is_array($n[
"admin"] ?? null)) {
209 $txt .=
"\n" . $lng->
txt(
"book_reservation_overview") .
"\n";
210 $txt .=
"-----------------------------------------\n";
211 foreach ($n[
"admin"] as $obj_id => $reservs) {
213 foreach ($reservs as $r) {
214 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " . $r[
"user_name"] .
", " .
221 $ntf->setLangModules(array(
"book"));
222 $ntf->setSubjectLangId(
"book_booking_reminders");
223 $ntf->setIntroductionLangId(
"book_rem_intro");
224 $ntf->addAdditionalInfo(
"",
$txt);
225 $ntf->setReasonLangId(
"book_rem_reason");
226 $this->book_log->debug(
"send Mail: " . $uid);
227 $ntf->sendMailAndReturnRecipients([$uid]);
static getLogger(string $a_component_id)
Get component logger.
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
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
loadLanguageModule(string $a_module)
Load language module.
static getPoolsWithReminders()
Get pools with reminders.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.
static writeLastReminderTimestamp(int $a_obj_id, int $a_ts)
getDefaultScheduleValue()
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccess(string $perm, int $uid, int $obj_id)
sendMails(array $notifications)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...