ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillTemplateReference.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected ilDBInterface $db;
29 protected int $skill_template_id = 0;
30
31 public function __construct(int $a_id = 0)
32 {
33 global $DIC;
34
35 $this->db = $DIC->database();
37 $this->setType("sktr");
38 }
39
40 public function setSkillTemplateId(int $a_val): void
41 {
42 $this->skill_template_id = $a_val;
43 }
44
45 public function getSkillTemplateId(): int
46 {
48 }
49
50 public function read(): void
51 {
53
54 parent::read();
55
56 $set = $ilDB->query(
57 "SELECT * FROM skl_templ_ref " .
58 " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
59 );
60 if ($rec = $ilDB->fetchAssoc($set)) {
61 $this->setSkillTemplateId((int) $rec["templ_id"]);
62 }
63 }
64
65 public function create(): void
66 {
68
69 parent::create();
70
71 $ilDB->manipulate("INSERT INTO skl_templ_ref " .
72 "(skl_node_id, templ_id) VALUES (" .
73 $ilDB->quote($this->getId(), "integer") . "," .
74 $ilDB->quote($this->getSkillTemplateId(), "integer") .
75 ")");
76 }
77
78 public function update(): void
79 {
81
82 parent::update();
83
84 $ilDB->manipulate(
85 "UPDATE skl_templ_ref SET " .
86 " templ_id = " . $ilDB->quote($this->getSkillTemplateId(), "integer") .
87 " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
88 );
89 }
90
91 public function delete(): void
92 {
94
95 $ilDB->manipulate(
96 "DELETE FROM skl_templ_ref WHERE "
97 . " skl_node_id = " . $ilDB->quote($this->getId(), "integer")
98 );
99
100 parent::delete();
101 }
102
104 {
105 $sktr = new ilSkillTemplateReference();
106 $sktr->setTitle($this->getTitle());
107 $sktr->setDescription($this->getDescription());
108 $sktr->setType($this->getType());
109 $sktr->setSkillTemplateId($this->getSkillTemplateId());
110 $sktr->setSelfEvaluation($this->getSelfEvaluation());
111 $sktr->setOrderNr($this->getOrderNr());
112 $sktr->create();
113
114 return $sktr;
115 }
116
117 public static function _lookupTemplateId(int $a_obj_id): int
118 {
119 global $DIC;
120
121 $ilDB = $DIC->database();
122
123 $query = "SELECT templ_id FROM skl_templ_ref WHERE skl_node_id = " .
124 $ilDB->quote($a_obj_id, "integer");
125 $obj_set = $ilDB->query($query);
126 $obj_rec = $ilDB->fetchAssoc($obj_set);
127
128 return (int) $obj_rec["templ_id"];
129 }
130
135 public static function _lookupTrefIdsForTopTemplateId(int $a_template_id): array
136 {
137 global $DIC;
138
139 $ilDB = $DIC->database();
140
141 $set = $ilDB->query(
142 "SELECT * FROM skl_templ_ref " .
143 " WHERE templ_id = " . $ilDB->quote($a_template_id, "integer")
144 );
145 $trefs = [];
146 while ($rec = $ilDB->fetchAssoc($set)) {
147 $trefs[] = (int) $rec["skl_node_id"];
148 }
149 return $trefs;
150 }
151
152
157 public static function _lookupTrefIdsForTemplateId(int $a_tid): array
158 {
159 global $DIC;
160
161 $tree = $DIC->skills()->internal()->repo()->getTreeRepo()->getTreeForNodeId($a_tid);
162 $top_template_id = $tree->getTopParentNodeId($a_tid);
163 return self::_lookupTrefIdsForTopTemplateId($top_template_id);
164 }
165}
static _lookupTrefIdsForTopTemplateId(int $a_template_id)
A node in the skill tree.
setType(string $a_type)
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26