ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBuddySystemNotification Class Reference

Class ilBuddyList. More...

+ Collaboration diagram for ilBuddySystemNotification:

Public Member Functions

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

Data Fields

const CONTACT_REQUEST_KEY = 'contact_requested_by'
 

Protected Member Functions

 hasPublicProfile (int $recipientUsrId)
 

Protected Attributes

ilObjUser $sender
 
ilSetting $settings
 
array $recipientIds = []
 

Detailed Description

Class ilBuddyList.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilBuddySystemNotification::__construct ( ilObjUser  $user,
ilSetting  $settings 
)
Parameters
ilObjUser$user
ilSetting$settings

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

References $settings, and ILIAS\Repository\settings().

45  {
46  $this->sender = $user;
47  $this->settings = $settings;
48  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getRecipientIds()

ilBuddySystemNotification::getRecipientIds ( )
Returns
int[]

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

References $recipientIds.

Referenced by send().

53  : array
54  {
55  return $this->recipientIds;
56  }
+ Here is the caller graph for this function:

◆ hasPublicProfile()

ilBuddySystemNotification::hasPublicProfile ( int  $recipientUsrId)
protected

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

References ilObjPortfolio\getDefaultPortfolio().

Referenced by send().

135  : bool
136  {
137  $portfolioId = ilObjPortfolio::getDefaultPortfolio($this->sender->getId());
138  if (is_numeric($portfolioId) && $portfolioId > 0) {
139  return (new ilPortfolioAccessHandler())->checkAccessOfUser($recipientUsrId, 'read', '', $portfolioId);
140  }
141 
142  return (
143  $this->sender->getPref('public_profile') === 'y' ||
144  $this->sender->getPref('public_profile') === 'g'
145  );
146  }
static getDefaultPortfolio(int $a_user_id)
Get default portfolio of user.
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 66 of file class.ilBuddySystemNotification.php.

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

66  : void
67  {
68  foreach ($this->getRecipientIds() as $usr_id) {
69  $user = new ilObjUser($usr_id);
70 
71  $recipientLanguage = ilLanguageFactory::_getLanguage($user->getLanguage());
72  $recipientLanguage->loadLanguageModule('buddysystem');
73 
74  $notification = new ilNotificationConfig(ContactNotificationProvider::NOTIFICATION_TYPE);
75 
76  $personalProfileLink = $recipientLanguage->txt('buddy_noti_cr_profile_not_published');
77  if ($this->hasPublicProfile($this->sender->getId())) {
78  $personalProfileLink = ilLink::_getStaticLink($this->sender->getId(), 'usr', true);
79 
80  $links[] = new ilNotificationLink(
82  $this->sender->getFirstname() . ', ' .
83  $this->sender->getLastname() . ' ' .
84  $this->sender->getLogin()
85  ),
86  $personalProfileLink
87  );
88  }
89  $links[] = new ilNotificationLink(
90  new ilNotificationParameter('buddy_notification_contact_request_link_osd', [], 'buddysystem'),
92  $this->sender->getId(),
93  'usr',
94  true,
95  '_contact_approved'
96  )
97  );
98  $links[] = new ilNotificationLink(
99  new ilNotificationParameter('buddy_notification_contact_request_ignore_osd', [], 'buddysystem'),
101  $this->sender->getId(),
102  'usr',
103  true,
104  '_contact_ignored'
105  )
106  );
107 
108  $bodyParams = [
109  'SALUTATION' => ilMail::getSalutation($user->getId(), $recipientLanguage),
110  'BR' => "\n",
111  'APPROVE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved'),
112  'APPROVE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_link'),
113  'IGNORE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored'),
114  'IGNORE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_ignore'),
115  'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId()),
116  'PERSONAL_PROFILE_LINK' => $personalProfileLink,
117  ];
118  $notification->setTitleVar('buddy_notification_contact_request', [], 'buddysystem');
119  $notification->setShortDescriptionVar('buddy_notification_contact_request_short', $bodyParams, 'buddysystem');
120  $notification->setLongDescriptionVar('buddy_notification_contact_request_long', $bodyParams, 'buddysystem');
121  $notification->setLinks($links);
122  $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
123  $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
124  $notification->setIconPath('templates/default/images/icon_usr.svg');
125  $notification->setHandlerParam('mail.sender', (string) ANONYMOUS_USER_ID);
126  $notification->setIdentification(new NotificationIdentification(
127  ContactNotificationProvider::NOTIFICATION_TYPE,
128  self::CONTACT_REQUEST_KEY . '_' . $this->sender->getId(),
129  ));
130 
131  $notification->notifyByUsers([$user->getId()]);
132  }
133  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
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:
description of a localized parameter this information is used locate translations while processing no...
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 61 of file class.ilBuddySystemNotification.php.

Referenced by ilContactAppEventListener\handleEvent().

61  : void
62  {
63  $this->recipientIds = array_map('intval', $recipientIds);
64  }
+ Here is the caller graph for this function:

Field Documentation

◆ $recipientIds

array ilBuddySystemNotification::$recipientIds = []
protected

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

Referenced by getRecipientIds().

◆ $sender

ilObjUser ilBuddySystemNotification::$sender
protected

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

◆ $settings

ilSetting ilBuddySystemNotification::$settings
protected

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

Referenced by __construct().

◆ CONTACT_REQUEST_KEY

const ilBuddySystemNotification::CONTACT_REQUEST_KEY = 'contact_requested_by'

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


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