ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyMailTemplateRaterInvitationContext.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
29 {
30  protected ilLanguage $lng;
32 
33  public function __construct(
36  ilMailUserHelper $usernameHelper = null,
38  ) {
39  global $DIC;
40 
43  $envHelper,
44  $usernameHelper,
46  );
47 
48  $this->lng = $DIC->language();
49  if (isset($DIC["ilObjDataCache"])) {
50  $this->obj_data_cache = $DIC["ilObjDataCache"];
51  }
52  }
53 
54  public const ID = 'svy_rater_inv';
55 
56  public function getId(): string
57  {
58  return self::ID;
59  }
60 
61  public function getTitle(): string
62  {
63  $lng = $this->lng;
64 
65  $lng->loadLanguageModule('survey');
66 
67  return $lng->txt('svy_mail_context_rater_invitation_title');
68  }
69 
70  public function getDescription(): string
71  {
72  $lng = $this->lng;
73 
74  $lng->loadLanguageModule('survey');
75 
76  return $lng->txt('svy_mail_context_rater_invitation_info');
77  }
78 
79  public function getSpecificPlaceholders(): array
80  {
81  $lng = $this->lng;
82 
83  $lng->loadLanguageModule('survey');
84 
85  $placeholders = array();
86 
87  $placeholders['svy_title'] = array(
88  'placeholder' => 'SURVEY_TITLE',
89  'label' => $lng->txt('svy_mail_context_rater_invitation_survey_title')
90  );
91 
92  $placeholders['svy_link'] = array(
93  'placeholder' => 'SURVEY_LINK',
94  'label' => $lng->txt('perma_link')
95  );
96 
97  $placeholders['svy_ext_rater_firstname'] = array(
98  'placeholder' => 'EXTERNAL_RATER_FIRSTNAME',
99  'label' => $lng->txt('svy_ext_rater_firstname')
100  );
101 
102  $placeholders['svy_ext_rater_lastname'] = array(
103  'placeholder' => 'EXTERNAL_RATER_LASTNAME',
104  'label' => $lng->txt('svy_ext_rater_lastname')
105  );
106 
107  return $placeholders;
108  }
109 
110  public function resolveSpecificPlaceholder(
111  string $placeholder_id,
112  array $context_parameters,
113  ilObjUser $recipient = null,
114  bool $html_markup = false
115  ): string {
119  $ilObjDataCache = $this->obj_data_cache;
120 
121  $svy = new ilObjSurvey((int) $context_parameters['ref_id']);
122  $raters = $svy->getRatersData((int) $context_parameters['appr_id']);
123  $current_rater = null;
124  foreach ($raters as $rater) {
125  if ($rater["user_id"] == $context_parameters['rater_id']) {
126  $current_rater = $rater;
127  }
128  }
129 
130  switch ($placeholder_id) {
131  case 'svy_title':
132  return $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId((int) $context_parameters['ref_id']));
133 
134  case 'svy_link':
135  $svy = new ilObjSurvey((int) $context_parameters['ref_id']);
136  $raters = $svy->getRatersData((int) $context_parameters['appr_id']);
137  $href = ilLink::_getLink((int) $context_parameters['ref_id'], 'svy');
138  if (isset($current_rater["href"]) && $current_rater["href"] !== "") {
139  $href = $current_rater["href"];
140  }
141  return $href;
142 
143  case 'svy_ext_rater_firstname':
144  return $current_rater["firstname"] ?? "";
145 
146  case 'svy_ext_rater_lastname':
147  return $current_rater["lastname"] ?? "";
148  }
149 
150  return '';
151  }
152 }
OrgUnitUserService $orgUnitUserService
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...
__construct(OrgUnitUserService $orgUnitUserService=null, ilMailEnvironmentHelper $envHelper=null, ilMailUserHelper $usernameHelper=null, ilMailLanguageHelper $languageHelper=null)
resolveSpecificPlaceholder(string $placeholder_id, array $context_parameters, ilObjUser $recipient=null, bool $html_markup=false)
loadLanguageModule(string $a_module)
Load language module.
Class ilMailEnvironmentHelper.
Class ilMailUserHelper.
ilMailLanguageHelper $languageHelper
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
Class ilMailLanguageHelper.
Class ilMailTemplateContext.
__construct(Container $dic, ilPlugin $plugin)
ilMailEnvironmentHelper $envHelper
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...