ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLSCompletionNotificationProvider Class Reference
+ Inheritance diagram for ilLSCompletionNotificationProvider:
+ Collaboration diagram for ilLSCompletionNotificationProvider:

Public Member Functions

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

Data Fields

const NOTIFICATION_TYPE = 'lso_completion'
 
const NOTIFICATION_TIME_PREFERENCE_KEY = 'lso_completion_note_ts'
 

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 26 of file class.ilLSCompletionNotificationProvider.php.

Member Function Documentation

◆ getNotifications()

ilLSCompletionNotificationProvider::getNotifications ( )
Returns
isItem[]

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

Definition at line 31 of file class.ilLSCompletionNotificationProvider.php.

References $lng, factory(), ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen(), if, ILIAS\UI\examples\MainControls\Slate\Notification\standard(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle().

31  : array
32  {
33  $current_user = $this->dic['ilUser'];
34 
35  if ($current_user->getId() === 0 || $current_user->isAnonymous()) {
36  return [];
37  }
38 
39  $osd_notification_handler = new ilNotificationOSDHandler(new ilNotificationOSDRepository($this->dic->database()));
40  $left_interval_timestamp = $current_user->getPref(self::NOTIFICATION_TIME_PREFERENCE_KEY);
41  $notifications = $osd_notification_handler->getOSDNotificationsForUser(
42  $current_user->getId(),
43  false,
44  time() - $left_interval_timestamp,
45  self::NOTIFICATION_TYPE
46  );
47 
48  if (count($notifications) === 0) {
49  return [];
50  }
51 
52  $icon = $this->dic['ui.factory']->symbol()->icon()->standard(Standard::LSO, 'lso_completion');
53  $item_factory = $this->dic['ui.factory']->item();
54  $lng = $this->dic['lng'];
55  $lng->loadLanguageModule('lso');
56 
57 
58  $group = $this->globalScreen()->notifications()->factory()->standardGroup(
59  $this->if->identifier('lso_bucket_group')
60  )
61  ->withTitle($lng->txt('obj_lso'));
62 
63  foreach ($notifications as $notification) {
64  $lso_title = $notification->getObject()->title;
65  $title = sprintf($lng->txt('notification_lso_completed_title'), $lso_title);
66  $notification_item = $item_factory->notification($title, $icon);
67 
68  $group->addNotification(
69  $this->globalScreen()->notifications()->factory()->standard(
70  $this->if->identifier('lso_bucket')
71  )
72  ->withNotificationItem($notification_item)
73  ->withClosedCallable(
74  function () use ($current_user, $osd_notification_handler): void {
75  $current_user->writePref(self::NOTIFICATION_TIME_PREFERENCE_KEY, (string) time());
76  $osd_notification_handler->deleteStaleNotificationsForUserAndType(
77  $current_user->getId(),
78  self::NOTIFICATION_TYPE
79  );
80  }
81  )
82  ->withNewAmount(count($notifications))
83  );
84  }
85 
86  return [$group];
87  }
standard()
description: > This is an example, of how the Notification Slate is generated by assigning Notificat...
Definition: standard.php:38
factory()
if(!file_exists('../ilias.ini.php'))
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

Field Documentation

◆ NOTIFICATION_TIME_PREFERENCE_KEY

const ilLSCompletionNotificationProvider::NOTIFICATION_TIME_PREFERENCE_KEY = 'lso_completion_note_ts'

Definition at line 29 of file class.ilLSCompletionNotificationProvider.php.

◆ NOTIFICATION_TYPE


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