ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilWorkspaceTree Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilWorkspaceTree:
+ Collaboration diagram for ilWorkspaceTree:

Public Member Functions

 __construct (int $a_tree_id, int $a_root_id=0)
 
 createReference (int $a_object_id)
 Create workspace reference for object. More...
 
 lookupObjectId (int $a_node_id)
 Get object id for node id. More...
 
 lookupNodeId (int $a_obj_id)
 Get node id for object id As we do not allow references in workspace this should not be ambigious. More...
 
 lookupOwner (int $a_node_id)
 Get owner for node id. More...
 
 insertObject (int $a_parent_node_id, int $a_object_id)
 Add object to tree. More...
 
 deleteReference (int $a_node_id)
 Delete object from reference table. More...
 
 cascadingDelete ()
 Remove all tree and node data. More...
 
 getObjectsFromType (string $a_type, bool $a_with_data=false)
 Get all workspace objects of specific type. More...
 
 createTreeForUser (int $a_user_id)
 Create personal workspace tree for user. More...
 
- Public Member Functions inherited from ilTree
 __construct (int $a_tree_id, int $a_root_id=0, ilDBInterface $db=null)
 
 initTreeImplementation ()
 Init tree implementation. More...
 
 getTreeImplementation ()
 Get tree implementation. More...
 
 useCache (bool $a_use=true)
 Use Cache (usually activated) More...
 
 isCacheUsed ()
 Check if cache is active. More...
 
 getDepthCache ()
 Get depth cache. More...
 
 getParentCache ()
 Get parent cache. More...
 
 initLangCode ()
 Do not use it Store user language. More...
 
 getTreeTable ()
 Get tree table name. More...
 
 getObjectDataTable ()
 Get object data table. More...
 
 getTreePk ()
 Get tree primary key. More...
 
 getTableReference ()
 Get reference table if available. More...
 
 getGap ()
 Get default gap. More...
 
 resetInTreeCache ()
 reset in tree cache More...
 
 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 a reference table. More...
 
 setReferenceTablePK (string $a_column_name)
 set column containing primary key in reference table More...
 
 setObjectTablePK (string $a_column_name)
 set column containing primary key in object table More...
 
 setTreeTablePK (string $a_column_name)
 set column containing primary key in tree table More...
 
 buildJoin ()
 build join depending on table settings private More...
 
 getRelation (int $a_node_a, int $a_node_b)
 Get relation of two nodes. More...
 
 getRelationOfNodes (array $a_node_a_arr, array $a_node_b_arr)
 get relation of two nodes by node data More...
 
 getChildIds (int $a_node)
 
 getChilds (int $a_node_id, string $a_order="", string $a_direction="ASC")
 get child nodes of given node More...
 
 getFilteredChilds (array $a_filter, int $a_node, string $a_order="", string $a_direction="ASC")
 get child nodes of given node (exclude filtered obj_types) More...
 
 getChildsByType (int $a_node_id, string $a_type)
 get child nodes of given node by object type More...
 
 getChildsByTypeFilter (int $a_node_id, array $a_types, string $a_order="", string $a_direction="ASC")
 get child nodes of given node by object type More...
 
 insertNodeFromTrash (int $a_source_id, int $a_target_id, int $a_tree_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deleted_date=false)
 Insert node from trash deletes trash entry. More...
 
 insertNode (int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
 insert new node with node_id under parent node with parent_id More...
 
 getFilteredSubTree (int $a_node_id, array $a_filter=[])
 get filtered subtree get all subtree nodes beginning at a specific node excluding specific object types and their child nodes. More...
 
 getSubTreeIds (int $a_ref_id)
 Get all ids of subnodes. More...
 
 getSubTree (array $a_node, bool $a_with_data=true, array $a_type=[])
 get all nodes in the subtree under specified node More...
 
 deleteTree (array $a_node)
 delete node and the whole subtree under this node More...
 
 validateParentRelations ()
 Validate parent relations of tree. More...
 
 getPathFull (int $a_endnode_id, int $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode. More...
 
 preloadDepthParent (array $a_node_ids)
 Preload depth/parent. More...
 
 getPathId (int $a_endnode_id, int $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode More...
 
 getNodePath (int $a_endnode_id, int $a_startnode_id=0)
 Returns the node path for the specified object reference. More...
 
 checkTree ()
 check consistence of tree all left & right values are checked if they are exists only once More...
 
 checkTreeChilds (bool $a_no_zero_child=true)
 check, if all childs of tree nodes exist in object table More...
 
 getMaximumDepth ()
 Return the current maximum depth in the tree. More...
 
 getDepth (int $a_node_id)
 return depth of a node in tree More...
 
 getNodeTreeData (int $a_node_id)
 return all columns of tabel tree More...
 
 getNodeData (int $a_node_id, ?int $a_tree_pk=null)
 get all information of a node. More...
 
 fetchNodeData (array $a_row)
 get data of parent node from tree and object_data More...
 
 isInTree (?int $a_node_id)
 get all information of a node. More...
 
 getParentNodeData (int $a_node_id)
 get data of parent node from tree and object_data More...
 
 isGrandChild (int $a_startnode_id, int $a_querynode_id)
 checks if a node is in the path of an other node More...
 
 addTree (int $a_tree_id, int $a_node_id=-1)
 create a new tree to do: ??? More...
 
 removeTree (int $a_tree_id)
 remove an existing tree More...
 
 moveToTrash (int $a_node_id, bool $a_set_deleted=false, int $a_deleted_by=0)
 Move node to trash bin. More...
 
 isDeleted (int $a_node_id)
 This is a wrapper for isSaved() with a more useful name. More...
 
 isSaved (int $a_node_id)
 Use method isDeleted. More...
 
 preloadDeleted (array $a_node_ids)
 Preload deleted information. More...
 
 getSavedNodeData (int $a_parent_id)
 get data saved/deleted nodes More...
 
 getSavedNodeObjIds (array $a_obj_ids)
 get object id of saved/deleted nodes More...
 
 getParentId (int $a_node_id)
 get parent id of given node More...
 
 getLeftValue (int $a_node_id)
 get left value of given node More...
 
 getChildSequenceNumber (array $a_node, string $type="")
 get sequence number of node in sibling sequence More...
 
 readRootId ()
 
 getRootId ()
 
 setRootId (int $a_root_id)
 
 getTreeId ()
 
 setTreeId (int $a_tree_id)
 
 fetchSuccessorNode (int $a_node_id, string $a_type="")
 get node data of successor node More...
 
 fetchPredecessorNode (int $a_node_id, string $a_type="")
 get node data of predecessor node More...
 
 renumber (int $node_id=1, int $i=1)
 Wrapper for renumber. More...
 
 checkForParentType (int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
 Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentType(3,'crs');. More...
 
 __isMainTree ()
 Check if operations are done on main tree. More...
 
 __checkDelete (array $a_node)
 Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relation. More...
 
 __getSubTreeByParentRelation (int $a_node_id, array &$parent_childs)
 
 __validateSubtrees (array &$lft_childs, array $parent_childs)
 
 moveTree (int $a_source_id, int $a_target_id, int $a_location=self::POS_LAST_NODE)
 Move Tree Implementation public. More...
 
 getRbacSubtreeInfo (int $a_endnode_id)
 This method is used for change existing objects and returns all necessary information for this action. More...
 
 getSubTreeQuery (int $a_node_id, array $a_fields=[], array $a_types=[], bool $a_force_join_reference=false)
 Get tree subtree query. More...
 
 getTrashSubTreeQuery (int $a_node_id, array $a_fields=[], array $a_types=[], bool $a_force_join_reference=false)
 
 getSubTreeFilteredByObjIds (int $a_node_id, array $a_obj_ids, array $a_fields=[])
 get all node ids in the subtree under specified node id, filter by object ids More...
 
 deleteNode (int $a_tree_id, int $a_node_id)
 
 lookupTrashedObjectTypes ()
 Lookup object types in trash. More...
 
 isRepositoryTree ()
 check if current tree instance operates on repository tree table More...
 

Protected Member Functions

 exists ()
 
- Protected Member Functions inherited from ilTree
 getLangCode ()
 
 fetchTranslationFromObjectDataCache (array $a_obj_ids)
 Get translation data from object cache (trigger in object cache on preload) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilTree
static lookupTreesForNode (int $node_id)
 
static _removeEntry (int $a_tree, int $a_child, string $a_db_table="tree")
 STATIC METHOD Removes a single entry from a tree. More...
 
- Data Fields inherited from ilTree
const TREE_TYPE_MATERIALIZED_PATH = 'mp'
 
const TREE_TYPE_NESTED_SET = 'ns'
 
const POS_LAST_NODE = -2
 
const POS_FIRST_NODE = -1
 
const RELATION_CHILD = 1
 
const RELATION_PARENT = 2
 
const RELATION_SIBLING = 3
 
const RELATION_EQUALS = 4
 
const RELATION_NONE = 5
 
- Protected Attributes inherited from ilTree
const DEFAULT_LANGUAGE = 'en'
 
const DEFAULT_GAP = 50
 
ilLogger $logger
 
ilDBInterface $db
 
ilAppEventHandler $eventHandler
 
int $root_id
 points to root node (may be a subtree) More...
 
int $tree_id
 to use different trees in one db-table More...
 
string $table_tree
 table name of tree table More...
 
string $table_obj_data
 table name of object_data table More...
 
string $table_obj_reference
 table name of object_reference table More...
 
string $ref_pk
 column name containing primary key in reference table More...
 
string $obj_pk
 column name containing primary key in object table More...
 
string $tree_pk
 column name containing tree id in tree table More...
 
bool $use_cache
 
array $oc_preloaded = []
 
array $depth_cache = []
 
array $parent_cache = []
 
array $in_tree_cache = []
 
array $translation_cache = []
 
array $parent_type_cache = []
 
array $is_saved_cache = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Tree handler for personal workspace

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilWorkspaceTree.php.

Constructor & Destructor Documentation

◆ __construct()

ilWorkspaceTree::__construct ( int  $a_tree_id,
int  $a_root_id = 0 
)

Definition at line 26 of file class.ilWorkspaceTree.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), createTreeForUser(), exists(), ilTree\readRootId(), ilTree\setObjectTablePK(), ilTree\setReferenceTablePK(), ilTree\setTableNames(), and ilTree\setTreeTablePK().

29  {
30  global $DIC;
31 
32  parent::__construct($a_tree_id, $a_root_id);
33  $this->setTableNames('tree_workspace', 'object_data', 'object_reference_ws');
34  $this->setTreeTablePK('tree');
35  $this->setObjectTablePK('obj_id');
36  $this->setReferenceTablePK('wsp_id');
37 
38  if (!$this->exists()) {
39  $this->createTreeForUser($a_tree_id);
40  }
41 
42  // ilTree sets it to ROOT_FOLDER_ID if not given...
43  if (!$a_root_id) {
44  $this->readRootId();
45  }
46  }
setObjectTablePK(string $a_column_name)
set column containing primary key in object table
setTreeTablePK(string $a_column_name)
set column containing primary key in tree table
global $DIC
Definition: feed.php:28
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...
__construct(Container $dic, ilPlugin $plugin)
createTreeForUser(int $a_user_id)
Create personal workspace tree for user.
setReferenceTablePK(string $a_column_name)
set column containing primary key in reference table
+ Here is the call graph for this function:

Member Function Documentation

◆ cascadingDelete()

ilWorkspaceTree::cascadingDelete ( )

Remove all tree and node data.

Definition at line 167 of file class.ilWorkspaceTree.php.

References ilTree\$root_id, deleteReference(), ilTree\deleteTree(), ilObjectFactory\getInstanceByObjId(), ilTree\getNodeData(), ilTree\getSubTree(), and ilTree\readRootId().

167  : void
168  {
169  $root_id = $this->readRootId();
170  if (!$root_id) {
171  return;
172  }
173 
174  $root = $this->getNodeData($root_id);
175 
176  $access_handler = new ilWorkspaceAccessHandler($this);
177 
178  // delete node data
179  $nodes = $this->getSubTree($root);
180  foreach ($nodes as $node) {
181  $access_handler->removePermission($node["wsp_id"]);
182 
183  $object = ilObjectFactory::getInstanceByObjId($node["obj_id"], false);
184  if ($object) {
185  $object->delete();
186  }
187 
188  $this->deleteReference($node["wsp_id"]);
189  }
190 
191  $this->deleteTree($root);
192  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deleteTree(array $a_node)
delete node and the whole subtree under this node
int $root_id
points to root node (may be a subtree)
deleteReference(int $a_node_id)
Delete object from reference table.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
+ Here is the call graph for this function:

◆ createReference()

ilWorkspaceTree::createReference ( int  $a_object_id)

Create workspace reference for object.

Parameters
int$a_object_id
Returns
int node id

Definition at line 68 of file class.ilWorkspaceTree.php.

References ilTree\$db, and $ilDB.

Referenced by createTreeForUser(), and insertObject().

68  : int
69  {
70  $ilDB = $this->db;
71 
72  $next_id = $ilDB->nextId($this->table_obj_reference);
73 
74  $fields = array($this->ref_pk => array("integer", $next_id),
75  $this->obj_pk => array("integer", $a_object_id));
76 
77  $ilDB->insert($this->table_obj_reference, $fields);
78 
79  return $next_id;
80  }
ilDBInterface $db
+ Here is the caller graph for this function:

◆ createTreeForUser()

ilWorkspaceTree::createTreeForUser ( int  $a_user_id)

Create personal workspace tree for user.

Parameters
int$a_user_id

Definition at line 213 of file class.ilWorkspaceTree.php.

References ilTree\$root_id, ilTree\addTree(), createReference(), ilObjectFactory\getClassByType(), and ilTree\setRootId().

Referenced by __construct(), ilSkillAssignMaterialsTableGUI\__construct(), and ilExSubmissionObjectGUI\getOverviewContentBlog().

213  : void
214  {
215  $root = ilObjectFactory::getClassByType("wsrt");
216  $root = new $root(0);
217  $root->create();
218 
219  $root_id = $this->createReference($root->getId());
220  $this->addTree($a_user_id, $root_id);
221  $this->setRootId($root_id);
222  }
addTree(int $a_tree_id, int $a_node_id=-1)
create a new tree to do: ???
int $root_id
points to root node (may be a subtree)
setRootId(int $a_root_id)
static getClassByType(string $obj_type)
createReference(int $a_object_id)
Create workspace reference for object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteReference()

ilWorkspaceTree::deleteReference ( int  $a_node_id)

Delete object from reference table.

Definition at line 155 of file class.ilWorkspaceTree.php.

References ilTree\$db, $ilDB, and $query.

Referenced by cascadingDelete().

155  : int
156  {
157  $ilDB = $this->db;
158 
159  $query = "DELETE FROM " . $this->table_obj_reference .
160  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer");
161  return $ilDB->manipulate($query);
162  }
ilDBInterface $db
$query
+ Here is the caller graph for this function:

◆ exists()

ilWorkspaceTree::exists ( )
protected

Definition at line 48 of file class.ilWorkspaceTree.php.

References ilTree\$db, ilDBInterface\fetchAssoc(), ilTree\getTreeId(), and ilDBInterface\queryF().

Referenced by __construct().

48  : bool
49  {
50  $db = $this->db;
51  $set = $db->queryF(
52  "SELECT * FROM tree_workspace " .
53  " WHERE tree = %s ",
54  ["integer"],
55  [$this->getTreeId()]
56  );
57  if ($rec = $db->fetchAssoc($set)) {
58  return true;
59  }
60  return false;
61  }
fetchAssoc(ilDBStatement $statement)
ilDBInterface $db
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectsFromType()

ilWorkspaceTree::getObjectsFromType ( string  $a_type,
bool  $a_with_data = false 
)

Get all workspace objects of specific type.

Returns
array[]

Definition at line 198 of file class.ilWorkspaceTree.php.

References ilTree\getNodeData(), ilTree\getRootId(), and ilTree\getSubTree().

201  : array {
202  return $this->getSubTree(
203  $this->getNodeData($this->getRootId()),
204  $a_with_data,
205  [$a_type]
206  );
207  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
+ Here is the call graph for this function:

◆ insertObject()

ilWorkspaceTree::insertObject ( int  $a_parent_node_id,
int  $a_object_id 
)

Add object to tree.

Parameters
int$a_parent_node_id
int$a_object_id
Returns
int node id

Definition at line 143 of file class.ilWorkspaceTree.php.

References createReference(), and ilTree\insertNode().

Referenced by ilExSubmissionObjectGUI\saveBlogObject().

146  : int {
147  $node_id = $this->createReference($a_object_id);
148  $this->insertNode($node_id, $a_parent_node_id);
149  return $node_id;
150  }
insertNode(int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
insert new node with node_id under parent node with parent_id
createReference(int $a_object_id)
Create workspace reference for object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupNodeId()

ilWorkspaceTree::lookupNodeId ( int  $a_obj_id)

Get node id for object id As we do not allow references in workspace this should not be ambigious.

Parameters
int$a_obj_id
Returns
int node id

Definition at line 106 of file class.ilWorkspaceTree.php.

References ilTree\$db, $ilDB, ilTree\$ref_pk, and $res.

106  : int
107  {
108  $ilDB = $this->db;
109 
110  $set = $ilDB->query("SELECT " . $this->ref_pk .
111  " FROM " . $this->table_obj_reference .
112  " WHERE " . $this->obj_pk . " = " . $ilDB->quote($a_obj_id, "integer"));
113  $res = $ilDB->fetchAssoc($set);
114 
115  return (int) ($res[$this->ref_pk] ?? 0);
116  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
string $ref_pk
column name containing primary key in reference table

◆ lookupObjectId()

ilWorkspaceTree::lookupObjectId ( int  $a_node_id)

Get object id for node id.

Parameters
int$a_node_id
Returns
int object id

Definition at line 87 of file class.ilWorkspaceTree.php.

References ilTree\$db, $ilDB, ilTree\$obj_pk, and $res.

Referenced by ilObject2GUI\__construct(), ilCheckSumOfWorkspaceFileSizesJob\calculateRecursive(), ilPDTasksBlockGUI\fillRow(), ilPDTasksBlockGUI\getListItemForData(), and ilDerivedTasksGUI\show().

87  : int
88  {
89  $ilDB = $this->db;
90 
91  $set = $ilDB->query("SELECT " . $this->obj_pk .
92  " FROM " . $this->table_obj_reference .
93  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer"));
94  $res = $ilDB->fetchAssoc($set);
95 
96  return (int) ($res[$this->obj_pk] ?? 0);
97  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
string $obj_pk
column name containing primary key in object table
+ Here is the caller graph for this function:

◆ lookupOwner()

ilWorkspaceTree::lookupOwner ( int  $a_node_id)

Get owner for node id.

Parameters
int$a_node_id
Returns
int object id

Definition at line 123 of file class.ilWorkspaceTree.php.

References ilTree\$db, $ilDB, and $res.

Referenced by ilSharedResourceGUI\cancelPassword().

123  : int
124  {
125  $ilDB = $this->db;
126 
127  $set = $ilDB->query("SELECT tree" .
128  " FROM " . $this->table_obj_reference .
129  " JOIN " . $this->table_tree . " ON (" . $this->table_obj_reference . "." . $this->ref_pk . " = " . $this->table_tree . ".child)" .
130  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer"));
131  $res = $ilDB->fetchAssoc($set);
132 
133  return (int) ($res["tree"] ?? 0);
134  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: