ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillTemplateCategory.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 {
12  public $id;
13 
18  public function __construct($a_id = 0)
19  {
20  parent::__construct($a_id);
21  $this->setType("sctp");
22  }
23 
27  public function copy()
28  {
29  $sctp = new ilSkillTemplateCategory();
30  $sctp->setTitle($this->getTitle());
31  $sctp->setDescription($this->getDescription());
32  $sctp->setType($this->getType());
33  $sctp->setOrderNr($this->getOrderNr());
34  $sctp->create();
35 
36  return $sctp;
37  }
38 
39  public function delete()
40  {
41  $ilDB = $this->db;
42 
43  $sctp_id = $this->getId();
44  $childs = $this->skill_tree->getChildsByTypeFilter(
45  $sctp_id,
46  ["sktp", "sctp"]
47  );
48  foreach ($childs as $node) {
49  switch ($node["type"]) {
50  case "sktp":
51  $obj = new ilBasicSkillTemplate((int) $node["obj_id"]);
52  $obj->delete();
53  break;
54 
55  case "sctp":
56  $obj = new ilSkillTemplateCategory((int) $node["obj_id"]);
57  $obj->delete();
58  break;
59  }
60  }
61 
62  foreach (\ilSkillTemplateReference::_lookupTrefIdsForTopTemplateId($sctp_id) as $tref_id) {
63  $obj = ilSkillTreeNodeFactory::getInstance($tref_id);
64  $node_data = $this->skill_tree->getNodeData($tref_id);
65  if (is_object($obj)) {
66  $obj->delete();
67  }
68  if ($this->skill_tree->isInTree($tref_id)) {
69  $this->skill_tree->deleteTree($node_data);
70  }
71  }
72 
73  $ilDB->manipulate(
74  "DELETE FROM skl_templ_ref WHERE "
75  . " templ_id = " . $ilDB->quote($this->getId(), "integer")
76  );
77 
78  parent::delete();
79  }
80 }
setType($a_type)
Set type.
getDescription()
Get description.
__construct($a_id=0)
Constructor public.
getOrderNr()
Get order nr.
__construct(Container $dic, ilPlugin $plugin)
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
A node in the skill tree.
global $ilDB