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

Class ilWebDAVLockBackend. More...

+ Inheritance diagram for ilWebDAVLockBackend:
+ Collaboration diagram for ilWebDAVLockBackend:

Public Member Functions

 __construct ($db_manager=null, ilWebDAVRepositoryHelper $repo_helper=null)
 Constructor with dependency injection. More...
 
 getLocks ($uri, $returnChildLocks)
 This function returns all locks and child locks as SabreDAV lock objects It is needed for sabreDAV to see if there are any locks. More...
 
 unlock ($uri, Sabre\DAV\Locks\LockInfo $lockInfo)
 
 lock ($uri, Sabre\DAV\Locks\LockInfo $lock_info)
 Function for the sabreDAV interface. More...
 
 getLocksOnObjectId (int $obj_id)
 Returns lock on given object. More...
 

Protected Member Functions

 getLocksRecursive ($sabre_locks, $ref_id, $uri)
 Iterates recursive through the ilias tree to search for locked objects. More...
 

Protected Attributes

 $db_manager
 
 $repo_helper
 
 $obj_dav_helper
 
 $uri_path_resolver
 

Detailed Description

Class ilWebDAVLockBackend.

Implementation for WebDAV locking mechanism. Extends the LockBackend from sabreDAV and saves sabreDAV locks as ILIAS locks to DB and returns ILIAS locks in DB as sabreDAV locks. Also removes existing locks

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

\DAV\Locks\Backend\AbstractBackend

Definition at line 16 of file class.ilWebDAVLockBackend.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVLockBackend::__construct (   $db_manager = null,
ilWebDAVRepositoryHelper  $repo_helper = null 
)

Constructor with dependency injection.

Parameters
unknown$db_manager
ilWebDAVRepositoryHelper | null$repo_helper

Definition at line 35 of file class.ilWebDAVLockBackend.php.

36 {
37 global $DIC;
38
39 $this->db_manager = $db_manager == null ? new ilWebDAVDBManager($DIC->database()) : $db_manager;
40 $this->repo_helper = $repo_helper == null ? new ilWebDAVRepositoryHelper($DIC->access(), $DIC->repositoryTree()) : $repo_helper;
41 $this->obj_dav_helper = new ilWebDAVObjDAVHelper($this->repo_helper);
42 $this->uri_path_resolver = new ilWebDAVUriPathResolver($this->repo_helper);
43 $this->user = $DIC->user();
44 }
user()
Definition: user.php:4
Class ilWebDAVDBManager.
Class ilWebDAVObjDAVHelper.
Class ilWebDAVRepositoryHelper.
Class ilWebDAVUriPathResolver.
global $DIC
Definition: goto.php:24

References $db_manager, $DIC, $repo_helper, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getLocks()

ilWebDAVLockBackend::getLocks (   $uri,
  $returnChildLocks 
)

This function returns all locks and child locks as SabreDAV lock objects It is needed for sabreDAV to see if there are any locks.

See also
\Sabre\DAV\Locks\Backend\BackendInterface::getLocks()

Definition at line 53 of file class.ilWebDAVLockBackend.php.

54 {
55 $sabre_locks = array();
56
57 // Get locks on given uri
58 try {
59 $ref_id = $this->uri_path_resolver->getRefIdForWebDAVPath($uri);
60
61 $obj_id = $this->repo_helper->getObjectIdFromRefId($ref_id);
62 $lock_on_obj = $this->getLocksOnObjectId($obj_id);
63
64 if ($lock_on_obj != false) {
65 $sabre_locks[] = $lock_on_obj->getAsSabreDavLock($uri);
66 }
67
68 // Get locks on childs
69 if ($returnChildLocks) {
70 $sabre_locks = $this->getLocksRecursive($sabre_locks, $ref_id, $uri);
71 }
72 } catch (Exception\NotFound $e) {
73 return $sabre_locks;
74 }
75
76 return $sabre_locks;
77 }
getLocksOnObjectId(int $obj_id)
Returns lock on given object.
getLocksRecursive($sabre_locks, $ref_id, $uri)
Iterates recursive through the ilias tree to search for locked objects.

References Vendor\Package\$e, getLocksOnObjectId(), and getLocksRecursive().

+ Here is the call graph for this function:

◆ getLocksOnObjectId()

ilWebDAVLockBackend::getLocksOnObjectId ( int  $obj_id)

Returns lock on given object.

Parameters
int$obj_id
Returns
array

Definition at line 159 of file class.ilWebDAVLockBackend.php.

160 {
161 try {
162 return $this->db_manager->getLockObjectWithObjIdFromDB($obj_id);
163 } catch (Exception $e) {
164 }
165 }

References Vendor\Package\$e.

Referenced by getLocks(), and getLocksRecursive().

+ Here is the caller graph for this function:

◆ getLocksRecursive()

ilWebDAVLockBackend::getLocksRecursive (   $sabre_locks,
  $ref_id,
  $uri 
)
protected

Iterates recursive through the ilias tree to search for locked objects.

Parameters
array$sabre_locks
integer$ref_id
string$uri
Returns
array

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

88 {
89 foreach ($this->repo_helper->getChildrenOfRefId($ref_id) as $child_ref) {
90 // Only get locks of DAVable objects. Because not DAVable objects won't be lockable anyway
91 $child_obj_id = $this->repo_helper->getObjectIdFromRefId($child_ref);
92 if ($this->obj_dav_helper->isDAVableObject($child_obj_id, false)) {
93 // Get Locks of this object
94 $title = $this->repo_helper->getObjectTitleFromObjId($child_obj_id, true);
95 $child_ilias_locks = $this->getLocksOnObjectId($child_obj_id);
96 if ($child_ilias_locks != false) {
97 foreach ($child_ilias_locks as $lock) {
98 $sabre_locks[] = $lock->getAsSabreDavLock($uri . '/' . $title);
99 }
100 }
101
102 // Get locks of child objects
103 $sabre_locks = $this->getLocksRecursive($sabre_locks, $child_ref, $uri . $title . '/');
104 }
105 }
106
107 return $sabre_locks;
108 }

References getLocksOnObjectId(), and getLocksRecursive().

Referenced by getLocks(), and getLocksRecursive().

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

◆ lock()

ilWebDAVLockBackend::lock (   $uri,
Sabre\DAV\Locks\LockInfo  $lock_info 
)

Function for the sabreDAV interface.

See also
\Sabre\DAV\Locks\Backend\BackendInterface::lock()

Definition at line 131 of file class.ilWebDAVLockBackend.php.

132 {
133 try {
134 $ref_id = $this->uri_path_resolver->getRefIdForWebDAVPath($uri);
135
136 if ($ref_id > 0 && $this->repo_helper->checkAccess('write', $ref_id)) {
137 $obj_id = $this->repo_helper->getObjectIdFromRefId($ref_id);
138 $ilias_lock = ilWebDAVLockObject::createFromSabreLock($lock_info, $obj_id);
139 $this->db_manager->saveLockToDB($ilias_lock);
140 } else {
141 throw new Exception\Forbidden();
142 }
143 } catch (Exception\NotFound $e) {
144 if ($e->getCode() == -1) {
145 return;
146 } else {
147 throw $e;
148 }
149 }
150 }
static createFromSabreLock(Sabre\DAV\Locks\LockInfo $lock_info, $obj_id)
Creates an ILIAS lock object from a sabreDAV lock object.

References Vendor\Package\$e, and ilWebDAVLockObject\createFromSabreLock().

+ Here is the call graph for this function:

◆ unlock()

ilWebDAVLockBackend::unlock (   $uri,
Sabre\DAV\Locks\LockInfo  $lockInfo 
)

See also
\Sabre\DAV\Locks\Backend\BackendInterface::unlock()

Definition at line 114 of file class.ilWebDAVLockBackend.php.

115 {
116 $ilias_lock = $this->db_manager->getLockObjectWithTokenFromDB($lockInfo->token);
117
118 if ($ilias_lock && $ilias_lock->getIliasOwner() == $this->user->getId()) {
119 $this->db_manager->removeLockWithTokenFromDB($lockInfo->token);
120 } else {
121 throw new Exception\Forbidden();
122 }
123 }

Field Documentation

◆ $db_manager

ilWebDAVLockBackend::$db_manager
protected

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

Referenced by __construct().

◆ $obj_dav_helper

ilWebDAVLockBackend::$obj_dav_helper
protected

Definition at line 25 of file class.ilWebDAVLockBackend.php.

◆ $repo_helper

ilWebDAVLockBackend::$repo_helper
protected

Definition at line 22 of file class.ilWebDAVLockBackend.php.

Referenced by __construct().

◆ $uri_path_resolver

ilWebDAVLockBackend::$uri_path_resolver
protected

Definition at line 28 of file class.ilWebDAVLockBackend.php.


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