ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilBuddySystemNotification Class Reference

Class ilBuddyList. More...

+ Collaboration diagram for ilBuddySystemNotification:

Public Member Functions

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

Protected Member Functions

 hasPublicProfile ($recipientUsrId)
 

Protected Attributes

 $sender
 
 $settings
 
 $recipient_ids = []
 

Detailed Description

Class ilBuddyList.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $settings, $user, and settings().

24  {
25  $this->sender = $user;
26  $this->settings = $settings;
27  }
settings()
Definition: settings.php:2
$user
Definition: migrateto20.php:57
+ Here is the call graph for this function:

Member Function Documentation

◆ getRecipientIds()

ilBuddySystemNotification::getRecipientIds ( )
Returns
array

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

References $recipient_ids.

Referenced by send().

+ Here is the caller graph for this function:

◆ hasPublicProfile()

ilBuddySystemNotification::hasPublicProfile (   $recipientUsrId)
protected
Parameters
int$recipientUsrId
Returns
bool

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

References ilObjPortfolio\getDefaultPortfolio().

Referenced by send().

99  {
100  $portfolioId = \ilObjPortfolio::getDefaultPortfolio($this->sender->getId());
101  if (is_numeric($portfolioId) && $portfolioId > 0) {
102  $accessHandler = new \ilPortfolioAccessHandler();
103  return $accessHandler->checkAccessOfUser($recipientUsrId, 'read', '', $portfolioId);
104  }
105 
106  return (
107  $this->sender->getPref('public_profile') === 'y' ||
108  $this->sender->getPref('public_profile') === 'g'
109  );
110  }
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ilBuddySystemNotification::send ( )

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

References $user, ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ilNotificationConfig\DEFAULT_TTS, ilUserUtil\getNamePresentation(), getRecipientIds(), ilMail\getSalutation(), hasPublicProfile(), and ilNotificationConfig\TTL_LONG.

49  {
50  foreach ($this->getRecipientIds() as $usr_id) {
51  $user = new ilObjUser((int) $usr_id);
52 
53  $rcp_lng = ilLanguageFactory::_getLanguage($user->getLanguage());
54  $rcp_lng->loadLanguageModule('buddysystem');
55 
56  $notification = new ilNotificationConfig('buddysystem_request');
57  $notification->setTitleVar('buddy_notification_contact_request', array(), 'buddysystem');
58 
59  $personalProfileLink = $rcp_lng->txt('buddy_noti_cr_profile_not_published');
60  if ($this->hasPublicProfile($user->getId())) {
61  $personalProfileLink = \ilLink::_getStaticLink($this->sender->getId(), 'usr', true);
62  }
63 
64  $bodyParams = array(
65  'SALUTATION' => ilMail::getSalutation($user->getId(), $rcp_lng),
66  'BR' => nl2br("\n"),
67  'APPROVE_REQUEST' => '<a href="' . ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved') . '">' . $rcp_lng->txt('buddy_notification_contact_request_link_osd') . '</a>',
68  'IGNORE_REQUEST' => '<a href="' . ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored') . '">' . $rcp_lng->txt('buddy_notification_contact_request_ignore_osd') . '</a>',
69  'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId())
70  );
71  $notification->setShortDescriptionVar('buddy_notification_contact_request_short', $bodyParams, 'buddysystem');
72 
73  $bodyParams = array(
74  'SALUTATION' => ilMail::getSalutation($user->getId(), $rcp_lng),
75  'BR' => "\n",
76  'APPROVE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved'),
77  'APPROVE_REQUEST_TXT' => $rcp_lng->txt('buddy_notification_contact_request_link'),
78  'IGNORE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored'),
79  'IGNORE_REQUEST_TXT' => $rcp_lng->txt('buddy_notification_contact_request_ignore'),
80  'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId()),
81  'PERSONAL_PROFILE_LINK' => $personalProfileLink,
82  );
83  $notification->setLongDescriptionVar('buddy_notification_contact_request_long', $bodyParams, 'buddysystem');
84 
85  $notification->setAutoDisable(false);
86  $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
87  $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
88  $notification->setIconPath('templates/default/images/icon_usr.svg');
89  $notification->setHandlerParam('mail.sender', ANONYMOUS_USER_ID);
90  $notification->notifyByUsers(array($user->getId()));
91  }
92  }
Describes a notification and provides methods for publishing this notification.
static _getLanguage($a_lang_key='')
Get langauge object.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
$user
Definition: migrateto20.php:57
static getSalutation($a_usr_id, ilLanguage $a_language=null)
+ Here is the call graph for this function:

◆ setRecipientIds()

ilBuddySystemNotification::setRecipientIds ( array  $recipient_ids)
Parameters
array$recipient_ids

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

References $recipient_ids.

Referenced by ilContactAppEventListener\handleEvent().

41  {
42  $this->recipient_ids = $recipient_ids;
43  }
+ Here is the caller graph for this function:

Field Documentation

◆ $recipient_ids

ilBuddySystemNotification::$recipient_ids = []
protected

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

Referenced by getRecipientIds(), and setRecipientIds().

◆ $sender

ilBuddySystemNotification::$sender
protected

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

◆ $settings

ilBuddySystemNotification::$settings
protected

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

Referenced by __construct().


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