ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBuddySystemNotification Class Reference

Class ilBuddyList. More...

+ Collaboration diagram for ilBuddySystemNotification:

Public Member Functions

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

Protected Member Functions

 hasPublicProfile (int $recipientUsrId)
 

Protected Attributes

 $sender
 
 $settings
 
 $recipientIds = []
 

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.

24 {
25 $this->sender = $user;
26 $this->settings = $settings;
27 }
settings()
Definition: settings.php:2

References $settings, and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getRecipientIds()

ilBuddySystemNotification::getRecipientIds ( )
Returns
int[]

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

References $recipientIds.

Referenced by send().

+ Here is the caller graph for this function:

◆ hasPublicProfile()

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

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

112 : bool
113 {
114 $portfolioId = ilObjPortfolio::getDefaultPortfolio($this->sender->getId());
115 if (is_numeric($portfolioId) && $portfolioId > 0) {
116 $accessHandler = new ilPortfolioAccessHandler();
117 return $accessHandler->checkAccessOfUser($recipientUsrId, 'read', '', $portfolioId);
118 }
119
120 return (
121 $this->sender->getPref('public_profile') === 'y' ||
122 $this->sender->getPref('public_profile') === 'g'
123 );
124 }
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
Access handler for portfolio.

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 48 of file class.ilBuddySystemNotification.php.

48 : void
49 {
50 foreach ($this->getRecipientIds() as $usr_id) {
51 $user = new ilObjUser((int) $usr_id);
52
53 $recipientLanguage = ilLanguageFactory::_getLanguage($user->getLanguage());
54 $recipientLanguage->loadLanguageModule('buddysystem');
55
56 $notification = new ilNotificationConfig('buddysystem_request');
57 $notification->setTitleVar('buddy_notification_contact_request', [], 'buddysystem');
58
59 $personalProfileLink = $recipientLanguage->txt('buddy_noti_cr_profile_not_published');
60 if ($this->hasPublicProfile((int) $user->getId())) {
61 $personalProfileLink = ilLink::_getStaticLink($this->sender->getId(), 'usr', true);
62 }
63
64 $bodyParams = [
65 'SALUTATION' => ilMail::getSalutation($user->getId(), $recipientLanguage),
66 'BR' => nl2br("\n"),
67 'APPROVE_REQUEST' => '<a href="' . ilLink::_getStaticLink(
68 $this->sender->getId(),
69 'usr',
70 true,
71 '_contact_approved'
72 ) . '">' . $recipientLanguage->txt('buddy_notification_contact_request_link_osd') . '</a>',
73 'IGNORE_REQUEST' => '<a href="' . ilLink::_getStaticLink(
74 $this->sender->getId(),
75 'usr',
76 true,
77 '_contact_ignored'
78 ) . '">' . $recipientLanguage->txt('buddy_notification_contact_request_ignore_osd') . '</a>',
79 'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId())
80 ];
81 $notification->setShortDescriptionVar(
82 'buddy_notification_contact_request_short',
83 $bodyParams,
84 'buddysystem'
85 );
86
87 $bodyParams = [
88 'SALUTATION' => ilMail::getSalutation($user->getId(), $recipientLanguage),
89 'BR' => "\n",
90 'APPROVE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved'),
91 'APPROVE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_link'),
92 'IGNORE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored'),
93 'IGNORE_REQUEST_TXT' => $recipientLanguage->txt('buddy_notification_contact_request_ignore'),
94 'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId()),
95 'PERSONAL_PROFILE_LINK' => $personalProfileLink,
96 ];
97 $notification->setLongDescriptionVar('buddy_notification_contact_request_long', $bodyParams, 'buddysystem');
98
99 $notification->setAutoDisable(false);
100 $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
101 $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
102 $notification->setIconPath('templates/default/images/icon_usr.svg');
103 $notification->setHandlerParam('mail.sender', ANONYMOUS_USER_ID);
104 $notification->notifyByUsers([$user->getId()]);
105 }
106 }
static _getLanguage($a_lang_key='')
Get langauge object.
static getSalutation($a_usr_id, ilLanguage $a_language=null)
Describes a notification and provides methods for publishing this notification.
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:
const ANONYMOUS_USER_ID
Definition: constants.php:25

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

+ Here is the call graph for this function:

◆ setRecipientIds()

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

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

41 {
42 $this->recipientIds = $recipientIds;
43 }

References $recipientIds.

Field Documentation

◆ $recipientIds

ilBuddySystemNotification::$recipientIds = []
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: