ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 
)

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

37  {
38  $this->org_unit_user_service = $org_unit_user_service ?? new OrgUnitUserService();
39  $this->env_helper = $environment_helper ?? new ilMailEnvironmentHelper();
40  $this->user_helper = $user_helper ?? new ilMailUserHelper();
41  $this->language_helper = $language_helper ?? new ilMailLanguageHelper();
42  }
ilMailLanguageHelper $language_helper
OrgUnitUserService $org_unit_user_service

Member Function Documentation

◆ getDescription()

ilMailTemplateContext::getDescription ( )
abstract

Referenced by getLanguage().

+ Here is the caller graph for this function:

◆ 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.

References getLanguage().

Referenced by getPlaceholders(), and resolvePlaceholder().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilMailTemplateContext::getId ( )
abstract

Referenced by ilMailTemplateContextService\createEntry(), and getLanguage().

+ Here is the caller graph for this function:

◆ getLanguage()

ilMailTemplateContext::getLanguage ( )

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

References getDescription(), getId(), getTitle(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by ilCourseMailTemplateTutorContext\getCachedPeriodByObjId(), ilMailTemplateGenericContext\getDescription(), ilScormMailTemplateLPContext\getDescription(), getGenericPlaceholders(), ilMailTemplateGenericContext\getTitle(), and resolvePlaceholder().

44  : ilLanguage
45  {
46  return $this->language ?? $this->language_helper->getCurrentLanguage();
47  }
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ 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.

References getPlaceholders().

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  }
+ 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.

References getGenericPlaceholders(), getSpecificPlaceholders(), null, and resolveSpecificPlaceholder().

Referenced by getNestedPlaceholders().

116  : array
117  {
118  $placeholders = $this->getGenericPlaceholders();
119  $specific = $this->getSpecificPlaceholders();
120 
121  return array_merge($placeholders, $specific);
122  }
+ 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}>

Referenced by ilScormMailTemplateLPContext\getDescription(), ilCourseMailTemplateTutorContext\getDescription(), ilCourseMailTemplateMemberContext\getDescription(), ilSurveyMailTemplateReminderContext\getDescription(), and getPlaceholders().

+ Here is the caller graph for this function:

◆ getTitle()

ilMailTemplateContext::getTitle ( )
abstract

Referenced by getLanguage().

+ Here is the caller graph for this function:

◆ initLanguage()

ilMailTemplateContext::initLanguage ( ilObjUser  $user)
protected

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

References ilObjUser\getLanguage(), and initLanguageByIso2Code().

Referenced by resolvePlaceholder().

225  : void
226  {
227  $this->initLanguageByIso2Code($user->getLanguage());
228  }
+ 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.

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

Referenced by initLanguage().

230  : void
231  {
232  $this->language = $this->language_helper->getLanguageByIsoCode($iso_code);
233  $this->language->loadLanguageModule('mail');
234  }
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller 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.

References getGenericPlaceholders(), getLanguage(), ilDatePresentation\getLanguage(), OrgUnit\User\ilOrgUnitUser\getUserId(), initLanguage(), null, resolveSpecificPlaceholder(), and ilDatePresentation\setLanguage().

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  }
static setLanguage(ilLanguage $a_lng)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
+ 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.

◆ $org_unit_user_service

OrgUnitUserService ilMailTemplateContext::$org_unit_user_service
protected

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

◆ $user_helper

ilMailUserHelper ilMailTemplateContext::$user_helper
protected

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


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