ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBuddySystemNotification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
13 protected $sender;
14
18 protected $recipient_ids = array();
19
24 {
25 $this->sender = $ilObjUser;
26 }
27
31 public function getRecipientIds()
32 {
34 }
35
39 public function setRecipientIds(array $recipient_ids)
40 {
41 $this->recipient_ids = $recipient_ids;
42 }
43
47 public function send()
48 {
49 require_once 'Services/Mail/classes/class.ilMail.php';
50 foreach($this->getRecipientIds() as $usr_id)
51 {
52 $user = new ilObjUser((int)$usr_id);
53
54 require_once 'Services/Language/classes/class.ilLanguageFactory.php';
55 require_once 'Services/User/classes/class.ilUserUtil.php';
56 require_once 'Services/Link/classes/class.ilLink.php';
57
58 $rcp_lng = ilLanguageFactory::_getLanguage($user->getLanguage());
59 $rcp_lng->loadLanguageModule('buddysystem');
60
61 require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
62 $notification = new ilNotificationConfig('buddysystem_request');
63 $notification->setTitleVar('buddy_notification_contact_request', array(), 'buddysystem');
64
65 $bodyParams = array(
66 'SALUTATION' => ilMail::getSalutation($user->getId(), $rcp_lng),
67 'BR' => nl2br("\n"),
68 'APPROVE_REQUEST' => '<a href="' . ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved') . '">' . $rcp_lng->txt('buddy_notification_contact_request_link_osd') . '</a>',
69 'IGNORE_REQUEST' => '<a href="' . ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored') . '">' . $rcp_lng->txt('buddy_notification_contact_request_ignore_osd') . '</a>',
70 'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId())
71 );
72 $notification->setShortDescriptionVar('buddy_notification_contact_request_short', $bodyParams, 'buddysystem');
73
74 $bodyParams = array(
75 'SALUTATION' => ilMail::getSalutation($user->getId(), $rcp_lng),
76 'BR' => "\n",
77 'APPROVE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_approved'),
78 'APPROVE_REQUEST_TXT' => $rcp_lng->txt('buddy_notification_contact_request_link'),
79 'IGNORE_REQUEST' => ilLink::_getStaticLink($this->sender->getId(), 'usr', true, '_contact_ignored'),
80 'IGNORE_REQUEST_TXT' => $rcp_lng->txt('buddy_notification_contact_request_ignore'),
81 'REQUESTING_USER' => ilUserUtil::getNamePresentation($this->sender->getId())
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 }
93}
static _getLanguage($a_lang_key='')
Get langauge object.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
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)
Default behaviour is: