38 protected \ILIAS\BookingManager\InternalRepoService
$repo;
49 $this->
lng = $DIC->language();
51 $this->repo =
$DIC->bookingManager()
54 $this->
access = $DIC->access();
55 $this->booking_access =
$DIC->bookingManager()->internal()->domain()->access();
56 $this->uri_builder =
$DIC[
'static_url']->builder();
61 return "book_notification";
69 return $lng->
txt(
"book_notification");
77 return $lng->
txt(
"book_notification_info");
82 return JobScheduleType::DAILY;
102 $status = JobResult::STATUS_NO_ACTION;
107 $status = JobResult::STATUS_OK;
111 $result->setStatus($status);
120 $log->debug(
"start");
131 $next_day_ts = mktime(0, 0, 0,
date(
'n'), (
int)
date(
'j') + 1);
132 $log->debug(
"next day ts: " . $next_day_ts);
133 $last_reminder_to_ts = $p[
"last_remind_ts"];
136 $log->debug(
"last_reminder ts: " . $last_reminder_to_ts);
137 $from_ts = max($next_day_ts, $last_reminder_to_ts);
138 $log->debug(
"from ts: " . $from_ts);
139 $to_ts = mktime(0, 0, 0,
date(
'n'), (
int)
date(
'j') + $p[
"reminder_day"] + 1);
148 $log->debug(
"pool id: "
149 . $p[
"booking_pool_id"]
152 .
date(
"Y-m-d, H:i:s", $from_ts)
153 .
" to " .
date(
"Y-m-d, H:i:s", $to_ts));
156 if ($to_ts > $from_ts) {
157 $repo = $this->repo->reservation();
158 $res =
$repo->getListByDate(
true,
null, [
161 ], [$p[
"booking_pool_id"]]);
164 $log->debug(
"reservations: " . count(
$res));
170 $log->debug(
"users: " . count($user_ids));
173 foreach (
$res as $r) {
175 $log->debug(
"check notification of user id: " . $r[
"user_id"]);
176 if (in_array($r[
"user_id"], $user_ids)) {
177 if ($this->booking_access->canRetrieveNotificationsForOwnReservationsByObjId(
178 (
int) $p[
"booking_pool_id"],
181 $log->debug(
"got read");
182 $notifications[$r[
"user_id"]][
"personal"][$r[
"pool_id"]][] = $r;
187 foreach ($user_ids as $uid) {
188 $log->debug(
"check write for user id: " . $uid .
", pool: " . $p[
"booking_pool_id"]);
190 if ($this->booking_access->canRetrieveNotificationsForAllReservationsByObjId(
191 (
int) $p[
"booking_pool_id"],
194 $log->debug(
"got write");
195 $notifications[$uid][
"admin"][$r[
"pool_id"]][] = $r;
205 return count($notifications);
211 foreach ($notifications as $uid => $n) {
217 $ntf->setLangModules(array(
"book"));
218 $ntf->setSubjectLangId(
"book_booking_reminders");
219 $ntf->setIntroductionLangId(
"book_rem_intro");
220 $ntf->addAdditionalInfo(
"", $txt);
221 $ntf->setReasonLangId(
"book_rem_reason");
222 $this->book_log->debug(
"send Mail: " . $uid);
223 $ntf->sendMailAndReturnRecipients([$uid]);
230 $this->personalSection($language, $notification[
'personal'] ??
null,
$user_id),
231 $this->adminSection($language, $notification[
'admin'] ??
null,
$user_id)
237 if (!is_array($pools)) {
242 foreach ($pools as $pool_id => $reservations) {
244 foreach ($reservations as $reservation) {
246 (
string) $reservation[
'title'],
247 (
int) $reservation[
'counter'],
249 .
', ' . $reservation[
'slot']
252 $blocks[] = $this->poolBlock((
int) $pool_id,
$user_id, $lines);
260 if (!is_array($pools)) {
265 foreach ($pools as $pool_id => $reservations) {
267 foreach ($reservations as $reservation) {
269 (
string) $reservation[
'title'],
270 (
int) $reservation[
'counter'],
271 (
string) $reservation[
'user_name'],
273 .
', ' . $reservation[
'slot'],
274 $reservation[
'message'] !=
''
275 ? $language->
txt(
'book_message') .
': ' . $reservation[
'message']
279 $blocks[] = $this->poolBlock((
int) $pool_id,
$user_id, $lines);
292 $this->poolGotoLink($pool_id,
$user_id),
300 if ($this->
access->checkAccessOfUser($user_id,
'read',
'', $ref_id)) {
301 return (
string) $this->uri_builder->build(
'book',
new ReferenceId((
int) $ref_id));
Cron for booking manager notification.
adminSection(ilLanguage $language, mixed $pools, int $user_id)
personalSection(ilLanguage $language, mixed $pools, int $user_id)
ILIAS BookingManager InternalRepoService $repo
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
buildReminderBody(ilLanguage $language, array $notification, int $user_id)
AccessManager $booking_access
sendMails(array $notifications)
getDefaultScheduleValue()
poolBlock(int $pool_id, int $user_id, array $reservations)
poolGotoLink(int $pool_obj_id, int $user_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
loadLanguageModule(string $a_module)
Load language module.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
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 getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
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)
static getPoolsWithReminders()
Get pools with reminders.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach( $report as $row)
Combines all available interfaces which can be called via global $ilAccess.
foreach($_POST as $key=> $value) $res