diff --git a/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php b/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php index 8577b6f034b3..6308d5d52189 100755 --- a/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php +++ b/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php @@ -68,9 +68,14 @@ public function getNotificationItem(int $nr_buckets): Notification */ protected function getAggregateItems(): array { + $user = $this->dic->user(); + if ($user->isAnonymous() || $user->getId() === 0) { + return []; + } + $persistence = $this->dic->backgroundTasks()->persistence(); $items = []; - $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC'); + $observer_ids = $persistence->getBucketIdsOfUser($user->getId(), 'id', 'DESC'); foreach ($persistence->loadBuckets($observer_ids) as $observer) { $items[] = $this->getItemForObserver($observer); } @@ -99,12 +104,6 @@ public function getItemForObserver(Bucket $observer): Notification } $item = $f->item()->notification($title, $icon); - // $item = $item->withProperties([ - // $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate( - // new \ilDateTime(time(), IL_CAL_UNIX) - // ) - // ]); - $item = $item->withActions($f->dropdown()->standard($actions)); $input = $current_task->getInput(); $message = $current_task->getMessage($input); @@ -125,8 +124,11 @@ public function getItemForObserver(Bucket $observer): Notification if ($state === State::RUNNING) { $url = $this->getRefreshUrl($observer); //Running Items probably need to refresh themselves, right? - $item = $item->withAdditionalOnLoadCode(fn($id): string => "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id')); - il.BGTask.refreshItem(notification_item,'$url');"); + $item = $item->withAdditionalOnLoadCode( + static fn(string $id): string => <<getExpectedTimeOfTaskInSeconds() : 0; $possibly_failed = ($observer->getLastHeartbeat() < (time() - $expected));