ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCertificate.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 
34 {
40  protected $ctrl;
41 
47  protected $tree;
48 
54  protected $ilias;
55 
61  protected $tpl;
62 
68  protected $lng;
69 
75  protected $adapter;
76 
83  {
84  global $lng, $tpl, $ilCtrl, $ilias, $tree;
85 
86  $this->lng =& $lng;
87  $this->tpl =& $tpl;
88  $this->ctrl =& $ilCtrl;
89  $this->ilias =& $ilias;
90  $this->tree =& $tree;
91  $this->adapter =& $adapter;
92  }
93 
99  public function getBackgroundImagePath()
100  {
101  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
102  }
103 
109  public function getBackgroundImageName()
110  {
111  return "background.jpg";
112  }
113 
119  public function getBackgroundImageThumbPath()
120  {
121  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName() . ".thumb.jpg";
122  }
123 
130  {
131  return $this->getAdapter()->getCertificatePath() . "background_upload";
132  }
133 
139  public function getXSLPath()
140  {
141  return $this->getAdapter()->getCertificatePath() . $this->getXSLName();
142  }
143 
149  function getXSLName()
150  {
151  return "certificate.xml";
152  }
153 
159  public static function _getXSLName()
160  {
161  return "certificate.xml";
162  }
163 
169  public function getBackgroundImagePathWeb()
170  {
171  // TODO: this is generic now -> provide better solution
172  include_once "./Services/Utilities/classes/class.ilUtil.php";
173  $webdir = $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
175  }
176 
183  {
184  // TODO: this is generic now -> provide better solution
185  include_once "./Services/Utilities/classes/class.ilUtil.php";
187  }
188 
194  public function deleteBackgroundImage()
195  {
196  $result = TRUE;
197  if (file_exists($this->getBackgroundImageThumbPath()))
198  {
199  $result = $result & unlink($this->getBackgroundImageThumbPath());
200  }
201  if (file_exists($this->getBackgroundImagePath()))
202  {
203  $result = $result & unlink($this->getBackgroundImagePath());
204  }
205  if (file_exists($this->getBackgroundImageTempfilePath()))
206  {
207  $result = $result & unlink($this->getBackgroundImageTempfilePath());
208  }
209  return $result;
210  }
211 
217  public function cloneCertificate($newObject)
218  {
219  $xsl = $this->getXSLPath();
220  $bgimage = $this->getBackgroundImagePath();
221  $bgimagethumb = $this->getBackgroundImageThumbPath();
222  $certificatepath = $this->getAdapter()->getCertificatePath();
223 
224  $new_xsl = $newObject->getXSLPath();
225  $new_bgimage = $newObject->getBackgroundImagePath();
226  $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
227  $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
228 
229  if (@file_exists($xsl))
230  {
231  ilUtil::makeDirParents($new_certificatepath);
232  @copy($xsl, $new_xsl);
233  if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
234  if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
235  }
236  }
237 
243  public function deleteCertificate()
244  {
245  if (@file_exists($this->getAdapter()->getCertificatePath()))
246  {
247  include_once "./Services/Utilities/classes/class.ilUtil.php";
248  ilUtil::delDir($this->getAdapter()->getCertificatePath());
249  $this->getAdapter()->deleteCertificate();
250  }
251  }
252 
256  public function getFormFieldsFromFO()
257  {
258  if (@file_exists($this->getXSLPath()))
259  {
260  $xslfo = file_get_contents($this->getXSLPath());
261  }
262  // retrieve form information (using a dirty way with regular expressions)
263  $pagewidth = "21cm";
264  if (preg_match("/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
265  {
266  $pagewidth = $matches[1];
267  }
268  $pageheight = "29.7cm";
269  if (preg_match("/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
270  {
271  $pageheight = $matches[1];
272  }
273  $certificatesettings = new ilSetting("certificate");
274  $pagesize = $certificatesettings->get("pageformat");;
275  if (((strcmp($pageheight, "29.7cm") == 0) || (strcmp($pageheight, "297mm") == 0)) && ((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)))
276  {
277  $pagesize = "a4";
278  }
279  else if (((strcmp($pagewidth, "29.7cm") == 0) || (strcmp($pagewidth, "297mm") == 0)) && ((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)))
280  {
281  $pagesize = "a4landscape";
282  }
283  else if (((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)) && ((strcmp($pagewidth, "14.8cm") == 0) || (strcmp($pagewidth, "148mm") == 0)))
284  {
285  $pagesize = "a5";
286  }
287  else if (((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)) && ((strcmp($pageheight, "14.8cm") == 0) || (strcmp($pageheight, "148mm") == 0)))
288  {
289  $pagesize = "a5landscape";
290  }
291  else if (((strcmp($pageheight, "11in") == 0)) && ((strcmp($pagewidth, "8.5in") == 0)))
292  {
293  $pagesize = "letter";
294  }
295  else if (((strcmp($pagewidth, "11in") == 0)) && ((strcmp($pageheight, "8.5in") == 0)))
296  {
297  $pagesize = "letterlandscape";
298  }
299  else
300  {
301  $pagesize = "custom";
302  }
303  if (!strlen($xslfo)) $pagesize = $certificatesettings->get("pageformat");;
304 
305  $paddingtop = "0cm";
306  if (preg_match("/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
307  {
308  $paddingtop = $matches[1];
309  }
310  $marginbody_top = "0cm";
311  $marginbody_right = "2cm";
312  $marginbody_bottom = "0cm";
313  $marginbody_left = "2cm";
314  if(preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
315  {
316  // Backwards compatibility
317  $marginbody = $matches[1];
318  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
319  {
320  $marginbody_top = $matches[1][0];
321  $marginbody_right = $matches[1][1];
322  $marginbody_bottom = $matches[1][2];
323  $marginbody_left = $matches[1][3];
324  }
325  }
326  else if(preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
327  {
328  $marginbody = $matches[1];
329  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
330  {
331  $marginbody_top = $matches[1][0];
332  $marginbody_right = $matches[1][1];
333  $marginbody_bottom = $matches[1][2];
334  $marginbody_left = $matches[1][3];
335  }
336  }
337 
338  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
339  if ((strlen($xslfo)) && (strlen($xsl)))
340  {
341  $args = array( '/_xml' => $xslfo, '/_xsl' => $xsl );
342  $xh = xslt_create();
343  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
344  xslt_error($xh);
345  xslt_free($xh);
346  }
347 
348  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
349  // dirty hack: the php xslt processing seems not to recognize the following
350  // replacements, so we do it in the code as well
351  $output = str_replace("&#xA0;", "<br />", $output);
352  $output = str_replace("&#160;", "<br />", $output);
353  $form_fields = array(
354  "pageformat" => $pagesize,
355  "pagewidth" => $pagewidth,
356  "pageheight" => $pageheight,
357  "padding_top" => $paddingtop,
358  "margin_body_top" => $marginbody_top,
359  "margin_body_right" => $marginbody_right,
360  "margin_body_bottom" => $marginbody_bottom,
361  "margin_body_left" => $marginbody_left,
362  "certificate_text" => $output
363  );
364  $this->getAdapter()->addFormFieldsFromObject($form_fields);
365  return $form_fields;
366  }
367 
374  public function processXHTML2FO($form_data, $for_export = FALSE)
375  {
376  $content = "<html><body>".$form_data["certificate_text"]."</body></html>";
377  $content = preg_replace("/<p>(&nbsp;){1,}<\\/p>/", "<p></p>", $content);
378  $content = preg_replace("/<p>(\\s)*?<\\/p>/", "<p></p>", $content);
379 // $content = str_replace("<p>&nbsp;</p>", "<p><br /></p>", $content);
380 // $content = str_replace("<p> </p>", "<p><br /></p>", $content);
381  $content = str_replace("<p></p>", "<p class=\"emptyrow\"></p>", $content);
382  $content = str_replace("&nbsp;", "&#160;", $content);
383  $content = preg_replace("//", "", $content);
384 
385  include_once "./Services/Certificate/classes/class.ilXmlChecker.php";
386  $check = new ilXMLChecker();
387  $check->setXMLContent($content);
388  $check->startParsing();
389  if ($check->hasError())
390  {
391  throw new Exception($this->lng->txt("certificate_not_well_formed"));
392  }
393 
394  $xsl = file_get_contents("./Services/Certificate/xml/xhtml2fo.xsl");
395  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
396  $xh = xslt_create();
397  if (strcmp($form_data["pageformat"], "custom") == 0)
398  {
399  $pageheight = $form_data["pageheight"];
400  $pagewidth = $form_data["pagewidth"];
401  }
402  else
403  {
404  $pageformats = $this->getPageFormats();
405  $pageheight = $pageformats[$form_data["pageformat"]]["height"];
406  $pagewidth = $pageformats[$form_data["pageformat"]]["width"];
407  }
408  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
410  $params = array(
411  "pageheight" => $pageheight,
412  "pagewidth" => $pagewidth,
413  "backgroundimage" => $backgroundimage,
414  "marginbody" => $form_data["margin_body_top"] . " " . $form_data["margin_body_right"] . " " . $form_data["margin_body_bottom"] . " " . $form_data["margin_body_left"],
415  "paddingtop" => $form_data["padding_top"]
416  );
417  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
418  xslt_error($xh);
419  xslt_free($xh);
420  return $output;
421  }
422 
430  private function exchangeCertificateVariables($certificate_text, $insert_tags = array())
431  {
432  if (count($insert_tags) == 0)
433  {
434  $insert_tags = $this->getAdapter()->getCertificateVariablesForPreview();
435  }
436  foreach ($insert_tags as $var => $value)
437  {
438  $certificate_text = str_replace($var, $value, $certificate_text);
439  }
440  return $certificate_text;
441  }
442 
448  public function outCertificate($params, $deliver = TRUE)
449  {
450  global $ilLog;
451 
453 
454  $insert_tags = $this->getAdapter()->getCertificateVariablesForPresentation($params);
455  $xslfo = file_get_contents($this->getXSLPath());
456 
457  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
458  try
459  {
460  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
461  $this->exchangeCertificateVariables($xslfo, $insert_tags));
462  if ($deliver)
463  {
464  include_once "./Services/Utilities/classes/class.ilUtil.php";
465  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
466  }
467  else
468  {
469  return $pdf_base64->scalar;
470  }
471  }
472  catch(XML_RPC2_FaultException $e)
473  {
474  $ilLog->write(__METHOD__.': '.$e->getMessage());
475  return false;
476  }
477  catch(Exception $e)
478  {
479  $ilLog->write(__METHOD__.': '.$e->getMessage());
480  return false;
481  }
482 
484 
485  /*
486  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
487  $fo2pdf = new ilFO2PDF();
488  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo, $insert_tags));
489  $result = $fo2pdf->send();
490  if ($deliver)
491  {
492  include_once "./Services/Utilities/classes/class.ilUtil.php";
493  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
494  }
495  else
496  {
497  return $result;
498  }
499  */
500  }
501 
505  public function createPreview()
506  {
507  global $ilLog;
508 
510 
511  $xslfo = file_get_contents($this->getXSLPath());
512 
513  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
514  try
515  {
516  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
517  $this->exchangeCertificateVariables($xslfo));
518  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
519 
520  }
521  catch(XML_RPC2_FaultException $e)
522  {
523  $ilLog->write(__METHOD__.': '.$e->getMessage());
524  return false;
525  }
526  catch(Exception $e)
527  {
528  $ilLog->write(__METHOD__.': '.$e->getMessage());
529  return false;
530  }
531 
533 
534  /*
535  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
536  $fo2pdf = new ilFO2PDF();
537  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo));
538  $result = $fo2pdf->send();
539  include_once "./Services/Utilities/classes/class.ilUtil.php";
540  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename(), "application/pdf");
541  */
542  }
543 
549  public function saveCertificate($xslfo, $filename = "")
550  {
551  if (!file_exists($this->getAdapter()->getCertificatePath()))
552  {
553  ilUtil::makeDirParents($this->getAdapter()->getCertificatePath());
554  }
555  if (strlen($filename) == 0)
556  {
557  $filename = $this->getXSLPath();
558  }
559  $fh = fopen($filename, "w");
560  fwrite($fh, $xslfo);
561  fclose($fh);
562  }
563 
571  public function uploadBackgroundImage($image_tempfilename)
572  {
573  if (!empty($image_tempfilename))
574  {
575  $image_filename = "background_upload";
576  $convert_filename = $this->getBackgroundImageName();
577  $imagepath = $this->getAdapter()->getCertificatePath();
578  if (!file_exists($imagepath))
579  {
580  ilUtil::makeDirParents($imagepath);
581  }
582  // upload the file
583  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $this->getBackgroundImageTempfilePath()))
584  {
585  return FALSE;
586  }
587  // convert the uploaded file to JPEG
590  if (!file_exists($this->getBackgroundImagePath()))
591  {
592  // something went wrong converting the file. use the original file and hope, that PDF can work with it
593  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
594  {
595  return FALSE;
596  }
597  }
598  unlink($this->getBackgroundImageTempfilePath());
599  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
600  {
601  return TRUE;
602  }
603  }
604  return FALSE;
605  }
606 
612  public function hasBackgroundImage()
613  {
614  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
615  {
616  return TRUE;
617  }
618  else
619  {
620  return FALSE;
621  }
622  }
623 
629  public function isComplete()
630  {
631  if (file_exists($this->getAdapter()->getCertificatePath()))
632  {
633  if (file_exists($this->getXSLPath()) && (filesize($this->getXSLPath()) > 0))
634  {
635  return TRUE;
636  }
637  }
638  return FALSE;
639  }
640 
648  {
649  if (is_object($adapter) && method_exists($adapter, "getCertificatePath"))
650  {
651  $certificatepath = $adapter->getCertificatePath();
652  if (file_exists($certificatepath))
653  {
654  $xslpath = $adapter->getCertificatePath() . ilCertificate::_getXSLName();
655  if (file_exists($xslpath) && (filesize($xslpath) > 0))
656  {
657  return TRUE;
658  }
659  }
660  }
661  return FALSE;
662  }
663 
669  public function getPageFormats()
670  {
671  return array(
672  "a4" => array(
673  "name" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
674  "value" => "a4",
675  "width" => "210mm",
676  "height" => "297mm"
677  ),
678  "a4landscape" => array(
679  "name" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
680  "value" => "a4landscape",
681  "width" => "297mm",
682  "height" => "210mm"
683  ),
684  "a5" => array(
685  "name" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
686  "value" => "a5",
687  "width" => "148mm",
688  "height" => "210mm"
689  ),
690  "a5landscape" => array(
691  "name" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
692  "value" => "a5landscape",
693  "width" => "210mm",
694  "height" => "148mm"
695  ),
696  "letter" => array(
697  "name" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
698  "value" => "letter",
699  "width" => "8.5in",
700  "height" => "11in"
701  ),
702  "letterlandscape" => array(
703  "name" => $this->lng->txt("certificate_letter_landscape"), // (8.5 inch x 11 inch)
704  "value" => "letterlandscape",
705  "width" => "11in",
706  "height" => "8.5in"
707  ),
708  "custom" => array(
709  "name" => $this->lng->txt("certificate_custom"),
710  "value" => "custom",
711  "width" => "",
712  "height" => ""
713  )
714  );
715  }
716 
720  public function deliverExportFileXML()
721  {
722  include_once "./Services/Utilities/classes/class.ilUtil.php";
723  $exportpath = $this->createArchiveDirectory();
724  ilUtil::makeDir($exportpath);
725  $xsl = file_get_contents($this->getXSLPath());
726  $xslexport = str_replace($this->getAdapter()->getCertificatePath(), "", $xsl);
727  // save export xsl file
728  $this->saveCertificate($xslexport, $exportpath . $this->getXSLName());
729  // save background image
730  if ($this->hasBackgroundImage())
731  {
732  copy($this->getBackgroundImagePath(), $exportpath . $this->getBackgroundImageName());
733  }
734  else
735  {
736  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
738  {
740  }
741  }
742  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate.zip";
743  ilUtil::zip($exportpath, $this->getAdapter()->getCertificatePath() . $zipfile);
744  ilUtil::delDir($exportpath);
745  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
746  }
747 
753  public function importCertificate($zipfile, $filename)
754  {
755  include_once "./Services/Utilities/classes/class.ilUtil.php";
756  $importpath = $this->createArchiveDirectory();
757  if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename))
758  {
759  ilUtil::delDir($importpath);
760  return FALSE;
761  }
762  ilUtil::unzip($importpath . $filename, TRUE);
763  $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
764  $copydir = "";
765  if (is_dir($importpath . $subdir))
766  {
767  $dirinfo = ilUtil::getDir($importpath . $subdir);
768  $copydir = $importpath . $subdir;
769  }
770  else
771  {
772  $dirinfo = ilUtil::getDir($importpath);
773  $copydir = $importpath;
774  }
775  $xmlfiles = 0;
776  $otherfiles = 0;
777  foreach ($dirinfo as $file)
778  {
779  if (strcmp($file["type"], "file") == 0)
780  {
781  if (strpos($file["entry"], ".xml") !== FALSE)
782  {
783  $xmlfiles++;
784  }
785  else if (strpos($file["entry"], ".zip") !== FALSE)
786  {
787  }
788  else
789  {
790  $otherfiles++;
791  }
792  }
793  }
794  // if one XML file is in the archive, we try to import it
795  if ($xmlfiles == 1)
796  {
797  foreach ($dirinfo as $file)
798  {
799  if (strcmp($file["type"], "file") == 0)
800  {
801  if (strpos($file["entry"], ".xml") !== FALSE)
802  {
803  $xsl = file_get_contents($copydir . $file["entry"]);
804  // as long as we cannot make RPC calls in a given directory, we have
805  // to add the complete path to every url
806  $xsl = preg_replace("/url\([']{0,1}(.*?)[']{0,1}\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
807  $this->saveCertificate($xsl);
808  }
809  else if (strpos($file["entry"], ".zip") !== FALSE)
810  {
811  }
812  else
813  {
814  @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
815  if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0)
816  {
817  // upload of the background image, create a preview
819  }
820  }
821  }
822  }
823  }
824  else
825  {
826  ilUtil::delDir($importpath);
827  return FALSE;
828  }
829  ilUtil::delDir($importpath);
830  return TRUE;
831  }
832 
838  public function getAdapter()
839  {
840  return $this->adapter;
841  }
842 
848  public function setAdapter($adapter)
849  {
850  $this->adapter =& $adapter;
851  }
852 
853  /***************************************
854  /* BULK CERTIFICATE PROCESSING METHODS *
855  /***************************************
856 
862  public function createArchiveDirectory()
863  {
864  $dir = $this->getAdapter()->getCertificatePath() . time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate/";
865  include_once "./Services/Utilities/classes/class.ilUtil.php";
866  ilUtil::makeDirParents($dir);
867  return $dir;
868  }
869 
877  public function addPDFtoArchiveDirectory($pdfdata, $dir, $filename)
878  {
879  $fh = fopen($dir . $filename, "wb");
880  fwrite($fh, $pdfdata);
881  fclose($fh);
882  }
883 
891  public function zipCertificatesInArchiveDirectory($dir, $deliver = TRUE)
892  {
893  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip";
894  ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile);
895  ilUtil::delDir($dir);
896  if ($deliver)
897  {
898  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
899  }
900  return $this->getAdapter()->getCertificatePath() . $zipfile;
901  }
902 
908  public static function _goto($ref_id)
909  {
910  global $ilCtrl;
911  include_once "./classes/class.ilObject.php";
912  $type = ilObject::_lookupType($ref_id, true);
913  switch ($type)
914  {
915  case 'sahs':
916  $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$ref_id.
917  "&cmd=downloadCertificate";
918  ilUtil::redirect($cmd_link);
919  break;
920  case 'tst':
921  default:
922  include_once "./Services/Utilities/classes/class.ilUtil.php";
923  ilUtil::redirect("repository.php?cmd=frameset");
924  break;
925  }
926  }
927 }
928 
929 ?>