ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ILIAS\Contact\Provider\ContactNotificationProvider Class Reference

Class ContactNotificationProvider. More...

+ Inheritance diagram for ILIAS\Contact\Provider\ContactNotificationProvider:
+ Collaboration diagram for ILIAS\Contact\Provider\ContactNotificationProvider:

Public Member Functions

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

Data Fields

const MUTED_UNTIL_PREFERENCE_KEY = 'bs_nc_muted_until'
 

Private Member Functions

 getIdentifier (string $id)
 

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

Member Function Documentation

◆ getIdentifier()

ILIAS\Contact\Provider\ContactNotificationProvider::getIdentifier ( string  $id)
private
Parameters
string$id
Returns
IdentificationInterface

Definition at line 27 of file ContactNotificationProvider.php.

Referenced by ILIAS\Contact\Provider\ContactNotificationProvider\getNotifications().

27  : IdentificationInterface
28  {
29  return $this->if->identifier($id);
30  }
+ Here is the caller graph for this function:

◆ getNotifications()

ILIAS\Contact\Provider\ContactNotificationProvider::getNotifications ( )

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

Definition at line 35 of file ContactNotificationProvider.php.

References $factory, ilObjUser\_lookupActive(), ILIAS\UI\Component\Symbol\Icon\Standard\CADM, ilDatePresentation\formatDate(), ILIAS\Contact\Provider\ContactNotificationProvider\getIdentifier(), ilBuddySystem\getInstance(), ilBuddyList\getInstanceByGlobalUser(), ilBuddySystemRelation\getTimestamp(), ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen(), and IL_CAL_UNIX.

35  : array
36  {
37  if (
38  0 === (int) $this->dic->user()->getId() ||
39  $this->dic->user()->isAnonymous() ||
40  !\ilBuddySystem::getInstance()->isEnabled()
41  ) {
42  return [];
43  }
44 
45  $leftIntervalTimestamp = $this->dic->user()->getPref(self::MUTED_UNTIL_PREFERENCE_KEY);
46  $latestRequestTimestamp = null;
47 
48  $relations = ilBuddyList::getInstanceByGlobalUser()->getRequestRelationsForOwner();
49 
50  $openRequests = $relations->filter(
51  function (\ilBuddySystemRelation $relation) use ($leftIntervalTimestamp, &$latestRequestTimestamp, $relations) : bool {
52  $timeStamp = $relation->getTimestamp();
53 
54  if ($timeStamp > $latestRequestTimestamp) {
55  $latestRequestTimestamp = $timeStamp;
56  }
57 
58  $usrId = $relations->getKey($relation);
59 
60  if (!ilObjUser::_lookupActive($usrId)) {
61  return false;
62  }
63 
64  if (!is_numeric($leftIntervalTimestamp)) {
65  return true;
66  }
67 
68  return $timeStamp > $leftIntervalTimestamp;
69  }
70  );
71 
72  $contactRequestsCount = count($openRequests->getKeys());
73  if ($contactRequestsCount === 0) {
74  return [];
75  }
76 
77  $factory = $this->globalScreen()->notifications()->factory();
78 
79  $icon = $this->dic->ui()->factory()
80  ->symbol()
81  ->icon()
82  ->standard(Standard::CADM, 'contacts')->withIsOutlined(true);
83 
84  $title = $this->dic->ui()->factory()
85  ->link()
86  ->standard(
87  $this->dic->language()->txt('nc_contact_requests_headline'),
88  $this->dic->ctrl()->getLinkTargetByClass([ilDashboardGUI::class, ilContactGUI::class], 'showContactRequests')
89  );
90  $description = sprintf(
91  $this->dic->language()->txt(
92  'nc_contact_requests_number' . (($contactRequestsCount > 1) ? '_p' : '_s')
93  ),
94  $contactRequestsCount
95  );
96  $notificationItem = $this->dic->ui()->factory()
97  ->item()
98  ->notification($title, $icon)
99  ->withDescription($description)
100  ->withProperties([
101  $this->dic->language()->txt('nc_contact_requests_prop_time') => \ilDatePresentation::formatDate(
102  new \ilDateTime($latestRequestTimestamp, IL_CAL_UNIX)
103  )
104  ]);
105 
106  $group = $factory
107  ->standardGroup($this->getIdentifier('contact_bucket_group'))
108  ->withTitle($this->dic->language()->txt('nc_contact_requests_headline'))
109  ->addNotification(
110  $factory->standard($this->getIdentifier('contact_bucket'))
111  ->withNotificationItem($notificationItem)
112  ->withClosedCallable(
113  function () {
114  $this->dic->user()->writePref(self::MUTED_UNTIL_PREFERENCE_KEY, time());
115  }
116  )->withNewAmount(1)
117  );
118 
119  return [
120  $group
121  ];
122  }
static getInstanceByGlobalUser()
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Class ilBuddySystemRelation.
static _lookupActive($a_usr_id)
Check user account active.
$factory
Definition: metadata.php:58
+ Here is the call graph for this function:

Field Documentation

◆ MUTED_UNTIL_PREFERENCE_KEY

const ILIAS\Contact\Provider\ContactNotificationProvider::MUTED_UNTIL_PREFERENCE_KEY = 'bs_nc_muted_until'

Definition at line 21 of file ContactNotificationProvider.php.


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