ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilMailMimeSenderUser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23abstract class ilMailMimeSenderUser implements ilMailMimeSender
24{
25 public function __construct(
26 protected ilSetting $settings,
27 protected ilObjUser $user,
28 protected TemplateEngineFactoryInterface $template_engine_factory
29 ) {
30 }
31
32 public function hasReplyToAddress(): bool
33 {
34 return true;
35 }
36
37 public function getReplyToAddress(): string
38 {
39 if (
40 $this->settings->get('use_global_reply_to_addr', '0') &&
41 is_string($this->settings->get('global_reply_to_addr', '')) &&
42 $this->settings->get('global_reply_to_addr', '') !== ''
43 ) {
44 return $this->settings->get('global_reply_to_addr', '');
45 }
46
47 return $this->user->getEmail();
48 }
49
50 public function getReplyToName(): string
51 {
52 return $this->user->getFullname();
53 }
54
55 public function hasEnvelopFromAddress(): bool
56 {
57 return $this->settings->get('mail_system_usr_env_from_addr', '') !== '' && $this->settings->get(
58 'mail_system_usr_env_from_addr',
59 ''
60 ) !== null;
61 }
62
63 public function getEnvelopFromAddress(): string
64 {
65 return $this->settings->get('mail_system_usr_env_from_addr', '');
66 }
67
68 public function getFromAddress(): string
69 {
70 return $this->settings->get('mail_system_usr_from_addr', '');
71 }
72
73 public function getFromName(): string
74 {
75 $from = $this->settings->get('mail_system_usr_from_name', '');
76 if ($from === '') {
77 return $this->user->getFullname();
78 }
79
80 $placeholders = [
81 'FULLNAME' => $this->user->getFullname(),
82 'FIRSTNAME' => $this->user->getFirstname(),
83 'LASTNAME' => $this->user->getLastname(),
84 ];
85
86 $template = $from;
87 $interpolated = $this->template_engine_factory->getBasicEngine()->render($template, $placeholders);
88
89 if ($template !== $interpolated) {
90 return $interpolated;
91 }
92
93 return $template;
94 }
95}
__construct(protected ilSetting $settings, protected ilObjUser $user, protected TemplateEngineFactoryInterface $template_engine_factory)
User class.
ILIAS Setting Class.
Factory interface for creating template engine instances.