ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCertificateAdapter.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
31 abstract class ilCertificateAdapter
32 {
38  abstract public function getCertificatePath();
39 
46  abstract public function getCertificateVariablesForPreview();
47 
56  abstract public function getCertificateVariablesForPresentation($params = array());
57 
64  abstract public function getCertificateVariablesDescription();
65 
72  abstract public function getAdapterType();
73 
80  abstract public function getCertificateID();
81 
91  public function addAdditionalFormElements(&$form, $form_fields)
92  {
93 
94  }
95 
104  public function addFormFieldsFromPOST(&$form_fields)
105  {
106 
107  }
108 
117  public function addFormFieldsFromObject(&$form_fields)
118  {
119 
120  }
121 
129  public function saveFormFields(&$form_fields)
130  {
131 
132  }
133 
139  public function deleteCertificate()
140  {
141 
142  }
143 
150  public function getCertificateFilename($params = array())
151  {
152  global $lng;
153  $lng->loadLanguageModule("certificate");
154  return $lng->txt("certificate_file_basename").".pdf";
155  }
156 
164  protected function getBaseVariablesDescription($a_enable_last_access = true, $a_enable_completion_date = true)
165  {
166  global $lng;
167 
168  $vars = array(
169  "USER_LOGIN" => $lng->txt("certificate_ph_login"),
170  "USER_FULLNAME" => $lng->txt("certificate_ph_fullname"),
171  "USER_FIRSTNAME" => $lng->txt("certificate_ph_firstname"),
172  "USER_LASTNAME" => $lng->txt("certificate_ph_lastname"),
173  "USER_TITLE" => $lng->txt("certificate_ph_title"),
174  "USER_SALUTATION" => $lng->txt("certificate_ph_salutation"),
175  "USER_BIRTHDAY" => $lng->txt("certificate_ph_birthday"),
176  "USER_INSTITUTION" => $lng->txt("certificate_ph_institution"),
177  "USER_DEPARTMENT" => $lng->txt("certificate_ph_department"),
178  "USER_STREET" => $lng->txt("certificate_ph_street"),
179  "USER_CITY" => $lng->txt("certificate_ph_city"),
180  "USER_ZIPCODE" => $lng->txt("certificate_ph_zipcode"),
181  "USER_COUNTRY" => $lng->txt("certificate_ph_country")
182  );
183 
184  if($a_enable_last_access)
185  {
186  $vars["USER_LASTACCESS"] = $lng->txt("certificate_ph_lastaccess");
187  }
188 
189  $vars["DATE"] = $lng->txt("certificate_ph_date");
190  $vars["DATETIME"] = $lng->txt("certificate_ph_datetime");
191 
192  if($a_enable_completion_date)
193  {
194  $vars["DATE_COMPLETED"] = $lng->txt("certificate_ph_date_completed");
195  $vars["DATETIME_COMPLETED"] = $lng->txt("certificate_ph_datetime_completed");
196  }
197 
198  return $vars;
199  }
200 
208  protected function getBaseVariablesForPreview($a_enable_last_access = true, $a_enable_completion_date = true)
209  {
210  global $lng;
211 
214 
215  $vars = array(
216  "USER_LOGIN" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_login")),
217  "USER_FULLNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_fullname")),
218  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_firstname")),
219  "USER_LASTNAME" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_lastname")),
220  "USER_TITLE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_title")),
221  "USER_SALUTATION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_salutation")),
222  "USER_BIRTHDAY" => ilDatePresentation::formatDate(new ilDate($lng->txt("certificate_var_user_birthday"), IL_CAL_DATE)),
223  "USER_INSTITUTION" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_institution")),
224  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_department")),
225  "USER_STREET" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_street")),
226  "USER_CITY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_city")),
227  "USER_ZIPCODE" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_zipcode")),
228  "USER_COUNTRY" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_country"))
229  );
230 
231  if($a_enable_last_access)
232  {
233  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
234  };
235 
236  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
237  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
238 
239  if($a_enable_completion_date)
240  {
241  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
242  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime(time() - (24 * 60 * 60 * 5), IL_CAL_UNIX));
243  }
244 
246 
247  return $vars;
248  }
249 
250 
259  protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false)
260  {
261  global $lng;
262 
265 
266  $salutation = "";
267  if (strlen($a_user_data["gender"]))
268  {
269  $salutation = $lng->txt("salutation_" . $a_user_data["gender"]);
270  }
271 
272  $birthday = "";
273  if($a_user_data["birthday"])
274  {
275  $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE));
276  }
277 
278  $country = $a_user_data["sel_country"];
279  if($country)
280  {
281  $lng->loadLanguageModule("meta");
282  $country = $lng->txt("meta_c_".$country);
283  }
284  else
285  {
286  $country = $a_user_data["country"];
287  }
288 
289  $vars = array(
290  "USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])),
291  "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])),
292  "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]),
293  "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]),
294  "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]),
295  "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation),
296  "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday),
297  "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]),
298  "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]),
299  "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]),
300  "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]),
301  "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]),
302  "USER_COUNTRY" => ilUtil::prepareFormOutput($country)
303  );
304 
305  if($a_last_access)
306  {
307  $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME));
308  }
309 
310  $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX));
311  $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
312 
313 
314  if($a_completion_date)
315  {
316  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME));
317  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME));
318  }
319 
321 
322  return $vars;
323  }
324 
332  protected function getUserCompletionDate($a_user_id, $a_object_id = null)
333  {
334  if(!$a_object_id)
335  {
336  $a_object_id = $this->object->getId();
337  }
338  include_once "Services/Tracking/classes/class.ilLPStatus.php";
339  return ilLPStatus::_lookupStatusChanged($a_object_id, $a_user_id);
340  }
341 
342 }