ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCourseMailTemplateMemberContext.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
27{
28 public const ID = 'crs_context_member_manual';
29
31 protected static array $periodInfoByObjIdCache = [];
32
33 protected ilLanguage $lng;
34
35 public function __construct(
36 ?\OrgUnit\PublicApi\OrgUnitUserService $orgUnitUserService = null,
37 ?ilMailEnvironmentHelper $envHelper = null,
38 ?ilMailUserHelper $usernameHelper = null,
39 ?ilMailLanguageHelper $languageHelper = null
40 ) {
41 parent::__construct($orgUnitUserService, $envHelper, $usernameHelper, $languageHelper);
42 }
43
44 public function getId(): string
45 {
46 return self::ID;
47 }
48
49 public function getTitle(): string
50 {
51 global $DIC;
52
53 $lng = $DIC['lng'];
54
56
57 return $lng->txt('crs_mail_context_member_title');
58 }
59
60 public function getDescription(): string
61 {
62 global $DIC;
63
64 $lng = $DIC['lng'];
65
67
68 return $lng->txt('crs_mail_context_member_info');
69 }
70
71 public function getSpecificPlaceholders(): array
72 {
76 global $DIC;
77
78 $lng = $DIC['lng'];
79
81
82 $placeholders = array();
83
84 $placeholders['course_title'] = array(
85 'placeholder' => 'COURSE_TITLE',
86 'label' => $lng->txt('crs_title')
87 );
88
89 $placeholders['course_period_start'] = array(
90 'placeholder' => 'COURSE_PERIOD_START',
91 'label' => $lng->txt('crs_period_start_mail_placeholder')
92 );
93
94 $placeholders['course_period_end'] = array(
95 'placeholder' => 'COURSE_PERIOD_END',
96 'label' => $lng->txt('crs_period_end_mail_placeholder')
97 );
98
99 $placeholders['course_link'] = array(
100 'placeholder' => 'COURSE_LINK',
101 'label' => $lng->txt('crs_mail_permanent_link')
102 );
103
104 return $placeholders;
105 }
106
107 private function getCachedPeriodByObjId(int $objId): array
108 {
109 if (!array_key_exists($objId, self::$periodInfoByObjIdCache)) {
110 self::$periodInfoByObjIdCache[$objId] = ilObjCourseAccess::lookupPeriodInfo($objId);
111 }
112
113 return self::$periodInfoByObjIdCache[$objId];
114 }
115
119 public function resolveSpecificPlaceholder(
120 string $placeholder_id,
121 array $context_parameters,
122 ?ilObjUser $recipient = null
123 ): string {
127 global $DIC;
128
129 $ilObjDataCache = $DIC['ilObjDataCache'];
130
131 if ('course_title' == $placeholder_id) {
132 return $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId((int) $context_parameters['ref_id']));
133 } else {
134 if ('course_link' == $placeholder_id) {
135 return ilLink::_getLink($context_parameters['ref_id'], 'crs');
136 } elseif ('course_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 ('course_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, ?ilObjUser $user=null,)
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...
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
static lookupPeriodInfo(int $a_obj_id)
User class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$objId
Definition: xapitoken.php:57