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