ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBuddySystemNotification Class Reference

Class ilBuddyList. More...

+ Collaboration diagram for ilBuddySystemNotification:

Public Member Functions

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

Data Fields

const CONTACT_REQUEST_KEY = 'contact_requested_by'
 

Protected Member Functions

 hasPublicProfile (int $recipientUsrId)
 

Protected Attributes

array $recipientIds = []
 

Detailed Description

Class ilBuddyList.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

38  {
39  }

Member Function Documentation

◆ getRecipientIds()

ilBuddySystemNotification::getRecipientIds ( )
Returns
int[]

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

References $recipientIds.

Referenced by send().

44  : array
45  {
46  return $this->recipientIds;
47  }
+ Here is the caller graph for this function:

◆ hasPublicProfile()

ilBuddySystemNotification::hasPublicProfile ( int  $recipientUsrId)
protected

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

References ilObjPortfolio\getDefaultPortfolio().

Referenced by send().

126  : bool
127  {
128  $portfolioId = ilObjPortfolio::getDefaultPortfolio($this->sender->getId());
129  if (is_numeric($portfolioId) && $portfolioId > 0) {
130  return (new ilPortfolioAccessHandler())->checkAccessOfUser($recipientUsrId, 'read', '', $portfolioId);
131  }
132 
133  return (
134  $this->sender->getPref('public_profile') === 'y' ||
135  $this->sender->getPref('public_profile') === 'g'
136  );
137  }
static getDefaultPortfolio(int $a_user_id)
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ilBuddySystemNotification::send ( )

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

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

57  : void
58  {
59  foreach ($this->getRecipientIds() as $usr_id) {
60  $user = new ilObjUser($usr_id);
61 
62  $recipientLanguage = ilLanguageFactory::_getLanguage($user->getLanguage());
63  $recipientLanguage->loadLanguageModule('buddysystem');
64 
65  $notification = new ilNotificationConfig(ContactNotificationProvider::NOTIFICATION_TYPE);
66 
67  $personalProfileLink = $recipientLanguage->txt('buddy_noti_cr_profile_not_published');
68  if ($this->hasPublicProfile($this->sender->getId())) {
69  $personalProfileLink = 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  $personalProfileLink
78  );
79  }
80  $links[] = new ilNotificationLink(
81  new ilNotificationParameter('buddy_notification_contact_request_link_osd', [], 'buddysystem'),
83  $this->sender->getId(),
84  'usr',
85  true,
86  '_contact_approved'
87  )
88  );
89  $links[] = new ilNotificationLink(
90  new ilNotificationParameter('buddy_notification_contact_request_ignore_osd', [], 'buddysystem'),
92  $this->sender->getId(),
93  'usr',
94  true,
95  '_contact_ignored'
96  )
97  );
98 
99  $bodyParams = [
100  'SALUTATION' => ilMail::getSalutation($user->getId(), $recipientLanguage),
101  'BR' => "\n",
102  'APPROVE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved'),
103  'APPROVE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_link'),
104  'IGNORE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored'),
105  'IGNORE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_ignore'),
106  'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId()),
107  'PERSONAL_PROFILE_LINK' => $personalProfileLink,
108  ];
109  $notification->setTitleVar('buddy_notification_contact_request', [], 'buddysystem');
110  $notification->setShortDescriptionVar('buddy_notification_contact_request_short', $bodyParams, 'buddysystem');
111  $notification->setLongDescriptionVar('buddy_notification_contact_request_long', $bodyParams, 'buddysystem');
112  $notification->setLinks($links);
113  $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
114  $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
115  $notification->setIconPath('assets/images/standard/icon_usr.svg');
116  $notification->setHandlerParam('mail.sender', (string) ANONYMOUS_USER_ID);
117  $notification->setIdentification(new NotificationIdentification(
118  ContactNotificationProvider::NOTIFICATION_TYPE,
119  self::CONTACT_REQUEST_KEY . '_' . $this->sender->getId(),
120  ));
121 
122  $notification->notifyByUsers([$user->getId()]);
123  }
124  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
description of a localized parameter this information is used locate translations while processing no...
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='ilpublicuserprofilegui')
Default behaviour is:
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getLanguage(string $a_lang_key='')
Get language object.
+ Here is the call graph for this function:

◆ setRecipientIds()

ilBuddySystemNotification::setRecipientIds ( array  $recipientIds)
Parameters
int[]$recipientIds

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

Referenced by ilContactAppEventListener\handleEvent().

52  : void
53  {
54  $this->recipientIds = array_map('intval', $recipientIds);
55  }
+ Here is the caller graph for this function:

Field Documentation

◆ $recipientIds

array ilBuddySystemNotification::$recipientIds = []
protected

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

Referenced by getRecipientIds().

◆ CONTACT_REQUEST_KEY

const ilBuddySystemNotification::CONTACT_REQUEST_KEY = 'contact_requested_by'

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


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