68 $logger = $DIC->logger()->cert();
96 public function cloneCertificate(
100 string $webDir = CLIENT_WEB_DIR
102 $oldType = $oldObject->
getType();
103 $newType = $newObject->
getType();
105 if ($oldType !== $newType) {
107 'The types "%s" and "%s" for cloning does not match',
113 $certificatePath = $this->pathFactory->create($newObject);
115 $templates = $this->templateRepository->fetchCertificateTemplatesByObjId($oldObject->
getId());
118 foreach ($templates as $template) {
119 $backgroundImagePath = $template->getBackgroundImagePath();
120 $backgroundImageFile = basename($backgroundImagePath);
121 $backgroundImageThumbnail = dirname($backgroundImagePath) .
'/background.jpg.thumb.jpg';
123 $newBackgroundImage =
'';
124 $newBackgroundImageThumbnail =
'';
125 if ($this->fileSystem->has($backgroundImagePath) &&
126 !$this->fileSystem->hasDir($backgroundImagePath)
128 $newBackgroundImage = $certificatePath . $backgroundImageFile;
130 if ($this->fileSystem->has($newBackgroundImage) &&
131 !$this->fileSystem->hasDir($newBackgroundImage)
133 $this->fileSystem->delete($newBackgroundImage);
136 $this->fileSystem->copy(
137 $backgroundImagePath,
143 strlen($newBackgroundImageThumbnail) > 0 &&
144 $this->fileSystem->has($backgroundImageThumbnail) &&
145 !$this->fileSystem->hasDir($backgroundImageThumbnail)
147 if ($this->fileSystem->has($newBackgroundImageThumbnail) &&
148 !$this->fileSystem->hasDir($newBackgroundImageThumbnail)
150 $this->fileSystem->delete($newBackgroundImageThumbnail);
153 $this->fileSystem->copy(
154 $backgroundImageThumbnail,
155 $newBackgroundImageThumbnail
159 $newCardThumbImage =
'';
160 $cardThumbImagePath = (string) $template->getThumbnailImagePath();
162 if ($this->fileSystem->has($cardThumbImagePath) && !$this->fileSystem->hasDir($cardThumbImagePath)) {
163 $newCardThumbImage = $certificatePath . basename($cardThumbImagePath);
164 if ($this->fileSystem->has($newCardThumbImage) && !$this->fileSystem->hasDir($newCardThumbImage)) {
165 $this->fileSystem->delete($newCardThumbImage);
167 $this->fileSystem->copy(
175 $this->objectHelper->lookupType((
int) $newObject->
getId()),
176 $template->getCertificateContent(),
177 $template->getCertificateHash(),
178 $template->getTemplateValues(),
179 $template->getVersion(),
182 $template->isCurrentlyActive(),
187 $this->templateRepository->save($newTemplate);
192 $this->database->replace(
194 array(
'obj_id' => array(
'integer', $newObject->
getId())),
206 $sql =
'SELECT obj_id FROM il_certificate WHERE obj_id = ' . $this->database->quote($objectId,
'integer');
208 $query = $this->database->query($sql);
210 return $this->database->numRows(
$query);
220 return "background.jpg";
const ILIAS_VERSION_NUMERIC
Class ChatMainBarProvider .
getId()
get object id public
getType()
get object type public
readActive(int $objectId)
__construct(ilDBInterface $database, ilCertificatePathFactory $pathFactory, ilCertificateTemplateRepository $templateRepository, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilLogger $logger=null, ilCertificateObjectHelper $objectHelper=null, string $webDirectory=CLIENT_WEB_DIR)
getBackgroundImageThumbPath(string $certificatePath)
Returns the filesystem path of the background image thumbnail.
Component logger with individual log levels by component id.
getBackgroundImageName()
Returns the filename of the background image.
Class FlySystemFileAccessTest.