ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilUserCertificateZip Class Reference
+ Collaboration diagram for ilUserCertificateZip:

Public Member Functions

 __construct (int $objectId, string $certificatePath, string $webDirectory=CLIENT_WEB_DIR, string $installationId=IL_INST_ID)
 
 createArchiveDirectory ()
 Creates a directory for a zip archive containing multiple certificates. More...
 
 addPDFtoArchiveDirectory ($pdfdata, $dir, $filename)
 Adds PDF data as a file to a given directory. More...
 
 zipCertificatesInArchiveDirectory ($dir, $deliver=true)
 Create a ZIP file from a directory with certificates. More...
 

Private Attributes

 $objectId
 
 $webDirectory
 
 $certificatePath
 
 $typeInFileName
 
 $installionId
 

Detailed Description

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 7 of file class.ilUserCertificateZip.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserCertificateZip::__construct ( int  $objectId,
string  $certificatePath,
string  $webDirectory = CLIENT_WEB_DIR,
string  $installationId = IL_INST_ID 
)

Definition at line 35 of file class.ilUserCertificateZip.php.

40 {
41 $this->objectId = $objectId;
42 $this->certificatePath = $certificatePath;
43 $this->webDirectory = $webDirectory;
44 $this->installionId = $installationId;
45
46 // The mapping to types is made to reflect the old behaviour of
47 // the adapters
48 $iliasType = ilObject::_lookupType($this->objectId);
49
50 $typeInFileName = 'not_defined';
51 if ('crs' === $iliasType) {
52 $typeInFileName = 'course';
53 } elseif ('tst' === $iliasType) {
54 $typeInFileName = 'test';
55 } elseif ('exc' === $iliasType) {
56 $typeInFileName = 'exc';
57 } elseif ('sahs' === $iliasType) {
58 $typeInFileName = 'scorm';
59 }
60
61 $this->typeInFileName = $typeInFileName;
62 }
static _lookupType($a_id, $a_reference=false)
lookup object type

References $certificatePath, $objectId, $typeInFileName, $webDirectory, and ilObject\_lookupType().

+ Here is the call graph for this function:

Member Function Documentation

◆ addPDFtoArchiveDirectory()

ilUserCertificateZip::addPDFtoArchiveDirectory (   $pdfdata,
  $dir,
  $filename 
)

Adds PDF data as a file to a given directory.

Parameters
string$pdfdataBinary PDF data
string$dirDirectory to contain the PDF data
string$filenameThe filename to save the PDF data

Definition at line 87 of file class.ilUserCertificateZip.php.

88 {
89 $fh = fopen($dir . $filename, 'wb');
90 fwrite($fh, $pdfdata);
91 fclose($fh);
92 }
$filename
Definition: buildRTE.php:89

References $filename.

◆ createArchiveDirectory()

ilUserCertificateZip::createArchiveDirectory ( )

Creates a directory for a zip archive containing multiple certificates.

Returns
string The created archive directory

Definition at line 69 of file class.ilUserCertificateZip.php.

70 {
71 $type = ilObject::_lookupType($this->objectId);
72 $certificateId = $this->objectId;
73
74 $directory = $this->webDirectory . $this->certificatePath . time() . '__' . $this->installionId . '__' . $type . '__' . $certificateId . '__certificate/';
75 ilUtil::makeDirParents($directory);
76
77 return $directory;
78 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$type

References $objectId, $type, ilObject\_lookupType(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ zipCertificatesInArchiveDirectory()

ilUserCertificateZip::zipCertificatesInArchiveDirectory (   $dir,
  $deliver = true 
)

Create a ZIP file from a directory with certificates.

Parameters
string$dirDirectory containing the certificates
boolean$deliverTRUE to deliver the ZIP file, FALSE to return the filename only
Returns
string The created ZIP archive path

Definition at line 101 of file class.ilUserCertificateZip.php.

102 {
103 $zipFile = time() . '__' . $this->installionId . '__' . $this->typeInFileName . '__' . $this->objectId . '__certificates.zip';
104 $zipFilePath = $this->webDirectory . $this->certificatePath . $zipFile;
105
106 ilUtil::zip($dir, $zipFilePath);
107 ilUtil::delDir($dir);
108
109 if ($deliver) {
110 ilUtil::deliverFile($zipFilePath, $zipFile, 'application/zip', false, true);
111 }
112
113 return $zipFilePath;
114 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References ilUtil\delDir(), ilUtil\deliverFile(), and ilUtil\zip().

+ Here is the call graph for this function:

Field Documentation

◆ $certificatePath

ilUserCertificateZip::$certificatePath
private

Definition at line 23 of file class.ilUserCertificateZip.php.

Referenced by __construct().

◆ $installionId

ilUserCertificateZip::$installionId
private

Definition at line 33 of file class.ilUserCertificateZip.php.

◆ $objectId

ilUserCertificateZip::$objectId
private

Definition at line 13 of file class.ilUserCertificateZip.php.

Referenced by __construct(), and createArchiveDirectory().

◆ $typeInFileName

ilUserCertificateZip::$typeInFileName
private

Definition at line 28 of file class.ilUserCertificateZip.php.

Referenced by __construct().

◆ $webDirectory

ilUserCertificateZip::$webDirectory
private

Definition at line 18 of file class.ilUserCertificateZip.php.

Referenced by __construct().


The documentation for this class was generated from the following file: