ILIAS  Release_4_4_x_branch Revision 61816
 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  "USER_MATRICULATION" => $lng->txt("certificate_ph_matriculation")
164  );
165 
166  if($a_enable_last_access)
167  {
168  $vars["USER_LASTACCESS"] = $lng->txt("certificate_ph_lastaccess");
169  }
170 
171  $vars["DATE"] = $lng->txt("certificate_ph_date");
172  $vars["DATETIME"] = $lng->txt("certificate_ph_datetime");
173 
174  if($a_enable_completion_date)
175  {
176  $vars["DATE_COMPLETED"] = $lng->txt("certificate_ph_date_completed");
177  $vars["DATETIME_COMPLETED"] = $lng->txt("certificate_ph_datetime_completed");
178  }
179 
180  return $vars;
181  }
182 
190  protected function getBaseVariablesForPreview($a_enable_last_access = true, $a_enable_completion_date = true)
191  {
192  global $lng;
193 
196 
197  $vars = array(
198  "USER_LOGIN" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_login")),
199  "USER_FULLNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_fullname")),
200  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_firstname")),
201  "USER_LASTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_lastname")),
202  "USER_TITLE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_title")),
203  "USER_SALUTATION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_salutation")),
204  "USER_BIRTHDAY" => ilDatePresentation::formatDate(new ilDate($lng->txt("certificate_var_user_birthday"), IL_CAL_DATE)),
205  "USER_INSTITUTION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_institution")),
206  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_department")),
207  "USER_STREET" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_street")),
208  "USER_CITY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_city")),
209  "USER_ZIPCODE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_zipcode")),
210  "USER_COUNTRY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_country")),
211  "USER_MATRICULATION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_matriculation"))
212  );
213 
214  if($a_enable_last_access)
215  {
216  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
217  };
218 
219  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
220  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
221 
222  if($a_enable_completion_date)
223  {
224  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
225  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
226  }
227 
229 
230  return $vars;
231  }
232 
233 
242  protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false)
243  {
244  global $lng;
245 
248 
249  $salutation = "";
250  if (strlen($a_user_data["gender"]))
251  {
252  $salutation = $lng->txt("salutation_" . $a_user_data["gender"]);
253  }
254 
255  $birthday = "";
256  if($a_user_data["birthday"])
257  {
258  $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE));
259  }
260 
261  $country = $a_user_data["sel_country"];
262  if($country)
263  {
264  $lng->loadLanguageModule("meta");
265  $country = $lng->txt("meta_c_".$country);
266  }
267  else
268  {
269  $country = $a_user_data["country"];
270  }
271 
272  $vars = array(
273  "USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])),
274  "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])),
275  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]),
276  "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]),
277  "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]),
278  "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation),
279  "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday),
280  "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]),
281  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]),
282  "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]),
283  "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]),
284  "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]),
285  "USER_COUNTRY" => ilUtil::prepareFormOutput($country),
286  "USER_MATRICULATION" => ilUtil::prepareFormOutput($a_user_data["matriculation"])
287  );
288 
289  if($a_last_access)
290  {
291  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME));
292  }
293 
294  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
295  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
296 
297 
298  if($a_completion_date)
299  {
300  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME));
301  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME));
302  }
303 
305 
306  return $vars;
307  }
308 
316  protected function getUserCompletionDate($a_user_id, $a_object_id = null)
317  {
318  if(!$a_object_id)
319  {
320  $a_object_id = $this->object->getId();
321  }
322  include_once "Services/Tracking/classes/class.ilLPStatus.php";
323  return ilLPStatus::_lookupStatusChanged($a_object_id, $a_user_id);
324  }
325 
332  function getUserIdForParams($a_params)
333  {
334  return $a_params["user_id"];
335  }
336 }