27     protected int $id = 0;
    37         $this->db = $DIC->database();
    50         $ilDB = $DIC->database();
    55         $set = 
$ilDB->query(
"SELECT * FROM badge_image_templ_type");
    56         while ($row = 
$ilDB->fetchAssoc($set)) {
    57             $types[$row[
"tmpl_id"]][] = $row[
"type_id"];
    60         $set = 
$ilDB->query(
"SELECT * FROM badge_image_template" .
    62         while ($row = 
$ilDB->fetchAssoc($set)) {
    63             $row[
"types"] = (array) ($types[$row[
"id"]] ?? null);
    66             $obj->importDBRow($row);
    80         foreach (self::getInstances() as $tmpl) {
    81             if (!count($tmpl->getTypes()) || in_array($a_type_unique_id, $tmpl->getTypes(), 
true)) {
    94     protected function setId(
int $a_id): void
   106         $this->title = trim($a_value);
   116         $this->image = trim($a_value);
   127     public function setTypes(array $types = null): void
   129         $this->types = is_array($types)
   130             ? array_unique($types)
   145         if ($this->
getId() &&
   146             $a_upload_meta[
"tmp_name"]) {
   153             $suffix = strtolower(array_pop($exp));
   154             $tgt = 
$path . 
"img" . $this->
getId() . 
"." . $suffix;
   165         if ($this->
getId()) {
   170             $exp = explode(
".", $this->
getImage());
   171             $suffix = strtolower(array_pop($exp));
   182         string $a_subdir = null
   187         $path = $storage->getAbsolutePath() . 
"/";
   190             $path .= $a_subdir . 
"/";
   192             if (!is_dir(
$path)) {
   205     protected function read(
int $a_id): void
   209         $set = 
$ilDB->query(
"SELECT * FROM badge_image_template" .
   210             " WHERE id = " . 
$ilDB->quote($a_id, 
"integer"));
   211         if (
$ilDB->numRows($set)) {
   212             $row = 
$ilDB->fetchAssoc($set);
   224         $set = 
$ilDB->query(
"SELECT * FROM badge_image_templ_type WHERE tmpl_id = " . 
$ilDB->quote($a_id, 
"integer"));
   225         while ($row = 
$ilDB->fetchAssoc($set)) {
   226             $res[] = $row[
"type_id"];
   238         $this->
setId($a_row[
"id"]);
   248         if ($this->
getId()) {
   253         $id = 
$ilDB->nextId(
"badge_image_template");
   257         $fields[
"id"] = array(
"integer", $id);
   259         $ilDB->insert(
"badge_image_template", $fields);
   268         if (!$this->
getId()) {
   276             "badge_image_template",
   278             array(
"id" => array(
"integer", $this->
getId()))
   284     public function delete(): 
void   288         if (!$this->
getId()) {
   295         $ilDB->manipulate(
"DELETE FROM badge_image_template" .
   296             " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer"));
   305             "title" => [
"text", $this->
getTitle()],
   306             "image" => [
"text", $this->
getImage()]
   314         if ($this->
getId()) {
   315             $ilDB->manipulate(
"DELETE FROM badge_image_templ_type" .
   316                 " WHERE tmpl_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
   319                 foreach ($this->
getTypes() as $type) {
   321                         "tmpl_id" => array(
"integer", $this->
getId()),
   322                         "type_id" => array(
"text", $type)
   324                     $ilDB->insert(
"badge_image_templ_type", $fields);
 
uploadImage(array $a_upload_meta)
 
static getInstancesByType(string $a_type_unique_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getPropertiesForStorage()
 
importDBRow(array $a_row)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getValidFilename(string $a_filename)
 
getFilePath(int $a_id, string $a_subdir=null)
Init file system storage. 
 
__construct(int $a_id=null)
 
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively 
 
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file 
 
setTitle(string $a_value)
 
setTypes(array $types=null)
 
setImage(string $a_value)