ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSkillTemplateReference.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
6
16{
20 protected $db;
21
22 public $id;
23
28 public function __construct($a_id = 0)
29 {
30 global $DIC;
31
32 $this->db = $DIC->database();
34 $this->setType("sktr");
35 }
36
42 public function setSkillTemplateId($a_val)
43 {
44 $this->skill_template_id = $a_val;
45 }
46
52 public function getSkillTemplateId()
53 {
54 return $this->skill_template_id;
55 }
56
60 public function read()
61 {
63
64 parent::read();
65
66 $set = $ilDB->query(
67 "SELECT * FROM skl_templ_ref " .
68 " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
69 );
70 $rec = $ilDB->fetchAssoc($set);
71 $this->setSkillTemplateId((int) $rec["templ_id"]);
72 }
73
77 public function create()
78 {
80
81 parent::create();
82
83 $ilDB->manipulate("INSERT INTO skl_templ_ref " .
84 "(skl_node_id, templ_id) VALUES (" .
85 $ilDB->quote($this->getId(), "integer") . "," .
86 $ilDB->quote($this->getSkillTemplateId(), "integer") .
87 ")");
88 }
89
93 public function update()
94 {
96
97 parent::update();
98
99 $ilDB->manipulate(
100 "UPDATE skl_templ_ref SET " .
101 " templ_id = " . $ilDB->quote($this->getSkillTemplateId(), "integer") .
102 " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
103 );
104 }
105
106
110 public function delete()
111 {
113
114 $ilDB->manipulate(
115 "DELETE FROM skl_templ_ref WHERE "
116 . " skl_node_id = " . $ilDB->quote($this->getId(), "integer")
117 );
118
119 parent::delete();
120 }
121
125 public function copy()
126 {
127 $sktr = new ilSkillTemplateReference();
128 $sktr->setTitle($this->getTitle());
129 $sktr->setDescription($this->getDescription());
130 $sktr->setType($this->getType());
131 $sktr->setSkillTemplateId($this->getSkillTemplateId());
132 $sktr->setSelfEvaluation($this->getSelfEvaluation());
133 $sktr->setOrderNr($this->getOrderNr());
134 $sktr->create();
135
136 return $sktr;
137 }
138
145 public static function _lookupTemplateId($a_obj_id)
146 {
147 global $DIC;
148
149 $ilDB = $DIC->database();
150
151 $query = "SELECT templ_id FROM skl_templ_ref WHERE skl_node_id = " .
152 $ilDB->quote($a_obj_id, "integer");
153 $obj_set = $ilDB->query($query);
154 $obj_rec = $ilDB->fetchAssoc($obj_set);
155
156 return $obj_rec["templ_id"];
157 }
158
165 public static function _lookupTrefIdsForTopTemplateId($a_template_id)
166 {
167 global $DIC;
168
169 $ilDB = $DIC->database();
170
171 $set = $ilDB->query(
172 "SELECT * FROM skl_templ_ref " .
173 " WHERE templ_id = " . $ilDB->quote($a_template_id, "integer")
174 );
175 $trefs = array();
176 while ($rec = $ilDB->fetchAssoc($set)) {
177 $trefs[] = $rec["skl_node_id"];
178 }
179 return $trefs;
180 }
181
182
189 public static function _lookupTrefIdsForTemplateId($a_tid)
190 {
191 include_once("./Services/Skill/classes/class.ilSkillTree.php");
192 $tree = new ilSkillTree();
193 $top_template_id = $tree->getTopParentNodeId($a_tid);
194 return self::_lookupTrefIdsForTopTemplateId($top_template_id);
195 }
196}
An exception for terminatinating execution or to throw for unit testing.
create()
Create skill template reference.
__construct($a_id=0)
Constructor @access public.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
getSkillTemplateId()
Get skill template id.
setSkillTemplateId($a_val)
Set skill template id.
A node in the skill tree.
getDescription()
Get description.
setType($a_type)
Set type.
getOrderNr()
Get order nr.
getSelfEvaluation()
Get self evaluation.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
global $ilDB
$DIC
Definition: xapitoken.php:46