ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilBasicSkillTemplate.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("sktp");
22  }
23 
27  public function copy()
28  {
29  $skill = new ilBasicSkillTemplate();
30  $skill->setTitle($this->getTitle());
31  $skill->setDescription($this->getDescription());
32  $skill->setType($this->getType());
33  $skill->setOrderNr($this->getOrderNr());
34  $skill->create();
35 
36  $levels = $this->getLevelData();
37  if (sizeof($levels)) {
38  foreach ($levels as $item) {
39  $skill->addLevel($item["title"], $item["description"]);
40  }
41  }
42  $skill->update();
43 
44  return $skill;
45  }
46 
47  public function delete(): void
48  {
49  $ilDB = $this->db;
50 
51  foreach (\ilSkillTemplateReference::_lookupTrefIdsForTopTemplateId($this->getId()) as $tref_id) {
52  $obj = ilSkillTreeNodeFactory::getInstance($tref_id);
53  $node_data = $this->skill_tree->getNodeData($tref_id);
54  if (is_object($obj)) {
55  $obj->delete();
56  }
57  if ($this->skill_tree->isInTree($tref_id)) {
58  $this->skill_tree->deleteTree($node_data);
59  }
60  }
61 
62  $ilDB->manipulate(
63  "DELETE FROM skl_templ_ref WHERE "
64  . " templ_id = " . $ilDB->quote($this->getId(), "integer")
65  );
66 
67  parent::delete();
68  }
69 }
setType($a_type)
Set type.
getDescription()
Get description.
getOrderNr()
Get order nr.
getLevelData(int $a_id=0)
__construct(Container $dic, ilPlugin $plugin)
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
global $ilDB
copy()
Copy basic skill template.
Basic Skill.
__construct($a_id=0)
Constructor public.