ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjCertificateSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
35 {
36  private readonly ilSetting $certificate_settings;
37  private readonly ResourceStorage $irss;
38  private readonly Filesystem $filesystem;
41 
42  public function __construct(int $a_id = 0, bool $a_reference = true)
43  {
44  global $DIC;
45 
46  parent::__construct($a_id, $a_reference);
47  $this->type = 'cert';
48  $this->certificate_settings = new ilSetting('certificate');
49  $this->irss = $DIC->resourceStorage();
50  $this->filesystem = $DIC->filesystem()->web();
51  $this->stakeholder = new ilCertificateTemplateStakeholder();
52  $this->resource_handler = new CertificateResourceHandler(
53  new ilUserCertificateRepository($DIC->database()),
54  new ilCertificateTemplateDatabaseRepository($DIC->database()),
55  $this->irss,
56  $this,
57  $this->stakeholder
58  );
59  }
60 
62  {
63  $id = $this->certificate_settings->get('cert_bg_image', '');
64 
65  if ($rid = $this->irss->manage()->find($id)) {
66  return $rid;
67  }
68  if ($id !== '') {
70  }
71  if ($id !== '' && $this->filesystem->has($id)) {
72  return ilWACSignedPath::signFile(ILIAS_HTTP_PATH . '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID . $id);
73  }
74  return null;
75  }
76 
77  public function getBackgroundImageDefaultFolder(): string
78  {
79  return '/certificates/default/';
80  }
81 
88  public function uploadBackgroundImage(UploadResult $upload_result): bool
89  {
90  $identification = $this->irss->manage()->upload($upload_result, $this->stakeholder);
91  $this->certificate_settings->set('cert_bg_image', $identification->serialize());
92 
93  return $identification->serialize() !== '';
94  }
95 
96  public function deleteBackgroundImage(): bool
97  {
98  $rid = $this->getBackgroundImageIdentification();
99  if ($rid instanceof ResourceIdentification) {
100  $this->certificate_settings->set('cert_bg_image', '');
101  $this->resource_handler->handleResourceChange($rid);
102 
103  return true;
104  }
105 
106  return false;
107  }
108 
109  public function hasBackgroundImage(): bool
110  {
111  return (bool) $this->certificate_settings->get('cert_bg_image', '');
112  }
113 }
uploadBackgroundImage(UploadResult $upload_result)
Uploads a background image for the certificate.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilCertificateTemplateStakeholder $stakeholder
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly CertificateResourceHandler $resource_handler
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
static signFile(string $path_to_file)
__construct(int $a_id=0, bool $a_reference=true)
const ILIAS_WEB_DIR
Definition: constants.php:45