ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMailMimeSenderUser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Mail/classes/Mime/Sender/interface.ilMailMimeSender.php';
5
10{
14 protected static $userInstances = array();
15
19 protected $settings;
20
24 protected $user;
25
32 {
33 $this->settings = $settings;
34 $this->user = $user;
35 }
36
42 public static function byUsrId(\ilSetting $settings, $usrId)
43 {
44 if (!array_key_exists($usrId, self::$userInstances)) {
45 self::$userInstances[$usrId] = new \ilObjUser($usrId);
46 }
47
48 return new self($settings, self::$userInstances[$usrId]);
49 }
50
55 public static function addUserToCache($usrId, \ilObjUser $user)
56 {
57 self::$userInstances[$usrId] = $user;
58 }
59
65 public static function byEmailAddress(\ilSetting $settings, $emailAddress)
66 {
67 $user = new \ilObjUser();
68 $user->setEmail($emailAddress);
69
70 return new self($settings, $user);
71 }
72
76 public function hasReplyToAddress()
77 {
78 return true;
79 }
80
84 public function getReplyToAddress()
85 {
86 return $this->user->getEmail();
87 }
88
92 public function getReplyToName()
93 {
94 return $this->user->getFullname();
95 }
96
100 public function hasEnvelopFromAddress()
101 {
102 return strlen($this->settings->get('mail_system_usr_env_from_addr')) > 0;
103 }
104
108 public function getEnvelopFromAddress()
109 {
110 return $this->settings->get('mail_system_usr_env_from_addr');
111 }
112
116 public function getFromAddress()
117 {
118 return $this->settings->get('mail_system_usr_from_addr');
119 }
120
124 public function getFromName()
125 {
126 $from = $this->settings->get('mail_system_usr_from_name');
127 if (0 == strlen($from)) {
128 return $this->user->getFullname();
129 }
130
131 $name = str_ireplace('[FULLNAME]', $this->user->getFullname(), $from);
132 $name = str_ireplace('[FIRSTNAME]', $this->user->getFirstname(), $name);
133 $name = str_ireplace('[LASTNAME]', $this->user->getLastname(), $name);
134 if ($name != $from) {
135 return $name;
136 }
137
138 return $from;
139 }
140}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Class ilMailMimeSenderSystem.
__construct(\ilSetting $settings, \ilObjUser $user)
ilMailMimeSenderSystem constructor.
static byEmailAddress(\ilSetting $settings, $emailAddress)
static byUsrId(\ilSetting $settings, $usrId)
static addUserToCache($usrId, \ilObjUser $user)
ILIAS Setting Class.
Interface ilMailMimeTransport.
if($format !==null) $name
Definition: metadata.php:146
settings()
Definition: settings.php:2
$from