ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillTemplateReference.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $db;
16 
17  public $id;
18 
23  public function __construct($a_id = 0)
24  {
25  global $DIC;
26 
27  $this->db = $DIC->database();
28  parent::__construct($a_id);
29  $this->setType("sktr");
30  }
31 
37  public function setSkillTemplateId($a_val)
38  {
39  $this->skill_template_id = $a_val;
40  }
41 
47  public function getSkillTemplateId()
48  {
49  return $this->skill_template_id;
50  }
51 
55  public function read()
56  {
57  $ilDB = $this->db;
58 
59  parent::read();
60 
61  $set = $ilDB->query(
62  "SELECT * FROM skl_templ_ref " .
63  " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
64  );
65  if ($rec = $ilDB->fetchAssoc($set)) {
66  $this->setSkillTemplateId((int) $rec["templ_id"]);
67  }
68  }
69 
73  public function create()
74  {
75  $ilDB = $this->db;
76 
77  parent::create();
78 
79  $ilDB->manipulate("INSERT INTO skl_templ_ref " .
80  "(skl_node_id, templ_id) VALUES (" .
81  $ilDB->quote($this->getId(), "integer") . "," .
82  $ilDB->quote($this->getSkillTemplateId(), "integer") .
83  ")");
84  }
85 
89  public function update()
90  {
91  $ilDB = $this->db;
92 
93  parent::update();
94 
95  $ilDB->manipulate(
96  "UPDATE skl_templ_ref SET " .
97  " templ_id = " . $ilDB->quote($this->getSkillTemplateId(), "integer") .
98  " WHERE skl_node_id = " . $ilDB->quote($this->getId(), "integer")
99  );
100  }
101 
102 
106  public function delete()
107  {
108  $ilDB = $this->db;
109 
110  $ilDB->manipulate(
111  "DELETE FROM skl_templ_ref WHERE "
112  . " skl_node_id = " . $ilDB->quote($this->getId(), "integer")
113  );
114 
115  parent::delete();
116  }
117 
121  public function copy()
122  {
123  $sktr = new ilSkillTemplateReference();
124  $sktr->setTitle($this->getTitle());
125  $sktr->setDescription($this->getDescription());
126  $sktr->setType($this->getType());
127  $sktr->setSkillTemplateId($this->getSkillTemplateId());
128  $sktr->setSelfEvaluation($this->getSelfEvaluation());
129  $sktr->setOrderNr($this->getOrderNr());
130  $sktr->create();
131 
132  return $sktr;
133  }
134 
141  public static function _lookupTemplateId($a_obj_id)
142  {
143  global $DIC;
144 
145  $ilDB = $DIC->database();
146 
147  $query = "SELECT templ_id FROM skl_templ_ref WHERE skl_node_id = " .
148  $ilDB->quote($a_obj_id, "integer");
149  $obj_set = $ilDB->query($query);
150  $obj_rec = $ilDB->fetchAssoc($obj_set);
151 
152  return $obj_rec["templ_id"];
153  }
154 
161  public static function _lookupTrefIdsForTopTemplateId($a_template_id)
162  {
163  global $DIC;
164 
165  $ilDB = $DIC->database();
166 
167  $set = $ilDB->query(
168  "SELECT * FROM skl_templ_ref " .
169  " WHERE templ_id = " . $ilDB->quote($a_template_id, "integer")
170  );
171  $trefs = array();
172  while ($rec = $ilDB->fetchAssoc($set)) {
173  $trefs[] = $rec["skl_node_id"];
174  }
175  return $trefs;
176  }
177 
178 
185  public static function _lookupTrefIdsForTemplateId($a_tid)
186  {
187  $tree = new ilSkillTree();
188  $top_template_id = $tree->getTopParentNodeId($a_tid);
189  return self::_lookupTrefIdsForTopTemplateId($top_template_id);
190  }
191 }
__construct($a_id=0)
Constructor public.
setSkillTemplateId($a_val)
Set skill template id.
setType($a_type)
Set type.
getSkillTemplateId()
Get skill template id.
getDescription()
Get description.
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.
global $DIC
Definition: goto.php:24
static _lookupTemplateId($a_obj_id)
Lookup template ID.
$query
__construct(Container $dic, ilPlugin $plugin)
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
A node in the skill tree.
global $ilDB
create()
Create skill template reference.