ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjCertificateSettings Class Reference

Class ilObjCertificateSettings. More...

+ Inheritance diagram for ilObjCertificateSettings:
+ Collaboration diagram for ilObjCertificateSettings:

Public Member Functions

 __construct (int $a_id=0, bool $a_reference=true)
 
 uploadBackgroundImage (UploadResult $upload_result)
 Uploads a background image for the certificate. More...
 
 deleteBackgroundImage ()
 
 getBackgroundImageDefaultFolder (bool $relativePath=false)
 
 getDefaultBackgroundImagePath (bool $relativePath=false)
 
 getDefaultBackgroundImageThumbPath (bool $relativePath=false)
 
 hasBackgroundImage ()
 
 getDefaultBackgroundImagePathWeb ()
 
 getBackgroundImageThumbPathWeb ()
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $desc)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Private Member Functions

 getDefaultBackgroundImageTempFilePath (string $extension)
 

Private Attributes

ilLogger $cert_logger
 
Factory $uuid_factory
 
ilSetting $certificate_settings
 
ilCertificateTemplateDatabaseRepository $certificate_repo
 
ilUserCertificateRepository $user_certificate_repo
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, \ilDBInterface $ilDB=null)
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
int $id
 
bool $referenced
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Detailed Description

Class ilObjCertificateSettings.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilObjCertificateSettings::__construct ( int  $a_id = 0,
bool  $a_reference = true 
)

Definition at line 38 of file class.ilObjCertificateSettings.php.

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

39  {
40  global $DIC;
41 
42  parent::__construct($a_id, $a_reference);
43  $this->type = 'cert';
44  $this->cert_logger = $DIC->logger()->cert();
45  $this->uuid_factory = new Factory();
46  $this->certificate_settings = new ilSetting('certificate');
47  $this->certificate_repo = new ilCertificateTemplateDatabaseRepository($DIC->database());
48  $this->user_certificate_repo = new ilUserCertificateRepository($DIC->database());
49  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteBackgroundImage()

ilObjCertificateSettings::deleteBackgroundImage ( )

PhpCastIsUnnecessaryInspection

UnnecessaryCastingInspection

Definition at line 167 of file class.ilObjCertificateSettings.php.

References getDefaultBackgroundImagePath(), getDefaultBackgroundImageTempFilePath(), getDefaultBackgroundImageThumbPath(), and ilCertificateBackgroundImageFileService\VALID_BACKGROUND_IMAGE_EXTENSIONS.

167  : bool
168  {
169  $result = true;
170 
171 
172  if (
173  $this->certificate_settings->get('defaultImageFileName', '')
174  && !$this->certificate_repo->isBackgroundImageUsed($this->getDefaultBackgroundImagePath(true))
175  && !$this->user_certificate_repo->isBackgroundImageUsed($this->getDefaultBackgroundImagePath(true))
176  ) {
177  //No certificates exist using the currently configured file, deleting file possible.
178 
179  if (is_file($this->getDefaultBackgroundImageThumbPath())) {
180  $result &= unlink($this->getDefaultBackgroundImageThumbPath());
181  }
182  if (is_file($this->getDefaultBackgroundImagePath())) {
183  $result &= unlink($this->getDefaultBackgroundImagePath());
184  }
185 
187  if (is_file($this->getDefaultBackgroundImageTempFilePath($extension))) {
188  $result &= unlink($this->getDefaultBackgroundImageTempFilePath($extension));
189  }
190  }
191  }
192 
193  $this->certificate_settings->set('defaultImageFileName', '');
194 
197  return (bool) $result; // Don't remove the cast, otherwise $result will be 1 or 0
198  }
getDefaultBackgroundImageThumbPath(bool $relativePath=false)
getDefaultBackgroundImageTempFilePath(string $extension)
getDefaultBackgroundImagePath(bool $relativePath=false)
+ Here is the call graph for this function:

◆ getBackgroundImageDefaultFolder()

ilObjCertificateSettings::getBackgroundImageDefaultFolder ( bool  $relativePath = false)

Definition at line 200 of file class.ilObjCertificateSettings.php.

References CLIENT_WEB_DIR.

Referenced by getDefaultBackgroundImagePath(), getDefaultBackgroundImageTempFilePath(), and uploadBackgroundImage().

200  : string
201  {
202  return ($relativePath ? '' : CLIENT_WEB_DIR) . '/certificates/default/';
203  }
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the caller graph for this function:

◆ getBackgroundImageThumbPathWeb()

ilObjCertificateSettings::getBackgroundImageThumbPathWeb ( )

Definition at line 241 of file class.ilObjCertificateSettings.php.

References getDefaultBackgroundImageThumbPath(), and ilFileUtils\removeTrailingPathSeparators().

241  : string
242  {
243  return str_replace(
244  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
247  );
248  }
getDefaultBackgroundImageThumbPath(bool $relativePath=false)
static removeTrailingPathSeparators(string $path)
+ Here is the call graph for this function:

◆ getDefaultBackgroundImagePath()

ilObjCertificateSettings::getDefaultBackgroundImagePath ( bool  $relativePath = false)

Definition at line 205 of file class.ilObjCertificateSettings.php.

References getBackgroundImageDefaultFolder().

Referenced by ilCertificateCloneAction\__construct(), deleteBackgroundImage(), getDefaultBackgroundImagePathWeb(), getDefaultBackgroundImageThumbPath(), hasBackgroundImage(), and uploadBackgroundImage().

205  : string
206  {
207  return $this->getBackgroundImageDefaultFolder($relativePath)
208  . $this->certificate_settings->get('defaultImageFileName', '');
209  }
getBackgroundImageDefaultFolder(bool $relativePath=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultBackgroundImagePathWeb()

ilObjCertificateSettings::getDefaultBackgroundImagePathWeb ( )

Definition at line 232 of file class.ilObjCertificateSettings.php.

References getDefaultBackgroundImagePath(), and ilFileUtils\removeTrailingPathSeparators().

232  : string
233  {
234  return str_replace(
235  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
238  );
239  }
static removeTrailingPathSeparators(string $path)
getDefaultBackgroundImagePath(bool $relativePath=false)
+ Here is the call graph for this function:

◆ getDefaultBackgroundImageTempFilePath()

ilObjCertificateSettings::getDefaultBackgroundImageTempFilePath ( string  $extension)
private

Definition at line 216 of file class.ilObjCertificateSettings.php.

References ilCertificateBackgroundImageFileService\BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME, and getBackgroundImageDefaultFolder().

Referenced by deleteBackgroundImage(), and uploadBackgroundImage().

216  : string
217  {
218  return implode('', [
221  '.' . $extension
222  ]);
223  }
getBackgroundImageDefaultFolder(bool $relativePath=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultBackgroundImageThumbPath()

ilObjCertificateSettings::getDefaultBackgroundImageThumbPath ( bool  $relativePath = false)

◆ hasBackgroundImage()

ilObjCertificateSettings::hasBackgroundImage ( )

Definition at line 225 of file class.ilObjCertificateSettings.php.

References getDefaultBackgroundImagePath().

225  : bool
226  {
227  $filePath = $this->getDefaultBackgroundImagePath();
228 
229  return is_file($filePath) && filesize($filePath) > 0;
230  }
getDefaultBackgroundImagePath(bool $relativePath=false)
+ Here is the call graph for this function:

◆ uploadBackgroundImage()

ilObjCertificateSettings::uploadBackgroundImage ( UploadResult  $upload_result)

Uploads a background image for the certificate.

Creates a new directory for the certificate if needed. Removes an existing certificate image if necessary

Returns
bool True on success, otherwise false
Exceptions
ilException

Definition at line 57 of file class.ilObjCertificateSettings.php.

References ilCertificateBackgroundImageFileService\BACKGROUND_THUMBNAIL_FILE_ENDING, ilShellUtil\convertImage(), getBackgroundImageDefaultFolder(), getDefaultBackgroundImagePath(), getDefaultBackgroundImageTempFilePath(), getDefaultBackgroundImageThumbPath(), ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), ilFileUtils\makeDirParents(), and ilFileUtils\moveUploadedFile().

57  : bool
58  {
59  $image_temp_file_name = $upload_result->getPath();
60  if ($image_temp_file_name !== '') {
61  $extension = pathinfo($upload_result->getName(), PATHINFO_EXTENSION);
62  $image_path = $this->getBackgroundImageDefaultFolder();
63  $new_image_file_name = "background_{$this->uuid_factory->uuid4AsString()}.jpg";
64  $new_image_path = $image_path . $new_image_file_name;
65 
66  if (!is_dir($image_path)) {
67  ilFileUtils::makeDirParents($image_path);
68  }
69  // upload the file
71  $image_temp_file_name,
72  basename($this->getDefaultBackgroundImageTempFilePath($extension)),
73  $this->getDefaultBackgroundImageTempFilePath($extension)
74  )) {
75  $this->cert_logger->error(sprintf(
76  "Could not upload certificate background image from '%s' to temporary file '%s' (name: '%s')",
77  $image_temp_file_name,
78  $this->getDefaultBackgroundImageTempFilePath($extension),
79  basename($this->getDefaultBackgroundImageTempFilePath($extension))
80  ));
81  return false;
82  }
83 
84  if (!is_file($this->getDefaultBackgroundImageTempFilePath($extension))) {
85  $this->cert_logger->error(sprintf(
86  "Uploaded certificate background image could not be moved to temporary file '%s'",
87  $this->getDefaultBackgroundImageTempFilePath($extension)
88  ));
89  return false;
90  }
91 
92  // convert the uploaded file to JPEG
94  $this->getDefaultBackgroundImageTempFilePath($extension),
95  $new_image_path,
96  'JPEG'
97  );
99  $this->getDefaultBackgroundImageTempFilePath($extension),
101  'JPEG',
102  '100'
103  );
104 
105  if (!is_file($new_image_path) || !file_exists($new_image_path)) {
106  // Something went wrong converting the file. Use the original file and hope, that PDF can work with it.
107  $this->cert_logger->error(sprintf(
108  "Could not convert certificate background image from '%s' as JPEG to '%s', trying fallbacj ...",
109  $this->getDefaultBackgroundImageTempFilePath($extension),
110  $new_image_path
111  ));
113  $this->getDefaultBackgroundImageTempFilePath($extension),
114  $new_image_file_name,
115  $new_image_path
116  )) {
117  $this->cert_logger->error(sprintf(
118  "Could not upload certificate background image from '%s' to final file '%s' (name: '%s')",
119  $this->getDefaultBackgroundImageTempFilePath($extension),
120  $new_image_path,
121  $new_image_file_name
122  ));
123  return false;
124  }
125  }
126 
127  if (
128  is_file($this->getDefaultBackgroundImageTempFilePath($extension))
129  && file_exists($this->getDefaultBackgroundImageTempFilePath($extension))
130  ) {
131  unlink($this->getDefaultBackgroundImageTempFilePath($extension));
132  }
133 
134  if (file_exists($new_image_path) && (filesize($new_image_path) > 0)) {
135  $old_path = $this->getDefaultBackgroundImagePath();
136  $old_path_thumb = $this->getDefaultBackgroundImageThumbPath();
137  $old_relative_path = $this->getDefaultBackgroundImagePath(true);
138  $this->certificate_settings->set('defaultImageFileName', $new_image_file_name);
139  $new_relative_path = $this->getDefaultBackgroundImagePath(true);
140 
141  $this->certificate_repo->updateDefaultBackgroundImagePaths($old_relative_path, $new_relative_path);
142 
143  if (
144  !$this->certificate_repo->isBackgroundImageUsed($old_relative_path)
145  && !$this->user_certificate_repo->isBackgroundImageUsed($old_relative_path)
146  ) {
147  if (is_file($old_path) && file_exists($old_path)) {
148  unlink($old_path);
149  }
150 
151  if (is_file($old_path_thumb) && file_exists($old_path_thumb)) {
152  unlink($old_path_thumb);
153  }
154  }
155  return true;
156  }
157 
158  $this->cert_logger->error(sprintf(
159  "Final background image '%s' does not exist or is empty",
160  $new_image_path
161  ));
162  }
163 
164  return false;
165  }
getDefaultBackgroundImageThumbPath(bool $relativePath=false)
getBackgroundImageDefaultFolder(bool $relativePath=false)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
getDefaultBackgroundImageTempFilePath(string $extension)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
getDefaultBackgroundImagePath(bool $relativePath=false)
+ Here is the call graph for this function:

Field Documentation

◆ $cert_logger

ilLogger ilObjCertificateSettings::$cert_logger
private

Definition at line 32 of file class.ilObjCertificateSettings.php.

◆ $certificate_repo

ilCertificateTemplateDatabaseRepository ilObjCertificateSettings::$certificate_repo
private

Definition at line 35 of file class.ilObjCertificateSettings.php.

◆ $certificate_settings

ilSetting ilObjCertificateSettings::$certificate_settings
private

Definition at line 34 of file class.ilObjCertificateSettings.php.

◆ $user_certificate_repo

ilUserCertificateRepository ilObjCertificateSettings::$user_certificate_repo
private

Definition at line 36 of file class.ilObjCertificateSettings.php.

◆ $uuid_factory

Factory ilObjCertificateSettings::$uuid_factory
private

Definition at line 33 of file class.ilObjCertificateSettings.php.


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