19declare(strict_types=1);
46 return $this->
language ?? $this->language_helper->getCurrentLanguage();
49 abstract public function getId(): string;
70 'mail_salutation' => [
71 'placeholder' =>
'MAIL_SALUTATION',
72 'label' => $this->
getLanguage()->txt(
'mail_nacc_salutation'),
73 'requiresRecipient' =>
true,
74 'supportsNestedPlaceholders' =>
true,
77 'placeholder' =>
'FIRST_NAME',
79 'requiresRecipient' =>
true,
82 'placeholder' =>
'LAST_NAME',
84 'requiresRecipient' =>
true,
87 'placeholder' =>
'LOGIN',
88 'label' => $this->
getLanguage()->txt(
'mail_nacc_login'),
89 'requiresRecipient' =>
true,
92 'placeholder' =>
'TITLE',
93 'label' => $this->
getLanguage()->txt(
'mail_nacc_title'),
94 'requiresRecipient' =>
true,
96 'firstname_lastname_superior' => [
97 'placeholder' =>
'FIRSTNAME_LASTNAME_SUPERIOR',
98 'label' => $this->
getLanguage()->txt(
'mail_firstname_last_name_superior'),
99 'requiresRecipient' =>
true,
102 'placeholder' =>
'ILIAS_URL',
103 'label' => $this->
getLanguage()->txt(
'mail_nacc_ilias_url'),
104 'requiresRecipient' =>
false,
106 'installation_name' => [
107 'placeholder' =>
'INSTALLATION_NAME',
108 'label' => $this->
getLanguage()->txt(
'mail_nacc_installation_name'),
109 'requiresRecipient' =>
false,
119 $nested_placeholders = [];
121 if (isset($ph[
'supportsNestedPlaceholders']) && $ph[
'supportsNestedPlaceholders']) {
122 $nested_placeholders[] = $ph[
'placeholder'];
126 return $nested_placeholders;
142 return array_merge($placeholders, $specific);
158 if ($found ===
null) {
175 foreach ($this->
getPlaceholders() as $key => $placeholder_definition) {
176 if (strtoupper($placeholder_definition[
'placeholder']) !== strtoupper($placeholder_name)) {
181 'key' => (string) $key,
182 'definition' => $placeholder_definition,
199 return $placeholder_definition[
'requiresRecipient'] ??
false;
206 string $placeholder_id,
207 array $context_parameters,
215 string $placeholder_id,
216 array $context_parameters,
219 if ($recipient !== null) {
223 $placeholder_id = strtolower($placeholder_id);
226 case ($placeholder_id ===
'mail_salutation' && $recipient !==
null):
227 $resolved = $this->
getLanguage()->txt(
'mail_salutation_n');
228 switch ($recipient->getGender()) {
230 $resolved = $this->
getLanguage()->txt(
'mail_salutation_f');
234 $resolved = $this->
getLanguage()->txt(
'mail_salutation_m');
238 $resolved = $this->
getLanguage()->txt(
'mail_salutation_n');
243 case ($placeholder_id ===
'first_name' && $recipient !==
null):
244 $resolved = $recipient->getFirstname();
247 case ($placeholder_id ===
'last_name' && $recipient !==
null):
248 $resolved = $recipient->getLastname();
251 case ($placeholder_id ===
'login' && $recipient !==
null):
252 $resolved = $recipient->getLogin();
255 case ($placeholder_id ===
'title' && $recipient !==
null):
256 $resolved = $recipient->getUTitle();
259 case $placeholder_id ===
'ilias_url':
260 $resolved = $this->env_helper->getHttpPath() .
' ';
263 case $placeholder_id ===
'installation_name':
264 $resolved = $this->env_helper->getClientId();
267 case $placeholder_id ===
'firstname_lastname_superior' && $recipient !==
null:
268 $ou_users = $this->org_unit_user_service->getUsers([$recipient->getId()],
true);
269 foreach ($ou_users as $ou_user) {
270 $superiors = $ou_user->getSuperiors();
272 $superior_usr_ids = array_map(
static fn(
ilOrgUnitUser $ou_user):
int => $ou_user->
getUserId(), $superiors);
274 $usr_id_by_name_map = $this->user_helper->getUsernameMapForIds($superior_usr_ids);
276 $resolved = implode(
', ', $usr_id_by_name_map);
300 $this->initLanguageByIso2Code($user->
getLanguage());
305 $this->
language = $this->language_helper->getLanguageByIsoCode($iso_code);
306 $this->
language->loadLanguageModule(
'mail');
Class for date presentation.
static setLanguage(ilLanguage $a_lng)
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
getSpecificPlaceholders()
ilMailEnvironmentHelper $env_helper
placeholderDefinitionRequiresRecipient(array $placeholder_definition)
ilMailLanguageHelper $language_helper
initLanguage(ilObjUser $user)
findPlaceholderByMustacheName(string $placeholder_name)
resolvePlaceholder(string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
ilMailUserHelper $user_helper
initLanguageByIso2Code(string $iso_code)
OrgUnitUserService $org_unit_user_service
__construct(?OrgUnitUserService $org_unit_user_service=null, ?ilMailEnvironmentHelper $environment_helper=null, ?ilMailUserHelper $user_helper=null, ?ilMailLanguageHelper $language_helper=null)
requiresRecipientByPlaceholderName(string $placeholder_name)
if(!file_exists('../ilias.ini.php'))