ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailTemplateContext Class Reference
+ Inheritance diagram for ilMailTemplateContext:
+ Collaboration diagram for ilMailTemplateContext:

Public Member Functions

 __construct (?OrgUnitUserService $org_unit_user_service=null, ?ilMailEnvironmentHelper $environment_helper=null, ?ilMailUserHelper $user_helper=null, ?ilMailLanguageHelper $language_helper=null)
 
 getLanguage ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getNestedPlaceholders ()
 
 getPlaceholders ()
 
 getSpecificPlaceholders ()
 
 resolveSpecificPlaceholder (string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
 
 resolvePlaceholder (string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
 

Protected Member Functions

 initLanguage (ilObjUser $user)
 
 initLanguageByIso2Code (string $iso_code)
 

Protected Attributes

ilLanguage $language
 
ilMailEnvironmentHelper $env_helper
 
ilMailLanguageHelper $language_helper
 
ilMailUserHelper $user_helper
 
OrgUnitUserService $org_unit_user_service
 

Private Member Functions

 getGenericPlaceholders ()
 

Detailed Description

Definition at line 24 of file class.ilMailTemplateContext.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailTemplateContext::__construct ( ?OrgUnitUserService  $org_unit_user_service = null,
?ilMailEnvironmentHelper  $environment_helper = null,
?ilMailUserHelper  $user_helper = null,
?ilMailLanguageHelper  $language_helper = null 
)

Member Function Documentation

◆ getDescription()

◆ getGenericPlaceholders()

ilMailTemplateContext::getGenericPlaceholders ( )
private
Returns
array{mail_salutation: array{placeholder: string, label: string, supportsNestedPlaceholders?: true}, first_name: array{placeholder: string, label: string}, last_name: array{placeholder: string, label: string}, login: array{placeholder: string, label: string}, title: array{placeholder: string, label: string, supportsCondition: true}, firstname_lastname_superior: array{placeholder: string, label: string}, ilias_url: array{placeholder: string, label: string}, installation_name: array{placeholder: string, label: string}}

Definition at line 58 of file class.ilMailTemplateContext.php.

58 : array
59 {
60 return [
61 'mail_salutation' => [
62 'placeholder' => 'MAIL_SALUTATION',
63 'label' => $this->getLanguage()->txt('mail_nacc_salutation'),
64 'supportsNestedPlaceholders' => true,
65 ],
66 'first_name' => [
67 'placeholder' => 'FIRST_NAME',
68 'label' => $this->getLanguage()->txt('firstname'),
69 ],
70 'last_name' => [
71 'placeholder' => 'LAST_NAME',
72 'label' => $this->getLanguage()->txt('lastname'),
73 ],
74 'login' => [
75 'placeholder' => 'LOGIN',
76 'label' => $this->getLanguage()->txt('mail_nacc_login'),
77 ],
78 'title' => [
79 'placeholder' => 'TITLE',
80 'label' => $this->getLanguage()->txt('mail_nacc_title'),
81 'supportsCondition' => true,
82 ],
83 'firstname_lastname_superior' => [
84 'placeholder' => 'FIRSTNAME_LASTNAME_SUPERIOR',
85 'label' => $this->getLanguage()->txt('mail_firstname_last_name_superior'),
86 ],
87 'ilias_url' => [
88 'placeholder' => 'ILIAS_URL',
89 'label' => $this->getLanguage()->txt('mail_nacc_ilias_url'),
90 ],
91 'installation_name' => [
92 'placeholder' => 'INSTALLATION_NAME',
93 'label' => $this->getLanguage()->txt('mail_nacc_installation_name'),
94 ],
95 ];
96 }

References getLanguage().

Referenced by getPlaceholders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

◆ getLanguage()

ilMailTemplateContext::getLanguage ( )

Definition at line 44 of file class.ilMailTemplateContext.php.

45 {
46 return $this->language ?? $this->language_helper->getCurrentLanguage();
47 }
language handling

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by ilMailTemplateGenericContext\getDescription(), getGenericPlaceholders(), and ilMailTemplateGenericContext\getTitle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNestedPlaceholders()

ilMailTemplateContext::getNestedPlaceholders ( )
Returns
list<string>

Definition at line 101 of file class.ilMailTemplateContext.php.

101 : array
102 {
103 $nested_placeholders = [];
104 foreach ($this->getPlaceholders() as $key => $ph) {
105 if (isset($ph['supportsNestedPlaceholders']) && $ph['supportsNestedPlaceholders']) {
106 $nested_placeholders[] = $ph['placeholder'];
107 }
108 }
109
110 return $nested_placeholders;
111 }

References getPlaceholders().

+ Here is the call graph for this function:

◆ getPlaceholders()

ilMailTemplateContext::getPlaceholders ( )
final
Returns
array<string, array{placeholder: string, crs_period_end_mail_placeholder: string}>

Definition at line 116 of file class.ilMailTemplateContext.php.

116 : array
117 {
118 $placeholders = $this->getGenericPlaceholders();
119 $specific = $this->getSpecificPlaceholders();
120
121 return array_merge($placeholders, $specific);
122 }

References getGenericPlaceholders(), and getSpecificPlaceholders().

Referenced by getNestedPlaceholders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSpecificPlaceholders()

ilMailTemplateContext::getSpecificPlaceholders ( )
abstract
Returns
array<string, array{placeholder: string, crs_period_end_mail_placeholder: string}>

Reimplemented in ilExcMailTemplateGradeReminderContext, ilExcMailTemplatePeerReminderContext, ilExcMailTemplateSubmitReminderContext, ilMailTemplateGenericContext, ilSessionMailTemplateParticipantContext, ilStudyProgrammeMailTemplateContext, and ilSurveyMailTemplateRaterInvitationContext.

Referenced by getPlaceholders().

+ Here is the caller graph for this function:

◆ getTitle()

◆ initLanguage()

ilMailTemplateContext::initLanguage ( ilObjUser  $user)
protected

Definition at line 225 of file class.ilMailTemplateContext.php.

225 : void
226 {
227 $this->initLanguageByIso2Code($user->getLanguage());
228 }

References ilObjUser\getLanguage().

Referenced by resolvePlaceholder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLanguageByIso2Code()

ilMailTemplateContext::initLanguageByIso2Code ( string  $iso_code)
protected

Definition at line 230 of file class.ilMailTemplateContext.php.

230 : void
231 {
232 $this->language = $this->language_helper->getLanguageByIsoCode($iso_code);
233 $this->language->loadLanguageModule('mail');
234 }

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ resolvePlaceholder()

ilMailTemplateContext::resolvePlaceholder ( string  $placeholder_id,
array  $context_parameters,
?ilObjUser  $recipient = null 
)
Parameters
array<string,mixed>$context_parameters

Definition at line 141 of file class.ilMailTemplateContext.php.

145 : string {
146 if ($recipient !== null) {
147 $this->initLanguage($recipient);
148 }
149
150 $placeholder_id = strtolower($placeholder_id);
151 $resolved = '';
152 switch (true) {
153 case ($placeholder_id === 'mail_salutation' && $recipient !== null):
154 $resolved = $this->getLanguage()->txt('mail_salutation_n');
155 switch ($recipient->getGender()) {
156 case 'f':
157 $resolved = $this->getLanguage()->txt('mail_salutation_f');
158 break;
159
160 case 'm':
161 $resolved = $this->getLanguage()->txt('mail_salutation_m');
162 break;
163
164 case 'n':
165 $resolved = $this->getLanguage()->txt('mail_salutation_n');
166 break;
167 }
168 break;
169
170 case ($placeholder_id === 'first_name' && $recipient !== null):
171 $resolved = $recipient->getFirstname();
172 break;
173
174 case ($placeholder_id === 'last_name' && $recipient !== null):
175 $resolved = $recipient->getLastname();
176 break;
177
178 case ($placeholder_id === 'login' && $recipient !== null):
179 $resolved = $recipient->getLogin();
180 break;
181
182 case ($placeholder_id === 'title' && $recipient !== null):
183 $resolved = $recipient->getUTitle();
184 break;
185
186 case $placeholder_id === 'ilias_url':
187 $resolved = $this->env_helper->getHttpPath() . ' ';
188 break;
189
190 case $placeholder_id === 'installation_name':
191 $resolved = $this->env_helper->getClientId();
192 break;
193
194 case $placeholder_id === 'firstname_lastname_superior' && $recipient !== null:
195 $ou_users = $this->org_unit_user_service->getUsers([$recipient->getId()], true);
196 foreach ($ou_users as $ou_user) {
197 $superiors = $ou_user->getSuperiors();
198
199 $superior_usr_ids = array_map(static fn(ilOrgUnitUser $ou_user): int => $ou_user->getUserId(), $superiors);
200
201 $usr_id_by_name_map = $this->user_helper->getUsernameMapForIds($superior_usr_ids);
202
203 $resolved = implode(', ', $usr_id_by_name_map);
204 break;
205 }
206 break;
207
208 case !array_key_exists($placeholder_id, $this->getGenericPlaceholders()):
209 $date_presentation_language = ilDatePresentation::getLanguage();
211
212 $resolved = $this->resolveSpecificPlaceholder(
213 $placeholder_id,
214 $context_parameters,
215 $recipient
216 );
217
218 ilDatePresentation::setLanguage($date_presentation_language);
219 break;
220 }
221
222 return $resolved;
223 }
Class for date presentation.
static setLanguage(ilLanguage $a_lng)
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)

References initLanguage().

+ Here is the call graph for this function:

◆ resolveSpecificPlaceholder()

ilMailTemplateContext::resolveSpecificPlaceholder ( string  $placeholder_id,
array  $context_parameters,
?ilObjUser  $recipient = null 
)
abstract

Field Documentation

◆ $env_helper

ilMailEnvironmentHelper ilMailTemplateContext::$env_helper
protected

Definition at line 27 of file class.ilMailTemplateContext.php.

◆ $language

ilLanguage ilMailTemplateContext::$language
protected

Definition at line 26 of file class.ilMailTemplateContext.php.

◆ $language_helper

ilMailLanguageHelper ilMailTemplateContext::$language_helper
protected

Definition at line 28 of file class.ilMailTemplateContext.php.

Referenced by __construct().

◆ $org_unit_user_service

OrgUnitUserService ilMailTemplateContext::$org_unit_user_service
protected

Definition at line 30 of file class.ilMailTemplateContext.php.

Referenced by __construct().

◆ $user_helper

ilMailUserHelper ilMailTemplateContext::$user_helper
protected

Definition at line 29 of file class.ilMailTemplateContext.php.

Referenced by __construct().


The documentation for this class was generated from the following file: