ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilBadge Class Reference

Class ilBadge. More...

+ 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

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  }
read($a_id)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilBadge::copy (   $a_new_parent_id)

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

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

Referenced by getStaticUrl(), and importImage().

110  {
111  $lng = $this->lng;
112 
113  $this->setTitle($this->getTitle() . " " . $lng->txt("copy_of_suffix"));
114  $this->setParentId($a_new_parent_id);
115  $this->setActive(false);
116 
117  if ($this->getId()) {
118  $img = $this->getImagePath();
119 
120  $this->setId(null);
121  $this->create();
122 
123  if ($img) {
124  // see uploadImage()
125  copy($img, $this->getImagePath());
126  }
127  }
128  }
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 384 of file class.ilBadge.php.

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

Referenced by copy(), and update().

385  {
386  $ilDB = $this->db;
387 
388  if ($this->getId()) {
389  return $this->update();
390  }
391 
392  $id = $ilDB->nextId("badge_badge");
393  $this->setId($id);
394 
395  $fields = $this->getPropertiesForStorage();
396 
397  $fields["id"] = array("integer", $id);
398  $fields["parent_id"] = array("integer", $this->getParentId());
399  $fields["type_id"] = array("text", $this->getTypeId());
400 
401  $ilDB->insert("badge_badge", $fields);
402  }
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 421 of file class.ilBadge.php.

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

422  {
423  $ilDB = $this->db;
424 
425  if (!$this->getId()) {
426  return;
427  }
428 
429  if (file_exists($this->getImagePath())) {
430  unlink($this->getImagePath());
431  }
432 
433  $this->deleteStaticFiles();
434 
436 
437  $ilDB->manipulate("DELETE FROM badge_badge" .
438  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
439  }
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 526 of file class.ilBadge.php.

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

Referenced by delete().

527  {
528  // remove instance files
529  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
530  if (is_dir($path)) {
531  ilUtil::delDir($path);
532  }
533  }
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 272 of file class.ilBadge.php.

References $config.

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

273  {
274  return $this->config;
275  }
+ Here is the caller graph for this function:

◆ getCriteria()

ilBadge::getCriteria ( )

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

References $criteria.

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

249  {
250  return $this->criteria;
251  }
+ Here is the caller graph for this function:

◆ getDescription()

ilBadge::getDescription ( )

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

References $desc.

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

239  {
240  return $this->desc;
241  }
+ Here is the caller graph for this function:

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

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

536  {
537  global $DIC;
538 
539  $lng = $DIC->language();
540 
541  return $a_type->getCaption() . " (" .
542  ($a_type instanceof ilBadgeAuto
543  ? $lng->txt("badge_subtype_auto")
544  : $lng->txt("badge_subtype_manual")) . ")";
545  }
getCaption()
Get caption.
Manual Badge Auto.
$DIC
Definition: xapitoken.php:46
+ 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 333 of file class.ilBadge.php.

Referenced by getImagePath().

334  {
335  $storage = new ilFSStorageBadge($a_id);
336  $storage->create();
337 
338  $path = $storage->getAbsolutePath() . "/";
339 
340  if ($a_subdir) {
341  $path .= $a_subdir . "/";
342 
343  if (!is_dir($path)) {
344  mkdir($path);
345  }
346  }
347 
348  return $path;
349  }
+ Here is the caller graph for this function:

◆ getId()

ilBadge::getId ( )

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

References $id.

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

189  {
190  return $this->id;
191  }
+ Here is the caller graph for this function:

◆ getImage()

ilBadge::getImage ( )

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

References $image.

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

283  {
284  return $this->image;
285  }
+ Here is the caller graph for this function:

◆ getImagePath()

ilBadge::getImagePath (   $a_full_path = true)

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

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

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

315  {
316  if ($this->getId()) {
317  $suffix = strtolower(array_pop(explode(".", $this->getImage())));
318  if ($a_full_path) {
319  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
320  } else {
321  return "img" . $this->getId() . "." . $suffix;
322  }
323  }
324  }
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 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 $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getObjectInstances()

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

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

References $DIC, $ilDB, and $res.

Referenced by ilObjectBadgeTableGUI\getItems().

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

◆ getParentId()

ilBadge::getParentId ( )

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

References $parent_id.

Referenced by create(), and getParentMeta().

199  {
200  return $this->parent_id;
201  }
+ Here is the caller graph for this function:

◆ getParentMeta()

ilBadge::getParentMeta ( )

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

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

Referenced by ilBadgePersonalTableGUI\getItems().

462  {
463  $parent_type = ilObject::_lookupType($this->getParentId());
464  if ($parent_type) {
465  $parent_title = ilObject::_lookupTitle($this->getParentId());
466  $deleted = false;
467  } else {
468  // already deleted?
469  $parent = ilObjectDataDeletionLog::get($this->getParentId());
470  if ($parent["type"]) {
471  $parent_type = $parent["type"];
472  $parent_title = $parent["title"];
473  }
474  $deleted = true;
475  }
476 
477  return array(
478  "id" => $this->getParentId(),
479  "type" => $parent_type,
480  "title" => $parent_title,
481  "deleted" => $deleted
482  );
483  }
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 441 of file class.ilBadge.php.

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

Referenced by create(), and update().

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

◆ getStaticUrl()

ilBadge::getStaticUrl ( )

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

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

506  {
507  $path = ilBadgeHandler::getInstance()->getBadgePath($this);
508 
509  $base_url = ILIAS_HTTP_PATH . substr($path, 1);
510 
511  if (!file_exists($path . "class.json")) {
512  $img_suffix = array_pop(explode(".", $this->getImage()));
513 
514  $json = json_encode($this->prepareJson($base_url, $img_suffix));
515  file_put_contents($path . "class.json", $json);
516 
517  // :TODO: scale?
518  copy($this->getImagePath(), $path . "image." . $img_suffix);
519 
520  file_put_contents($path . "criteria.txt", $this->getCriteria());
521  }
522 
523  return $base_url . "class.json";
524  }
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 228 of file class.ilBadge.php.

References $title.

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

229  {
230  return $this->title;
231  }
+ Here is the caller graph for this function:

◆ getTypeId()

ilBadge::getTypeId ( )

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

References $type_id.

Referenced by create(), and getTypeInstance().

209  {
210  return $this->type_id;
211  }
+ Here is the caller graph for this function:

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

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

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

102  {
103  if ($this->getTypeId()) {
104  $handler = ilBadgeHandler::getInstance();
105  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
106  }
107  }
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

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

References $valid.

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

259  {
260  return $this->valid;
261  }
+ Here is the caller graph for this function:

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

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

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

Referenced by read().

369  {
370  $this->setId($a_row["id"]);
371  $this->setParentId($a_row["parent_id"]);
372  $this->setTypeId($a_row["type_id"]);
373  $this->setActive($a_row["active"]);
374  $this->setTitle($a_row["title"]);
375  $this->setDescription($a_row["descr"]);
376  $this->setCriteria($a_row["crit"]);
377  $this->setImage($a_row["image"]);
378  $this->setValid($a_row["valid"]);
379  $this->setConfiguration($a_row["conf"]
380  ? unserialize($a_row["conf"])
381  : null);
382  }
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 304 of file class.ilBadge.php.

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

305  {
306  if (file_exists($a_file)) {
307  $this->setImage($a_name);
308  copy($a_file, $this->getImagePath()); // #18280
309 
310  $this->update();
311  }
312  }
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 218 of file class.ilBadge.php.

References $active.

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

219  {
220  return $this->active;
221  }
+ Here is the caller graph for this function:

◆ prepareJson()

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

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

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

Referenced by getStaticUrl().

491  {
492  $json = new stdClass();
493  $json->{"@context"} = "https://w3id.org/openbadges/v1";
494  $json->type = "BadgeClass";
495  $json->id = $a_base_url . "class.json";
496  $json->name = $this->getTitle();
497  $json->description = $this->getDescription();
498  $json->image = $a_base_url . "image." . $a_img_suffix;
499  $json->criteria = $a_base_url . "criteria.txt";
500  $json->issuer = ilBadgeHandler::getInstance()->getIssuerStaticUrl();
501 
502  return $json;
503  }
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 356 of file class.ilBadge.php.

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

Referenced by __construct().

357  {
358  $ilDB = $this->db;
359 
360  $set = $ilDB->query("SELECT * FROM badge_badge" .
361  " WHERE id = " . $ilDB->quote($a_id, "integer"));
362  if ($ilDB->numRows($set)) {
363  $row = $ilDB->fetchAssoc($set);
364  $this->importDBRow($row);
365  }
366  }
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 213 of file class.ilBadge.php.

Referenced by copy(), and importDBRow().

214  {
215  $this->active = (bool) $a_value;
216  }
+ Here is the caller graph for this function:

◆ setConfiguration()

ilBadge::setConfiguration ( array  $a_value = null)

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

Referenced by importDBRow().

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

◆ setCriteria()

ilBadge::setCriteria (   $a_value)

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

Referenced by importDBRow().

244  {
245  $this->criteria = trim($a_value);
246  }
+ Here is the caller graph for this function:

◆ setDescription()

ilBadge::setDescription (   $a_value)

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

Referenced by importDBRow().

234  {
235  $this->desc = trim($a_value);
236  }
+ Here is the caller graph for this function:

◆ setId()

ilBadge::setId (   $a_id)
protected

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

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

184  {
185  $this->id = (int) $a_id;
186  }
+ Here is the caller graph for this function:

◆ setImage()

ilBadge::setImage (   $a_value)
protected

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

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

278  {
279  $this->image = trim($a_value);
280  }
+ Here is the caller graph for this function:

◆ setParentId()

ilBadge::setParentId (   $a_id)

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

Referenced by copy(), and importDBRow().

194  {
195  $this->parent_id = (int) $a_id;
196  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBadge::setTitle (   $a_value)

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

Referenced by copy(), and importDBRow().

224  {
225  $this->title = trim($a_value);
226  }
+ Here is the caller graph for this function:

◆ setTypeId()

ilBadge::setTypeId (   $a_id)

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

Referenced by importDBRow().

204  {
205  $this->type_id = trim($a_id);
206  }
+ Here is the caller graph for this function:

◆ setValid()

ilBadge::setValid (   $a_value)

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

Referenced by importDBRow().

254  {
255  $this->valid = trim($a_value);
256  }
+ Here is the caller graph for this function:

◆ update()

ilBadge::update ( )

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

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

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

405  {
406  $ilDB = $this->db;
407 
408  if (!$this->getId()) {
409  return $this->create();
410  }
411 
412  $fields = $this->getPropertiesForStorage();
413 
414  $ilDB->update(
415  "badge_badge",
416  $fields,
417  array("id" => array("integer", $this->getId()))
418  );
419  }
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 291 of file class.ilBadge.php.

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

292  {
293  if ($this->getId() &&
294  $a_upload_meta["tmp_name"]) {
295  $this->setImage($a_upload_meta["name"]);
296  $path = $this->getImagePath();
297 
298  if (ilUtil::moveUploadedFile($a_upload_meta["tmp_name"], $this->getImagePath(false), $path)) {
299  $this->update();
300  }
301  }
302  }
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: