45 $sql =
"SELECT * FROM badge_badge".
46 " WHERE parent_id = ".$ilDB->quote($a_parent_id);
50 if($a_filter[
"title"])
52 $sql .=
" AND ".$ilDB->like(
"title",
"text",
"%".trim($a_filter[
"title"]).
"%");
56 $sql .=
" AND type_id = ".$ilDB->quote($a_filter[
"type"],
"integer");
60 $set = $ilDB->query($sql.
62 while(
$row = $ilDB->fetchAssoc($set))
65 $obj->importDBRow(
$row);
78 $set = $ilDB->query(
"SELECT * FROM badge_badge".
79 " WHERE type_id = ".$ilDB->quote($a_type_id).
81 while(
$row = $ilDB->fetchAssoc($set))
84 $obj->importDBRow(
$row);
95 include_once
"./Services/Badge/classes/class.ilBadgeHandler.php";
97 return $handler->getTypeInstanceByUniqueId($this->
getTypeId());
101 public function copy($a_new_parent_id)
132 if($a_filter[
"type"])
134 $where .=
" AND bb.type_id = ".$ilDB->quote($a_filter[
"type"],
"text");
136 if($a_filter[
"title"])
138 $where .=
" AND ".$ilDB->like(
"bb.title",
"text",
"%".$a_filter[
"title"].
"%");
140 if($a_filter[
"object"])
142 $where .=
" AND ".$ilDB->like(
"od.title",
"text",
"%".$a_filter[
"object"].
"%");
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").
150 while(
$row = $ilDB->fetchAssoc($set))
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").
160 while(
$row = $ilDB->fetchAssoc($set))
162 $row[
"deleted"] =
true;
166 foreach($raw as
$row)
183 $this->
id = (int)$a_id;
193 $this->parent_id = (int)$a_id;
203 $this->type_id = trim($a_id);
213 $this->active = (bool)$a_value;
223 $this->title = trim($a_value);
233 $this->desc = trim($a_value);
243 $this->criteria = trim($a_value);
253 $this->valid = trim($a_value);
263 if(is_array($a_value) &&
268 $this->config = $a_value;
278 $this->
image = trim($a_value);
293 $a_upload_meta[
"tmp_name"])
295 $this->
setImage($a_upload_meta[
"name"]);
307 if(file_exists($a_file))
320 $suffix = strtolower(array_pop(explode(
".", $this->
getImage())));
327 return "img" . $this->
getId() .
"." . $suffix;
341 include_once
"Services/Badge/classes/class.ilFSStorageBadge.php";
345 $path = $storage->getAbsolutePath().
"/";
349 $path .= $a_subdir.
"/";
369 $set = $ilDB->query(
"SELECT * FROM badge_badge".
370 " WHERE id = ".$ilDB->quote($a_id,
"integer"));
371 if($ilDB->numRows($set))
373 $row = $ilDB->fetchAssoc($set);
380 $this->
setId($a_row[
"id"]);
390 ? unserialize($a_row[
"conf"])
403 $id = $ilDB->nextId(
"badge_badge");
408 $fields[
"id"] =
array(
"integer",
$id);
412 $ilDB->insert(
"badge_badge", $fields);
426 $ilDB->update(
"badge_badge", $fields,
431 public function delete()
447 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
450 $ilDB->manipulate(
"DELETE FROM badge_badge".
451 " WHERE id = ".$ilDB->quote($this->getId(),
"integer"));
485 include_once
"Services/Object/classes/class.ilObjectDataDeletionLog.php";
489 $parent_type = $parent[
"type"];
490 $parent_title = $parent[
"title"];
497 "type" => $parent_type,
498 "title" => $parent_title,
499 "deleted" => $deleted
510 $json =
new stdClass();
511 $json->{
"@context"} =
"https://w3id.org/openbadges/v1";
512 $json->type =
"BadgeClass";
513 $json->id = $a_base_url.
"class.json";
516 $json->image = $a_base_url.
"image.".$a_img_suffix;
517 $json->criteria = $a_base_url.
"criteria.txt";
527 $base_url = ILIAS_HTTP_PATH.substr(
$path, 1);
529 if(!file_exists(
$path.
"class.json"))
531 $img_suffix = array_pop(explode(
".", $this->
getImage()));
533 $json = json_encode($this->
prepareJson($base_url, $img_suffix));
534 file_put_contents(
$path.
"class.json", $json);
539 file_put_contents(
$path.
"criteria.txt", $this->getCriteria());
542 return $base_url.
"class.json";
561 ? $lng->txt(
"badge_subtype_auto")
562 : $lng->txt(
"badge_subtype_manual")).
")";
getPropertiesForStorage()
uploadImage(array $a_upload_meta)
getImagePath($a_full_path=true)
static getObjectInstances(array $a_filter=null)
static _lookupTitle($a_id)
lookup object title
getFilePath($a_id, $a_subdir=null)
Init file system storage.
static getInstancesByParentId($a_parent_id, array $a_filter=null)
static getExtendedTypeCaption(ilBadgeType $a_type)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
__construct($a_id=null)
Constructor.
static deleteByBadgeId($a_badge_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
importImage($a_name, $a_file)
setConfiguration(array $a_value=null)
importDBRow(array $a_row)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getInstancesByType($a_type_id)
prepareJson($a_base_url, $a_img_suffix)
static getInstance()
Constructor.