ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 @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 (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getNotifications ()
 
 getAdministrativeNotifications ()
 

Data Fields

final const string MUTED_UNTIL_PREFERENCE_KEY = 'bs_nc_muted_until'
 
final const string NOTIFICATION_TYPE = 'buddysystem_request'
 

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
Container $dic
 
IdentificationProviderInterface $if
 
NotificationFactory $notification_factory
 

Detailed Description

Member Function Documentation

◆ getIdentifier()

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

Definition at line 47 of file ContactNotificationProvider.php.

47 : IdentificationInterface
48 {
49 return $this->if->identifier($id);
50 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

+ Here is the caller graph for this function:

◆ getNotifications()

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

@inheritDoc

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

Definition at line 55 of file ContactNotificationProvider.php.

55 : array
56 {
57 if (
58 0 === $this->dic->user()->getId() ||
59 $this->dic->user()->isAnonymous() ||
60 !ilBuddySystem::getInstance()->isEnabled()
61 ) {
62 return [];
63 }
64
65 $leftIntervalTimestamp = $this->dic->user()->getPref(self::MUTED_UNTIL_PREFERENCE_KEY);
66 $latestRequestTimestamp = null;
67
68 $relations = ilBuddyList::getInstanceByGlobalUser()->getRequestRelationsForOwner();
69
70 $openRequests = $relations->filter(
71 function (ilBuddySystemRelation $relation) use ($leftIntervalTimestamp, &$latestRequestTimestamp, $relations): bool {
72 $timeStamp = $relation->getTimestamp();
73
74 if ($timeStamp > $latestRequestTimestamp) {
75 $latestRequestTimestamp = $timeStamp;
76 }
77
78 $usrId = $relations->getKey($relation);
79
80 if (!ilObjUser::_lookupActive($usrId)) {
81 return false;
82 }
83
84 if (!is_numeric($leftIntervalTimestamp)) {
85 return true;
86 }
87
88 return $timeStamp > $leftIntervalTimestamp;
89 }
90 );
91
92 $contactRequestsCount = count($openRequests->getKeys());
93 if ($contactRequestsCount === 0) {
94 return [];
95 }
96
97 $factory = $this->globalScreen()->notifications()->factory();
98
99 $icon = $this->dic->ui()->factory()
100 ->symbol()
101 ->icon()
102 ->standard(Standard::CADM, 'contacts');
103
104 $title = $this->dic->ui()->factory()
105 ->link()
106 ->standard(
107 $this->dic->language()->txt('nc_contact_requests_headline'),
108 $this->dic->ctrl()->getLinkTargetByClass([ilDashboardGUI::class, ilContactGUI::class], 'showContactRequests')
109 );
110 $description = sprintf(
111 $this->dic->language()->txt(
112 'nc_contact_requests_number' . (($contactRequestsCount > 1) ? '_p' : '_s')
113 ),
114 $contactRequestsCount
115 );
116 $notificationItem = $this->dic->ui()->factory()
117 ->item()
118 ->notification($title, $icon)
119 ->withDescription($description)
120 ->withProperties([
121 $this->dic->language()->txt('nc_contact_requests_prop_time') => ilDatePresentation::formatDate(
122 new ilDateTime($latestRequestTimestamp, IL_CAL_UNIX)
123 )
124 ]);
125
126 $osd_notification_handler = new ilNotificationOSDHandler(new ilNotificationOSDRepository($this->dic->database()));
127
128 $group = $factory
129 ->standardGroup($this->getIdentifier('contact_bucket_group'))
130 ->withTitle($this->dic->language()->txt('nc_contact_requests_headline'))
131 ->addNotification(
132 $factory->standard($this->getIdentifier('contact_bucket'))
133 ->withNotificationItem($notificationItem)
134 ->withClosedCallable(
135 function () use ($osd_notification_handler): void {
136 $this->dic->user()->writePref(self::MUTED_UNTIL_PREFERENCE_KEY, (string) time());
137
138 $osd_notification_handler->deleteStaleNotificationsForUserAndType(
139 $this->dic->user()->getId(),
140 self::NOTIFICATION_TYPE
141 );
142 }
143 )->withNewAmount(1)
144 );
145
146 return [
147 $group
148 ];
149 }
$relation
const IL_CAL_UNIX
static getInstanceByGlobalUser(?ilObjUser $user=null)
Class ilBuddySystemRelation.
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
static _lookupActive(int $a_usr_id)

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

+ Here is the call graph for this function:

Field Documentation

◆ MUTED_UNTIL_PREFERENCE_KEY

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

Definition at line 44 of file ContactNotificationProvider.php.

◆ NOTIFICATION_TYPE

final const string ILIAS\Contact\Provider\ContactNotificationProvider::NOTIFICATION_TYPE = 'buddysystem_request'

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