ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilBuddySystemNotification Class Reference
+ Collaboration diagram for ilBuddySystemNotification:

Public Member Functions

 __construct (protected ilObjUser $sender, protected ilSetting $settings)
 
 getRecipientIds ()
 
 setRecipientIds (array $recipient_ids)
 
 send ()
 

Data Fields

const string CONTACT_REQUEST_KEY = 'contact_requested_by'
 

Protected Member Functions

 hasPublicProfile (int $recipientUsrId)
 

Protected Attributes

array $recipient_ids = []
 

Detailed Description

Definition at line 27 of file class.ilBuddySystemNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilBuddySystemNotification::__construct ( protected ilObjUser  $sender,
protected ilSetting  $settings 
)

Definition at line 34 of file class.ilBuddySystemNotification.php.

35 {
36 }

Member Function Documentation

◆ getRecipientIds()

ilBuddySystemNotification::getRecipientIds ( )
Returns
list<int>

Definition at line 41 of file class.ilBuddySystemNotification.php.

41 : array
42 {
44 }

References $recipient_ids.

Referenced by send().

+ Here is the caller graph for this function:

◆ hasPublicProfile()

ilBuddySystemNotification::hasPublicProfile ( int  $recipientUsrId)
protected

Definition at line 116 of file class.ilBuddySystemNotification.php.

116 : bool
117 {
118 $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->sender->getId());
119 if (is_numeric($portfolio_id) && $portfolio_id > 0) {
120 return (new ilPortfolioAccessHandler())->checkAccessOfUser($recipientUsrId, 'read', '', $portfolio_id);
121 }
122
123 return (
124 $this->sender->getPref('public_profile') === 'y' ||
125 $this->sender->getPref('public_profile') === 'g'
126 );
127 }
static getDefaultPortfolio(int $a_user_id)
Access handler for portfolio NOTE: This file needs to stay in the classes directory,...

References ilObjPortfolio\getDefaultPortfolio().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ilBuddySystemNotification::send ( )

Definition at line 54 of file class.ilBuddySystemNotification.php.

54 : void
55 {
56 foreach ($this->getRecipientIds() as $usr_id) {
57 $user = new ilObjUser($usr_id);
58
59 $recipient_language = ilLanguageFactory::_getLanguage($user->getLanguage());
60 $recipient_language->loadLanguageModule('buddysystem');
61
62 $notification = new ilNotificationConfig(ContactNotificationProvider::NOTIFICATION_TYPE);
63
64 $approve_url = ilLink::_getLink($this->sender->getId(), 'contact', ['approve']);
65 $ignore_url = ilLink::_getLink($this->sender->getId(), 'contact', ['ignore']);
66
67 $profile_url = $recipient_language->txt('buddy_noti_cr_profile_not_published');
68 if ($this->hasPublicProfile($this->sender->getId())) {
69 $profile_url = ilLink::_getStaticLink($this->sender->getId(), 'usr', true);
70
71 $links[] = new ilNotificationLink(
73 $this->sender->getFirstname() . ', ' .
74 $this->sender->getLastname() . ' ' .
75 $this->sender->getLogin()
76 ),
77 $profile_url
78 );
79 }
80 $links[] = new ilNotificationLink(
81 new ilNotificationParameter('buddy_notification_contact_request_link_osd', [], 'buddysystem'),
82 $approve_url
83 );
84 $links[] = new ilNotificationLink(
85 new ilNotificationParameter('buddy_notification_contact_request_ignore_osd', [], 'buddysystem'),
86 $ignore_url
87 );
88
89 $body_params = [
90 'SALUTATION' => ilMail::getSalutation($user->getId(), $recipient_language),
91 'BR' => "\n",
92 'APPROVE_REQUEST' => $approve_url,
93 'APPROVE_REQUEST_TXT' => $recipient_language->txt('buddy_notification_contact_request_link'),
94 'IGNORE_REQUEST' => $ignore_url,
95 'IGNORE_REQUEST_TXT' => $recipient_language->txt('buddy_notification_contact_request_ignore'),
96 'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId()),
97 'PERSONAL_PROFILE_LINK' => $profile_url,
98 ];
99 $notification->setTitleVar('buddy_notification_contact_request', [], 'buddysystem');
100 $notification->setShortDescriptionVar('buddy_notification_contact_request_short', $body_params, 'buddysystem');
101 $notification->setLongDescriptionVar('buddy_notification_contact_request_long', $body_params, 'buddysystem');
102 $notification->setLinks($links);
103 $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
104 $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
105 $notification->setIconPath('assets/images/standard/icon_usr.svg');
106 $notification->setHandlerParam('mail.sender', (string) ANONYMOUS_USER_ID);
107 $notification->setIdentification(new NotificationIdentification(
108 ContactNotificationProvider::NOTIFICATION_TYPE,
109 self::CONTACT_REQUEST_KEY . '_' . $this->sender->getId(),
110 ));
111
112 $notification->notifyByUsers([$user->getId()]);
113 }
114 }
description of a localized parameter this information is used locate translations while processing no...
static _getLanguage(string $a_lang_key='')
Get language object.
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
User class.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ANONYMOUS_USER_ID, ilUserUtil\getNamePresentation(), getRecipientIds(), ilMail\getSalutation(), and hasPublicProfile().

+ Here is the call graph for this function:

◆ setRecipientIds()

ilBuddySystemNotification::setRecipientIds ( array  $recipient_ids)
Parameters
list<int>$recipient_ids

Definition at line 49 of file class.ilBuddySystemNotification.php.

49 : void
50 {
51 $this->recipient_ids = array_map('\intval', $recipient_ids);
52 }

References $recipient_ids.

Field Documentation

◆ $recipient_ids

array ilBuddySystemNotification::$recipient_ids = []
protected

Definition at line 32 of file class.ilBuddySystemNotification.php.

Referenced by getRecipientIds(), and setRecipientIds().

◆ CONTACT_REQUEST_KEY

const string ilBuddySystemNotification::CONTACT_REQUEST_KEY = 'contact_requested_by'

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


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