ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Notifications\ilNotificationOSDHandler Class Reference
+ Inheritance diagram for ILIAS\Notifications\ilNotificationOSDHandler:
+ Collaboration diagram for ILIAS\Notifications\ilNotificationOSDHandler:

Public Member Functions

 __construct (?ilNotificationOSDRepository $repo=null, ?ClockInterface $clock=null)
 
 notify (ilNotificationObject $notification)
 
 getOSDNotificationsForUser (int $user_id, bool $append_osd_id_to_link=true, int $max_age_seconds=0, string $type='')
 
 deleteStaleNotificationsForUserAndType (int $user_id, string $type)
 
 deleteStaleOSDNotificationsForUser (string $provider, int $user_id)
 
 removeOSDNotification (int $notification_osd_id)
 
 removeOSDNotificationByIdentification (string $provider, string $identification, int $user_id=0)
 
 clear ()
 
- Public Member Functions inherited from ILIAS\Notifications\ilNotificationHandler
 notify (ilNotificationObject $notification)
 
 showSettings ($form)
 
 clear ()
 

Private Member Functions

 appendParamToLink (string $link, string $param, int $value)
 

Private Attributes

ilNotificationOSDRepository $repo
 
ClockInterface $clock
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notifications\ilNotificationOSDHandler::__construct ( ?ilNotificationOSDRepository  $repo = null,
?ClockInterface  $clock = null 
)

Definition at line 36 of file ilNotificationOSDHandler.php.

References ILIAS\Notifications\ilNotificationOSDHandler\$clock, and ILIAS\Notifications\ilNotificationOSDHandler\$repo.

37  {
38  if ($repo === null) {
39  $repo = new ilNotificationOSDRepository();
40  }
41  $this->repo = $repo;
42 
43  if ($clock === null) {
44  $clock = (new \ILIAS\Data\Factory())->clock()->utc();
45  }
46  $this->clock = $clock;
47  }

Member Function Documentation

◆ appendParamToLink()

ILIAS\Notifications\ilNotificationOSDHandler::appendParamToLink ( string  $link,
string  $param,
int  $value 
)
private

Definition at line 99 of file ilNotificationOSDHandler.php.

Referenced by ILIAS\Notifications\ilNotificationOSDHandler\getOSDNotificationsForUser().

99  : string
100  {
101  if (strpos($link, '?') !== false) {
102  $link .= '&' . $param . '=' . $value;
103  } else {
104  $link .= '?' . $param . '=' . $value;
105  }
106  return $link;
107  }
$param
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ clear()

ILIAS\Notifications\ilNotificationOSDHandler::clear ( )

Definition at line 109 of file ilNotificationOSDHandler.php.

109  : void
110  {
111  $this->repo->deleteAllOSDNotifications();
112  }

◆ deleteStaleNotificationsForUserAndType()

ILIAS\Notifications\ilNotificationOSDHandler::deleteStaleNotificationsForUserAndType ( int  $user_id,
string  $type 
)
Deprecated:

Definition at line 75 of file ilNotificationOSDHandler.php.

75  : void
76  {
77  $this->repo->deleteStaleOSDNotificationsForUserAndType($type, $user_id, $this->clock->now()->getTimestamp());
78  }
$type

◆ deleteStaleOSDNotificationsForUser()

ILIAS\Notifications\ilNotificationOSDHandler::deleteStaleOSDNotificationsForUser ( string  $provider,
int  $user_id 
)

Definition at line 80 of file ilNotificationOSDHandler.php.

80  : void
81  {
82  $this->repo->deleteStaleOSDNotificationsForUserAndType($provider, $user_id, $this->clock->now()->getTimestamp());
83  }
$provider
Definition: ltitoken.php:83

◆ getOSDNotificationsForUser()

ILIAS\Notifications\ilNotificationOSDHandler::getOSDNotificationsForUser ( int  $user_id,
bool  $append_osd_id_to_link = true,
int  $max_age_seconds = 0,
string  $type = '' 
)
Returns
ilOSDNotificationObject[]

Definition at line 57 of file ilNotificationOSDHandler.php.

References $type, and ILIAS\Notifications\ilNotificationOSDHandler\appendParamToLink().

57  : array
58  {
59  $notifications = $this->repo->getOSDNotificationsByUser($user_id, $max_age_seconds, $type);
60 
61  foreach ($notifications as $notification) {
62  if ($append_osd_id_to_link) {
63  foreach ($notification->getObject()->links as $link) {
64  $link->setUrl($this->appendParamToLink($link->getUrl(), 'osd_id', $notification->getId()));
65  }
66  }
67  }
68 
69  return $notifications;
70  }
$type
appendParamToLink(string $link, string $param, int $value)
+ Here is the call graph for this function:

◆ notify()

ILIAS\Notifications\ilNotificationOSDHandler::notify ( ilNotificationObject  $notification)

Definition at line 49 of file ilNotificationOSDHandler.php.

49  : void
50  {
51  $this->repo->createOSDNotification($notification->user->getId(), $notification);
52  }

◆ removeOSDNotification()

ILIAS\Notifications\ilNotificationOSDHandler::removeOSDNotification ( int  $notification_osd_id)

Definition at line 85 of file ilNotificationOSDHandler.php.

85  : bool
86  {
87  return $this->repo->deleteOSDNotificationById($notification_osd_id);
88  }

◆ removeOSDNotificationByIdentification()

ILIAS\Notifications\ilNotificationOSDHandler::removeOSDNotificationByIdentification ( string  $provider,
string  $identification,
int  $user_id = 0 
)

Definition at line 90 of file ilNotificationOSDHandler.php.

90  : bool
91  {
92  return $this->repo->deleteOSDNotificationByIdentification(
93  $provider,
94  $identification,
95  $user_id
96  );
97  }
$provider
Definition: ltitoken.php:83

Field Documentation

◆ $clock

ClockInterface ILIAS\Notifications\ilNotificationOSDHandler::$clock
private

◆ $repo

ilNotificationOSDRepository ILIAS\Notifications\ilNotificationOSDHandler::$repo
private

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