ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Badge\GlobalScreen\BadgeNotificationProvider Class Reference

Class BadgeNotificationProvider. More...

+ Inheritance diagram for ILIAS\Badge\GlobalScreen\BadgeNotificationProvider:
+ Collaboration diagram for ILIAS\Badge\GlobalScreen\BadgeNotificationProvider:

Public Member Functions

 getNotifications ()
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractNotificationProvider
 __construct (Container $dic)
 @inheritDoc More...
 
 getAdministrativeNotifications ()
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (Container $dic)
 @inheritDoc More...
 
 getFullyQualifiedClassName ()
 @inheritDoc More...
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getNotifications ()
 
 getAdministrativeNotifications ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractNotificationProvider
 $dic
 
 $if
 
 $notification_factory
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 $dic
 

Detailed Description

Class BadgeNotificationProvider.

Definition at line 14 of file BadgeNotificationProvider.php.

Member Function Documentation

◆ getNotifications()

ILIAS\Badge\GlobalScreen\BadgeNotificationProvider::getNotifications ( )

@inheritDoc

Implements ILIAS\GlobalScreen\Scope\Notification\Provider\NotificationProvider.

Definition at line 19 of file BadgeNotificationProvider.php.

19 : array
20 {
21 $lng = $this->dic->language();
22 $ui = $this->dic->ui();
23 $user = $this->dic->user();
24 $ctrl = $this->dic->ctrl();
25
26 $lng->loadLanguageModule("badge");
27
28 $factory = $this->globalScreen()->notifications()->factory();
29 $id = function (string $id) : IdentificationInterface {
30 return $this->if->identifier($id);
31 };
32
33 $new_badges = \ilBadgeAssignment::getNewCounter($user->getId());
34 if ($new_badges == 0) {
35 return [];
36 }
37
38 //Creating a badge Notification Item
39 $badge_icon = $this->dic->ui()->factory()->symbol()->icon()->standard("bdga", $lng->txt("badge_badge"))->withIsOutlined(true);
40 $badge_title = $ui->factory()->link()->standard(
41 $lng->txt("mm_badges"),
42 $ctrl->getLinkTargetByClass(["ilDashboardGUI"], "jumpToBadges")
43 );
44 $latest = new \ilDateTime(\ilBadgeAssignment::getLatestTimestamp($user->getId()), IL_CAL_UNIX);
45 $badge_notification_item = $ui->factory()->item()->notification($badge_title, $badge_icon)
46 ->withDescription(str_replace("%1", $new_badges, $lng->txt("badge_new_badges")))
47 ->withProperties([$lng->txt("time") => \ilDatePresentation::formatDate($latest)]);
48
49 $group = $factory->standardGroup($id('badge_bucket_group'))->withTitle($lng->txt('badge_badge'))
50 ->addNotification(
51 $factory->standard($id('badge_bucket'))->withNotificationItem($badge_notification_item)
52 ->withClosedCallable(
53 function () use ($user) {
54 // Stuff we do, when the notification is closed
55 $noti_repo = new \ILIAS\Badge\Notification\BadgeNotificationPrefRepository($user);
56 $noti_repo->updateLastCheckedTimestamp();
57 }
58 )
59 ->withNewAmount($new_badges)
60 )
61 ->withOpenedCallable(function () {
62 // Stuff we do, when the notification is opened
63 });
64
65 return [
66 $group,
67 ];
68 }
const IL_CAL_UNIX
static getNewCounter(int $a_user_id)
Get new counter.
static getLatestTimestamp(int $a_user_id)
Get latest badge.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
$factory
Definition: metadata.php:58
$lng

References $factory, $lng, ilDatePresentation\formatDate(), ilBadgeAssignment\getLatestTimestamp(), ilBadgeAssignment\getNewCounter(), ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: