ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilContainerSkills.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12 
16  protected $db;
17 
21  protected $skills = array();
22 
26  protected $id;
27 
33  public function __construct($a_obj_id)
34  {
35  global $DIC;
36 
37  $this->db = $DIC->database();
38 
39  $this->setId($a_obj_id);
40  if ($a_obj_id > 0) {
41  $this->read();
42  }
43  }
44 
50  public function setId($a_val)
51  {
52  $this->id = $a_val;
53  }
54 
60  public function getId()
61  {
62  return $this->id;
63  }
64 
68  public function resetSkills()
69  {
70  $this->skills = array();
71  }
72 
79  public function addSkill($a_skill_id, $a_tref_id)
80  {
81  $this->skills[$a_skill_id . "-" . $a_tref_id] = array(
82  "skill_id" => $a_skill_id,
83  "tref_id" => $a_tref_id
84  );
85  }
86 
93  public function removeSkill($a_skill_id, $a_tref_id)
94  {
95  unset($this->skills[$a_skill_id . "-" . $a_tref_id]);
96  }
97 
98 
104  public function getSkills()
105  {
106  return $this->skills;
107  }
108 
115  public function getOrderedSkills()
116  {
117  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
118  $vtree = new ilVirtualSkillTree();
119  return $vtree->getOrderedNodeset($this->getSkills(), "skill_id", "tref_id");
120  }
121 
122 
126  public function read()
127  {
128  $db = $this->db;
129 
130  $this->skills = array();
131  $set = $db->query("SELECT * FROM cont_skills " .
132  " WHERE id = " . $db->quote($this->getId(), "integer"));
133  while ($rec = $db->fetchAssoc($set)) {
134  $this->skills[$rec["skill_id"] . "-" . $rec["tref_id"]] = $rec;
135  }
136  }
137 
141  public function delete()
142  {
143  $db = $this->db;
144 
145  $db->manipulate("DELETE FROM cont_skills WHERE " .
146  " id = " . $db->quote($this->getId(), "integer"));
147  }
148 
152  public function save()
153  {
154  $db = $this->db;
155 
156  $this->delete();
157  foreach ($this->skills as $s) {
158  $db->manipulate("INSERT INTO cont_skills " .
159  "(id, skill_id, tref_id) VALUES (" .
160  $db->quote($this->getId(), "integer") . "," .
161  $db->quote($s["skill_id"], "integer") . "," .
162  $db->quote($s["tref_id"], "integer") . ")");
163  }
164  }
165 }
addSkill($a_skill_id, $a_tref_id)
Add skill.
global $DIC
Definition: saml.php:7
Skills of a container.
$s
Definition: pwgen.php:45
__construct($a_obj_id)
Constrictor.
getOrderedSkills()
Get odered skills.
removeSkill($a_skill_id, $a_tref_id)
Remove skill.
Create styles array
The data for the language used.