ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
5 include_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();
33  parent::__construct($a_id);
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  {
62  $ilDB = $this->db;
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  {
79  $ilDB = $this->db;
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  {
95  $ilDB = $this->db;
96 
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  {
112  $ilDB = $this->db;
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->setType($this->getType());
130  $sktr->setSkillTemplateId($this->getSkillTemplateId());
131  $sktr->setSelfEvaluation($this->getSelfEvaluation());
132  $sktr->setOrderNr($this->getOrderNr());
133  $sktr->create();
134 
135  return $sktr;
136  }
137 
144  public static function _lookupTemplateId($a_obj_id)
145  {
146  global $DIC;
147 
148  $ilDB = $DIC->database();
149 
150  $query = "SELECT templ_id FROM skl_templ_ref WHERE skl_node_id = " .
151  $ilDB->quote($a_obj_id, "integer");
152  $obj_set = $ilDB->query($query);
153  $obj_rec = $ilDB->fetchAssoc($obj_set);
154 
155  return $obj_rec["templ_id"];
156  }
157 
164  public static function _lookupTrefIdsForTopTemplateId($a_template_id)
165  {
166  global $DIC;
167 
168  $ilDB = $DIC->database();
169 
170  $set = $ilDB->query(
171  "SELECT * FROM skl_templ_ref " .
172  " WHERE templ_id = " . $ilDB->quote($a_template_id, "integer")
173  );
174  $trefs = array();
175  while ($rec = $ilDB->fetchAssoc($set)) {
176  $trefs[] = $rec["skl_node_id"];
177  }
178  return $trefs;
179  }
180 
181 
188  public static function _lookupTrefIdsForTemplateId($a_tid)
189  {
190  include_once("./Services/Skill/classes/class.ilSkillTree.php");
191  $tree = new ilSkillTree();
192  $top_template_id = $tree->getTopParentNodeId($a_tid);
193  return self::_lookupTrefIdsForTopTemplateId($top_template_id);
194  }
195 }
__construct($a_id=0)
Constructor public.
setSkillTemplateId($a_val)
Set skill template id.
setType($a_type)
Set type.
getSkillTemplateId()
Get skill template id.
global $DIC
Definition: saml.php:7
Skill tree.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
copy()
Copy basic skill template.
getSelfEvaluation()
Get self evaluation.
getOrderNr()
Get order nr.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
$query
Create styles array
The data for the language used.
update($pash, $contents, Config $config)
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
A node in the skill tree.
global $ilDB
create()
Create skill template reference.