ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 include_once 'Services/Mail/classes/class.ilMailNotification.php';
6 
14 {
18  protected $mime_mail;
19 
23  protected $current_recipient;
24 
28  public function sendMimeMail($a_rcp)
29  {
30  $this->mime_mail->To($a_rcp);
31  $this->mime_mail->Subject($this->getSubject(), true);
32  $this->mime_mail->Body($this->getBody());
33  $this->mime_mail->Send();
34  }
35 
39  protected function initMimeMail()
40  {
42  $senderFactory = $GLOBALS["DIC"]["mail.mime.sender.factory"];
43 
44  $this->mime_mail = new ilMimeMail();
45  $this->mime_mail->From($senderFactory->system());
46 
47  return $this->mime_mail;
48  }
49 
53  protected function initLanguageByIso2Code($a_code = '')
54  {
55  parent::initLanguageByIso2Code($a_code);
56  $this->getLanguage()->loadLanguageModule('registration');
57  }
58 
62  protected function initLanguage($a_usr_id)
63  {
64  parent::initLanguage($a_usr_id);
65  $this->getLanguage()->loadLanguageModule('registration');
66  }
67 
72  protected function handleCurrentRecipient($rcp)
73  {
74  require_once 'Services/Mail/exceptions/class.ilMailException.php';
75 
76  if (is_numeric($rcp)) {
80  $rcp = ilObjectFactory::getInstanceByObjId($rcp, false);
81  if (!$rcp) {
82  throw new ilMailException('no_recipient_found');
83  }
84  $this->setCurrentRecipient($rcp->getEmail());
85  $this->initLanguage($rcp->getId());
86  } elseif (is_string($rcp) && ilUtil::is_email($rcp)) {
87  $this->setCurrentRecipient($rcp);
88  $this->initLanguageByIso2Code();
89  } elseif ($rcp instanceof ilObjUser) {
93  $this->setCurrentRecipient($rcp->getEmail());
94  $this->initLanguage($rcp->getId());
95  } else {
96  throw new ilMailException('no_recipient_found');
97  }
98  }
99 
104  {
105  $this->current_recipient = $current_recipient;
106  return $this;
107  }
108 
112  public function getCurrentRecipient()
113  {
115  }
116 
121  public function setMimeMail($mime_mail)
122  {
123  $this->mime_mail = $mime_mail;
124  return $this;
125  }
126 
130  public function getMimeMail()
131  {
132  return $this->mime_mail;
133  }
134 }
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class ilMailException.
Base class for course/group mail notifications.
Class ilMimeMail.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for mime mail notifications.