ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMimeMailNotification.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Mail/classes/class.ilMimeMail.php';
5 
13 {
17  protected $mime_mail;
18 
22  protected $current_recipient;
23 
27  public function sendMimeMail($a_rcp)
28  {
29  $this->mime_mail->To($a_rcp);
30  $this->mime_mail->Subject($this->getSubject());
31  $this->mime_mail->Body($this->getBody());
32  $this->mime_mail->Send();
33  }
34 
38  protected function initMimeMail()
39  {
43  global $ilSetting;
44 
45  $this->mime_mail = new ilMimeMail();
46  $this->mime_mail->From($ilSetting->get('admin_email'));
47  $this->mime_mail->autoCheck(false);
48 
49  return $this->mime_mail;
50  }
51 
55  protected function initLanguageByIso2Code($a_code = '')
56  {
58  $this->getLanguage()->loadLanguageModule('registration');
59  }
60 
64  protected function initLanguage($a_usr_id)
65  {
66  parent::initLanguage($a_usr_id);
67  $this->getLanguage()->loadLanguageModule('registration');
68  }
69 
74  protected function handleCurrentRecipient($rcp)
75  {
76  require_once 'Services/Mail/exceptions/class.ilMailException.php';
77 
78  if(is_numeric($rcp))
79  {
83  $rcp = ilObjectFactory::getInstanceByObjId($rcp, false);
84  if(!$rcp)
85  {
86  throw new ilMailException('no_recipient_found');
87  }
88  $this->setCurrentRecipient($rcp->getEmail());
89  $this->initLanguage($rcp->getId());
90  }
91  else if(is_string($rcp) && ilUtil::is_email($rcp))
92  {
93  $this->setCurrentRecipient($rcp);
94  $this->initLanguageByIso2Code();
95  }
96  else if($rcp instanceof ilObjUser)
97  {
101  $this->setCurrentRecipient($rcp->getEmail());
102  $this->initLanguage($rcp->getId());
103  }
104  else
105  {
106  throw new ilMailException('no_recipient_found');
107  }
108  }
109 
114  {
115  $this->current_recipient = $current_recipient;
116  return $this;
117  }
118 
122  public function getCurrentRecipient()
123  {
125  }
126 
131  public function setMimeMail($mime_mail)
132  {
133  $this->mime_mail = $mime_mail;
134  return $this;
135  }
136 
140  public function getMimeMail()
141  {
142  return $this->mime_mail;
143  }
144 }