23 lines
No EOL
657 B
PHP
23 lines
No EOL
657 B
PHP
<?php
|
|
|
|
return function ($group, $item) {
|
|
foreach (kirby()->users()->not($this) as $otherUser) {
|
|
try {
|
|
$notifications = $otherUser->notifications()->isNotEmpty()
|
|
? Yaml::decode($otherUser->notifications()->value())
|
|
: [];
|
|
|
|
if (!isset($notifications[$group])) {
|
|
$notifications[$group] = [];
|
|
}
|
|
|
|
$notifications[$group][$item->id()] = $item->toArray();
|
|
|
|
$otherUser->update([
|
|
'notifications' => $notifications
|
|
]);
|
|
} catch (\Throwable $th) {
|
|
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
|
}
|
|
}
|
|
}; |