ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 addPDFtoArchiveDirectory (string $pdfdata, string $dir, string $filename)
 Adds PDF data as a file to a given directory. More...
 
 zipCertificatesInArchiveDirectory (string $dir, bool $deliver=true)
 

Private Attributes

int $objectId
 
string $webDirectory
 
string $certificatePath
 
string $typeInFileName
 
string $installionId
 

Detailed Description

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

Definition at line 24 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 32 of file class.ilUserCertificateZip.php.

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

37  {
38  $this->objectId = $objectId;
39  $this->certificatePath = $certificatePath;
40  $this->webDirectory = $webDirectory;
41  $this->installionId = $installationId;
42 
43  // The mapping to types is made to reflect the old behaviour of
44  // the adapters
45  $iliasType = ilObject::_lookupType($this->objectId);
46 
47  $typeInFileName = 'not_defined';
48  if ('crs' === $iliasType) {
49  $typeInFileName = 'course';
50  } elseif ('tst' === $iliasType) {
51  $typeInFileName = 'test';
52  } elseif ('exc' === $iliasType) {
53  $typeInFileName = 'exc';
54  } elseif ('sahs' === $iliasType) {
55  $typeInFileName = 'scorm';
56  }
57 
58  $this->typeInFileName = $typeInFileName;
59  }
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ addPDFtoArchiveDirectory()

ilUserCertificateZip::addPDFtoArchiveDirectory ( string  $pdfdata,
string  $dir,
string  $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 78 of file class.ilUserCertificateZip.php.

78  : void
79  {
80  $fh = fopen($dir . $filename, 'wb');
81  fwrite($fh, $pdfdata);
82  fclose($fh);
83  }
$filename
Definition: buildRTE.php:78

◆ createArchiveDirectory()

ilUserCertificateZip::createArchiveDirectory ( )

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

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

Referenced by ilTestEvaluationGUI\exportCertificate().

61  : string
62  {
63  $type = ilObject::_lookupType($this->objectId);
64  $certificateId = $this->objectId;
65 
66  $directory = $this->webDirectory . $this->certificatePath . time() . '__' . $this->installionId . '__' . $type . '__' . $certificateId . '__certificate/';
67  ilFileUtils::makeDirParents($directory);
68 
69  return $directory;
70  }
$type
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zipCertificatesInArchiveDirectory()

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

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

References ilFileUtils\delDir(), ilFileDelivery\deliverFileLegacy(), and ilFileUtils\zip().

85  : string
86  {
87  $zipFile = time() . '__' . $this->installionId . '__' . $this->typeInFileName . '__' . $this->objectId . '__certificates.zip';
88  $zipFilePath = $this->webDirectory . $this->certificatePath . $zipFile;
89 
90  ilFileUtils::zip($dir, $zipFilePath);
91  ilFileUtils::delDir($dir);
92 
93  if ($deliver) {
94  ilFileDelivery::deliverFileLegacy($zipFilePath, $zipFile, 'application/zip', false, true);
95  }
96 
97  return $zipFilePath;
98  }
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
+ Here is the call graph for this function:

Field Documentation

◆ $certificatePath

string ilUserCertificateZip::$certificatePath
private

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

Referenced by __construct().

◆ $installionId

string ilUserCertificateZip::$installionId
private

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

◆ $objectId

int ilUserCertificateZip::$objectId
private

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

Referenced by __construct(), and createArchiveDirectory().

◆ $typeInFileName

string ilUserCertificateZip::$typeInFileName
private

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

Referenced by __construct().

◆ $webDirectory

string ilUserCertificateZip::$webDirectory
private

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

Referenced by __construct().


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