ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 }
92
101 public function addFormFieldsFromPOST(&$form_fields)
102 {
103
104 }
105
114 public function addFormFieldsFromObject(&$form_fields)
115 {
116
117 }
118
126 public function saveFormFields(&$form_fields)
127 {
128
129 }
130
136 public function deleteCertificate()
137 {
138
139 }
140
147 public function getCertificateFilename($params = array())
148 {
149 $this->lng->loadLanguageModule("certificate");
150
151 return $this->lng->txt("certificate_file_basename").".pdf";
152 }
153
161 protected function getBaseVariablesDescription($a_enable_last_access = true, $a_enable_completion_date = true)
162 {
163 $vars = array(
164 "USER_LOGIN" => $this->lng->txt("certificate_ph_login"),
165 "USER_FULLNAME" => $this->lng->txt("certificate_ph_fullname"),
166 "USER_FIRSTNAME" => $this->lng->txt("certificate_ph_firstname"),
167 "USER_LASTNAME" => $this->lng->txt("certificate_ph_lastname"),
168 "USER_TITLE" => $this->lng->txt("certificate_ph_title"),
169 "USER_SALUTATION" => $this->lng->txt("certificate_ph_salutation"),
170 "USER_BIRTHDAY" => $this->lng->txt("certificate_ph_birthday"),
171 "USER_INSTITUTION" => $this->lng->txt("certificate_ph_institution"),
172 "USER_DEPARTMENT" => $this->lng->txt("certificate_ph_department"),
173 "USER_STREET" => $this->lng->txt("certificate_ph_street"),
174 "USER_CITY" => $this->lng->txt("certificate_ph_city"),
175 "USER_ZIPCODE" => $this->lng->txt("certificate_ph_zipcode"),
176 "USER_COUNTRY" => $this->lng->txt("certificate_ph_country"),
177 "USER_MATRICULATION" => $this->lng->txt("certificate_ph_matriculation")
178 );
179
180 if($a_enable_last_access)
181 {
182 $vars["USER_LASTACCESS"] = $this->lng->txt("certificate_ph_lastaccess");
183 }
184
185 $vars["DATE"] = $this->lng->txt("certificate_ph_date");
186 $vars["DATETIME"] = $this->lng->txt("certificate_ph_datetime");
187
188 if($a_enable_completion_date)
189 {
190 $vars["DATE_COMPLETED"] = $this->lng->txt("certificate_ph_date_completed");
191 $vars["DATETIME_COMPLETED"] = $this->lng->txt("certificate_ph_datetime_completed");
192 }
193
194 return $vars;
195 }
196
204 protected function getBaseVariablesForPreview($a_enable_last_access = true, $a_enable_completion_date = true)
205 {
208
209 $vars = array(
210 "USER_LOGIN" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_login")),
211 "USER_FULLNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_fullname")),
212 "USER_FIRSTNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_firstname")),
213 "USER_LASTNAME" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_lastname")),
214 "USER_TITLE" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_title")),
215 "USER_SALUTATION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_salutation")),
216 "USER_BIRTHDAY" => ilDatePresentation::formatDate(new ilDate($this->lng->txt("certificate_var_user_birthday"), IL_CAL_DATE)),
217 "USER_INSTITUTION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_institution")),
218 "USER_DEPARTMENT" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_department")),
219 "USER_STREET" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_street")),
220 "USER_CITY" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_city")),
221 "USER_ZIPCODE" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_zipcode")),
222 "USER_COUNTRY" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_country")),
223 "USER_MATRICULATION" => ilUtil::prepareFormOutput($this->lng->txt("certificate_var_user_matriculation"))
224 );
225
226 if($a_enable_last_access)
227 {
228 $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
229 };
230
231 $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
232 $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
233
234 if($a_enable_completion_date)
235 {
236 $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
237 $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
238 }
239
241
242 return $vars;
243 }
244
245
254 protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false)
255 {
258
259 $salutation = "";
260 if (strlen($a_user_data["gender"]))
261 {
262 $salutation = $this->lng->txt("salutation_" . $a_user_data["gender"]);
263 }
264
265 $birthday = "";
266 if($a_user_data["birthday"])
267 {
268 $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE));
269 }
270
271 $country = $a_user_data["sel_country"];
272 if($country)
273 {
274 $this->lng->loadLanguageModule("meta");
275 $country = $this->lng->txt("meta_c_".$country);
276 }
277 else
278 {
279 $country = $a_user_data["country"];
280 }
281
282 $vars = array(
283 "USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])),
284 "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])),
285 "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]),
286 "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]),
287 "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]),
288 "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation),
289 "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday),
290 "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]),
291 "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]),
292 "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]),
293 "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]),
294 "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]),
295 "USER_COUNTRY" => ilUtil::prepareFormOutput($country),
296 "USER_MATRICULATION" => ilUtil::prepareFormOutput($a_user_data["matriculation"])
297 );
298
299 if($a_last_access)
300 {
301 $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME));
302 }
303
304 $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
305 $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
306
307
308 if($a_completion_date)
309 {
310 $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME));
311 $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME));
312 }
313
315
316 return $vars;
317 }
318
326 protected function getUserCompletionDate($a_user_id, $a_object_id = null)
327 {
328 if(!$a_object_id)
329 {
330 $a_object_id = $this->object->getId();
331 }
332 include_once "Services/Tracking/classes/class.ilLPStatus.php";
333 return ilLPStatus::_lookupStatusChanged($a_object_id, $a_user_id);
334 }
335
342 function getUserIdForParams($a_params)
343 {
344 return $a_params["user_id"];
345 }
346}
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 setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
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
$params
Definition: example_049.php:96
$old
global $DIC