ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
12 abstract class ilCertificateAdapter
13 {
19  abstract public function getCertificatePath();
20 
27  abstract public function getCertificateVariablesForPreview();
28 
37  abstract public function getCertificateVariablesForPresentation($params = array());
38 
45  abstract public function getCertificateVariablesDescription();
46 
53  abstract public function getAdapterType();
54 
61  abstract public function getCertificateID();
62 
72  public function addAdditionalFormElements(&$form, $form_fields)
73  {
74 
75  }
76 
85  public function addFormFieldsFromPOST(&$form_fields)
86  {
87 
88  }
89 
98  public function addFormFieldsFromObject(&$form_fields)
99  {
100 
101  }
102 
110  public function saveFormFields(&$form_fields)
111  {
112 
113  }
114 
120  public function deleteCertificate()
121  {
122 
123  }
124 
131  public function getCertificateFilename($params = array())
132  {
133  global $lng;
134  $lng->loadLanguageModule("certificate");
135  return $lng->txt("certificate_file_basename").".pdf";
136  }
137 
145  protected function getBaseVariablesDescription($a_enable_last_access = true, $a_enable_completion_date = true)
146  {
147  global $lng;
148 
149  $vars = array(
150  "USER_LOGIN" => $lng->txt("certificate_ph_login"),
151  "USER_FULLNAME" => $lng->txt("certificate_ph_fullname"),
152  "USER_FIRSTNAME" => $lng->txt("certificate_ph_firstname"),
153  "USER_LASTNAME" => $lng->txt("certificate_ph_lastname"),
154  "USER_TITLE" => $lng->txt("certificate_ph_title"),
155  "USER_SALUTATION" => $lng->txt("certificate_ph_salutation"),
156  "USER_BIRTHDAY" => $lng->txt("certificate_ph_birthday"),
157  "USER_INSTITUTION" => $lng->txt("certificate_ph_institution"),
158  "USER_DEPARTMENT" => $lng->txt("certificate_ph_department"),
159  "USER_STREET" => $lng->txt("certificate_ph_street"),
160  "USER_CITY" => $lng->txt("certificate_ph_city"),
161  "USER_ZIPCODE" => $lng->txt("certificate_ph_zipcode"),
162  "USER_COUNTRY" => $lng->txt("certificate_ph_country")
163  );
164 
165  if($a_enable_last_access)
166  {
167  $vars["USER_LASTACCESS"] = $lng->txt("certificate_ph_lastaccess");
168  }
169 
170  $vars["DATE"] = $lng->txt("certificate_ph_date");
171  $vars["DATETIME"] = $lng->txt("certificate_ph_datetime");
172 
173  if($a_enable_completion_date)
174  {
175  $vars["DATE_COMPLETED"] = $lng->txt("certificate_ph_date_completed");
176  $vars["DATETIME_COMPLETED"] = $lng->txt("certificate_ph_datetime_completed");
177  }
178 
179  return $vars;
180  }
181 
189  protected function getBaseVariablesForPreview($a_enable_last_access = true, $a_enable_completion_date = true)
190  {
191  global $lng;
192 
195 
196  $vars = array(
197  "USER_LOGIN" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_login")),
198  "USER_FULLNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_fullname")),
199  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_firstname")),
200  "USER_LASTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_lastname")),
201  "USER_TITLE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_title")),
202  "USER_SALUTATION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_salutation")),
203  "USER_BIRTHDAY" => ilDatePresentation::formatDate(new ilDate($lng->txt("certificate_var_user_birthday"), IL_CAL_DATE)),
204  "USER_INSTITUTION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_institution")),
205  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_department")),
206  "USER_STREET" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_street")),
207  "USER_CITY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_city")),
208  "USER_ZIPCODE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_zipcode")),
209  "USER_COUNTRY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_country"))
210  );
211 
212  if($a_enable_last_access)
213  {
214  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
215  };
216 
217  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
218  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
219 
220  if($a_enable_completion_date)
221  {
222  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
223  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
224  }
225 
227 
228  return $vars;
229  }
230 
231 
240  protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false)
241  {
242  global $lng;
243 
246 
247  $salutation = "";
248  if (strlen($a_user_data["gender"]))
249  {
250  $salutation = $lng->txt("salutation_" . $a_user_data["gender"]);
251  }
252 
253  $birthday = "";
254  if($a_user_data["birthday"])
255  {
256  $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE));
257  }
258 
259  $country = $a_user_data["sel_country"];
260  if($country)
261  {
262  $lng->loadLanguageModule("meta");
263  $country = $lng->txt("meta_c_".$country);
264  }
265  else
266  {
267  $country = $a_user_data["country"];
268  }
269 
270  $vars = array(
271  "USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])),
272  "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])),
273  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]),
274  "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]),
275  "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]),
276  "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation),
277  "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday),
278  "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]),
279  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]),
280  "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]),
281  "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]),
282  "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]),
283  "USER_COUNTRY" => ilUtil::prepareFormOutput($country)
284  );
285 
286  if($a_last_access)
287  {
288  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME));
289  }
290 
291  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
292  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
293 
294 
295  if($a_completion_date)
296  {
297  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME));
298  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME));
299  }
300 
302 
303  return $vars;
304  }
305 
313  protected function getUserCompletionDate($a_user_id, $a_object_id = null)
314  {
315  if(!$a_object_id)
316  {
317  $a_object_id = $this->object->getId();
318  }
319  include_once "Services/Tracking/classes/class.ilLPStatus.php";
320  return ilLPStatus::_lookupStatusChanged($a_object_id, $a_user_id);
321  }
322 
329  function getUserIdForParams($a_params)
330  {
331  return $a_params["user_id"];
332  }
333 }