115 public function cloneCertificate(
121 $oldType = $oldObject->
getType();
122 $newType = $newObject->
getType();
124 if ($oldType !== $newType) {
126 'The types "%s" and "%s" for cloning does not match',
132 $certificatePath = $this->pathFactory->create($newObject);
134 $templates = $this->templateRepository->fetchCertificateTemplatesByObjId($oldObject->
getId());
137 foreach ($templates as $template) {
138 $backgroundImagePath = $template->getBackgroundImagePath();
139 $backgroundImageFile = basename($backgroundImagePath);
140 $backgroundImageThumbnail = dirname($backgroundImagePath) .
'/background.jpg.thumb.jpg';
142 $newBackgroundImage =
'';
143 $newBackgroundImageThumbnail =
'';
144 if ($this->global_certificate_path !== $backgroundImagePath) {
145 if ($this->fileSystem->has($backgroundImagePath) &&
146 !$this->fileSystem->hasDir($backgroundImagePath)
148 $newBackgroundImage = $certificatePath . $backgroundImageFile;
149 $newBackgroundImageThumbnail = str_replace(
154 if ($this->fileSystem->has($newBackgroundImage) &&
155 !$this->fileSystem->hasDir($newBackgroundImage)
157 $this->fileSystem->delete($newBackgroundImage);
160 $this->fileSystem->copy(
161 $backgroundImagePath,
167 $newBackgroundImageThumbnail !==
'' &&
168 $this->fileSystem->has($backgroundImageThumbnail) &&
169 !$this->fileSystem->hasDir($backgroundImageThumbnail)
171 if ($this->fileSystem->has($newBackgroundImageThumbnail) &&
172 !$this->fileSystem->hasDir($newBackgroundImageThumbnail)
174 $this->fileSystem->delete($newBackgroundImageThumbnail);
177 $this->fileSystem->copy(
178 $backgroundImageThumbnail,
179 $newBackgroundImageThumbnail
186 $newCardThumbImage =
'';
187 $cardThumbImagePath = $template->getThumbnailImagePath();
188 if ($this->fileSystem->has($cardThumbImagePath) && !$this->fileSystem->hasDir($cardThumbImagePath)) {
189 $newCardThumbImage = $certificatePath . basename($cardThumbImagePath);
190 if ($this->fileSystem->has($newCardThumbImage) && !$this->fileSystem->hasDir($newCardThumbImage)) {
191 $this->fileSystem->delete($newCardThumbImage);
193 $this->fileSystem->copy(
201 $this->objectHelper->lookupType((
int) $newObject->
getId()),
202 $template->getCertificateContent(),
203 $template->getCertificateHash(),
204 $template->getTemplateValues(),
205 $template->getVersion(),
208 $template->isCurrentlyActive(),
213 $this->templateRepository->save($newTemplate);
218 $this->database->replace(
220 array(
'obj_id' => array(
'integer', $newObject->
getId())),
232 $sql =
'SELECT obj_id FROM il_certificate WHERE obj_id = ' . $this->database->quote($objectId,
'integer');
234 $query = $this->database->query($sql);
236 return $this->database->numRows(
$query);
246 return "background.jpg";
An exception for terminatinating execution or to throw for unit testing.
$global_certificate_settings
getBackgroundImageThumbPath(string $certificatePath)
Returns the filesystem path of the background image thumbnail.
getBackgroundImageName()
Returns the filename of the background image.
readActive(int $objectId)
__construct(ilDBInterface $database, ilCertificatePathFactory $pathFactory, ilCertificateTemplateRepository $templateRepository, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilLogger $logger=null, ilCertificateObjectHelper $objectHelper=null, ?ilObjCertificateSettings $global_certificate_settings=null, string $webDirectory=CLIENT_WEB_DIR, string $global_certificate_path=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
Class ilObjCertificateSettings.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
getId()
get object id @access public
const ILIAS_VERSION_NUMERIC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.