ILIAS  release_8 Revision v8.24
class.ilECSCmsTree.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
23class ilECSCmsTree extends ilTree
24{
25 public function __construct(int $a_tree_id)
26 {
27 parent::__construct($a_tree_id, self::lookupRootId($a_tree_id));
28
29 $this->setObjectTablePK('obj_id');
30 $this->setTableNames('ecs_cms_tree', 'ecs_cms_data');
31 $this->useCache(false);
32 }
33
34 public function insertRootNode(int $tree, int $a_child): bool
35 {
36 $query = 'INSERT INTO ecs_cms_tree ' .
37 '(tree,child,parent,lft,rgt,depth) ' .
38 'VALUES ( ' .
39 $this->db->quote($tree, 'integer') . ', ' .
40 $this->db->quote($a_child, 'integer') . ', ' .
41 $this->db->quote(0, 'integer') . ', ' .
42 $this->db->quote(1, 'integer') . ', ' .
43 $this->db->quote(100, 'integer') . ', ' .
44 $this->db->quote(1, 'integer') . ' )';
45
46 $this->db->manipulate($query);
47
48 return true;
49 }
50
54 public static function deleteByTreeId(int $a_tree_id): bool
55 {
56 global $DIC;
57
58 $ilDB = $DIC['ilDB'];
59
60 $DIC->logger()->wsrv()->debug('Deleting cms tree: ' . $a_tree_id);
61 $query = 'DELETE FROM ecs_cms_tree ' .
62 'WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
63 $ilDB->manipulate($query);
64 return true;
65 }
66
70 public function treeExists(int $a_tree_id): bool
71 {
72 $query = 'SELECT COUNT(*) num FROM ecs_cms_tree WHERE tree = ' . $this->db->quote($a_tree_id, 'integer');
73 $res = $this->db->query($query);
74 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
75 return $row->num > 0;
76 }
77 return false;
78 }
79
80
84 public static function lookupRootId($a_tree_id): int
85 {
86 global $DIC;
87
88 $ilDB = $DIC['ilDB'];
89
90 $query = 'SELECT child FROM ecs_cms_tree WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
91 $res = $ilDB->query($query);
92 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
93 return (int) $row->child;
94 }
95 return 0;
96 }
97}
static lookupRootId($a_tree_id)
lookup root id
static deleteByTreeId(int $a_tree_id)
Delete tree by tree_id.
__construct(int $a_tree_id)
insertRootNode(int $tree, int $a_child)
treeExists(int $a_tree_id)
Check if tree exists.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
useCache(bool $a_use=true)
Use Cache (usually activated)
setObjectTablePK(string $a_column_name)
set column containing primary key in object table
setTableNames(string $a_table_tree, string $a_table_obj_data, string $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query