ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilWorkspaceTree Class Reference

Tree handler for personal workspace. More...

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

Public Member Functions

 __construct ($a_tree_id, $a_root_id=0)
 
 createReference ($a_object_id)
 Create workspace reference for object. More...
 
 lookupObjectId ($a_node_id)
 Get object id for node id. More...
 
 lookupNodeId ($a_obj_id)
 Get node id for object id. More...
 
 lookupOwner ($a_node_id)
 Get owner for node id. More...
 
 insertObject ($a_parent_node_id, $a_object_id)
 Add object to tree. More...
 
 deleteReference ($a_node_id)
 Delete object from reference table. More...
 
 cascadingDelete ()
 Remove all tree and node data. More...
 
 getObjectsFromType ($a_type, $a_with_data=false)
 Get all workspace objects of specific type. More...
 
 createTreeForUser ($a_user_id)
 Create personal workspace tree for user. More...
 
- Public Member Functions inherited from ilTree
 __construct ($a_tree_id, $a_root_id=0)
 Constructor public. More...
 
 initTreeImplementation ()
 Init tree implementation. More...
 
 getTreeImplementation ()
 Get tree implementation. More...
 
 useCache ($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 ()
 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 ()
 
 setTableNames ($a_table_tree, $a_table_obj_data, $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 ($a_column_name)
 set column containing primary key in reference table public More...
 
 setObjectTablePK ($a_column_name)
 set column containing primary key in object table public More...
 
 setTreeTablePK ($a_column_name)
 set column containing primary key in tree table public More...
 
 buildJoin ()
 build join depending on table settings private More...
 
 getRelation ($a_node_a, $a_node_b)
 Get relation of two nodes. More...
 
 getRelationOfNodes ($a_node_a_arr, $a_node_b_arr)
 get relation of two nodes by node data More...
 
 getChildIds ($a_node)
 Get node child ids type $ilDB. More...
 
 getChilds ($a_node_id, $a_order="", $a_direction="ASC")
 get child nodes of given node public More...
 
 getFilteredChilds ($a_filter, $a_node, $a_order="", $a_direction="ASC")
 get child nodes of given node (exclude filtered obj_types) public More...
 
 getChildsByType ($a_node_id, $a_type)
 get child nodes of given node by object type public More...
 
 getChildsByTypeFilter ($a_node_id, $a_types, $a_order="", $a_direction="ASC")
 get child nodes of given node by object type public More...
 
 insertNodeFromTrash ($a_source_id, $a_target_id, $a_tree_id, $a_pos=IL_LAST_NODE, $a_reset_deleted_date=false)
 Insert node from trash deletes trash entry. More...
 
 insertNode ($a_node_id, $a_parent_id, $a_pos=IL_LAST_NODE, $a_reset_deletion_date=false)
 insert new node with node_id under parent node with parent_id public More...
 
 getFilteredSubTree ($a_node_id, $a_filter=array())
 get filtered subtree More...
 
 getSubTreeIds ($a_ref_id)
 Get all ids of subnodes. More...
 
 getSubTree ($a_node, $a_with_data=true, $a_type="")
 get all nodes in the subtree under specified node More...
 
 getSubTreeTypes ($a_node, $a_filter=0)
 get types of nodes in the subtree under specified node More...
 
 deleteTree ($a_node)
 delete node and the whole subtree under this node public More...
 
 validateParentRelations ()
 Validate parent relations of tree. More...
 
 getPathFull ($a_endnode_id, $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 ($a_node_ids)
 Preload depth/parent. More...
 
 getPathId ($a_endnode_id, $a_startnode_id=0)
 get path from a given startnode to a given endnode if startnode is not given the rootnode is startnode public More...
 
 getNodePathForTitlePath ($titlePath, $a_startnode_id=null)
 Converts a path consisting of object titles into a path consisting of tree nodes. More...
 
 getNodePath ($a_endnode_id, $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 public More...
 
 checkTreeChilds ($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 public. More...
 
 getDepth ($a_node_id)
 return depth of a node in tree private More...
 
 getNodeTreeData ($a_node_id)
 return all columns of tabel tree More...
 
 getNodeData ($a_node_id, $a_tree_pk=null)
 get all information of a node. More...
 
 fetchNodeData ($a_row)
 get data of parent node from tree and object_data private More...
 
 isInTree ($a_node_id)
 get all information of a node. More...
 
 getParentNodeData ($a_node_id)
 get data of parent node from tree and object_data public More...
 
 isGrandChild ($a_startnode_id, $a_querynode_id)
 checks if a node is in the path of an other node public More...
 
 addTree ($a_tree_id, $a_node_id=-1)
 create a new tree to do: ??? More...
 
 getNodeDataByType ($a_type)
 get nodes by type More...
 
 removeTree ($a_tree_id)
 remove an existing tree More...
 
 moveToTrash ($a_node_id, $a_set_deleted=false)
 Wrapper for saveSubTree. More...
 
 saveSubTree ($a_node_id, $a_set_deleted=false)
 Use the wrapper moveToTrash save subtree: delete a subtree (defined by node_id) to a new tree with $this->tree_id -node_id. More...
 
 isDeleted ($a_node_id)
 This is a wrapper for isSaved() with a more useful name. More...
 
 isSaved ($a_node_id)
 Use method isDeleted check if node is saved. More...
 
 preloadDeleted ($a_node_ids)
 Preload deleted information. More...
 
 getSavedNodeData ($a_parent_id)
 get data saved/deleted nodes More...
 
 getSavedNodeObjIds (array $a_obj_ids)
 get object id of saved/deleted nodes More...
 
 getParentId ($a_node_id)
 get parent id of given node public More...
 
 getLeftValue ($a_node_id)
 get left value of given node public More...
 
 getChildSequenceNumber ($a_node, $type="")
 get sequence number of node in sibling sequence public More...
 
 readRootId ()
 read root id from database More...
 
 getRootId ()
 get the root id of tree public More...
 
 setRootId ($a_root_id)
 
 getTreeId ()
 get tree id public More...
 
 setTreeId ($a_tree_id)
 set tree id public More...
 
 fetchSuccessorNode ($a_node_id, $a_type="")
 get node data of successor node More...
 
 fetchPredecessorNode ($a_node_id, $a_type="")
 get node data of predecessor node More...
 
 renumber ($node_id=1, $i=1)
 Wrapper for renumber. More...
 
 __renumber ($node_id=1, $i=1)
 This method is private. More...
 
 checkForParentType ($a_ref_id, $a_type, $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 ($a_node)
 Check for deleteTree() compares a subtree of a given node by checking lft, rgt against parent relation. More...
 
 __getSubTreeByParentRelation ($a_node_id, &$parent_childs)
 type $ilDB More...
 
 __validateSubtrees (&$lft_childs, $parent_childs)
 
 moveTree ($a_source_id, $a_target_id, $a_location=self::POS_LAST_NODE)
 Move Tree Implementation. More...
 
 getRbacSubtreeInfo ($a_endnode_id)
 This method is used for change existing objects and returns all necessary information for this action. More...
 
 getSubTreeQuery ($a_node_id, $a_fields=array(), $a_types='', $a_force_join_reference=false)
 Get tree subtree query. More...
 
 getSubTreeFilteredByObjIds ($a_node_id, array $a_obj_ids, array $a_fields=array())
 get all node ids in the subtree under specified node id, filter by object ids More...
 
 deleteNode ($a_tree_id, $a_node_id)
 
 lookupTrashedObjectTypes ()
 Lookup object types in trash type $ilDB. More...
 

Protected Attributes

 $db
 
- Protected Attributes inherited from ilTree
 $depth_cache = array()
 
 $parent_cache = array()
 
 $in_tree_cache = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from ilTree
static _removeEntry ($a_tree, $a_child, $a_db_table="tree")
 STATIC METHOD Removes a single entry from a tree. More...
 
- Data Fields inherited from ilTree
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
 
 $ilias
 
 $log
 
 $root_id
 
 $tree_id
 
 $table_tree
 
 $table_obj_data
 
 $table_obj_reference
 
 $ref_pk
 
 $obj_pk
 
 $tree_pk
 
 $gap
 
- Protected Member Functions inherited from ilTree
 fetchTranslationFromObjectDataCache ($a_obj_ids)
 Get translation data from object cache (trigger in object cache on preload) More...
 

Detailed Description

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
Version
Id
class.ilPersonalDesktopGUI.php 26976 2010-12-16 13:24:38Z akill

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ilTree\readRootId(), ilTree\setObjectTablePK(), ilTree\setReferenceTablePK(), ilTree\setTableNames(), and ilTree\setTreeTablePK().

21  {
22  global $DIC;
23 
24  $this->db = $DIC->database();
25  parent::__construct($a_tree_id, $a_root_id);
26 
27  $this->setTableNames('tree_workspace', 'object_data', 'object_reference_ws');
28  $this->setTreeTablePK('tree');
29  $this->setObjectTablePK('obj_id');
30  $this->setReferenceTablePK('wsp_id');
31 
32  // ilTree sets it to ROOT_FOLDER_ID if not given...
33  if (!$a_root_id) {
34  $this->readRootId();
35  }
36  }
global $DIC
Definition: saml.php:7
setObjectTablePK($a_column_name)
set column containing primary key in object table public
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
setReferenceTablePK($a_column_name)
set column containing primary key in reference table public
readRootId()
read root id from database
+ Here is the call graph for this function:

Member Function Documentation

◆ cascadingDelete()

ilWorkspaceTree::cascadingDelete ( )

Remove all tree and node data.

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

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

149  {
150  $root_id = $this->readRootId();
151  if (!$root_id) {
152  return;
153  }
154 
155  $root = $this->getNodeData($root_id);
156 
157  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
158  $access_handler = new ilWorkspaceAccessHandler($this);
159 
160  // delete node data
161  $nodes = $this->getSubTree($root);
162  foreach ($nodes as $node) {
163  $access_handler->removePermission($node["wsp_id"]);
164 
165  $object = ilObjectFactory::getInstanceByObjId($node["obj_id"], false);
166  if ($object) {
167  $object->delete();
168  }
169 
170  $this->deleteReference($node["wsp_id"]);
171  }
172 
173  $this->deleteTree($root);
174  }
Access handler for personal workspace.
deleteTree($a_node)
delete node and the whole subtree under this node public
deleteReference($a_node_id)
Delete object from reference table.
getNodeData($a_node_id, $a_tree_pk=null)
get all information of a node.
$root
Definition: sabredav.php:45
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getSubTree($a_node, $a_with_data=true, $a_type="")
get all nodes in the subtree under specified node
readRootId()
read root id from database
+ Here is the call graph for this function:

◆ createReference()

ilWorkspaceTree::createReference (   $a_object_id)

Create workspace reference for object.

Parameters
int$a_object_id
Returns
int node id

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

References $db, and $ilDB.

Referenced by ilWorkspaceExplorer\__construct(), createTreeForUser(), and insertObject().

45  {
46  $ilDB = $this->db;
47 
48  $next_id = $ilDB->nextId($this->table_obj_reference);
49 
50  $fields = array($this->ref_pk => array("integer", $next_id),
51  $this->obj_pk => array("integer", $a_object_id));
52 
53  $ilDB->insert($this->table_obj_reference, $fields);
54 
55  return $next_id;
56  }
global $ilDB
+ Here is the caller graph for this function:

◆ createTreeForUser()

ilWorkspaceTree::createTreeForUser (   $a_user_id)

Create personal workspace tree for user.

Parameters
int$a_user_id

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

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

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

198  {
200  $root = new $root(null);
201  $root->create();
202 
203  $root_id = $this->createReference($root->getId());
204  $this->addTree($a_user_id, $root_id);
205  $this->setRootId($root_id);
206  }
static getClassByType($a_obj_type)
Get class by type.
createReference($a_object_id)
Create workspace reference for object.
setRootId($a_root_id)
$root
Definition: sabredav.php:45
addTree($a_tree_id, $a_node_id=-1)
create a new tree to do: ???
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteReference()

ilWorkspaceTree::deleteReference (   $a_node_id)

Delete object from reference table.

Parameters
int$a_node_id
Returns
bool

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

References $db, $ilDB, and $query.

Referenced by cascadingDelete().

137  {
138  $ilDB = $this->db;
139 
140  $query = "DELETE FROM " . $this->table_obj_reference .
141  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer");
142  return $ilDB->manipulate($query);
143  }
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getObjectsFromType()

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

Get all workspace objects of specific type.

Parameters
string$a_type
bool$a_with_data
Returns
array

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

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

184  {
185  return $this->getSubTree(
186  $this->getNodeData($this->getRootId()),
187  $a_with_data,
188  $a_type
189  );
190  }
$a_type
Definition: workflow.php:92
getRootId()
get the root id of tree public
getNodeData($a_node_id, $a_tree_pk=null)
get all information of a node.
getSubTree($a_node, $a_with_data=true, $a_type="")
get all nodes in the subtree under specified node
+ Here is the call graph for this function:

◆ insertObject()

ilWorkspaceTree::insertObject (   $a_parent_node_id,
  $a_object_id 
)

Add object to tree.

Parameters
int$a_parent_node_id
int$a_object_id
Returns
int node id

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

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

124  {
125  $node_id = $this->createReference($a_object_id);
126  $this->insertNode($node_id, $a_parent_node_id);
127  return $node_id;
128  }
createReference($a_object_id)
Create workspace reference for object.
insertNode($a_node_id, $a_parent_id, $a_pos=IL_LAST_NODE, $a_reset_deletion_date=false)
insert new node with node_id under parent node with parent_id public
+ Here is the call graph for this function:

◆ lookupNodeId()

ilWorkspaceTree::lookupNodeId (   $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 85 of file class.ilWorkspaceTree.php.

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

Referenced by ilNote\_getRelatedObjectsOfUser().

86  {
87  $ilDB = $this->db;
88 
89  $set = $ilDB->query("SELECT " . $this->ref_pk .
90  " FROM " . $this->table_obj_reference .
91  " WHERE " . $this->obj_pk . " = " . $ilDB->quote($a_obj_id, "integer"));
92  $res = $ilDB->fetchAssoc($set);
93 
94  return $res[$this->ref_pk];
95  }
foreach($_POST as $key=> $value) $res
global $ilDB
+ Here is the caller graph for this function:

◆ lookupObjectId()

ilWorkspaceTree::lookupObjectId (   $a_node_id)

Get object id for node id.

Parameters
int$a_node_id
Returns
int object id

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

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

Referenced by ilObject2GUI\__construct().

65  {
66  $ilDB = $this->db;
67 
68  $set = $ilDB->query("SELECT " . $this->obj_pk .
69  " FROM " . $this->table_obj_reference .
70  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer"));
71  $res = $ilDB->fetchAssoc($set);
72 
73  return $res[$this->obj_pk];
74  }
foreach($_POST as $key=> $value) $res
global $ilDB
+ Here is the caller graph for this function:

◆ lookupOwner()

ilWorkspaceTree::lookupOwner (   $a_node_id)

Get owner for node id.

Parameters
int$a_node_id
Returns
int object id

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

References $db, $ilDB, and $res.

104  {
105  $ilDB = $this->db;
106 
107  $set = $ilDB->query("SELECT tree" .
108  " FROM " . $this->table_obj_reference .
109  " JOIN " . $this->table_tree . " ON (" . $this->table_obj_reference . "." . $this->ref_pk . " = " . $this->table_tree . ".child)" .
110  " WHERE " . $this->ref_pk . " = " . $ilDB->quote($a_node_id, "integer"));
111  $res = $ilDB->fetchAssoc($set);
112 
113  return $res["tree"];
114  }
foreach($_POST as $key=> $value) $res
global $ilDB

Field Documentation

◆ $db

ilWorkspaceTree::$db
protected

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