3declare(strict_types=1);
25 public const ID =
'prg_context_manual';
27 private const TITLE =
"prg_title";
29 private const TYPE =
"prg_type";
30 private const LINK =
"prg_link";
60 $this->
lng = $DIC[
'lng'];
61 $this->
lng->loadLanguageModule(
'prg');
71 return $this->
lng->txt(
'prg_mail_context_title');
76 return $this->
lng->txt(
'prg_mail_context_info');
87 'placeholder' =>
'STUDY_PROGRAMME_TITLE',
88 'label' => $this->
lng->txt(self::TITLE)
92 'placeholder' =>
'STUDY_PROGRAMME_DESCRIPTION',
93 'label' => $this->
lng->txt(self::DESCRIPTION)
97 'placeholder' =>
'STUDY_PROGRAMME_TYPE',
98 'label' => $this->
lng->txt(self::TYPE)
102 'placeholder' =>
'STUDY_PROGRAMME_LINK',
103 'label' => $this->
lng->txt(self::LINK)
107 'placeholder' =>
'STUDY_PROGRAMME_ORG_UNITS',
108 'label' => $this->
lng->txt(self::ORG_UNIT)
112 'placeholder' =>
'STUDY_PROGRAMME_STATUS',
113 'label' => $this->
lng->txt(self::STATUS)
117 'placeholder' =>
'STUDY_PROGRAMME_COMPLETION_DATE',
118 'label' => $this->
lng->txt(self::COMPLETION_DATE)
122 'placeholder' =>
'STUDY_PROGRAMME_COMPLETED_BY',
123 'label' => $this->
lng->txt(self::COMPLETED_BY)
127 'placeholder' =>
'STUDY_PROGRAMME_POINTS_REQUIRED',
128 'label' => $this->
lng->txt(self::POINTS_REQUIRED)
132 'placeholder' =>
'STUDY_PROGRAMME_POINTS_CURRENT',
133 'label' => $this->
lng->txt(self::POINTS_CURRENT)
137 'placeholder' =>
'STUDY_PROGRAMME_DEADLINE',
138 'label' => $this->
lng->txt(self::DEADLINE)
142 'placeholder' =>
'STUDY_PROGRAMME_EXPIRE_DATE',
143 'label' => $this->
lng->txt(self::EXPIRE_DATE)
147 'placeholder' =>
'STUDY_PROGRAMME_VALIDITY',
148 'label' => $this->
lng->txt(self::VALIDITY)
151 return $placeholders;
158 string $placeholder_id,
159 array $context_parameters,
161 bool $html_markup =
false
163 if (is_null($recipient)) {
167 if (!in_array($placeholder_id, [
174 self::COMPLETION_DATE,
176 self::POINTS_REQUIRED,
177 self::POINTS_CURRENT,
187 $assignments = $prg->getAssignmentsOfSingleProgramForUser($recipient->getId());
191 switch ($placeholder_id) {
193 $string = $prg->getTitle();
196 $string = $prg->getDescription();
200 if (!is_null($prg->getSubType())) {
201 $string = $prg->getSubType()->getTitle();
205 $string =
ilLink::_getLink((
int)$context_parameters[
'ref_id'],
'prg') .
' ';
211 $string = $this->
statusToRepr($latest->getProgressTree()->getStatus(), $recipient->getLanguage());
214 $string = $this->
date2String($latest->getProgressTree()->getCompletionDate(), $recipient);
218 $id = $latest->getProgressTree()->getCompletionBy();
221 if ($obj->getType() ===
'usr') {
234 $string = (string) $latest->getProgressTree()->getAmountOfPoints();
237 $string = (string) $latest->getProgressTree()->getCurrentAmountOfPoints();
240 $string = $latest->getProgressTree()->isInProgress() ?
241 $this->
date2String($latest->getProgressTree()->getDeadline(), $recipient) :
'';
246 if ($latest_successful) {
247 $langvar = $latest_successful->getProgressTree()->isInvalidated() ?
'prg_not_valid' :
'prg_still_valid';
248 $string = $this->
lng->txtlng(
'prg', $langvar, $recipient->getLanguage());
254 if ($latest_successful) {
255 $string = $this->
date2String($latest_successful->getProgressTree()->getValidityOfQualification(), $recipient);
259 throw new \Exception(
"cannot resolve placeholder: " . $placeholder_id);
269 $a_dat =
$a->getProgressTree()->getAssignmentDate();
270 $b_dat =
$b->getProgressTree()->getAssignmentDate();
271 if ($a_dat > $b_dat) {
273 } elseif ($a_dat < $b_dat) {
279 return array_shift($assignments);
284 $successful = array_filter(
286 fn ($ass) => $ass->getProgressTree()->isSuccessful()
288 if (count($successful) === 0) {
293 $a_dat =
$a->getProgressTree()->getCompletionDate();
294 $b_dat =
$b->getProgressTree()->getCompletionDate();
295 if ($a_dat > $b_dat) {
297 } elseif ($a_dat < $b_dat) {
303 return array_shift($successful);
311 return $this->
lng->txtlng(
'prg',
'prg_status_in_progress', $lang);
314 return $this->
lng->txtlng(
'prg',
'prg_status_completed', $lang);
317 return $this->
lng->txtlng(
'prg',
'prg_status_accredited', $lang);
320 return $this->
lng->txtlng(
'prg',
'prg_status_not_relevant', $lang);
323 return $this->
lng->txtlng(
'prg',
'prg_status_failed', $lang);
326 throw new ilException(
"Unknown status: '$status'");
330 DateTimeImmutable $date_time =
null,
333 if (is_null($date_time)) {
336 if (is_null($user)) {
337 return $date_time->format(self::DATE_FORMAT);
339 return $user->getDateFormat()->applyTo($date_time);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _lookupTitle(int $obj_id)
static _lookupTargetRefId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getLink(?int $a_ref_id, string $a_type='', array $a_params=array(), string $append="")
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)
static _lookupLogin(int $a_user_id)
static lookupOrgUnitsRepresentation(int $a_usr_id)
lookup org unit representation
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupDeletedDate(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
const STATUS_NOT_RELEVANT
statusToRepr(int $status, string $lang)
getLatestSuccessfulAssignment(array $assignments)
__construct(OrgUnitUserService $orgUnitUserService=null, ilMailEnvironmentHelper $envHelper=null, ilMailUserHelper $usernameHelper=null, ilMailLanguageHelper $languageHelper=null)
getSpecificPlaceholders()
Return an array of placeholders.
getLatestAssignment(array $assignments)
date2String(DateTimeImmutable $date_time=null, ilObjUser $user=null)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples