ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWebDAVTree Class Reference

Class ilWebDAVTree. More...

+ Collaboration diagram for ilWebDAVTree:

Static Public Member Functions

static getInstance ()
 
static getRefIdForWebDAVPath ($a_uri)
 Returns the ref_id of the given webdav path. More...
 
static getRefIdForGivenRootAndPath (int $start_ref, string $path_from_startnode)
 

Static Protected Member Functions

static iterateRecursiveThroughTree ($path_title_array, $searched_element_index, $parent_ref_id)
 Recursive function to iterate through tree with given path. More...
 

Static Protected Attributes

static $instance
 

Detailed Description

Class ilWebDAVTree.

This class is used for manual tree traversal from a WebDAV-Request if it isn't handled by Sabre\DAV\Tree

Mostly used for lock and unlock calls. Might be refactored to be a substitute for Sabre\DAV\Tree in a future version.

Author
Raphael Heer rapha.nosp@m.el.h.nosp@m.eer@h.nosp@m.slu..nosp@m.ch $Id$

Definition at line 17 of file class.ilWebDAVTree.php.

Member Function Documentation

◆ getInstance()

static ilWebDAVTree::getInstance ( )
static

Definition at line 21 of file class.ilWebDAVTree.php.

22 {
23 if (!isset(self::$instance)) {
24 self::$instance = new self();
25 }
26 return self::$instance;
27 }

References $instance.

◆ getRefIdForGivenRootAndPath()

static ilWebDAVTree::getRefIdForGivenRootAndPath ( int  $start_ref,
string  $path_from_startnode 
)
static
Parameters
int$start_ref
string$path_from_startnode
Returns
int

Definition at line 98 of file class.ilWebDAVTree.php.

99 {
100 return self::iterateRecursiveThroughTree(explode('/', $path_from_startnode), 0, $start_ref);
101 }
static iterateRecursiveThroughTree($path_title_array, $searched_element_index, $parent_ref_id)
Recursive function to iterate through tree with given path.

References iterateRecursiveThroughTree().

Referenced by getRefIdForWebDAVPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefIdForWebDAVPath()

static ilWebDAVTree::getRefIdForWebDAVPath (   $a_uri)
static

Returns the ref_id of the given webdav path.

Path starts without php-script

Examples

Path starts at a ref: <client_name>/ref_<ref_id>/folder1/folder2 Path starts at root: <client_name>/ILIAS/foo_container1/course1/

Parameters
$a_uri
Returns
int|mixed
Exceptions
BadRequest
NotFound

Definition at line 42 of file class.ilWebDAVTree.php.

43 {
44 $a_uri = strtolower(trim($a_uri, '/'));
45
46 /* After this funciton, the array SHOULD look like this:
47 * $splitted_path[0] = '<client_name>'
48 * $splitted_path[1] = 'ref_<ref_id>' or <ilias_root_name>
49 * $splitted_path[2] = '<rest>/<of>/<the>/<path>
50 */
51 $splitted_path = explode('/', $a_uri, 3);
52
53 // Early exit for bad request
54 if (count($splitted_path) < 2) {
55 throw new BadRequest();
56 }
57
58 $repository_mountpoint = $splitted_path[1];
59 $path_in_mountpoint = $splitted_path[2];
60
61 // Since we already know our client, we only have to check the requested root for our path
62 // if second string = 'ilias', the request was for the ilias root
63 if ($repository_mountpoint == 'ilias') {
64 if ($path_in_mountpoint != '') {
65 $ref_path = self::getRefIdForGivenRootAndPath(ROOT_FOLDER_ID, $path_in_mountpoint);
66 $searched_node = $ref_path[count($ref_path) - 1];
67 $ref_id = $searched_node['child'];
68 } else {
69 $ref_id = ROOT_FOLDER_ID;
70 }
71 }
72 // if the first 4 letters are 'ref_', we are searching for a ref ID in the tree
73 elseif (substr($splitted_path[1], 0, 4) == 'ref_') {
74 // Make a 'ref_1234' to a '1234'
75 // Since we already tested for 'ref_', we can be sure there is at least one '_' character
76 $start_node = (int) explode('_', $repository_mountpoint)[1];
77 if ($path_in_mountpoint != '' && $start_node > 0) {
78 $ref_id = self::getRefIdForGivenRootAndPath($start_node, $path_in_mountpoint);
79 } elseif ($path_in_mountpoint == '') {
80 $ref_id = $start_node;
81 } else {
82 throw new NotFound();
83 }
84 }
85 // if there was no 'ilias' and no 'ref_' in the second string, this was a bad request...
86 else {
87 throw new BadRequest();
88 }
89
90 return $ref_id;
91 }
static getRefIdForGivenRootAndPath(int $start_ref, string $path_from_startnode)
const ROOT_FOLDER_ID
Definition: constants.php:30

References getRefIdForGivenRootAndPath(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ iterateRecursiveThroughTree()

static ilWebDAVTree::iterateRecursiveThroughTree (   $path_title_array,
  $searched_element_index,
  $parent_ref_id 
)
staticprotected

Recursive function to iterate through tree with given path.

Parameters
$path_title_arrayArray with all object titles in this path
$searched_element_indexIndex for the path_title_array which points to the searched obj title
$parent_ref_idRef ID of parent of the searched element
Returns
int

Definition at line 111 of file class.ilWebDAVTree.php.

112 {
113 global $DIC;
114
115 // Check if last element was already found
116 if ($path_title_array[$searched_element_index] == '' || count($path_title_array) == $searched_element_index) {
117 return $parent_ref_id;
118 }
119
120 // Search if any child of the given ref has the name of the given searched element
121 foreach ($DIC->repositoryTree()->getChildIds($parent_ref_id) as $child_ref) {
122 $child_obj_id = ilObject::_lookupObjectId($child_ref);
123 $child_title = strtolower(ilObject::_lookupTitle($child_obj_id));
124 if ($path_title_array[$searched_element_index] == $child_title) {
125 if (count($path_title_array) - 1 == $searched_element_index) {
126 // Last element found. Return ref_id
127 return $child_ref;
128 } else {
129 // Search next element in path
130 return self::iterateRecursiveThroughTree($path_title_array, $searched_element_index + 1, $child_ref);
131 }
132 }
133 }
134
135 return -1;
136 }
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
global $DIC
Definition: goto.php:24

References $DIC, ilObject\_lookupObjectId(), ilObject\_lookupTitle(), and iterateRecursiveThroughTree().

Referenced by getRefIdForGivenRootAndPath(), and iterateRecursiveThroughTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $instance

ilWebDAVTree::$instance
staticprotected

Definition at line 19 of file class.ilWebDAVTree.php.

Referenced by getInstance().


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