45        $this->lng = 
$DIC->language();
 
   46        $this->db = 
$DIC->database();
 
   60        $sql = 
"SELECT * FROM badge_badge" .
 
   61            " WHERE parent_id = " . 
$ilDB->quote($a_parent_id);
 
   64            if ($a_filter[
"title"]) {
 
   65                $sql .= 
" AND " . 
$ilDB->like(
"title", 
"text", 
"%" . trim($a_filter[
"title"]) . 
"%");
 
   67            if ($a_filter[
"type"]) {
 
   68                $sql .= 
" AND type_id = " . 
$ilDB->quote($a_filter[
"type"], 
"integer");
 
   72        $set = 
$ilDB->query($sql .
 
   76            $obj->importDBRow(
$row);
 
   91        $set = 
$ilDB->query(
"SELECT * FROM badge_badge" .
 
   92            " WHERE type_id = " . 
$ilDB->quote($a_type_id) .
 
   96            $obj->importDBRow(
$row);
 
  106            include_once 
"./Services/Badge/classes/class.ilBadgeHandler.php";
 
  112    public function copy($a_new_parent_id)
 
  120        if ($this->
getId()) {
 
  139        $res = $raw = array();
 
  143        if ($a_filter[
"type"]) {
 
  144            $where .= 
" AND bb.type_id = " . 
$ilDB->quote($a_filter[
"type"], 
"text");
 
  146        if ($a_filter[
"title"]) {
 
  147            $where .= 
" AND " . 
$ilDB->like(
"bb.title", 
"text", 
"%" . $a_filter[
"title"] . 
"%");
 
  149        if ($a_filter[
"object"]) {
 
  150            $where .= 
" AND " . 
$ilDB->like(
"od.title", 
"text", 
"%" . $a_filter[
"object"] . 
"%");
 
  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") .
 
  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") .
 
  168            $row[
"deleted"] = 
true;
 
  172        foreach ($raw as 
$row) {
 
  188        $this->
id = (int) $a_id;
 
  198        $this->parent_id = (int) $a_id;
 
  208        $this->type_id = trim($a_id);
 
  218        $this->active = (bool) $a_value;
 
  228        $this->title = trim($a_value);
 
  238        $this->desc = trim($a_value);
 
  248        $this->criteria = trim($a_value);
 
  258        $this->valid = trim($a_value);
 
  268        if (is_array($a_value) &&
 
  272        $this->config = $a_value;
 
  282        $this->image = trim($a_value);
 
  296        if ($this->
getId() &&
 
  297            $a_upload_meta[
"tmp_name"]) {
 
  298            $this->
setImage($a_upload_meta[
"name"]);
 
  301            if (ilUtil::moveUploadedFile($a_upload_meta[
"tmp_name"], $this->
getImagePath(
false), 
$path)) {
 
  309        if (file_exists($a_file)) {
 
  319        if ($this->
getId()) {
 
  320            $suffix = strtolower(array_pop(explode(
".", $this->
getImage())));
 
  324                return "img" . $this->
getId() . 
"." . $suffix;
 
  338        include_once 
"Services/Badge/classes/class.ilFSStorageBadge.php";
 
  342        $path = $storage->getAbsolutePath() . 
"/";
 
  345            $path .= $a_subdir . 
"/";
 
  347            if (!is_dir(
$path)) {
 
  364        $set = 
$ilDB->query(
"SELECT * FROM badge_badge" .
 
  365            " WHERE id = " . 
$ilDB->quote($a_id, 
"integer"));
 
  366        if (
$ilDB->numRows($set)) {
 
  374        $this->
setId($a_row[
"id"]);
 
  384                ? unserialize($a_row[
"conf"])
 
  392        if ($this->
getId()) {
 
  401        $fields[
"id"] = array(
"integer", 
$id);
 
  402        $fields[
"parent_id"] = array(
"integer", $this->
getParentId());
 
  403        $fields[
"type_id"] = array(
"text", $this->
getTypeId());
 
  405        $ilDB->insert(
"badge_badge", $fields);
 
  412        if (!$this->
getId()) {
 
  421            array(
"id"=>array(
"integer", $this->
getId()))
 
  425    public function delete()
 
  429        if (!$this->
getId()) {
 
  439        include_once 
"Services/Badge/classes/class.ilBadgeAssignment.php";
 
  442        $ilDB->manipulate(
"DELETE FROM badge_badge" .
 
  443            " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
  449            "active" => array(
"integer", $this->
isActive()),
 
  450            "title" => array(
"text", $this->
getTitle()),
 
  453            "image" => array(
"text", $this->
getImage()),
 
  454            "valid" => array(
"text", $this->
getValid()),
 
  474            include_once 
"Services/Object/classes/class.ilObjectDataDeletionLog.php";
 
  476            if ($parent[
"type"]) {
 
  477                $parent_type = $parent[
"type"];
 
  478                $parent_title = $parent[
"title"];
 
  485            "type" => $parent_type,
 
  486            "title" => $parent_title,
 
  487            "deleted" => $deleted
 
  498        $json = 
new stdClass();
 
  499        $json->{
"@context"} = 
"https://w3id.org/openbadges/v1";
 
  500        $json->type = 
"BadgeClass";
 
  501        $json->id = $a_base_url . 
"class.json";
 
  504        $json->image = $a_base_url . 
"image." . $a_img_suffix;
 
  505        $json->criteria = $a_base_url . 
"criteria.txt";
 
  515        $base_url = ILIAS_HTTP_PATH . substr(
$path, 1);
 
  517        if (!file_exists(
$path . 
"class.json")) {
 
  518            $img_suffix = array_pop(explode(
".", $this->getImage()));
 
  520            $json = json_encode($this->prepareJson($base_url, $img_suffix));
 
  521            file_put_contents(
$path . 
"class.json", $json);
 
  524            copy($this->getImagePath(), 
$path . 
"image." . $img_suffix);
 
  526            file_put_contents(
$path . 
"criteria.txt", $this->getCriteria());
 
  529        return $base_url . 
"class.json";
 
  547        return $a_type->getCaption() . 
" (" .
 
  549                ? 
$lng->txt(
"badge_subtype_auto")
 
  550                : 
$lng->txt(
"badge_subtype_manual")) . 
")";
 
An exception for terminatinating execution or to throw for unit testing.
static deleteByBadgeId($a_badge_id)
static getInstance()
Constructor.
setConfiguration(array $a_value=null)
__construct($a_id=null)
Constructor.
uploadImage(array $a_upload_meta)
static getInstancesByParentId($a_parent_id, array $a_filter=null)
importImage($a_name, $a_file)
static getInstancesByType($a_type_id)
getImagePath($a_full_path=true)
static getExtendedTypeCaption(ilBadgeType $a_type)
prepareJson($a_base_url, $a_img_suffix)
getPropertiesForStorage()
importDBRow(array $a_row)
getFilePath($a_id, $a_subdir=null)
Init file system storage.
static getObjectInstances(array $a_filter=null)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
foreach($_POST as $key=> $value) $res