ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilCourseMailTemplateTutorContextPreview.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public const string ID = 'crs_context_tutor_manual_preview';
24 public const string DEFAULT_COURSE_TITLE = "preview_crs_title";
25 public const string DEFAULT_COURSE_STATUS = "preview_crs_status";
26 public const string DEFAULT_COURSE_MARK = "preview_crs_mark";
27 public const string DEFAULT_COURSE_TIME_SPENT = "3671";
28
29 public function __construct()
30 {
31 global $DIC;
32 $this->g_lng = $DIC->language();
34 }
35
36 public function getId(): string
37 {
38 return self::ID;
39 }
40
42 $placeholder_id,
43 array $context_parameters,
44 ?ilObjUser $recipient = null
45 ): string {
46 if (!in_array($placeholder_id, array('crs_title', 'crs_link'))) {
47 return "";
48 }
49
50 $this->g_lng->loadLanguageModule('sess');
51 $ret = null;
52 switch ($placeholder_id) {
53 case 'crs_title':
54 $ret = $this->g_lng->txt(self::DEFAULT_COURSE_TITLE);
55 break;
56 case 'crs_link':
57 require_once './Services/Link/classes/class.ilLink.php';
58 $ret = ilLink::_getLink($context_parameters['ref_id'], 'crs');
59 break;
60 case 'crs_status':
61 $ret = $this->g_lng->txt(self::DEFAULT_COURSE_STATUS);
62 break;
63 case 'crs_mark':
64 $ret = $this->g_lng->txt(self::DEFAULT_COURSE_MARK);
65 break;
66 case 'crs_time_spent':
67 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
68 require_once("Services/Calendar/classes/class.ilDatePresentation.php");
69 $ret = ilDatePresentation::secondsToString(self::DEFAULT_COURSE_TIME_SPENT, true, $this->g_lng);
70 }
71 break;
72 case 'crs_first_access':
73 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
74 $ret = date("d.m.Y", strtotime("-5 day"));
75 }
76 break;
77 case 'crs_last_access':
78 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
79 $ret = date("d.m.Y", strtotime("-1 day"));
80 }
81 break;
82 default:
83 $ret = "";
84 }
85
86 return $ret;
87 }
88}
resolveSpecificPlaceholder( $placeholder_id, array $context_parameters, ?ilObjUser $recipient=null)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
User class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26