ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

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

References read().

32  {
33  if($a_id)
34  {
35  $this->read($a_id);
36  }
37  }
read($a_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilBadge::copy (   $a_new_parent_id)

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

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

Referenced by getStaticUrl(), and importImage().

102  {
103  global $lng;
104 
105  $this->setTitle($this->getTitle()." ".$lng->txt("copy_of_suffix"));
106  $this->setParentId($a_new_parent_id);
107  $this->setActive(false);
108 
109  if($this->getId())
110  {
111  $img = $this->getImagePath();
112 
113  $this->setId(null);
114  $this->create();
115 
116  if($img)
117  {
118  // see uploadImage()
119  copy($img, $this->getImagePath());
120  }
121  }
122  }
getImagePath($a_full_path=true)
setActive($a_value)
setParentId($a_id)
copy($a_new_parent_id)
setId($a_id)
global $lng
Definition: privfeed.php:17
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 394 of file class.ilBadge.php.

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

Referenced by copy(), and update().

395  {
396  global $ilDB;
397 
398  if($this->getId())
399  {
400  return $this->update();
401  }
402 
403  $id = $ilDB->nextId("badge_badge");
404  $this->setId($id);
405 
406  $fields = $this->getPropertiesForStorage();
407 
408  $fields["id"] = array("integer", $id);
409  $fields["parent_id"] = array("integer", $this->getParentId());
410  $fields["type_id"] = array("text", $this->getTypeId());
411 
412  $ilDB->insert("badge_badge", $fields);
413  }
getPropertiesForStorage()
setId($a_id)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilBadge::delete ( )

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

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

432  {
433  global $ilDB;
434 
435  if(!$this->getId())
436  {
437  return;
438  }
439 
440  if(file_exists($this->getImagePath()))
441  {
442  unlink($this->getImagePath());
443  }
444 
445  $this->deleteStaticFiles();
446 
447  include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
449 
450  $ilDB->manipulate("DELETE FROM badge_badge".
451  " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
452  }
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 545 of file class.ilBadge.php.

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

Referenced by delete().

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

References $config.

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

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

◆ getCriteria()

ilBadge::getCriteria ( )

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

References $criteria.

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

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

◆ getDescription()

ilBadge::getDescription ( )

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

References $desc.

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

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

◆ getExtendedTypeCaption()

static ilBadge::getExtendedTypeCaption ( ilBadgeType  $a_type)
static

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

References $lng, and ilBadgeType\getCaption().

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

556  {
557  global $lng;
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 $lng
Definition: privfeed.php:17
+ 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 339 of file class.ilBadge.php.

References $path.

Referenced by getImagePath().

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

◆ getId()

ilBadge::getId ( )

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

References $id.

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

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

◆ getImage()

ilBadge::getImage ( )

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

References $image.

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

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

◆ getImagePath()

ilBadge::getImagePath (   $a_full_path = true)

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

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

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

317  {
318  if($this->getId())
319  {
320  $suffix = strtolower(array_pop(explode(".", $this->getImage())));
321  if ($a_full_path)
322  {
323  return $this->getFilePath($this->getId()) . "img" . $this->getId() . "." . $suffix;
324  }
325  else
326  {
327  return "img" . $this->getId() . "." . $suffix;
328  }
329  }
330  }
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 39 of file class.ilBadge.php.

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

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

40  {
41  global $ilDB;
42 
43  $res = array();
44 
45  $sql = "SELECT * FROM badge_badge".
46  " WHERE parent_id = ".$ilDB->quote($a_parent_id);
47 
48  if($a_filter)
49  {
50  if($a_filter["title"])
51  {
52  $sql .= " AND ".$ilDB->like("title", "text", "%".trim($a_filter["title"])."%");
53  }
54  if($a_filter["type"])
55  {
56  $sql .= " AND type_id = ".$ilDB->quote($a_filter["type"], "integer");
57  }
58  }
59 
60  $set = $ilDB->query($sql.
61  " ORDER BY title");
62  while($row = $ilDB->fetchAssoc($set))
63  {
64  $obj = new self();
65  $obj->importDBRow($row);
66  $res[] = $obj;
67  }
68 
69  return $res;
70  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getInstancesByType()

static ilBadge::getInstancesByType (   $a_type_id)
static

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

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

Referenced by ilBadgeHandler\triggerEvaluation().

73  {
74  global $ilDB;
75 
76  $res = array();
77 
78  $set = $ilDB->query("SELECT * FROM badge_badge".
79  " WHERE type_id = ".$ilDB->quote($a_type_id).
80  " ORDER BY title");
81  while($row = $ilDB->fetchAssoc($set))
82  {
83  $obj = new self();
84  $obj->importDBRow($row);
85  $res[] = $obj;
86  }
87 
88  return $res;
89  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getObjectInstances()

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

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

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

Referenced by ilObjectBadgeTableGUI\getItems().

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

◆ getParentId()

ilBadge::getParentId ( )

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

References $parent_id.

Referenced by create(), and getParentMeta().

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

◆ getParentMeta()

ilBadge::getParentMeta ( )

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

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

Referenced by ilBadgePersonalTableGUI\getItems().

475  {
476  $parent_type = ilObject::_lookupType($this->getParentId());
477  if($parent_type)
478  {
479  $parent_title = ilObject::_lookupTitle($this->getParentId());
480  $deleted = false;
481  }
482  else
483  {
484  // already deleted?
485  include_once "Services/Object/classes/class.ilObjectDataDeletionLog.php";
486  $parent = ilObjectDataDeletionLog::get($this->getParentId());
487  if($parent["type"])
488  {
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
Create styles array
The data for the language used.
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 454 of file class.ilBadge.php.

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

Referenced by create(), and update().

455  {
456  return array(
457  "active" => array("integer", $this->isActive()),
458  "title" => array("text", $this->getTitle()),
459  "descr" => array("text", $this->getDescription()),
460  "crit" => array("text", $this->getCriteria()),
461  "image" => array("text", $this->getImage()),
462  "valid" => array("text", $this->getValid()),
463  "conf" => array("text", $this->getConfiguration()
464  ? serialize($this->getConfiguration())
465  : null)
466  );
467  }
getConfiguration()
Create styles array
The data for the language used.
+ 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 $path, copy(), 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  {
531  $img_suffix = array_pop(explode(".", $this->getImage()));
532 
533  $json = json_encode($this->prepareJson($base_url, $img_suffix));
534  file_put_contents($path."class.json", $json);
535 
536  // :TODO: scale?
537  copy($this->getImagePath(), $path."image.".$img_suffix);
538 
539  file_put_contents($path."criteria.txt", $this->getCriteria());
540  }
541 
542  return $base_url."class.json";
543  }
$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 226 of file class.ilBadge.php.

References $title.

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

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

◆ getTypeId()

ilBadge::getTypeId ( )

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

References $type_id.

Referenced by create(), and getTypeInstance().

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

◆ getTypeInstance()

ilBadge::getTypeInstance ( )

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

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

92  {
93  if($this->getTypeId())
94  {
95  include_once "./Services/Badge/classes/class.ilBadgeHandler.php";
96  $handler = ilBadgeHandler::getInstance();
97  return $handler->getTypeInstanceByUniqueId($this->getTypeId());
98  }
99  }
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getValid()

ilBadge::getValid ( )

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

References $valid.

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

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

◆ importDBRow()

ilBadge::importDBRow ( array  $a_row)
protected

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

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

Referenced by read().

379  {
380  $this->setId($a_row["id"]);
381  $this->setParentId($a_row["parent_id"]);
382  $this->setTypeId($a_row["type_id"]);
383  $this->setActive($a_row["active"]);
384  $this->setTitle($a_row["title"]);
385  $this->setDescription($a_row["descr"]);
386  $this->setCriteria($a_row["crit"]);
387  $this->setImage($a_row["image"]);
388  $this->setValid($a_row["valid"]);
389  $this->setConfiguration($a_row["conf"]
390  ? unserialize($a_row["conf"])
391  : null);
392  }
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 305 of file class.ilBadge.php.

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

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

References $active.

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

217  {
218  return $this->active;
219  }
+ 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 365 of file class.ilBadge.php.

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

Referenced by __construct().

366  {
367  global $ilDB;
368 
369  $set = $ilDB->query("SELECT * FROM badge_badge".
370  " WHERE id = ".$ilDB->quote($a_id, "integer"));
371  if($ilDB->numRows($set))
372  {
373  $row = $ilDB->fetchAssoc($set);
374  $this->importDBRow($row);
375  }
376  }
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 211 of file class.ilBadge.php.

Referenced by copy(), and importDBRow().

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

◆ setConfiguration()

ilBadge::setConfiguration ( array  $a_value = null)

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

Referenced by importDBRow().

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

◆ setCriteria()

ilBadge::setCriteria (   $a_value)

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

Referenced by importDBRow().

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

◆ setDescription()

ilBadge::setDescription (   $a_value)

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

Referenced by importDBRow().

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

◆ setId()

ilBadge::setId (   $a_id)
protected

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

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

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

◆ setImage()

ilBadge::setImage (   $a_value)
protected

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

References image.

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

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

◆ setParentId()

ilBadge::setParentId (   $a_id)

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

Referenced by copy(), and importDBRow().

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

◆ setTitle()

ilBadge::setTitle (   $a_value)

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

Referenced by copy(), and importDBRow().

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

◆ setTypeId()

ilBadge::setTypeId (   $a_id)

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

Referenced by importDBRow().

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

◆ setValid()

ilBadge::setValid (   $a_value)

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

Referenced by importDBRow().

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

◆ update()

ilBadge::update ( )

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

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

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

416  {
417  global $ilDB;
418 
419  if(!$this->getId())
420  {
421  return $this->create();
422  }
423 
424  $fields = $this->getPropertiesForStorage();
425 
426  $ilDB->update("badge_badge", $fields,
427  array("id"=>array("integer", $this->getId()))
428  );
429  }
getPropertiesForStorage()
Create styles array
The data for the language used.
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 290 of file class.ilBadge.php.

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

291  {
292  if($this->getId() &&
293  $a_upload_meta["tmp_name"])
294  {
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  {
300  $this->update();
301  }
302  }
303  }
$path
Definition: aliased.php:25
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 17 of file class.ilBadge.php.

Referenced by isActive().

◆ $config

ilBadge::$config
protected

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

Referenced by getConfiguration().

◆ $criteria

ilBadge::$criteria
protected

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

Referenced by getCriteria().

◆ $desc

ilBadge::$desc
protected

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

Referenced by getDescription().

◆ $id

ilBadge::$id
protected

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

Referenced by create(), and getId().

◆ $image

ilBadge::$image
protected

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

Referenced by getImage().

◆ $parent_id

ilBadge::$parent_id
protected

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

Referenced by getParentId().

◆ $title

ilBadge::$title
protected

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

Referenced by getTitle().

◆ $type_id

ilBadge::$type_id
protected

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

Referenced by getTypeId().

◆ $valid

ilBadge::$valid
protected

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

Referenced by getValid().


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