27 protected \ILIAS\BookingManager\InternalRepoService
$repo;
36 $this->
lng = $DIC->language();
37 if (isset($DIC[
"ilAccess"])) {
38 $this->
access = $DIC->access();
42 $this->repo = $DIC->bookingManager()
49 return "book_notification";
57 return $lng->
txt(
"book_notification");
65 return $lng->
txt(
"book_notification_info");
70 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
99 $result->setStatus($status);
108 $log->debug(
"start");
119 $next_day_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + 1);
120 $log->debug(
"next day ts: " . $next_day_ts);
121 $last_reminder_to_ts = $p[
"last_remind_ts"];
124 $log->debug(
"last_reminder ts: " . $last_reminder_to_ts);
125 $from_ts = max($next_day_ts, $last_reminder_to_ts);
126 $log->debug(
"from ts: " . $from_ts);
127 $to_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + $p[
"reminder_day"] + 1);
136 $log->debug(
"pool id: " 137 . $p[
"booking_pool_id"]
140 . date(
"Y-m-d, H:i:s", $from_ts)
141 .
" to " . date(
"Y-m-d, H:i:s", $to_ts));
144 if ($to_ts > $from_ts) {
145 $repo = $this->repo->reservation();
146 $res = $repo->getListByDate(
true, null, [
149 ], [$p[
"booking_pool_id"]]);
152 $log->debug(
"reservations: " . count(
$res));
158 $log->debug(
"users: " . count($user_ids));
163 $log->debug(
"check notification of user id: " . $r[
"user_id"]);
164 if (in_array($r[
"user_id"], $user_ids)) {
165 if ($this->
checkAccess(
"read", $r[
"user_id"], $p[
"booking_pool_id"])) {
166 $log->debug(
"got read");
167 $notifications[$r[
"user_id"]][
"personal"][$r[
"pool_id"]][] =
$r;
172 foreach ($user_ids as $uid) {
173 $log->debug(
"check write for user id: " . $uid .
", pool: " . $p[
"booking_pool_id"]);
175 if ($this->
checkAccess(
"write", $uid, $p[
"booking_pool_id"])) {
176 $log->debug(
"got write");
177 $notifications[$uid][
"admin"][$r[
"pool_id"]][] =
$r;
187 return count($notifications);
193 foreach ($notifications as $uid => $n) {
199 if (is_array($n[
"personal"] ?? null)) {
200 $txt .=
"\n" . $lng->
txt(
"book_your_reservations") .
"\n";
201 $txt .=
"-----------------------------------------\n";
202 foreach ($n[
"personal"] as $obj_id => $reservs) {
204 foreach ($reservs as
$r) {
205 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " .
212 if (is_array($n[
"admin"] ?? null)) {
213 $txt .=
"\n" . $lng->
txt(
"book_reservation_overview") .
"\n";
214 $txt .=
"-----------------------------------------\n";
215 foreach ($n[
"admin"] as $obj_id => $reservs) {
217 foreach ($reservs as
$r) {
218 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " . $r[
"user_name"] .
", " .
221 if ($r[
"message"] !=
"") {
222 $txt .=
" " . $lng->
txt(
"book_message") .
223 ": " . $r[
"message"];
228 $ntf->setLangModules(array(
"book"));
229 $ntf->setSubjectLangId(
"book_booking_reminders");
230 $ntf->setIntroductionLangId(
"book_rem_intro");
231 $ntf->addAdditionalInfo(
"",
$txt);
232 $ntf->setReasonLangId(
"book_rem_reason");
233 $this->book_log->debug(
"send Mail: " . $uid);
234 $ntf->sendMailAndReturnRecipients([$uid]);
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
final const STATUS_NO_ACTION
Cron for booking manager notification.
ILIAS BookingManager InternalRepoService $repo
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) ...