ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBadge Class Reference

Class ilBadge. More...

+ Collaboration diagram for ilBadge:

Public Member Functions

 __construct ($a_id=null)
 Constructor. More...
 
 clone (int $target_parent_obj_id)
 
 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

Class ilBadge.

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 10 of file class.ilBadge.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadge::__construct (   $a_id = null)

Constructor.

Parameters
int$a_id
Returns
self

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

References $DIC, and read().

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

Member Function Documentation

◆ clone()

ilBadge::clone ( int  $target_parent_obj_id)

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

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

101  : void
102  {
103  $this->setParentId($target_parent_obj_id);
104  $this->setActive(false);
105 
106  if ($this->getId()) {
107  $img = $this->getImagePath();
108 
109  $this->setId(0);
110  $this->create();
111 
112  if ($img) {
113  // see uploadImage()
114  copy($img, $this->getImagePath());
115  }
116  }
117  }
getImagePath($a_full_path=true)
setActive($a_value)
setParentId($a_id)
copy($a_new_parent_id)
setId($a_id)
$img
Definition: imgupload.php:57
+ Here is the call graph for this function:

◆ copy()

ilBadge::copy (   $a_new_parent_id)

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

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

Referenced by clone(), getStaticUrl(), and importImage().

128  {
129  $lng = $this->lng;
130 
131  $this->setTitle($this->getTitle() . " " . $lng->txt("copy_of_suffix"));
132  $this->setParentId($a_new_parent_id);
133  $this->setActive(false);
134 
135  if ($this->getId()) {
136  $img = $this->getImagePath();
137 
138  $this->setId(null);
139  $this->create();
140 
141  if ($img) {
142  // see uploadImage()
143  copy($img, $this->getImagePath());
144  }
145  }
146  }
getImagePath($a_full_path=true)
setActive($a_value)
setParentId($a_id)
copy($a_new_parent_id)
setId($a_id)
$img
Definition: imgupload.php:57
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 402 of file class.ilBadge.php.

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

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

403  {
404  $ilDB = $this->db;
405 
406  if ($this->getId()) {
407  return $this->update();
408  }
409 
410  $id = $ilDB->nextId("badge_badge");
411  $this->setId($id);
412 
413  $fields = $this->getPropertiesForStorage();
414 
415  $fields["id"] = array("integer", $id);
416  $fields["parent_id"] = array("integer", $this->getParentId());
417  $fields["type_id"] = array("text", $this->getTypeId());
418 
419  $ilDB->insert("badge_badge", $fields);
420  }
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 439 of file class.ilBadge.php.

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

440  {
441  $ilDB = $this->db;
442 
443  if (!$this->getId()) {
444  return;
445  }
446 
447  if (file_exists($this->getImagePath())) {
448  unlink($this->getImagePath());
449  }
450 
451  $this->deleteStaticFiles();
452 
454 
455  $ilDB->manipulate("DELETE FROM badge_badge" .
456  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
457  }
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 544 of file class.ilBadge.php.

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

Referenced by delete().

545  {
546  // remove instance files
547  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
548  if (is_dir($path)) {
549  ilUtil::delDir($path);
550  }
551  }
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 290 of file class.ilBadge.php.

References $config.

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

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

◆ getCriteria()

ilBadge::getCriteria ( )

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

References $criteria.

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

267  {
268  return $this->criteria;
269  }
+ Here is the caller graph for this function:

◆ getDescription()

ilBadge::getDescription ( )

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

References $desc.

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

257  {
258  return $this->desc;
259  }
+ Here is the caller graph for this function:

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

Definition at line 553 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().

554  {
555  global $DIC;
556 
557  $lng = $DIC->language();
558 
559  return $a_type->getCaption() . " (" .
560  ($a_type instanceof ilBadgeAuto
561  ? $lng->txt("badge_subtype_auto")
562  : $lng->txt("badge_subtype_manual")) . ")";
563  }
getCaption()
Get caption.
Manual Badge Auto.
global $DIC
Definition: goto.php:24
+ 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 351 of file class.ilBadge.php.

Referenced by getImagePath().

352  {
353  $storage = new ilFSStorageBadge($a_id);
354  $storage->create();
355 
356  $path = $storage->getAbsolutePath() . "/";
357 
358  if ($a_subdir) {
359  $path .= $a_subdir . "/";
360 
361  if (!is_dir($path)) {
362  mkdir($path);
363  }
364  }
365 
366  return $path;
367  }
+ Here is the caller graph for this function:

◆ getId()

ilBadge::getId ( )

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

References $id.

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

207  {
208  return $this->id;
209  }
+ Here is the caller graph for this function:

◆ getImage()

ilBadge::getImage ( )

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

References $image.

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

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

◆ getImagePath()

ilBadge::getImagePath (   $a_full_path = true)

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

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

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

333  {
334  if ($this->getId()) {
335  $suffix = strtolower(array_pop(explode(".", $this->getImage())));
336  if ($a_full_path) {
337  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
338  } else {
339  return "img" . $this->getId() . "." . $suffix;
340  }
341  }
342  }
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 50 of file class.ilBadge.php.

References $DIC, $ilDB, and $res.

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

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

◆ getInstancesByType()

static ilBadge::getInstancesByType (   $a_type_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilBadgeHandler\triggerEvaluation().

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

◆ getObjectInstances()

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

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

References $DIC, $ilDB, and $res.

Referenced by ilObjectBadgeTableGUI\getItems().

149  {
150  global $DIC;
151 
152  $ilDB = $DIC->database();
153 
154  $res = $raw = array();
155 
156  $where = "";
157 
158  if ($a_filter["type"]) {
159  $where .= " AND bb.type_id = " . $ilDB->quote($a_filter["type"], "text");
160  }
161  if ($a_filter["title"]) {
162  $where .= " AND " . $ilDB->like("bb.title", "text", "%" . $a_filter["title"] . "%");
163  }
164  if ($a_filter["object"]) {
165  $where .= " AND " . $ilDB->like("od.title", "text", "%" . $a_filter["object"] . "%");
166  }
167 
168  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
169  " FROM badge_badge bb" .
170  " JOIN object_data od ON (bb.parent_id = od.obj_id)" .
171  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
172  $where);
173  while ($row = $ilDB->fetchAssoc($set)) {
174  $raw[] = $row;
175  }
176 
177  $set = $ilDB->query("SELECT bb.*, od.title parent_title, od.type parent_type" .
178  " FROM badge_badge bb" .
179  " JOIN object_data_del od ON (bb.parent_id = od.obj_id)" .
180  " WHERE od.type <> " . $ilDB->quote("bdga", "text") .
181  $where);
182  while ($row = $ilDB->fetchAssoc($set)) {
183  $row["deleted"] = true;
184  $raw[] = $row;
185  }
186 
187  foreach ($raw as $row) {
188  // :TODO:
189 
190  $res[] = $row;
191  }
192 
193  return $res;
194  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ getParentId()

ilBadge::getParentId ( )

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

References $parent_id.

Referenced by create(), and getParentMeta().

217  {
218  return $this->parent_id;
219  }
+ Here is the caller graph for this function:

◆ getParentMeta()

ilBadge::getParentMeta ( )

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

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

Referenced by ilBadgePersonalTableGUI\getItems().

480  {
481  $parent_type = ilObject::_lookupType($this->getParentId());
482  if ($parent_type) {
483  $parent_title = ilObject::_lookupTitle($this->getParentId());
484  $deleted = false;
485  } else {
486  // already deleted?
487  $parent = ilObjectDataDeletionLog::get($this->getParentId());
488  if ($parent["type"]) {
489  $parent_type = $parent["type"];
490  $parent_title = $parent["title"];
491  }
492  $deleted = true;
493  }
494 
495  return array(
496  "id" => $this->getParentId(),
497  "type" => $parent_type,
498  "title" => $parent_title,
499  "deleted" => $deleted
500  );
501  }
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 459 of file class.ilBadge.php.

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

Referenced by create(), and update().

460  {
461  return array(
462  "active" => array("integer", $this->isActive()),
463  "title" => array("text", $this->getTitle()),
464  "descr" => array("text", $this->getDescription()),
465  "crit" => array("text", $this->getCriteria()),
466  "image" => array("text", $this->getImage()),
467  "valid" => array("text", $this->getValid()),
468  "conf" => array("text", $this->getConfiguration()
469  ? serialize($this->getConfiguration())
470  : null)
471  );
472  }
getConfiguration()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStaticUrl()

ilBadge::getStaticUrl ( )

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

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

524  {
525  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
526 
527  $base_url = ILIAS_HTTP_PATH . substr($path, 1);
528 
529  if (!file_exists($path . "class.json")) {
530  $img_suffix = array_pop(explode(".", $this->getImage()));
531 
532  $json = json_encode($this->prepareJson($base_url, $img_suffix));
533  file_put_contents($path . "class.json", $json);
534 
535  // :TODO: scale?
536  copy($this->getImagePath(), $path . "image." . $img_suffix);
537 
538  file_put_contents($path . "criteria.txt", $this->getCriteria());
539  }
540 
541  return $base_url . "class.json";
542  }
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 246 of file class.ilBadge.php.

References $title.

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

247  {
248  return $this->title;
249  }
+ Here is the caller graph for this function:

◆ getTypeId()

ilBadge::getTypeId ( )

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

References $type_id.

Referenced by create(), and getTypeInstance().

227  {
228  return $this->type_id;
229  }
+ Here is the caller graph for this function:

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

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

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

120  {
121  if ($this->getTypeId()) {
122  $handler = ilBadgeHandler::getInstance();
123  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
124  }
125  }
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

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

References $valid.

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

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

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

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

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

Referenced by read().

387  {
388  $this->setId($a_row["id"]);
389  $this->setParentId($a_row["parent_id"]);
390  $this->setTypeId($a_row["type_id"]);
391  $this->setActive($a_row["active"]);
392  $this->setTitle($a_row["title"]);
393  $this->setDescription($a_row["descr"]);
394  $this->setCriteria($a_row["crit"]);
395  $this->setImage($a_row["image"]);
396  $this->setValid($a_row["valid"]);
397  $this->setConfiguration($a_row["conf"]
398  ? unserialize($a_row["conf"])
399  : null);
400  }
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 322 of file class.ilBadge.php.

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

323  {
324  if (file_exists($a_file)) {
325  $this->setImage($a_name);
326  copy($a_file, $this->getImagePath()); // #18280
327 
328  $this->update();
329  }
330  }
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 236 of file class.ilBadge.php.

References $active.

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

237  {
238  return $this->active;
239  }
+ Here is the caller graph for this function:

◆ prepareJson()

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

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

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

Referenced by getStaticUrl().

509  {
510  $json = new stdClass();
511  $json->{"@context"} = "https://w3id.org/openbadges/v1";
512  $json->type = "BadgeClass";
513  $json->id = $a_base_url . "class.json";
514  $json->name = $this->getTitle();
515  $json->description = $this->getDescription();
516  $json->image = $a_base_url . "image." . $a_img_suffix;
517  $json->criteria = $a_base_url . "criteria.txt";
518  $json->issuer = ilBadgeHandler::getInstance()->getIssuerStaticUrl();
519 
520  return $json;
521  }
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 374 of file class.ilBadge.php.

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

Referenced by __construct().

375  {
376  $ilDB = $this->db;
377 
378  $set = $ilDB->query("SELECT * FROM badge_badge" .
379  " WHERE id = " . $ilDB->quote($a_id, "integer"));
380  if ($ilDB->numRows($set)) {
381  $row = $ilDB->fetchAssoc($set);
382  $this->importDBRow($row);
383  }
384  }
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 231 of file class.ilBadge.php.

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

232  {
233  $this->active = (bool) $a_value;
234  }
+ Here is the caller graph for this function:

◆ setConfiguration()

ilBadge::setConfiguration ( array  $a_value = null)

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

Referenced by importDBRow().

282  {
283  if (is_array($a_value) &&
284  !sizeof($a_value)) {
285  $a_value = null;
286  }
287  $this->config = $a_value;
288  }
+ Here is the caller graph for this function:

◆ setCriteria()

ilBadge::setCriteria (   $a_value)

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

Referenced by importDBRow().

262  {
263  $this->criteria = trim($a_value);
264  }
+ Here is the caller graph for this function:

◆ setDescription()

ilBadge::setDescription (   $a_value)

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

Referenced by importDBRow().

252  {
253  $this->desc = trim($a_value);
254  }
+ Here is the caller graph for this function:

◆ setId()

ilBadge::setId (   $a_id)
protected

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

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

202  {
203  $this->id = (int) $a_id;
204  }
+ Here is the caller graph for this function:

◆ setImage()

ilBadge::setImage (   $a_value)
protected

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

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

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

◆ setParentId()

ilBadge::setParentId (   $a_id)

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

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

212  {
213  $this->parent_id = (int) $a_id;
214  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBadge::setTitle (   $a_value)

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

Referenced by copy(), and importDBRow().

242  {
243  $this->title = trim($a_value);
244  }
+ Here is the caller graph for this function:

◆ setTypeId()

ilBadge::setTypeId (   $a_id)

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

Referenced by importDBRow().

222  {
223  $this->type_id = trim($a_id);
224  }
+ Here is the caller graph for this function:

◆ setValid()

ilBadge::setValid (   $a_value)

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

Referenced by importDBRow().

272  {
273  $this->valid = trim($a_value);
274  }
+ Here is the caller graph for this function:

◆ update()

ilBadge::update ( )

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

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

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

423  {
424  $ilDB = $this->db;
425 
426  if (!$this->getId()) {
427  return $this->create();
428  }
429 
430  $fields = $this->getPropertiesForStorage();
431 
432  $ilDB->update(
433  "badge_badge",
434  $fields,
435  array("id" => array("integer", $this->getId()))
436  );
437  }
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 309 of file class.ilBadge.php.

References getId(), getImagePath(), ilUtil\moveUploadedFile(), setImage(), and update().

310  {
311  if ($this->getId() &&
312  $a_upload_meta["tmp_name"]) {
313  $this->setImage($a_upload_meta["name"]);
314  $path = $this->getImagePath();
315 
316  if (ilUtil::moveUploadedFile($a_upload_meta["tmp_name"], $this->getImagePath(false), $path)) {
317  $this->update();
318  }
319  }
320  }
getImagePath($a_full_path=true)
setImage($a_value)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

Field Documentation

◆ $active

ilBadge::$active
protected

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

Referenced by isActive().

◆ $config

ilBadge::$config
protected

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

Referenced by getConfiguration().

◆ $criteria

ilBadge::$criteria
protected

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

Referenced by getCriteria().

◆ $db

ilBadge::$db
protected

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

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

◆ $desc

ilBadge::$desc
protected

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

Referenced by getDescription().

◆ $id

ilBadge::$id
protected

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

Referenced by create(), and getId().

◆ $image

ilBadge::$image
protected

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

Referenced by getImage().

◆ $lng

ilBadge::$lng
protected

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

Referenced by copy(), and getExtendedTypeCaption().

◆ $parent_id

ilBadge::$parent_id
protected

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

Referenced by getParentId().

◆ $title

ilBadge::$title
protected

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

Referenced by getTitle().

◆ $type_id

ilBadge::$type_id
protected

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

Referenced by getTypeId().

◆ $valid

ilBadge::$valid
protected

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

Referenced by getValid().


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