ILIAS  release_8 Revision v8.24
class.ilCourseMailTemplateMemberContext.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
26{
27 public const ID = 'crs_context_member_manual';
28
30 protected static array $periodInfoByObjIdCache = [];
31
32 protected ilLanguage $lng;
33
34 public function __construct(
35 \OrgUnit\PublicApi\OrgUnitUserService $orgUnitUserService = null,
37 ilMailUserHelper $usernameHelper = null,
39 ) {
41 }
42
43 public function getId(): string
44 {
45 return self::ID;
46 }
47
48 public function getTitle(): string
49 {
50 global $DIC;
51
52 $lng = $DIC['lng'];
53
55
56 return $lng->txt('crs_mail_context_member_title');
57 }
58
59 public function getDescription(): string
60 {
61 global $DIC;
62
63 $lng = $DIC['lng'];
64
66
67 return $lng->txt('crs_mail_context_member_info');
68 }
69
70 public function getSpecificPlaceholders(): array
71 {
75 global $DIC;
76
77 $lng = $DIC['lng'];
78
80
81 $placeholders = array();
82
83 $placeholders['crs_title'] = array(
84 'placeholder' => 'COURSE_TITLE',
85 'label' => $lng->txt('crs_title')
86 );
87
88 $placeholders['crs_period_start'] = array(
89 'placeholder' => 'COURSE_PERIOD_START',
90 'label' => $lng->txt('crs_period_start_mail_placeholder')
91 );
92
93 $placeholders['crs_period_end'] = array(
94 'placeholder' => 'COURSE_PERIOD_END',
95 'label' => $lng->txt('crs_period_end_mail_placeholder')
96 );
97
98 $placeholders['crs_link'] = array(
99 'placeholder' => 'COURSE_LINK',
100 'label' => $lng->txt('crs_mail_permanent_link')
101 );
102
103 return $placeholders;
104 }
105
106 private function getCachedPeriodByObjId(int $objId): array
107 {
108 if (!array_key_exists($objId, self::$periodInfoByObjIdCache)) {
109 self::$periodInfoByObjIdCache[$objId] = ilObjCourseAccess::lookupPeriodInfo($objId);
110 }
111
112 return self::$periodInfoByObjIdCache[$objId];
113 }
114
118 public function resolveSpecificPlaceholder(
119 string $placeholder_id,
120 array $context_parameters,
121 ilObjUser $recipient = null,
122 bool $html_markup = false
123 ): string {
127 global $DIC;
128
129 $ilObjDataCache = $DIC['ilObjDataCache'];
130
131 if ('crs_title' == $placeholder_id) {
132 return $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId((int) $context_parameters['ref_id']));
133 } else {
134 if ('crs_link' == $placeholder_id) {
135 return ilLink::_getLink($context_parameters['ref_id'], 'crs');
136 } elseif ('crs_period_start' == $placeholder_id) {
137 $periodInfo = $this->getCachedPeriodByObjId((int) $ilObjDataCache->lookupObjId((int) $context_parameters['ref_id']));
138 if ($periodInfo) {
139 $useRelativeDates = ilDatePresentation::useRelativeDates();
141 $formattedDate = ilDatePresentation::formatDate($periodInfo['crs_end']);
143
144 return $formattedDate;
145 }
146
147 return '';
148 } elseif ('crs_period_end' == $placeholder_id) {
149 $periodInfo = $this->getCachedPeriodByObjId((int) $ilObjDataCache->lookupObjId((int) $context_parameters['ref_id']));
150 if ($periodInfo) {
151 $useRelativeDates = ilDatePresentation::useRelativeDates();
153 $formattedDate = ilDatePresentation::formatDate($periodInfo['crs_end']);
155
156 return $formattedDate;
157 }
158
159 return '';
160 }
161 }
162
163 return '';
164 }
165}
__construct(\OrgUnit\PublicApi\OrgUnitUserService $orgUnitUserService=null, ilMailEnvironmentHelper $envHelper=null, ilMailUserHelper $usernameHelper=null, ilMailLanguageHelper $languageHelper=null)
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilMailEnvironmentHelper.
Class ilMailLanguageHelper.
Class ilMailTemplateContext.
ilMailLanguageHelper $languageHelper
OrgUnitUserService $orgUnitUserService
ilMailEnvironmentHelper $envHelper
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ilObjUser $recipient=null, bool $html_markup=false)
Class ilMailUserHelper.
static lookupPeriodInfo(int $a_obj_id)
User class.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$objId
Definition: xapitoken.php:57