ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilSetting;
47 
48  // parent::send();
49 
50  switch ($this->getType()) {
51  case self::TYPE_ADMISSION_MEMBER:
52 
53  // automatic mails about status change disabled
54  if (!$ilSetting->get('mail_grp_member_notification', false)) {
55  return;
56  }
57 
58  foreach ($this->getRecipients() as $rcp) {
59  $this->initLanguage($rcp);
60  $this->initMail();
61  $this->setSubject(
62  sprintf($this->getLanguageText('grp_mail_admission_new_sub'), $this->getObjectTitle(true))
63  );
64  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
65  $this->appendBody("\n\n");
66  $this->appendBody(
67  sprintf($this->getLanguageText('grp_mail_admission_new_bod'), $this->getObjectTitle())
68  );
69  $this->appendBody("\n\n");
70  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
71  $this->appendBody("\n\n");
72  $this->appendBody($this->createPermanentLink());
73  $this->getMail()->appendInstallationSignature(true);
74 
75  $this->sendMail(array($rcp), array('system'));
76  }
77  break;
78 
79  case self::TYPE_DISMISS_MEMBER:
80 
81  // automatic mails about status change disabled
82  if (!$ilSetting->get('mail_grp_member_notification', false)) {
83  return;
84  }
85 
86  foreach ($this->getRecipients() as $rcp) {
87  $this->initLanguage($rcp);
88  $this->initMail();
89  $this->setSubject(
90  sprintf($this->getLanguageText('grp_mail_dismiss_sub'), $this->getObjectTitle(true))
91  );
92  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
93  $this->appendBody("\n\n");
94  $this->appendBody(
95  sprintf($this->getLanguageText('grp_mail_dismiss_bod'), $this->getObjectTitle())
96  );
97  $this->getMail()->appendInstallationSignature(true);
98  $this->sendMail(array($rcp), array('system'));
99  }
100  break;
101 
102 
103 
104 
105  case self::TYPE_SUBSCRIBE_MEMBER:
106 
107  foreach ($this->getRecipients() as $rcp) {
108  $this->initLanguage($rcp);
109  $this->initMail();
110  $this->setSubject(
111  sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'), $this->getObjectTitle(true))
112  );
113  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
114  $this->appendBody("\n\n");
115  $this->appendBody(
116  sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'), $this->getObjectTitle())
117  );
118 
119  $this->appendBody("\n\n");
120  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
121  $this->appendBody("\n\n");
122  $this->appendBody($this->createPermanentLink());
123  $this->getMail()->appendInstallationSignature(true);
124 
125  $this->sendMail(array($rcp), array('system'));
126  }
127  break;
128 
129 
130  case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
131 
132  foreach ($this->getRecipients() as $rcp) {
133  $this->initLanguage($rcp);
134  $this->initMail();
135  $this->setSubject(
136  sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'), $this->getObjectTitle(true))
137  );
138  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
139  $this->appendBody("\n\n");
140 
141  $info = $this->getAdditionalInformation();
142  $this->appendBody(
143  sprintf(
144  $this->getLanguageText('grp_mail_notification_reg_req_bod'),
145  $this->userToString($info['usr_id']),
146  $this->getObjectTitle()
147  )
148  );
149  $this->appendBody("\n\n");
150  $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
151  $this->appendBody("\n");
152  $this->appendBody($this->createPermanentLink(array(), '_mem'));
153 
154  $this->appendBody("\n\n");
155  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
156 
157  $this->getMail()->appendInstallationSignature(true);
158  $this->sendMail(array($rcp), array('system'));
159  }
160  break;
161 
162  case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
163 
164  foreach ($this->getRecipients() as $rcp) {
165  $this->initLanguage($rcp);
166  $this->initMail();
167  $this->setSubject(
168  sprintf($this->getLanguageText('sess_mail_sub_dec_sub'), $this->getObjectTitle(true))
169  );
170  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
171  $this->appendBody("\n\n");
172  $this->appendBody(
173  sprintf($this->getLanguageText('sess_mail_sub_dec_bod'), $this->getObjectTitle())
174  );
175 
176  $this->getMail()->appendInstallationSignature(true);
177 
178  $this->sendMail(array($rcp), array('system'));
179  }
180  break;
181 
182  case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
183 
184  foreach ($this->getRecipients() as $rcp) {
185  $this->initLanguage($rcp);
186  $this->initMail();
187  $this->setSubject(
188  sprintf($this->getLanguageText('sess_mail_sub_acc_sub'), $this->getObjectTitle(true))
189  );
190  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
191  $this->appendBody("\n\n");
192  $this->appendBody(
193  sprintf($this->getLanguageText('sess_mail_sub_acc_bod'), $this->getObjectTitle())
194  );
195  $this->appendBody("\n\n");
196  $this->appendBody($this->getLanguageText('sess_mail_permanent_link'));
197  $this->appendBody("\n\n");
198  $this->appendBody($this->createPermanentLink());
199  $this->getMail()->appendInstallationSignature(true);
200 
201  $this->sendMail(array($rcp), array('system'));
202  }
203  break;
204 
205  }
206  return true;
207  }
208 
214  protected function initLanguage($a_usr_id)
215  {
216  parent::initLanguage($a_usr_id);
217  $this->getLanguage()->loadLanguageModule('sess');
218  }
219 }
getType()
Get notification type.
Base class for course/group mail notifications.
getObjectTitle($a_shorten=false)
Create styles array
The data for the language used.
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)