ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMailMimeSenderFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  protected $settings;
13 
17  protected $senders = array();
18 
23  public function __construct(\ilSetting $settings)
24  {
25  $this->settings = $settings;
26  }
27 
32  protected function isSystemMail($usrId)
33  {
34  return $usrId == ANONYMOUS_USER_ID;
35  }
36 
41  public function getSenderByUsrId($usrId)
42  {
43  if (array_key_exists($usrId, $this->senders)) {
44  return $this->senders[$usrId];
45  }
46 
47  switch (true) {
48  case $this->isSystemMail($usrId):
49  $sender = $this->system();
50  break;
51 
52  default:
53  $sender = $this->user($usrId);
54  break;
55  }
56 
57  $this->senders[$usrId] = $sender;
58 
59  return $sender;
60  }
61 
65  public function system()
66  {
67  require_once 'Services/Mail/classes/Mime/Sender/class.ilMailMimeSenderSystem.php';
68  return new ilMailMimeSenderSystem($this->settings);
69  }
70 
75  public function user($usrId)
76  {
77  require_once 'Services/Mail/classes/Mime/Sender/class.ilMailMimeSenderUser.php';
78  return ilMailMimeSenderUser::byUsrId($this->settings, $usrId);
79  }
80 
85  public function userByEmailAddress($emailAddress)
86  {
87  require_once 'Services/Mail/classes/Mime/Sender/class.ilMailMimeSenderUser.php';
88  return ilMailMimeSenderUser::byEmailAddress($this->settings, $emailAddress);
89  }
90 }
settings()
Definition: settings.php:2
Class ilMailMimeSenderFactory.
static byUsrId(\ilSetting $settings, $usrId)
__construct(\ilSetting $settings)
ilMailMimeSenderFactory constructor.
static byEmailAddress(\ilSetting $settings, $emailAddress)
Class ilMailMimeSenderSystem.