76 $logger = $DIC->logger()->cert();
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";
const ILIAS_VERSION_NUMERIC
Class ChatMainBarProvider .
__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)
Class ilObjCertificateSettings.
$global_certificate_settings
getId()
get object id public
getType()
get object type public
readActive(int $objectId)
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 disabled disabled disabled.