ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilBadge Class Reference
+ Collaboration diagram for ilBadge:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 setId ($a_id)
 
 setImage ($a_value)
 
 getFilePath ($a_id, $a_subdir=null)
 Init file system storage. More...
 
 read ($a_id)
 
 importDBRow (array $a_row)
 
 getPropertiesForStorage ()
 
 prepareJson ($a_base_url, $a_img_suffix)
 

Protected Attributes

 $lng
 
 $db
 
 $id
 
 $parent_id
 
 $type_id
 
 $active
 
 $title
 
 $desc
 
 $image
 
 $valid
 
 $config
 
 $criteria
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilBadge::__construct (   $a_id = null)

Constructor.

Parameters
int$a_id
Returns
self

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

References $DIC, 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: saml.php:7
read($a_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilBadge::copy (   $a_new_parent_id)

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

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

Referenced by getStaticUrl(), and importImage().

113  {
114  $lng = $this->lng;
115 
116  $this->setTitle($this->getTitle() . " " . $lng->txt("copy_of_suffix"));
117  $this->setParentId($a_new_parent_id);
118  $this->setActive(false);
119 
120  if ($this->getId()) {
121  $img = $this->getImagePath();
122 
123  $this->setId(null);
124  $this->create();
125 
126  if ($img) {
127  // see uploadImage()
128  copy($img, $this->getImagePath());
129  }
130  }
131  }
getImagePath($a_full_path=true)
setActive($a_value)
setParentId($a_id)
copy($a_new_parent_id)
setId($a_id)
setTitle($a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilBadge::create ( )

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

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

Referenced by copy(), and update().

389  {
390  $ilDB = $this->db;
391 
392  if ($this->getId()) {
393  return $this->update();
394  }
395 
396  $id = $ilDB->nextId("badge_badge");
397  $this->setId($id);
398 
399  $fields = $this->getPropertiesForStorage();
400 
401  $fields["id"] = array("integer", $id);
402  $fields["parent_id"] = array("integer", $this->getParentId());
403  $fields["type_id"] = array("text", $this->getTypeId());
404 
405  $ilDB->insert("badge_badge", $fields);
406  }
getPropertiesForStorage()
setId($a_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilBadge::delete ( )

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

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

426  {
427  $ilDB = $this->db;
428 
429  if (!$this->getId()) {
430  return;
431  }
432 
433  if (file_exists($this->getImagePath())) {
434  unlink($this->getImagePath());
435  }
436 
437  $this->deleteStaticFiles();
438 
439  include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
441 
442  $ilDB->manipulate("DELETE FROM badge_badge" .
443  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
444  }
getImagePath($a_full_path=true)
deleteStaticFiles()
static deleteByBadgeId($a_badge_id)
global $ilDB
+ Here is the call graph for this function:

◆ deleteStaticFiles()

ilBadge::deleteStaticFiles ( )

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

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

Referenced by delete().

533  {
534  // remove instance files
535  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
536  if (is_dir($path)) {
538  }
539  }
$path
Definition: aliased.php:25
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConfiguration()

ilBadge::getConfiguration ( )

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

References $config.

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

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

◆ getCriteria()

ilBadge::getCriteria ( )

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

References $criteria.

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

252  {
253  return $this->criteria;
254  }
+ Here is the caller graph for this function:

◆ getDescription()

ilBadge::getDescription ( )

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

References $desc.

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

242  {
243  return $this->desc;
244  }
+ Here is the caller graph for this function:

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

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

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

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

542  {
543  global $DIC;
544 
545  $lng = $DIC->language();
546 
547  return $a_type->getCaption() . " (" .
548  ($a_type instanceof ilBadgeAuto
549  ? $lng->txt("badge_subtype_auto")
550  : $lng->txt("badge_subtype_manual")) . ")";
551  }
global $DIC
Definition: saml.php:7
getCaption()
Get caption.
Manual Badge Auto.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilePath()

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

Init file system storage.

Parameters
type$a_id
type$a_subdir
Returns
string

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

References $path.

Referenced by getImagePath().

337  {
338  include_once "Services/Badge/classes/class.ilFSStorageBadge.php";
339  $storage = new ilFSStorageBadge($a_id);
340  $storage->create();
341 
342  $path = $storage->getAbsolutePath() . "/";
343 
344  if ($a_subdir) {
345  $path .= $a_subdir . "/";
346 
347  if (!is_dir($path)) {
348  mkdir($path);
349  }
350  }
351 
352  return $path;
353  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

◆ getId()

ilBadge::getId ( )

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

References $id.

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

192  {
193  return $this->id;
194  }
+ Here is the caller graph for this function:

◆ getImage()

ilBadge::getImage ( )

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

References $image.

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

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

◆ getImagePath()

ilBadge::getImagePath (   $a_full_path = true)

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

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

Referenced by copy(), delete(), ilBadgeAssignment\getImagePath(), getStaticUrl(), importImage(), ilBadgeManagementGUI\setBadgeFormValues(), and uploadImage().

318  {
319  if ($this->getId()) {
320  $suffix = strtolower(array_pop(explode(".", $this->getImage())));
321  if ($a_full_path) {
322  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
323  } else {
324  return "img" . $this->getId() . "." . $suffix;
325  }
326  }
327  }
getFilePath($a_id, $a_subdir=null)
Init file system storage.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstancesByParentId()

static ilBadge::getInstancesByParentId (   $a_parent_id,
array  $a_filter = null 
)
static

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

References $DIC, $ilDB, $res, and $row.

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

53  {
54  global $DIC;
55 
56  $ilDB = $DIC->database();
57 
58  $res = array();
59 
60  $sql = "SELECT * FROM badge_badge" .
61  " WHERE parent_id = " . $ilDB->quote($a_parent_id);
62 
63  if ($a_filter) {
64  if ($a_filter["title"]) {
65  $sql .= " AND " . $ilDB->like("title", "text", "%" . trim($a_filter["title"]) . "%");
66  }
67  if ($a_filter["type"]) {
68  $sql .= " AND type_id = " . $ilDB->quote($a_filter["type"], "integer");
69  }
70  }
71 
72  $set = $ilDB->query($sql .
73  " ORDER BY title");
74  while ($row = $ilDB->fetchAssoc($set)) {
75  $obj = new self();
76  $obj->importDBRow($row);
77  $res[] = $obj;
78  }
79 
80  return $res;
81  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getInstancesByType()

static ilBadge::getInstancesByType (   $a_type_id)
static

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

References $DIC, $ilDB, $res, and $row.

Referenced by ilBadgeHandler\triggerEvaluation().

84  {
85  global $DIC;
86 
87  $ilDB = $DIC->database();
88 
89  $res = array();
90 
91  $set = $ilDB->query("SELECT * FROM badge_badge" .
92  " WHERE type_id = " . $ilDB->quote($a_type_id) .
93  " ORDER BY title");
94  while ($row = $ilDB->fetchAssoc($set)) {
95  $obj = new self();
96  $obj->importDBRow($row);
97  $res[] = $obj;
98  }
99 
100  return $res;
101  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getObjectInstances()

static ilBadge::getObjectInstances ( array  $a_filter = null)
static

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

References $DIC, $ilDB, $res, and $row.

Referenced by ilObjectBadgeTableGUI\getItems().

134  {
135  global $DIC;
136 
137  $ilDB = $DIC->database();
138 
139  $res = $raw = array();
140 
141  $where = "";
142 
143  if ($a_filter["type"]) {
144  $where .= " AND bb.type_id = " . $ilDB->quote($a_filter["type"], "text");
145  }
146  if ($a_filter["title"]) {
147  $where .= " AND " . $ilDB->like("bb.title", "text", "%" . $a_filter["title"] . "%");
148  }
149  if ($a_filter["object"]) {
150  $where .= " AND " . $ilDB->like("od.title", "text", "%" . $a_filter["object"] . "%");
151  }
152 
153  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
154  " FROM badge_badge bb" .
155  " JOIN object_data od ON (bb.parent_id = od.obj_id)" .
156  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
157  $where);
158  while ($row = $ilDB->fetchAssoc($set)) {
159  $raw[] = $row;
160  }
161 
162  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
163  " FROM badge_badge bb" .
164  " JOIN object_data_del od ON (bb.parent_id = od.obj_id)" .
165  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
166  $where);
167  while ($row = $ilDB->fetchAssoc($set)) {
168  $row["deleted"] = true;
169  $raw[] = $row;
170  }
171 
172  foreach ($raw as $row) {
173  // :TODO:
174 
175  $res[] = $row;
176  }
177 
178  return $res;
179  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getParentId()

ilBadge::getParentId ( )

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

References $parent_id.

Referenced by create(), and getParentMeta().

202  {
203  return $this->parent_id;
204  }
+ Here is the caller graph for this function:

◆ getParentMeta()

ilBadge::getParentMeta ( )

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

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

Referenced by ilBadgePersonalTableGUI\getItems().

467  {
468  $parent_type = ilObject::_lookupType($this->getParentId());
469  if ($parent_type) {
470  $parent_title = ilObject::_lookupTitle($this->getParentId());
471  $deleted = false;
472  } else {
473  // already deleted?
474  include_once "Services/Object/classes/class.ilObjectDataDeletionLog.php";
475  $parent = ilObjectDataDeletionLog::get($this->getParentId());
476  if ($parent["type"]) {
477  $parent_type = $parent["type"];
478  $parent_title = $parent["title"];
479  }
480  $deleted = true;
481  }
482 
483  return array(
484  "id" => $this->getParentId(),
485  "type" => $parent_type,
486  "title" => $parent_title,
487  "deleted" => $deleted
488  );
489  }
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPropertiesForStorage()

ilBadge::getPropertiesForStorage ( )
protected

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

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

Referenced by create(), and update().

447  {
448  return array(
449  "active" => array("integer", $this->isActive()),
450  "title" => array("text", $this->getTitle()),
451  "descr" => array("text", $this->getDescription()),
452  "crit" => array("text", $this->getCriteria()),
453  "image" => array("text", $this->getImage()),
454  "valid" => array("text", $this->getValid()),
455  "conf" => array("text", $this->getConfiguration()
456  ? serialize($this->getConfiguration())
457  : null)
458  );
459  }
getConfiguration()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStaticUrl()

ilBadge::getStaticUrl ( )

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

References $path, copy(), getCriteria(), getImage(), getImagePath(), ilBadgeHandler\getInstance(), and prepareJson().

512  {
513  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
514 
515  $base_url = ILIAS_HTTP_PATH . substr($path, 1);
516 
517  if (!file_exists($path . "class.json")) {
518  $img_suffix = array_pop(explode(".", $this->getImage()));
519 
520  $json = json_encode($this->prepareJson($base_url, $img_suffix));
521  file_put_contents($path . "class.json", $json);
522 
523  // :TODO: scale?
524  copy($this->getImagePath(), $path . "image." . $img_suffix);
525 
526  file_put_contents($path . "criteria.txt", $this->getCriteria());
527  }
528 
529  return $base_url . "class.json";
530  }
$path
Definition: aliased.php:25
getImagePath($a_full_path=true)
copy($a_new_parent_id)
prepareJson($a_base_url, $a_img_suffix)
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getTitle()

ilBadge::getTitle ( )

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

References $title.

Referenced by ilBadgeProfileGUI\addToBackpackMulti(), copy(), getPropertiesForStorage(), prepareJson(), ilBadgeManagementGUI\setBadgeFormValues(), and ilPersonalProfileGUI\showPublicProfileFields().

232  {
233  return $this->title;
234  }
+ Here is the caller graph for this function:

◆ getTypeId()

ilBadge::getTypeId ( )

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

References $type_id.

Referenced by create(), and getTypeInstance().

212  {
213  return $this->type_id;
214  }
+ Here is the caller graph for this function:

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

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

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

104  {
105  if ($this->getTypeId()) {
106  include_once "./Services/Badge/classes/class.ilBadgeHandler.php";
108  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
109  }
110  }
$handler
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

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

References $valid.

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

262  {
263  return $this->valid;
264  }
+ Here is the caller graph for this function:

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

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

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

Referenced by read().

373  {
374  $this->setId($a_row["id"]);
375  $this->setParentId($a_row["parent_id"]);
376  $this->setTypeId($a_row["type_id"]);
377  $this->setActive($a_row["active"]);
378  $this->setTitle($a_row["title"]);
379  $this->setDescription($a_row["descr"]);
380  $this->setCriteria($a_row["crit"]);
381  $this->setImage($a_row["image"]);
382  $this->setValid($a_row["valid"]);
383  $this->setConfiguration($a_row["conf"]
384  ? unserialize($a_row["conf"])
385  : null);
386  }
setCriteria($a_value)
setImage($a_value)
setActive($a_value)
setParentId($a_id)
setValid($a_value)
setTypeId($a_id)
setId($a_id)
setConfiguration(array $a_value=null)
setDescription($a_value)
setTitle($a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importImage()

ilBadge::importImage (   $a_name,
  $a_file 
)

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

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

308  {
309  if (file_exists($a_file)) {
310  $this->setImage($a_name);
311  copy($a_file, $this->getImagePath()); // #18280
312 
313  $this->update();
314  }
315  }
getImagePath($a_full_path=true)
setImage($a_value)
copy($a_new_parent_id)
+ Here is the call graph for this function:

◆ isActive()

ilBadge::isActive ( )

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

References $active.

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

222  {
223  return $this->active;
224  }
+ Here is the caller graph for this function:

◆ prepareJson()

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

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

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

Referenced by getStaticUrl().

497  {
498  $json = new stdClass();
499  $json->{"@context"} = "https://w3id.org/openbadges/v1";
500  $json->type = "BadgeClass";
501  $json->id = $a_base_url . "class.json";
502  $json->name = $this->getTitle();
503  $json->description = $this->getDescription();
504  $json->image = $a_base_url . "image." . $a_img_suffix;
505  $json->criteria = $a_base_url . "criteria.txt";
506  $json->issuer = ilBadgeHandler::getInstance()->getIssuerStaticUrl();
507 
508  return $json;
509  }
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilBadge::read (   $a_id)
protected

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

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

Referenced by __construct().

361  {
362  $ilDB = $this->db;
363 
364  $set = $ilDB->query("SELECT * FROM badge_badge" .
365  " WHERE id = " . $ilDB->quote($a_id, "integer"));
366  if ($ilDB->numRows($set)) {
367  $row = $ilDB->fetchAssoc($set);
368  $this->importDBRow($row);
369  }
370  }
$row
global $ilDB
importDBRow(array $a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActive()

ilBadge::setActive (   $a_value)

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

Referenced by copy(), and importDBRow().

217  {
218  $this->active = (bool) $a_value;
219  }
+ Here is the caller graph for this function:

◆ setConfiguration()

ilBadge::setConfiguration ( array  $a_value = null)

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

Referenced by importDBRow().

267  {
268  if (is_array($a_value) &&
269  !sizeof($a_value)) {
270  $a_value = null;
271  }
272  $this->config = $a_value;
273  }
+ Here is the caller graph for this function:

◆ setCriteria()

ilBadge::setCriteria (   $a_value)

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

Referenced by importDBRow().

247  {
248  $this->criteria = trim($a_value);
249  }
+ Here is the caller graph for this function:

◆ setDescription()

ilBadge::setDescription (   $a_value)

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

Referenced by importDBRow().

237  {
238  $this->desc = trim($a_value);
239  }
+ Here is the caller graph for this function:

◆ setId()

ilBadge::setId (   $a_id)
protected

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

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

187  {
188  $this->id = (int) $a_id;
189  }
+ Here is the caller graph for this function:

◆ setImage()

ilBadge::setImage (   $a_value)
protected

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

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

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

◆ setParentId()

ilBadge::setParentId (   $a_id)

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

Referenced by copy(), and importDBRow().

197  {
198  $this->parent_id = (int) $a_id;
199  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBadge::setTitle (   $a_value)

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

Referenced by copy(), and importDBRow().

227  {
228  $this->title = trim($a_value);
229  }
+ Here is the caller graph for this function:

◆ setTypeId()

ilBadge::setTypeId (   $a_id)

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

Referenced by importDBRow().

207  {
208  $this->type_id = trim($a_id);
209  }
+ Here is the caller graph for this function:

◆ setValid()

ilBadge::setValid (   $a_value)

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

Referenced by importDBRow().

257  {
258  $this->valid = trim($a_value);
259  }
+ Here is the caller graph for this function:

◆ update()

ilBadge::update ( )

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

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

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

409  {
410  $ilDB = $this->db;
411 
412  if (!$this->getId()) {
413  return $this->create();
414  }
415 
416  $fields = $this->getPropertiesForStorage();
417 
418  $ilDB->update(
419  "badge_badge",
420  $fields,
421  array("id" => array("integer", $this->getId()))
422  );
423  }
getPropertiesForStorage()
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uploadImage()

ilBadge::uploadImage ( array  $a_upload_meta)
Parameters
array$a_upload_meta
Exceptions
ilFileUtilsException

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

References $path, getId(), getImagePath(), setImage(), and update().

295  {
296  if ($this->getId() &&
297  $a_upload_meta["tmp_name"]) {
298  $this->setImage($a_upload_meta["name"]);
299  $path = $this->getImagePath();
300 
301  if (ilUtil::moveUploadedFile($a_upload_meta["tmp_name"], $this->getImagePath(false), $path)) {
302  $this->update();
303  }
304  }
305  }
$path
Definition: aliased.php:25
getImagePath($a_full_path=true)
setImage($a_value)
+ Here is the call graph for this function:

Field Documentation

◆ $active

ilBadge::$active
protected

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

Referenced by isActive().

◆ $config

ilBadge::$config
protected

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

Referenced by getConfiguration().

◆ $criteria

ilBadge::$criteria
protected

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

Referenced by getCriteria().

◆ $db

ilBadge::$db
protected

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

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

◆ $desc

ilBadge::$desc
protected

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

Referenced by getDescription().

◆ $id

ilBadge::$id
protected

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

Referenced by create(), and getId().

◆ $image

ilBadge::$image
protected

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

Referenced by getImage().

◆ $lng

ilBadge::$lng
protected

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

Referenced by copy(), and getExtendedTypeCaption().

◆ $parent_id

ilBadge::$parent_id
protected

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

Referenced by getParentId().

◆ $title

ilBadge::$title
protected

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

Referenced by getTitle().

◆ $type_id

ilBadge::$type_id
protected

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

Referenced by getTypeId().

◆ $valid

ilBadge::$valid
protected

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

Referenced by getValid().


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