ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBadge Class Reference
+ Collaboration diagram for ilBadge:

Public Member Functions

 __construct (int $a_id=null)
 
 clone (int $target_parent_obj_id)
 
 getTypeInstance ()
 
 copy (int $a_new_parent_id)
 
 getId ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 setTypeId (string $a_id)
 
 getTypeId ()
 
 setActive (bool $a_value)
 
 isActive ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 setDescription (string $a_value)
 
 getDescription ()
 
 setCriteria (string $a_value)
 
 getCriteria ()
 
 setValid (string $a_value)
 
 getValid ()
 
 setConfiguration (array $a_value=null)
 
 getConfiguration ()
 
 getImage ()
 
 uploadImage (array $a_upload_meta)
 
 importImage (string $a_name, string $a_file)
 
 getImagePath (bool $a_full_path=true)
 
 create ()
 
 update ()
 
 delete ()
 
 getParentMeta ()
 
 deleteStaticFiles ()
 

Static Public Member Functions

static getInstancesByParentId (int $a_parent_id, array $a_filter=null)
 
static getInstancesByType (string $a_type_id)
 
static getObjectInstances (array $a_filter=null)
 
static getExtendedTypeCaption (ilBadgeType $a_type)
 

Protected Member Functions

 setId (int $a_id)
 
 setImage (string $a_value)
 
 getFilePath (int $a_id, string $a_subdir=null)
 
 read (int $a_id)
 
 importDBRow (array $a_row)
 
 getPropertiesForStorage ()
 
 prepareJson (string $a_base_url, string $a_img_suffix)
 

Protected Attributes

ilLanguage $lng
 
ilDBInterface $db
 
int $id = 0
 
int $parent_id = 0
 
string $type_id = ""
 
bool $active = false
 
string $title = ""
 
string $desc = ""
 
string $image = ""
 
string $valid = ""
 
array $config = null
 
string $criteria = ""
 

Detailed Description

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilBadge.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadge::__construct ( int  $a_id = null)

Definition at line 40 of file class.ilBadge.php.

References $DIC, ILIAS\Repository\lng(), and read().

42  {
43  global $DIC;
44 
45  $this->lng = $DIC->language();
46  $this->db = $DIC->database();
47  if ($a_id) {
48  $this->read($a_id);
49  }
50  }
global $DIC
Definition: feed.php:28
read(int $a_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ clone()

ilBadge::clone ( int  $target_parent_obj_id)

Definition at line 115 of file class.ilBadge.php.

References $img, copy(), create(), getId(), getImagePath(), setActive(), setId(), and setParentId().

115  : void
116  {
117  $this->setParentId($target_parent_obj_id);
118  $this->setActive(false);
119 
120  if ($this->getId()) {
121  $img = $this->getImagePath();
122 
123  $this->setId(0);
124  $this->create();
125 
126  if ($img) {
127  // see uploadImage()
128  copy($img, $this->getImagePath());
129  }
130  }
131  }
setId(int $a_id)
getImagePath(bool $a_full_path=true)
$img
Definition: imgupload.php:83
setParentId(int $a_id)
setActive(bool $a_value)
copy(int $a_new_parent_id)
+ Here is the call graph for this function:

◆ copy()

ilBadge::copy ( int  $a_new_parent_id)

Definition at line 142 of file class.ilBadge.php.

References $img, $lng, create(), getId(), getImagePath(), getTitle(), setActive(), setId(), setParentId(), setTitle(), and ilLanguage\txt().

Referenced by clone(), and importImage().

144  : void {
145  $lng = $this->lng;
146 
147  $this->setTitle($this->getTitle() . " " . $lng->txt("copy_of_suffix"));
148  $this->setParentId($a_new_parent_id);
149  $this->setActive(false);
150 
151  if ($this->getId()) {
152  $img = $this->getImagePath();
153 
154  $this->setId(0);
155  $this->create();
156 
157  if ($img) {
158  // see uploadImage()
159  copy($img, $this->getImagePath());
160  }
161  }
162  }
ilLanguage $lng
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setId(int $a_id)
setTitle(string $a_value)
getImagePath(bool $a_full_path=true)
$img
Definition: imgupload.php:83
setParentId(int $a_id)
setActive(bool $a_value)
copy(int $a_new_parent_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilBadge::create ( )

Definition at line 431 of file class.ilBadge.php.

References $db, $id, $ilDB, getId(), getParentId(), getPropertiesForStorage(), getTypeId(), setId(), and update().

Referenced by clone(), copy(), and update().

431  : void
432  {
433  $ilDB = $this->db;
434 
435  if ($this->getId()) {
436  $this->update();
437  return;
438  }
439 
440  $id = $ilDB->nextId("badge_badge");
441  $this->setId($id);
442 
443  $fields = $this->getPropertiesForStorage();
444 
445  $fields["id"] = ["integer", $id];
446  $fields["parent_id"] = ["integer", $this->getParentId()];
447  $fields["type_id"] = ["text", $this->getTypeId()];
448 
449  $ilDB->insert("badge_badge", $fields);
450  }
getPropertiesForStorage()
setId(int $a_id)
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilBadge::delete ( )

Definition at line 470 of file class.ilBadge.php.

References $db, $ilDB, ilBadgeAssignment\deleteByBadgeId(), deleteStaticFiles(), getId(), and getImagePath().

470  : void
471  {
472  $ilDB = $this->db;
473 
474  if (!$this->getId()) {
475  return;
476  }
477 
478  if (file_exists($this->getImagePath())) {
479  unlink($this->getImagePath());
480  }
481 
482  $this->deleteStaticFiles();
483 
485 
486  $ilDB->manipulate("DELETE FROM badge_badge" .
487  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
488  }
deleteStaticFiles()
getImagePath(bool $a_full_path=true)
static deleteByBadgeId(int $a_badge_id)
ilDBInterface $db
+ Here is the call graph for this function:

◆ deleteStaticFiles()

ilBadge::deleteStaticFiles ( )

Definition at line 564 of file class.ilBadge.php.

References $path, ilFileUtils\delDir(), and ilBadgeHandler\getInstance().

Referenced by delete().

564  : void
565  {
566  // remove instance files
567  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
568  if (is_dir($path)) {
570  }
571  }
$path
Definition: ltiservices.php:32
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConfiguration()

ilBadge::getConfiguration ( )

Definition at line 308 of file class.ilBadge.php.

References $config.

Referenced by getPropertiesForStorage(), and ilBadgeManagementGUI\setBadgeFormValues().

308  : ?array
309  {
310  return $this->config;
311  }
array $config
+ Here is the caller graph for this function:

◆ getCriteria()

ilBadge::getCriteria ( )

Definition at line 285 of file class.ilBadge.php.

References $criteria.

Referenced by getPropertiesForStorage(), and ilBadgeManagementGUI\setBadgeFormValues().

285  : string
286  {
287  return $this->criteria;
288  }
string $criteria
+ Here is the caller graph for this function:

◆ getDescription()

ilBadge::getDescription ( )

Definition at line 275 of file class.ilBadge.php.

References $desc.

Referenced by getPropertiesForStorage(), prepareJson(), and ilBadgeManagementGUI\setBadgeFormValues().

275  : string
276  {
277  return $this->desc;
278  }
string $desc
+ Here is the caller graph for this function:

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

Definition at line 573 of file class.ilBadge.php.

References $DIC, $lng, ilBadgeType\getCaption(), and ilLanguage\txt().

Referenced by ilBadgeTableGUI\getItems(), ilObjectBadgeTableGUI\getItems(), ilBadgeUserTableGUI\getItems(), ilObjectBadgeTableGUI\initFilter(), ilBadgeTableGUI\initFilter(), and ilBadgeManagementGUI\listBadges().

575  : string {
576  global $DIC;
577 
578  $lng = $DIC->language();
579 
580  return $a_type->getCaption() . " (" .
581  ($a_type instanceof ilBadgeAuto
582  ? $lng->txt("badge_subtype_auto")
583  : $lng->txt("badge_subtype_manual")) . ")";
584  }
ilLanguage $lng
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilePath()

ilBadge::getFilePath ( int  $a_id,
string  $a_subdir = null 
)
protected

Definition at line 377 of file class.ilBadge.php.

References $path.

Referenced by getImagePath().

380  : string {
381  $storage = new ilFSStorageBadge($a_id);
382  $storage->create();
383 
384  $path = $storage->getAbsolutePath() . "/";
385 
386  if ($a_subdir) {
387  $path .= $a_subdir . "/";
388 
389  if (!is_dir($path)) {
390  mkdir($path);
391  }
392  }
393 
394  return $path;
395  }
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getId()

ilBadge::getId ( )

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

References $id.

Referenced by clone(), copy(), ilBadgeHandler\countStaticBadgeInstances(), create(), delete(), ilBadgeHandler\getBadgePath(), getImagePath(), update(), and uploadImage().

225  : int
226  {
227  return $this->id;
228  }
+ Here is the caller graph for this function:

◆ getImage()

ilBadge::getImage ( )

Definition at line 318 of file class.ilBadge.php.

References $image.

Referenced by getImagePath(), getPropertiesForStorage(), and ilBadgeManagementGUI\setBadgeFormValues().

318  : string
319  {
320  return $this->image;
321  }
string $image
+ Here is the caller graph for this function:

◆ getImagePath()

ilBadge::getImagePath ( bool  $a_full_path = true)

Definition at line 362 of file class.ilBadge.php.

References getFilePath(), getId(), and getImage().

Referenced by clone(), copy(), delete(), importImage(), ilBadgeManagementGUI\setBadgeFormValues(), and uploadImage().

364  : string {
365  if ($this->getId()) {
366  $exp = explode(".", $this->getImage());
367  $suffix = strtolower(array_pop($exp));
368  if ($a_full_path) {
369  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
370  }
371 
372  return "img" . $this->getId() . "." . $suffix;
373  }
374  return "";
375  }
getFilePath(int $a_id, string $a_subdir=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstancesByParentId()

static ilBadge::getInstancesByParentId ( int  $a_parent_id,
array  $a_filter = null 
)
static
Parameters
int$a_parent_id
array | null$a_filter
Returns
self[]

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

References $DIC, $ilDB, and $res.

Referenced by ilObjCourse\cloneObject(), ilBadgeHandler\getAvailableManualBadges(), ilBadgeAssignment\getInstancesByParentId(), ilBadgeTableGUI\getItems(), and ilBadgeUserTableGUI\getItems().

60  : array {
61  global $DIC;
62 
63  $ilDB = $DIC->database();
64 
65  $res = [];
66 
67  $sql = "SELECT * FROM badge_badge" .
68  " WHERE parent_id = " . $ilDB->quote($a_parent_id);
69 
70  if ($a_filter) {
71  if ($a_filter["title"] ?? false) {
72  $sql .= " AND " . $ilDB->like("title", "text", "%" . trim($a_filter["title"]) . "%");
73  }
74  if ($a_filter["type"] ?? false) {
75  $sql .= " AND type_id = " . $ilDB->quote($a_filter["type"], "integer");
76  }
77  }
78 
79  $set = $ilDB->query($sql .
80  " ORDER BY title");
81  while ($row = $ilDB->fetchAssoc($set)) {
82  $obj = new self();
83  $obj->importDBRow($row);
84  $res[] = $obj;
85  }
86 
87  return $res;
88  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getInstancesByType()

static ilBadge::getInstancesByType ( string  $a_type_id)
static
Parameters
string$a_type_id
Returns
self[]

Definition at line 94 of file class.ilBadge.php.

References $DIC, $ilDB, and $res.

Referenced by ilBadgeHandler\triggerEvaluation().

96  : array {
97  global $DIC;
98 
99  $ilDB = $DIC->database();
100 
101  $res = [];
102 
103  $set = $ilDB->query("SELECT * FROM badge_badge" .
104  " WHERE type_id = " . $ilDB->quote($a_type_id, "text") .
105  " ORDER BY title");
106  while ($row = $ilDB->fetchAssoc($set)) {
107  $obj = new self();
108  $obj->importDBRow($row);
109  $res[] = $obj;
110  }
111 
112  return $res;
113  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getObjectInstances()

static ilBadge::getObjectInstances ( array  $a_filter = null)
static
Parameters
array<string,mixed>|null$a_filter
Returns
array[]

Definition at line 168 of file class.ilBadge.php.

References $DIC, $ilDB, and $res.

Referenced by ilObjectBadgeTableGUI\getItems().

170  : array {
171  global $DIC;
172 
173  $ilDB = $DIC->database();
174 
175  $res = $raw = [];
176 
177  $where = "";
178 
179  if ($a_filter["type"]) {
180  $where .= " AND bb.type_id = " . $ilDB->quote($a_filter["type"], "text");
181  }
182  if ($a_filter["title"]) {
183  $where .= " AND " . $ilDB->like("bb.title", "text", "%" . $a_filter["title"] . "%");
184  }
185  if ($a_filter["object"]) {
186  $where .= " AND " . $ilDB->like("od.title", "text", "%" . $a_filter["object"] . "%");
187  }
188 
189  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
190  " FROM badge_badge bb" .
191  " JOIN object_data od ON (bb.parent_id = od.obj_id)" .
192  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
193  $where);
194  while ($row = $ilDB->fetchAssoc($set)) {
195  $raw[] = $row;
196  }
197 
198  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
199  " FROM badge_badge bb" .
200  " JOIN object_data_del od ON (bb.parent_id = od.obj_id)" .
201  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
202  $where);
203  while ($row = $ilDB->fetchAssoc($set)) {
204  $row["deleted"] = true;
205  $raw[] = $row;
206  }
207 
208  foreach ($raw as $row) {
209  $res[] = $row;
210  }
211 
212  return $res;
213  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getParentId()

ilBadge::getParentId ( )

Definition at line 235 of file class.ilBadge.php.

References $parent_id.

Referenced by create(), and getParentMeta().

235  : int
236  {
237  return $this->parent_id;
238  }
int $parent_id
+ Here is the caller graph for this function:

◆ getParentMeta()

ilBadge::getParentMeta ( )
Returns
array{id: int, type: string, title: string, deleted: bool}

Definition at line 516 of file class.ilBadge.php.

References ilObject\_lookupTitle(), ilObject\_lookupType(), ilObjectDataDeletionLog\get(), and getParentId().

Referenced by ilBadgePersonalTableGUI\getItems().

516  : array
517  {
518  $parent_type = ilObject::_lookupType($this->getParentId());
519  $parent_title = "";
520  if ($parent_type) {
521  $parent_title = ilObject::_lookupTitle($this->getParentId());
522  $deleted = false;
523  } else {
524  // already deleted?
525  $parent = ilObjectDataDeletionLog::get($this->getParentId());
526  if ($parent["type"]) {
527  $parent_type = $parent["type"];
528  $parent_title = $parent["title"];
529  }
530  $deleted = true;
531  }
532 
533  return [
534  "id" => $this->getParentId(),
535  "type" => $parent_type,
536  "title" => $parent_title,
537  "deleted" => $deleted
538  ];
539  }
static _lookupTitle(int $obj_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPropertiesForStorage()

ilBadge::getPropertiesForStorage ( )
protected
Returns
array<string, array>

Definition at line 493 of file class.ilBadge.php.

References getConfiguration(), getCriteria(), getDescription(), getImage(), getTitle(), getValid(), and isActive().

Referenced by create(), and update().

493  : array
494  {
495  return [
496  "active" => ["integer", $this->isActive()],
497  "title" => ["text", $this->getTitle()],
498  "descr" => ["text", $this->getDescription()],
499  "crit" => ["text", $this->getCriteria()],
500  "image" => ["text", $this->getImage()],
501  "valid" => ["text", $this->getValid()],
502  "conf" => [
503  "text", $this->getConfiguration() ? serialize($this->getConfiguration()) : null
504  ]
505  ];
506  }
getConfiguration()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilBadge::getTitle ( )

Definition at line 265 of file class.ilBadge.php.

References $title.

Referenced by copy(), getPropertiesForStorage(), prepareJson(), and ilBadgeManagementGUI\setBadgeFormValues().

265  : string
266  {
267  return $this->title;
268  }
string $title
+ Here is the caller graph for this function:

◆ getTypeId()

ilBadge::getTypeId ( )

Definition at line 245 of file class.ilBadge.php.

References $type_id.

Referenced by create(), ilBadgeManagementGUI\executeCommand(), and getTypeInstance().

245  : string
246  {
247  return $this->type_id;
248  }
string $type_id
+ Here is the caller graph for this function:

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

Definition at line 133 of file class.ilBadge.php.

References ilBadgeHandler\getInstance(), and getTypeId().

133  : ?ilBadgeType
134  {
135  if ($this->getTypeId()) {
136  $handler = ilBadgeHandler::getInstance();
137  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
138  }
139  return null;
140  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

Definition at line 295 of file class.ilBadge.php.

References $valid.

Referenced by getPropertiesForStorage(), and ilBadgeManagementGUI\setBadgeFormValues().

295  : string
296  {
297  return $this->valid;
298  }
string $valid
+ Here is the caller graph for this function:

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

Definition at line 414 of file class.ilBadge.php.

References setActive(), setConfiguration(), setCriteria(), setDescription(), setId(), setImage(), setParentId(), setTitle(), setTypeId(), and setValid().

Referenced by read().

416  : void {
417  $this->setId($a_row["id"]);
418  $this->setParentId($a_row["parent_id"]);
419  $this->setTypeId($a_row["type_id"]);
420  $this->setActive($a_row["active"]);
421  $this->setTitle($a_row["title"]);
422  $this->setDescription($a_row["descr"]);
423  $this->setCriteria($a_row["crit"]);
424  $this->setImage($a_row["image"]);
425  $this->setValid($a_row["valid"]);
426  $this->setConfiguration($a_row["conf"]
427  ? unserialize($a_row["conf"], ["allowed_classes" => false])
428  : null);
429  }
setValid(string $a_value)
setId(int $a_id)
setTitle(string $a_value)
setImage(string $a_value)
setDescription(string $a_value)
setCriteria(string $a_value)
setParentId(int $a_id)
setConfiguration(array $a_value=null)
setTypeId(string $a_id)
setActive(bool $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importImage()

ilBadge::importImage ( string  $a_name,
string  $a_file 
)
Exceptions
BadgeException

Definition at line 348 of file class.ilBadge.php.

References copy(), getImagePath(), setImage(), and update().

351  : void {
352  if (file_exists($a_file)) {
353  $this->setImage($a_name);
354  copy($a_file, $this->getImagePath()); // #18280
355 
356  $this->update();
357  } else {
358  throw BadgeException::uploadedBadgeImageFileNotFound($this);
359  }
360  }
setImage(string $a_value)
getImagePath(bool $a_full_path=true)
copy(int $a_new_parent_id)
+ Here is the call graph for this function:

◆ isActive()

ilBadge::isActive ( )

Definition at line 255 of file class.ilBadge.php.

References $active.

Referenced by getPropertiesForStorage(), and ilBadgeManagementGUI\setBadgeFormValues().

255  : bool
256  {
257  return $this->active;
258  }
bool $active
+ Here is the caller graph for this function:

◆ prepareJson()

ilBadge::prepareJson ( string  $a_base_url,
string  $a_img_suffix 
)
protected

Definition at line 546 of file class.ilBadge.php.

References getDescription(), ilBadgeHandler\getInstance(), and getTitle().

549  : stdClass {
550  $json = new stdClass();
551  $json->{"@context"} = "https://w3id.org/openbadges/v1";
552  $json->type = "BadgeClass";
553  $json->id = $a_base_url . "class.json";
554  $json->name = $this->getTitle();
555  $json->description = $this->getDescription();
556  $json->image = $a_base_url . "image." . $a_img_suffix;
557  $json->criteria = $a_base_url . "criteria.txt";
558  $json->issuer = ilBadgeHandler::getInstance()->getIssuerStaticUrl();
559 
560  return $json;
561  }
+ Here is the call graph for this function:

◆ read()

ilBadge::read ( int  $a_id)
protected

Definition at line 402 of file class.ilBadge.php.

References $db, $ilDB, and importDBRow().

Referenced by __construct().

402  : void
403  {
404  $ilDB = $this->db;
405 
406  $set = $ilDB->query("SELECT * FROM badge_badge" .
407  " WHERE id = " . $ilDB->quote($a_id, "integer"));
408  if ($ilDB->numRows($set)) {
409  $row = $ilDB->fetchAssoc($set);
410  $this->importDBRow($row);
411  }
412  }
importDBRow(array $a_row)
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActive()

ilBadge::setActive ( bool  $a_value)

Definition at line 250 of file class.ilBadge.php.

Referenced by clone(), copy(), and importDBRow().

250  : void
251  {
252  $this->active = $a_value;
253  }
+ Here is the caller graph for this function:

◆ setConfiguration()

ilBadge::setConfiguration ( array  $a_value = null)

Definition at line 300 of file class.ilBadge.php.

Referenced by importDBRow().

300  : void
301  {
302  if (is_array($a_value) && !count($a_value)) {
303  $a_value = null;
304  }
305  $this->config = $a_value;
306  }
+ Here is the caller graph for this function:

◆ setCriteria()

ilBadge::setCriteria ( string  $a_value)

Definition at line 280 of file class.ilBadge.php.

Referenced by importDBRow().

280  : void
281  {
282  $this->criteria = trim($a_value);
283  }
+ Here is the caller graph for this function:

◆ setDescription()

ilBadge::setDescription ( string  $a_value)

Definition at line 270 of file class.ilBadge.php.

Referenced by importDBRow().

270  : void
271  {
272  $this->desc = trim($a_value);
273  }
+ Here is the caller graph for this function:

◆ setId()

ilBadge::setId ( int  $a_id)
protected

Definition at line 220 of file class.ilBadge.php.

Referenced by clone(), copy(), create(), and importDBRow().

220  : void
221  {
222  $this->id = $a_id;
223  }
+ Here is the caller graph for this function:

◆ setImage()

ilBadge::setImage ( string  $a_value)
protected

Definition at line 313 of file class.ilBadge.php.

Referenced by importDBRow(), importImage(), and uploadImage().

313  : void
314  {
315  $this->image = trim($a_value);
316  }
+ Here is the caller graph for this function:

◆ setParentId()

ilBadge::setParentId ( int  $a_id)

Definition at line 230 of file class.ilBadge.php.

Referenced by clone(), copy(), and importDBRow().

230  : void
231  {
232  $this->parent_id = $a_id;
233  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBadge::setTitle ( string  $a_value)

Definition at line 260 of file class.ilBadge.php.

Referenced by copy(), and importDBRow().

260  : void
261  {
262  $this->title = trim($a_value);
263  }
+ Here is the caller graph for this function:

◆ setTypeId()

ilBadge::setTypeId ( string  $a_id)

Definition at line 240 of file class.ilBadge.php.

Referenced by importDBRow().

240  : void
241  {
242  $this->type_id = trim($a_id);
243  }
+ Here is the caller graph for this function:

◆ setValid()

ilBadge::setValid ( string  $a_value)

Definition at line 290 of file class.ilBadge.php.

Referenced by importDBRow().

290  : void
291  {
292  $this->valid = trim($a_value);
293  }
+ Here is the caller graph for this function:

◆ update()

ilBadge::update ( )

Definition at line 452 of file class.ilBadge.php.

References $db, $ilDB, create(), getId(), and getPropertiesForStorage().

Referenced by create(), importImage(), and uploadImage().

452  : void
453  {
454  $ilDB = $this->db;
455 
456  if (!$this->getId()) {
457  $this->create();
458  return;
459  }
460 
461  $fields = $this->getPropertiesForStorage();
462 
463  $ilDB->update(
464  "badge_badge",
465  $fields,
466  ["id" => ["integer", $this->getId()]]
467  );
468  }
getPropertiesForStorage()
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uploadImage()

ilBadge::uploadImage ( array  $a_upload_meta)
Exceptions
BadgeException

Definition at line 326 of file class.ilBadge.php.

References Vendor\Package\$e, $path, getId(), getImagePath(), ilFileUtils\moveUploadedFile(), setImage(), and update().

328  : void {
329  if ($this->getId() &&
330  $a_upload_meta["tmp_name"]) {
331  $this->setImage($a_upload_meta["name"]);
332  $path = $this->getImagePath();
333 
334  try {
335  if (ilFileUtils::moveUploadedFile($a_upload_meta['tmp_name'], $this->getImagePath(false), $path)) {
336  $this->update();
337  }
338  } catch (ilException $e) {
339  throw BadgeException::moveUploadedBadgeImageFailed($this, $e);
340  }
341 
342  }
343  }
$path
Definition: ltiservices.php:32
setImage(string $a_value)
getImagePath(bool $a_full_path=true)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

Field Documentation

◆ $active

bool ilBadge::$active = false
protected

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

Referenced by isActive().

◆ $config

array ilBadge::$config = null
protected

Definition at line 37 of file class.ilBadge.php.

Referenced by getConfiguration().

◆ $criteria

string ilBadge::$criteria = ""
protected

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

Referenced by getCriteria().

◆ $db

ilDBInterface ilBadge::$db
protected

Definition at line 27 of file class.ilBadge.php.

Referenced by create(), delete(), read(), and update().

◆ $desc

string ilBadge::$desc = ""
protected

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

Referenced by getDescription().

◆ $id

int ilBadge::$id = 0
protected

Definition at line 29 of file class.ilBadge.php.

Referenced by create(), and getId().

◆ $image

string ilBadge::$image = ""
protected

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

Referenced by getImage().

◆ $lng

ilLanguage ilBadge::$lng
protected

Definition at line 26 of file class.ilBadge.php.

Referenced by copy(), and getExtendedTypeCaption().

◆ $parent_id

int ilBadge::$parent_id = 0
protected

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

Referenced by getParentId().

◆ $title

string ilBadge::$title = ""
protected

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

Referenced by getTitle().

◆ $type_id

string ilBadge::$type_id = ""
protected

Definition at line 31 of file class.ilBadge.php.

Referenced by getTypeId().

◆ $valid

string ilBadge::$valid = ""
protected

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

Referenced by getValid().


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