ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBadge Class Reference
+ Collaboration diagram for ilBadge:

Public Member Functions

 __construct (?int $a_id=null, ?Container $container=null)
 
 clone (int $target_parent_obj_id)
 
 getTypeInstance ()
 
 copy (int $a_new_parent_id, string $copy_suffix)
 
 setId (int $a_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 ()
 
 setImage (?string $a_value)
 
 getImage ()
 
 uploadImage (array $a_upload_meta)
 
 importImage (string $a_name, string $a_file)
 
 getImagePath (bool $a_full_path=true)
 
 create ()
 
 update ()
 
 delete ()
 
 getParentMeta ()
 
 deleteStaticFiles ()
 
 getImageRid ()
 
 setImageRid (?string $image_rid)
 

Static Public Member Functions

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

Protected Member Functions

 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

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

Private Attributes

ilLogger $log
 
Services $resource_storage
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilBadge::__construct ( ?int  $a_id = null,
?Container  $container = null 
)

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

References $container, $DIC, null, and read().

45  {
46 
47  if ($container === null) {
48  global $DIC;
49  $container = $DIC;
50  }
51 
52  $this->db = $container->database();
53  $this->resource_storage = $container->resourceStorage();
54  $this->log = $container->logger()->root();
55  if ($a_id) {
56  $this->read($a_id);
57  }
58  }
$container
Definition: wac.php:36
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
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 121 of file class.ilBadge.php.

References create(), getId(), getImageRid(), setActive(), setId(), setImageRid(), and setParentId().

121  : void
122  {
123  $this->setParentId($target_parent_obj_id);
124  $this->setActive(false);
125 
126  if ($this->getId()) {
127  if ($this->getImageRid()) {
128  $current_collection_id = new ResourceIdentification($this->getImageRid());
129  $new_collection_id = $this->resource_storage->manage()->clone($current_collection_id);
130  $this->setId(0);
131  $this->setImageRid($new_collection_id);
132  $this->create();
133  } else {
134  $this->log->warning('Please run the "Migration of files of badges to the resource storage service" job, before working with badges.');
135  }
136  }
137  }
setId(int $a_id)
setParentId(int $a_id)
setActive(bool $a_value)
setImageRid(?string $image_rid)
+ Here is the call graph for this function:

◆ copy()

ilBadge::copy ( int  $a_new_parent_id,
string  $copy_suffix 
)

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

References create(), getId(), getImageRid(), getTitle(), null, setActive(), setId(), setImageRid(), setParentId(), setTitle(), and update().

Referenced by importImage().

151  : void {
152  $this->setTitle($this->getTitle() . " " . $copy_suffix);
153  $this->setParentId($a_new_parent_id);
154  $this->setActive(false);
155 
156  if ($this->getId()) {
157  $this->setId(0);
158  $old_rid = $this->getImageRid();
159  $this->create();
160  if ($old_rid !== null) {
161  $new_rid = $this->resource_storage->manage()->clone(new ResourceIdentification($old_rid));
162  $this->setImageRid($new_rid);
163  $this->update();
164  }
165  }
166  }
setId(int $a_id)
setTitle(string $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setParentId(int $a_id)
setActive(bool $a_value)
setImageRid(?string $image_rid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilBadge::create ( )

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

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

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

450  : void
451  {
452  $ilDB = $this->db;
453 
454  if ($this->getId()) {
455  $this->update();
456  return;
457  }
458 
459  $id = $ilDB->nextId("badge_badge");
460  $this->setId($id);
461 
462  $fields = $this->getPropertiesForStorage();
463 
464  $fields["id"] = ["integer", $id];
465  $fields["parent_id"] = ["integer", $this->getParentId()];
466  $fields["type_id"] = ["text", $this->getTypeId()];
467 
468  $ilDB->insert("badge_badge", $fields);
469  }
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 489 of file class.ilBadge.php.

References $db, Vendor\Package\$e, $ilDB, ilBadgeAssignment\deleteByBadgeId(), deleteStaticFiles(), getId(), and getImageRid().

489  : void
490  {
491  $ilDB = $this->db;
492 
493  if (!$this->getId()) {
494  return;
495  }
496 
497  if ($this->getImageRid()) {
498  try {
499  $this->resource_storage->manage()->remove(new ResourceIdentification($this->getImageRid()), new ilBadgeFileStakeholder());
500  } catch (Exception $e) {
501  $this->log->warning(sprintf('There was an exception, while deleting the badge with id %s. Exception: %s', $this->getId(), $e->getMessage()));
502  }
503  }
504 
505  $this->deleteStaticFiles();
506 
508 
509  $ilDB->manipulate("DELETE FROM badge_badge" .
510  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
511  }
deleteStaticFiles()
static deleteByBadgeId(int $a_badge_id)
ilDBInterface $db
+ Here is the call graph for this function:

◆ deleteStaticFiles()

ilBadge::deleteStaticFiles ( )

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

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

Referenced by delete().

588  : void
589  {
590  // remove instance files
591  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
592  if (is_dir($path)) {
594  }
595  }
$path
Definition: ltiservices.php:29
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 323 of file class.ilBadge.php.

References $config.

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

323  : ?array
324  {
325  return $this->config;
326  }
array $config
+ Here is the caller graph for this function:

◆ getCriteria()

ilBadge::getCriteria ( )

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

References $criteria.

Referenced by getPropertiesForStorage(), ILIAS\Badge\Tile\modalContent(), and ilBadgeManagementGUI\setBadgeFormValues().

300  : string
301  {
302  return $this->criteria;
303  }
string $criteria
+ Here is the caller graph for this function:

◆ getDescription()

ilBadge::getDescription ( )

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

References $desc.

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

290  : string
291  {
292  return $this->desc;
293  }
string $desc
+ Here is the caller graph for this function:

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

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

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

Referenced by ILIAS\Badge\ilBadgeUserTableGUI\__construct(), ILIAS\Badge\ilBadgeTableGUI\getRecords(), ILIAS\Badge\ilObjectBadgeTableGUI\getRecords(), and ilBadgeManagementGUI\listBadges().

599  : string {
600  global $DIC;
601 
602  $lng = $DIC->language();
603 
604  return $a_type->getCaption() . " (" .
605  ($a_type instanceof ilBadgeAuto
606  ? $lng->txt("badge_subtype_auto")
607  : $lng->txt("badge_subtype_manual")) . ")";
608  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ 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 395 of file class.ilBadge.php.

References $path.

Referenced by getImagePath().

398  : string {
399  $storage = new ilFSStorageBadge($a_id);
400  $storage->create();
401 
402  $path = $storage->getAbsolutePath() . "/";
403 
404  if ($a_subdir) {
405  $path .= $a_subdir . "/";
406 
407  if (!is_dir($path)) {
408  mkdir($path);
409  }
410  }
411 
412  return $path;
413  }
$path
Definition: ltiservices.php:29
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 240 of file class.ilBadge.php.

References $id.

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

240  : int
241  {
242  return $this->id;
243  }
+ Here is the caller graph for this function:

◆ getImage()

ilBadge::getImage ( )

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

References $image.

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

335  : string
336  {
337  return $this->image;
338  }
string $image
+ Here is the caller graph for this function:

◆ getImagePath()

ilBadge::getImagePath ( bool  $a_full_path = true)

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

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

Referenced by ILIAS\Badge\ilBadgeImage\getImageFromResourceId(), importImage(), ilBadgeManagementGUI\setBadgeFormValues(), and uploadImage().

381  : string {
382  if ($this->getId()) {
383  $exp = explode(".", $this->getImage());
384  $suffix = strtolower(array_pop($exp));
385  if ($a_full_path) {
386  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
387  }
388 
389  return "img" . $this->getId() . "." . $suffix;
390  }
391 
392  return "";
393  }
getFilePath(int $a_id, ?string $a_subdir=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageRid()

ilBadge::getImageRid ( )

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

References $image_rid.

Referenced by clone(), copy(), delete(), ILIAS\Badge\ilBadgeImage\getImageFromResourceId(), getPropertiesForStorage(), and ilBadgeManagementGUI\removeResourceStorageImage().

610  : ?string
611  {
612  return $this->image_rid;
613  }
string $image_rid
+ Here is the caller graph for this function:

◆ getInstancesByParentId()

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

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

References $DIC, $ilDB, and $res.

Referenced by ILIAS\Badge\ilBadgeUserTableGUI\__construct(), ilObjCourse\cloneObject(), ilBadgeManagementGUI\confirmDeleteBadges(), ilBadgeHandler\getAvailableManualBadges(), ilBadgeAssignment\getInstancesByParentId(), ILIAS\Badge\ilBadgeTableGUI\getRecords(), and ilBadgeManagementGUI\toggleBadges().

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

◆ getInstancesByType()

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

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

References $DIC, $ilDB, and $res.

Referenced by ilBadgeHandler\triggerEvaluation().

102  : array {
103  global $DIC;
104 
105  $ilDB = $DIC->database();
106 
107  $res = [];
108 
109  $set = $ilDB->query("SELECT * FROM badge_badge" .
110  " WHERE type_id = " . $ilDB->quote($a_type_id, "text") .
111  " ORDER BY title");
112  while ($row = $ilDB->fetchAssoc($set)) {
113  $obj = new self();
114  $obj->importDBRow($row);
115  $res[] = $obj;
116  }
117 
118  return $res;
119  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getObjectInstances()

static ilBadge::getObjectInstances ( ?array  $filter = null)
static
Parameters
array{typestring, title: string, object: string}|null $filter
Returns
list<array{ id: int, parent_id: int, type_id: string, active: int, title: ?string, descr: ?string, conf: ?string, image: ?string, valid: ?string, crit: ?string, image_rid: ?string, parent_title: ?string, parent_type: ?string, deleted: bool }>

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

References $DIC, $ilDB, and ilDBConstants\T_TEXT.

Referenced by ilObjBadgeAdministrationGUI\confirmDeleteObjectBadges(), ILIAS\Badge\ilObjectBadgeTableGUI\getRecords(), ILIAS\Badge\ilObjectBadgeTableGUI\renderTable(), and ilObjBadgeAdministrationGUI\toggleObjectBadges().

189  : array {
190  global $DIC;
191 
192  $ilDB = $DIC->database();
193 
194  $rows = [];
195 
196  $where = '';
197 
198  if ($filter['type']) {
199  $where .= ' AND bb.type_id = ' . $ilDB->quote($filter['type'], ilDBConstants::T_TEXT);
200  }
201  if ($filter['title']) {
202  $where .= ' AND ' . $ilDB->like('bb.title', ilDBConstants::T_TEXT, '%' . $filter['title'] . '%');
203  }
204  if ($filter['object']) {
205  $where .= ' AND ' . $ilDB->like('od.title', ilDBConstants::T_TEXT, '%' . $filter['object'] . '%');
206  }
207 
208  $set = $ilDB->query('SELECT bb.*, od.title parent_title, od.type parent_type' .
209  ' FROM badge_badge bb' .
210  ' INNER JOIN object_data od ON bb.parent_id = od.obj_id' .
211  ' WHERE od.type != ' . $ilDB->quote('bdga', ilDBConstants::T_TEXT) .
212  $where);
213  while ($row = $ilDB->fetchAssoc($set)) {
214  $row['deleted'] = false;
215  $rows[] = $row;
216  }
217 
218  $set = $ilDB->query('SELECT bb.*, od.title parent_title, od.type parent_type' .
219  ' FROM badge_badge bb' .
220  ' INNER JOIN object_data_del od ON bb.parent_id = od.obj_id' .
221  ' WHERE od.type != ' . $ilDB->quote('bdga', ilDBConstants::T_TEXT) .
222  $where);
223  while ($row = $ilDB->fetchAssoc($set)) {
224  $row['deleted'] = true;
225  $rows[] = $row;
226  }
227 
228  return $rows;
229  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getParentId()

ilBadge::getParentId ( )

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

References $parent_id.

Referenced by create(), getParentMeta(), and ILIAS\Badge\BadgeParent\metaData().

250  : int
251  {
252  return $this->parent_id;
253  }
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 540 of file class.ilBadge.php.

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

Referenced by ilBadgePersonalTableGUI\getRecords(), and ILIAS\Badge\BadgeParent\metaData().

540  : array
541  {
542  $parent_type = ilObject::_lookupType($this->getParentId());
543  $parent_title = "";
544  if ($parent_type) {
545  $parent_title = ilObject::_lookupTitle($this->getParentId());
546  $deleted = false;
547  } else {
548  // already deleted?
549  $parent = ilObjectDataDeletionLog::get($this->getParentId());
550  if ($parent["type"]) {
551  $parent_type = $parent["type"];
552  $parent_title = $parent["title"];
553  }
554  $deleted = true;
555  }
556 
557  return [
558  "id" => $this->getParentId(),
559  "type" => $parent_type,
560  "title" => $parent_title,
561  "deleted" => $deleted
562  ];
563  }
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 516 of file class.ilBadge.php.

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

Referenced by create(), and update().

516  : array
517  {
518  return [
519  "active" => ["integer", $this->isActive()],
520  "title" => ["text", $this->getTitle()],
521  "descr" => ["text", $this->getDescription()],
522  "crit" => ["text", $this->getCriteria()],
523  "image" => ["text", $this->getImage()],
524  "image_rid" => ["text", $this->getImageRid()],
525  "valid" => ["text", $this->getValid()],
526  "conf" => [
527  "text", $this->getConfiguration() ? serialize($this->getConfiguration()) : null
528  ]
529  ];
530  }
getConfiguration()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilBadge::getTitle ( )

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

References $title.

Referenced by copy(), getPropertiesForStorage(), ILIAS\Badge\Tile\image(), prepareJson(), ilBadgeManagementGUI\setBadgeFormValues(), and ILIAS\Badge\Tile\title().

280  : string
281  {
282  return $this->title;
283  }
string $title
+ Here is the caller graph for this function:

◆ getTypeId()

ilBadge::getTypeId ( )

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

References $type_id.

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

260  : string
261  {
262  return $this->type_id;
263  }
string $type_id
+ Here is the caller graph for this function:

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

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

References $handler, ilBadgeHandler\getInstance(), getTypeId(), and null.

139  : ?ilBadgeType
140  {
141  if ($this->getTypeId()) {
143  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
144  }
145  return null;
146  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$handler
Definition: oai.php:30
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

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

References $valid.

Referenced by getPropertiesForStorage(), ILIAS\Badge\Tile\modalContent(), and ilBadgeManagementGUI\setBadgeFormValues().

310  : string
311  {
312  return $this->valid;
313  }
string $valid
+ Here is the caller graph for this function:

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

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

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

Referenced by read().

434  : void {
435  $this->setId($a_row["id"]);
436  $this->setParentId($a_row["parent_id"]);
437  $this->setTypeId($a_row["type_id"]);
438  $this->setActive($a_row["active"]);
439  $this->setTitle($a_row["title"]);
440  $this->setDescription($a_row["descr"]);
441  $this->setCriteria($a_row["crit"]);
442  $this->setImage($a_row["image"]);
443  $this->setImageRid($a_row["image_rid"]);
444  $this->setValid($a_row["valid"]);
445  $this->setConfiguration($a_row["conf"]
446  ? unserialize($a_row["conf"], ["allowed_classes" => false])
447  : null);
448  }
setValid(string $a_value)
setId(int $a_id)
setTitle(string $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setImage(?string $a_value)
setDescription(string $a_value)
setConfiguration(?array $a_value=null)
setCriteria(string $a_value)
setParentId(int $a_id)
setTypeId(string $a_id)
setActive(bool $a_value)
setImageRid(?string $image_rid)
+ 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 365 of file class.ilBadge.php.

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

368  : void {
369  if (file_exists($a_file)) {
370  $this->setImage($a_name);
371  copy($a_file, $this->getImagePath()); // #18280
372 
373  $this->update();
374  } else {
375  throw BadgeException::uploadedBadgeImageFileNotFound($this);
376  }
377  }
setImage(?string $a_value)
getImagePath(bool $a_full_path=true)
copy(int $a_new_parent_id, string $copy_suffix)
+ Here is the call graph for this function:

◆ isActive()

ilBadge::isActive ( )

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

References $active.

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

270  : bool
271  {
272  return $this->active;
273  }
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 570 of file class.ilBadge.php.

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

573  : stdClass {
574  $json = new stdClass();
575  $json->{"@context"} = "https://w3id.org/openbadges/v1";
576  $json->type = "BadgeClass";
577  $json->id = $a_base_url . "class.json";
578  $json->name = $this->getTitle();
579  $json->description = $this->getDescription();
580  $json->image = $a_base_url . "image." . $a_img_suffix;
581  $json->criteria = $a_base_url . "criteria.txt";
582  $json->issuer = ilBadgeHandler::getInstance()->getIssuerStaticUrl();
583 
584  return $json;
585  }
+ Here is the call graph for this function:

◆ read()

ilBadge::read ( int  $a_id)
protected

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

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

Referenced by __construct().

420  : void
421  {
422  $ilDB = $this->db;
423 
424  $set = $ilDB->query("SELECT * FROM badge_badge" .
425  " WHERE id = " . $ilDB->quote($a_id, "integer"));
426  if ($ilDB->numRows($set)) {
427  $row = $ilDB->fetchAssoc($set);
428  $this->importDBRow($row);
429  }
430  }
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 265 of file class.ilBadge.php.

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

265  : void
266  {
267  $this->active = $a_value;
268  }
+ Here is the caller graph for this function:

◆ setConfiguration()

ilBadge::setConfiguration ( ?array  $a_value = null)

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

References null.

Referenced by importDBRow().

315  : void
316  {
317  if (is_array($a_value) && !count($a_value)) {
318  $a_value = null;
319  }
320  $this->config = $a_value;
321  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ setCriteria()

ilBadge::setCriteria ( string  $a_value)

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

Referenced by importDBRow().

295  : void
296  {
297  $this->criteria = trim($a_value);
298  }
+ Here is the caller graph for this function:

◆ setDescription()

ilBadge::setDescription ( string  $a_value)

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

Referenced by importDBRow().

285  : void
286  {
287  $this->desc = trim($a_value);
288  }
+ Here is the caller graph for this function:

◆ setId()

ilBadge::setId ( int  $a_id)

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

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

235  : void
236  {
237  $this->id = $a_id;
238  }
+ Here is the caller graph for this function:

◆ setImage()

ilBadge::setImage ( ?string  $a_value)

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

References null.

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

328  : void
329  {
330  if ($a_value !== null) {
331  $this->image = trim($a_value);
332  }
333  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ setImageRid()

ilBadge::setImageRid ( ?string  $image_rid)

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

References $image_rid.

Referenced by clone(), ilBadgeManagementGUI\cloneBadgeTemplate(), copy(), importDBRow(), and ILIAS\Badge\ilBadgeImage\processImageUpload().

615  : void
616  {
617  $this->image_rid = $image_rid;
618  }
string $image_rid
+ Here is the caller graph for this function:

◆ setParentId()

ilBadge::setParentId ( int  $a_id)

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

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

245  : void
246  {
247  $this->parent_id = $a_id;
248  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBadge::setTitle ( string  $a_value)

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

Referenced by copy(), and importDBRow().

275  : void
276  {
277  $this->title = trim($a_value);
278  }
+ Here is the caller graph for this function:

◆ setTypeId()

ilBadge::setTypeId ( string  $a_id)

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

Referenced by importDBRow().

255  : void
256  {
257  $this->type_id = trim($a_id);
258  }
+ Here is the caller graph for this function:

◆ setValid()

ilBadge::setValid ( string  $a_value)

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

Referenced by importDBRow().

305  : void
306  {
307  $this->valid = trim($a_value);
308  }
+ Here is the caller graph for this function:

◆ update()

ilBadge::update ( )

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

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

Referenced by ilBadgeManagementGUI\cloneBadgeTemplate(), copy(), create(), importImage(), ILIAS\Badge\ilBadgeImage\processImageUpload(), and uploadImage().

471  : void
472  {
473  $ilDB = $this->db;
474 
475  if (!$this->getId()) {
476  $this->create();
477  return;
478  }
479 
480  $fields = $this->getPropertiesForStorage();
481 
482  $ilDB->update(
483  "badge_badge",
484  $fields,
485  ["id" => ["integer", $this->getId()]]
486  );
487  }
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 343 of file class.ilBadge.php.

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

345  : void {
346  if ($this->getId() &&
347  $a_upload_meta["tmp_name"]) {
348  $this->setImage($a_upload_meta["name"]);
349  $path = $this->getImagePath();
350 
351  try {
352  if (ilFileUtils::moveUploadedFile($a_upload_meta['tmp_name'], $this->getImagePath(false), $path)) {
353  $this->update();
354  }
355  } catch (ilException $e) {
356  throw BadgeException::moveUploadedBadgeImageFailed($this, $e);
357  }
358 
359  }
360  }
$path
Definition: ltiservices.php:29
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 31 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 33 of file class.ilBadge.php.

Referenced by getDescription().

◆ $id

int ilBadge::$id = 0
protected

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

Referenced by create(), and getId().

◆ $image

string ilBadge::$image = ""
protected

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

Referenced by getImage().

◆ $image_rid

string ilBadge::$image_rid = null
protected

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

Referenced by getImageRid(), and setImageRid().

◆ $log

ilLogger ilBadge::$log
private

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

◆ $parent_id

int ilBadge::$parent_id = 0
protected

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

Referenced by getParentId().

◆ $resource_storage

Services ilBadge::$resource_storage
private

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

◆ $title

string ilBadge::$title = ""
protected

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

Referenced by getTitle().

◆ $type_id

string ilBadge::$type_id = ""
protected

Definition at line 30 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: