ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider Class Reference
+ Inheritance diagram for ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider:
+ Collaboration diagram for ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider:

Public Member Functions

 getNotifications ()
 
- 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 (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getNotifications ()
 
 getAdministrativeNotifications ()
 

Data Fields

final const string MUTED_UNTIL_PREFERENCE_KEY = 'chatinv_nc_muted_until'
 
final const string NOTIFICATION_TYPE = 'chat_invitation'
 

Additional Inherited Members

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

Detailed Description

Definition at line 30 of file ChatInvitationNotificationProvider.php.

Member Function Documentation

◆ getNotifications()

ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider::getNotifications ( )
Returns
isItem[]

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

Definition at line 35 of file ChatInvitationNotificationProvider.php.

35 : array
36 {
37 if (0 === $this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
38 return [];
39 }
40
41 $leftIntervalTimestamp = $this->dic->user()->getPref(self::MUTED_UNTIL_PREFERENCE_KEY);
42
43 $latest_time = 0;
44 $osd_notification_handler = new ilNotificationOSDHandler(new ilNotificationOSDRepository($this->dic->database()));
45 $invitations = [];
46 foreach ($osd_notification_handler->getOSDNotificationsForUser(
47 $this->dic->user()->getId(),
48 true,
49 time() - $leftIntervalTimestamp,
50 self::NOTIFICATION_TYPE
51 ) as $osd) {
52 $invitations[] = $osd;
53 if ($latest_time < $osd->getTimeAdded()) {
54 $latest_time = $osd->getTimeAdded();
55 }
56 }
57
58 $this->dic->language()->loadLanguageModule('chatroom');
59
60 if ($invitations === []) {
61 return [];
62 }
63
64 $aggregatedItems = [];
65 foreach ($invitations as $invitation) {
66 $link = '';
67 if (count($invitation->getObject()->links) === 1) {
68 $link = $this->dic->ui()->renderer()->render(
69 $this->dic->ui()->factory()->link()->standard(
70 $invitation->getObject()->shortDescription,
71 $invitation->getObject()->links[0]->getUrl()
72 )
73 );
74 }
75 $aggregatedItems[] = $this->dic->ui()->factory()->item()->notification(
76 $invitation->getObject()->title,
77 $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::CHTA, 'chat_invitations')
78 )->withDescription($link)
79 ->withProperties([
80 $this->dic->language()->txt('time') => ilDatePresentation::formatDate(
81 new ilDateTime($invitation->getTimeAdded(), IL_CAL_UNIX)
82 )
83 ]);
84 }
85
86 $notificationItem = $this->dic->ui()->factory()->item()->notification(
87 $this->dic->ui()->factory()->link()->standard($this->dic->language()->txt('chat_invitations'), '#'),
88 $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::CHTA, 'chat_invitations')
89 )->withAggregateNotifications($aggregatedItems)
90 ->withDescription(
91 sprintf(
92 $this->dic->language()->txt('chat_invitation_nc_inv_x'),
93 count($aggregatedItems)
94 )
95 )->withProperties([
96 $this->dic->language()->txt('time') => ilDatePresentation::formatDate(
97 new ilDateTime($latest_time, IL_CAL_UNIX)
98 )
99 ]);
100
101 return [
102 $this->globalScreen()->notifications()->factory()->standardGroup(
103 $this->if->identifier('chat_invitation_bucket_group')
104 )->withTitle('Chat')
105 ->addNotification(
106 $this->globalScreen()->notifications()->factory()->standard(
107 $this->if->identifier('chat_invitation_bucket')
108 )->withNotificationItem($notificationItem)
109 ->withNewAmount(count($invitations))
110 ->withClosedCallable(
111 function () use ($osd_notification_handler): void {
112 $this->dic->user()->writePref(self::MUTED_UNTIL_PREFERENCE_KEY, (string) time());
113
114 $osd_notification_handler->deleteStaleNotificationsForUserAndType(
115 $this->dic->user()->getId(),
116 self::NOTIFICATION_TYPE
117 );
118 }
119 )
120 )
121 ];
122 }
factory()
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
if(!file_exists('../ilias.ini.php'))

References ILIAS\UI\Component\Symbol\Icon\Standard\CHTA, factory(), ilDatePresentation\formatDate(), ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen(), if, IL_CAL_UNIX, and ILIAS\UI\examples\MainControls\Slate\Notification\standard().

+ Here is the call graph for this function:

Field Documentation

◆ MUTED_UNTIL_PREFERENCE_KEY

final const string ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider::MUTED_UNTIL_PREFERENCE_KEY = 'chatinv_nc_muted_until'

Definition at line 32 of file ChatInvitationNotificationProvider.php.

◆ NOTIFICATION_TYPE

final const string ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider::NOTIFICATION_TYPE = 'chat_invitation'

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