ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCertificateAdapter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $lng;
18
22 public function __construct()
23 {
24 global $DIC;
25
26 $this->lng = $DIC['lng'];
27 $this->lng->loadLanguageModule('certificate');
28 }
29
35 abstract public function getCertificatePath();
36
43 abstract public function getCertificateVariablesForPreview();
44
53 abstract public function getCertificateVariablesForPresentation($params = array());
54
61 abstract public function getCertificateVariablesDescription();
62
69 abstract public function getAdapterType();
70
77 abstract public function getCertificateID();
78
88 public function addAdditionalFormElements(&$form, $form_fields)
89 {
90 }
91
100 public function addFormFieldsFromPOST(&$form_fields)
101 {
102 }
103
112 public function addFormFieldsFromObject(&$form_fields)
113 {
114 }
115
123 public function saveFormFields(&$form_fields)
124 {
125 }
126
132 public function deleteCertificate()
133 {
134 }
135
142 public function getCertificateFilename($params = array())
143 {
144 $this->lng->loadLanguageModule("certificate");
145
146 return $this->lng->txt("certificate_file_basename") . ".pdf";
147 }
148
156 protected function getBaseVariablesDescription($a_enable_last_access = true, $a_enable_completion_date = true)
157 {
158 $vars = array(
159 "USER_LOGIN" => $this->lng->txt("certificate_ph_login"),
160 "USER_FULLNAME" => $this->lng->txt("certificate_ph_fullname"),
161 "USER_FIRSTNAME" => $this->lng->txt("certificate_ph_firstname"),
162 "USER_LASTNAME" => $this->lng->txt("certificate_ph_lastname"),
163 "USER_TITLE" => $this->lng->txt("certificate_ph_title"),
164 "USER_SALUTATION" => $this->lng->txt("certificate_ph_salutation"),
165 "USER_BIRTHDAY" => $this->lng->txt("certificate_ph_birthday"),
166 "USER_INSTITUTION" => $this->lng->txt("certificate_ph_institution"),
167 "USER_DEPARTMENT" => $this->lng->txt("certificate_ph_department"),
168 "USER_STREET" => $this->lng->txt("certificate_ph_street"),
169 "USER_CITY" => $this->lng->txt("certificate_ph_city"),
170 "USER_ZIPCODE" => $this->lng->txt("certificate_ph_zipcode"),
171 "USER_COUNTRY" => $this->lng->txt("certificate_ph_country"),
172 "USER_MATRICULATION" => $this->lng->txt("certificate_ph_matriculation")
173 );
174
175 if ($a_enable_last_access) {
176 $vars["USER_LASTACCESS"] = $this->lng->txt("certificate_ph_lastaccess");
177 }
178
179 $vars["DATE"] = $this->lng->txt("certificate_ph_date");
180 $vars["DATETIME"] = $this->lng->txt("certificate_ph_datetime");
181
182 if ($a_enable_completion_date) {
183 $vars["DATE_COMPLETED"] = $this->lng->txt("certificate_ph_date_completed");
184 $vars["DATETIME_COMPLETED"] = $this->lng->txt("certificate_ph_datetime_completed");
185 }
186
187 return $vars;
188 }
189
197 protected function getBaseVariablesForPreview($a_enable_last_access = true, $a_enable_completion_date = true)
198 {
201
202 $vars = array(
203 "USER_LOGIN" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_login")),
204 "USER_FULLNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_fullname")),
205 "USER_FIRSTNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_firstname")),
206 "USER_LASTNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_lastname")),
207 "USER_TITLE" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_title")),
208 "USER_SALUTATION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_salutation")),
209 "USER_BIRTHDAY" => ilDatePresentation::formatDate(new ilDate($this->lng->txt("certificate_var_user_birthday"), IL_CAL_DATE)),
210 "USER_INSTITUTION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_institution")),
211 "USER_DEPARTMENT" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_department")),
212 "USER_STREET" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_street")),
213 "USER_CITY" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_city")),
214 "USER_ZIPCODE" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_zipcode")),
215 "USER_COUNTRY" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_country")),
216 "USER_MATRICULATION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_matriculation"))
217 );
218
219 if ($a_enable_last_access) {
220 $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
221 };
222
223 $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
224 $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
225
226 if ($a_enable_completion_date) {
227 $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
228 $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
229 }
230
232
233 return $vars;
234 }
235
236
245 protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false)
246 {
249
250 $salutation = "";
251 if (strlen($a_user_data["gender"])) {
252 $salutation = $this->lng->txt("salutation_" . $a_user_data["gender"]);
253 }
254
255 $birthday = "";
256 if ($a_user_data["birthday"]) {
257 $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE));
258 }
259
260 $country = $a_user_data["sel_country"];
261 if ($country) {
262 $this->lng->loadLanguageModule("meta");
263 $country = $this->lng->txt("meta_c_" . $country);
264 } else {
265 $country = $a_user_data["country"];
266 }
267
268 $vars = array(
269 "USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])),
270 "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])),
271 "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]),
272 "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]),
273 "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]),
274 "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation),
275 "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday),
276 "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]),
277 "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]),
278 "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]),
279 "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]),
280 "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]),
281 "USER_COUNTRY" => ilUtil::prepareFormOutput($country),
282 "USER_MATRICULATION" => ilUtil::prepareFormOutput($a_user_data["matriculation"])
283 );
284
285 if ($a_last_access) {
286 $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME));
287 }
288
289 $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
290 $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
291
292
293 if ($a_completion_date) {
294 $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME));
295 $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME));
296 }
297
299
300 return $vars;
301 }
302
310 protected function getUserCompletionDate($a_user_id, $a_object_id = null)
311 {
312 if (!$a_object_id) {
313 $a_object_id = $this->object->getId();
314 }
315 include_once "Services/Tracking/classes/class.ilLPStatus.php";
316 return ilLPStatus::_lookupStatusChanged($a_object_id, $a_user_id);
317 }
318
325 public function getUserIdForParams($a_params)
326 {
327 return $a_params["user_id"];
328 }
329}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
Adapter class to provide certificate data for the certificate generator.
getCertificateID()
Returns a certificate ID This value will be used to generate unique file names for the certificates.
getCertificateVariablesDescription()
Returns a description of the available certificate parameters.
saveFormFields(&$form_fields)
Allows to save additional adapter form fields This method will be called when the certificate editor ...
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
getCertificateFilename($params=array())
Set the name of the certificate file This method will be called when the certificate will be generate...
getUserIdForParams($a_params)
Get user id for params.
getUserCompletionDate($a_user_id, $a_object_id=null)
Get completion for user.
deleteCertificate()
Is called when the certificate is deleted Add some adapter specific code if more work has to be done ...
addFormFieldsFromObject(&$form_fields)
Allows to add additional form values to the array of form values evaluating the associated adapter cl...
getCertificatePath()
Returns the certificate path (with a trailing path separator)
getCertificateVariablesForPreview()
Returns an array containing all variables and values which can be exchanged in the certificate.
__construct()
ilCertificateAdapter constructor.
addAdditionalFormElements(&$form, $form_fields)
Allows to add additional form fields to the certificate editor form This method will be called when t...
addFormFieldsFromPOST(&$form_fields)
Allows to add additional form values to the array of form values evaluating a HTTP POST action.
getCertificateVariablesForPresentation($params=array())
Returns an array containing all variables and values which can be exchanged in the certificate The va...
getAdapterType()
Returns the adapter type This value will be used to generate file names for the certificates.
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class for single dates.
static _lookupStatusChanged($a_obj_id, $a_user_id)
Lookup status changed.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
if(isset($_POST['submit'])) $form
$old
global $DIC
Definition: saml.php:7
$params
Definition: disable.php:11