ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSessionMembershipMailNotification.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Mail/classes/class.ilMailNotification.php';
5 
13 {
15  const TYPE_DISMISS_MEMBER = 21;
16 
19 
20 
21  const TYPE_BLOCKED_MEMBER = 25;
23 
26 
30 
31 
35  public function __construct()
36  {
37  parent::__construct();
38  }
39 
44  public function send()
45  {
46  global $DIC;
47 
48  $ilSetting = $DIC['ilSetting'];
49 
50  // parent::send();
51 
52  switch ($this->getType()) {
53  case self::TYPE_ADMISSION_MEMBER:
54 
55  // automatic mails about status change disabled
56  if (!$ilSetting->get('mail_grp_member_notification', false)) {
57  return;
58  }
59 
60  foreach ($this->getRecipients() as $rcp) {
61  $this->initLanguage($rcp);
62  $this->initMail();
63  $this->setSubject(
64  sprintf($this->getLanguageText('grp_mail_admission_new_sub'), $this->getObjectTitle(true))
65  );
66  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
67  $this->appendBody("\n\n");
68  $this->appendBody(
69  sprintf($this->getLanguageText('grp_mail_admission_new_bod'), $this->getObjectTitle())
70  );
71  $this->appendBody("\n\n");
72  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
73  $this->appendBody("\n\n");
74  $this->appendBody($this->createPermanentLink());
75  $this->getMail()->appendInstallationSignature(true);
76 
77  $this->sendMail(array($rcp), array('system'));
78  }
79  break;
80 
81  case self::TYPE_DISMISS_MEMBER:
82 
83  // automatic mails about status change disabled
84  if (!$ilSetting->get('mail_grp_member_notification', false)) {
85  return;
86  }
87 
88  foreach ($this->getRecipients() as $rcp) {
89  $this->initLanguage($rcp);
90  $this->initMail();
91  $this->setSubject(
92  sprintf($this->getLanguageText('grp_mail_dismiss_sub'), $this->getObjectTitle(true))
93  );
94  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
95  $this->appendBody("\n\n");
96  $this->appendBody(
97  sprintf($this->getLanguageText('grp_mail_dismiss_bod'), $this->getObjectTitle())
98  );
99  $this->getMail()->appendInstallationSignature(true);
100  $this->sendMail(array($rcp), array('system'));
101  }
102  break;
103 
104 
105 
106 
107  case self::TYPE_SUBSCRIBE_MEMBER:
108 
109  foreach ($this->getRecipients() as $rcp) {
110  $this->initLanguage($rcp);
111  $this->initMail();
112  $this->setSubject(
113  sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'), $this->getObjectTitle(true))
114  );
115  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
116  $this->appendBody("\n\n");
117  $this->appendBody(
118  sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'), $this->getObjectTitle())
119  );
120 
121  $this->appendBody("\n\n");
122  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
123  $this->appendBody("\n\n");
124  $this->appendBody($this->createPermanentLink());
125  $this->getMail()->appendInstallationSignature(true);
126 
127  $this->sendMail(array($rcp), array('system'));
128  }
129  break;
130 
131 
132  case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
133 
134  foreach ($this->getRecipients() as $rcp) {
135  $this->initLanguage($rcp);
136  $this->initMail();
137  $this->setSubject(
138  sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'), $this->getObjectTitle(true))
139  );
140  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
141  $this->appendBody("\n\n");
142 
143  $info = $this->getAdditionalInformation();
144  $this->appendBody(
145  sprintf(
146  $this->getLanguageText('grp_mail_notification_reg_req_bod'),
147  $this->userToString($info['usr_id']),
148  $this->getObjectTitle()
149  )
150  );
151  $this->appendBody("\n\n");
152  $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
153  $this->appendBody("\n");
154  $this->appendBody($this->createPermanentLink(array(), '_mem'));
155 
156  $this->appendBody("\n\n");
157  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
158 
159  $this->getMail()->appendInstallationSignature(true);
160  $this->sendMail(array($rcp), array('system'));
161  }
162  break;
163 
164  case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
165 
166  foreach ($this->getRecipients() as $rcp) {
167  $this->initLanguage($rcp);
168  $this->initMail();
169  $this->setSubject(
170  sprintf($this->getLanguageText('sess_mail_sub_dec_sub'), $this->getObjectTitle(true))
171  );
172  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
173  $this->appendBody("\n\n");
174  $this->appendBody(
175  sprintf($this->getLanguageText('sess_mail_sub_dec_bod'), $this->getObjectTitle())
176  );
177 
178  $this->getMail()->appendInstallationSignature(true);
179 
180  $this->sendMail(array($rcp), array('system'));
181  }
182  break;
183 
184  case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
185 
186  foreach ($this->getRecipients() as $rcp) {
187  $this->initLanguage($rcp);
188  $this->initMail();
189  $this->setSubject(
190  sprintf($this->getLanguageText('sess_mail_sub_acc_sub'), $this->getObjectTitle(true))
191  );
192  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
193  $this->appendBody("\n\n");
194  $this->appendBody(
195  sprintf($this->getLanguageText('sess_mail_sub_acc_bod'), $this->getObjectTitle())
196  );
197  $this->appendBody("\n\n");
198  $this->appendBody($this->getLanguageText('sess_mail_permanent_link'));
199  $this->appendBody("\n\n");
200  $this->appendBody($this->createPermanentLink());
201  $this->getMail()->appendInstallationSignature(true);
202 
203  $this->sendMail(array($rcp), array('system'));
204  }
205  break;
206 
207  }
208  return true;
209  }
210 
216  protected function initLanguage($a_usr_id)
217  {
218  parent::initLanguage($a_usr_id);
219  $this->getLanguage()->loadLanguageModule('sess');
220  }
221 }
getType()
Get notification type.
global $DIC
Definition: saml.php:7
Base class for course/group mail notifications.
getObjectTitle($a_shorten=false)
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
getRecipients()
get array of recipients
createPermanentLink($a_params=array(), $a_append='')
global $ilSetting
Definition: privfeed.php:17
appendBody($a_body)
Append body text.
$info
Definition: index.php:5
static getSalutation($a_usr_id, ilLanguage $a_language=null)