ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
- Public Member Functions inherited from Sabre\DAV\Locks\Backend\BackendInterface
 lock ($uri, Locks\LockInfo $lockInfo)
 Locks a uri. More...
 
 unlock ($uri, Locks\LockInfo $lockInfo)
 Removes a lock from a uri. 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$

Definition at line 24 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 43 of file class.ilWebDAVLockBackend.php.

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

44  {
45  global $DIC;
46 
47  $this->db_manager = $db_manager == null ? new ilWebDAVDBManager($DIC->database()) : $db_manager;
48  $this->repo_helper = $repo_helper == null ? new ilWebDAVRepositoryHelper($DIC->access(), $DIC->repositoryTree()) : $repo_helper;
49  $this->obj_dav_helper = new ilWebDAVObjDAVHelper($this->repo_helper);
50  $this->uri_path_resolver = new ilWebDAVUriPathResolver($this->repo_helper);
51  $this->user = $DIC->user();
52  }
global $DIC
Definition: saml.php:7
Class ilWebDAVRepositoryHelper.
user()
Definition: user.php:4
Class ilWebDAVObjDAVHelper.
Class ilWebDAVDBManager.
Class ilWebDAVUriPathResolver.
+ 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.

Returns a list of Sabre objects.This method should return all the locks for a particular uri, including locks that might be set on a parent uri.If returnChildLocks is set to true, this method should also look for any locks in the subtree of the uri for locks.

Parameters
string$uri
bool$returnChildLocks
Returns
array

See also
::getLocks()

Implements Sabre\DAV\Locks\Backend\BackendInterface.

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

References getLocksOnObjectId(), and getLocksRecursive().

62  {
63  $sabre_locks = array();
64 
65  // Get locks on given uri
66  try {
67  $ref_id = $this->uri_path_resolver->getRefIdForWebDAVPath($uri);
68 
69  $obj_id = $this->repo_helper->getObjectIdFromRefId($ref_id);
70  $lock_on_obj = $this->getLocksOnObjectId($obj_id);
71 
72  if ($lock_on_obj != false) {
73  $sabre_locks[] = $lock_on_obj->getAsSabreDavLock($uri);
74  }
75 
76  // Get locks on childs
77  if ($returnChildLocks) {
78  $sabre_locks = $this->getLocksRecursive($sabre_locks, $ref_id, $uri);
79  }
80  } catch (Exception\NotFound $e) {
81  return $sabre_locks;
82  }
83 
84  return $sabre_locks;
85  }
getLocksRecursive($sabre_locks, $ref_id, $uri)
Iterates recursive through the ilias tree to search for locked objects.
getLocksOnObjectId(int $obj_id)
Returns lock on given object.
+ 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 167 of file class.ilWebDAVLockBackend.php.

Referenced by getLocks(), and getLocksRecursive().

168  {
169  try {
170  return $this->db_manager->getLockObjectWithObjIdFromDB($obj_id);
171  } catch (Exception $e) {
172  }
173  }
+ 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 95 of file class.ilWebDAVLockBackend.php.

References $title, and getLocksOnObjectId().

Referenced by getLocks().

96  {
97  foreach ($this->repo_helper->getChildrenOfRefId($ref_id) as $child_ref) {
98  // Only get locks of DAVable objects. Because not DAVable objects won't be lockable anyway
99  $child_obj_id = $this->repo_helper->getObjectIdFromRefId($child_ref);
100  if ($this->obj_dav_helper->isDAVableObject($child_obj_id, false)) {
101  // Get Locks of this object
102  $title = $this->repo_helper->getObjectTitleFromObjId($child_obj_id, true);
103  $child_ilias_locks = $this->getLocksOnObjectId($child_obj_id);
104  if ($child_ilias_locks != false) {
105  foreach ($child_ilias_locks as $lock) {
106  $sabre_locks[] = $lock->getAsSabreDavLock($uri . '/' . $title);
107  }
108  }
109 
110  // Get locks of child objects
111  $sabre_locks = $this->getLocksRecursive($sabre_locks, $child_ref, $uri . $title . '/');
112  }
113  }
114 
115  return $sabre_locks;
116  }
getLocksRecursive($sabre_locks, $ref_id, $uri)
Iterates recursive through the ilias tree to search for locked objects.
getLocksOnObjectId(int $obj_id)
Returns lock on given object.
+ 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
::lock()

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

References ilWebDAVLockObject\createFromSabreLock().

140  {
141  try {
142  $ref_id = $this->uri_path_resolver->getRefIdForWebDAVPath($uri);
143 
144  if ($ref_id > 0 && $this->repo_helper->checkAccess('write', $ref_id)) {
145  $obj_id = $this->repo_helper->getObjectIdFromRefId($ref_id);
146  $ilias_lock = ilWebDAVLockObject::createFromSabreLock($lock_info, $obj_id);
147  $this->db_manager->saveLockToDB($ilias_lock);
148  } else {
149  throw new Exception\Forbidden();
150  }
151  } catch (Exception\NotFound $e) {
152  if ($e->getCode() == -1) {
153  return;
154  } else {
155  throw $e;
156  }
157  }
158  }
static createFromSabreLock(Sabre\DAV\Locks\LockInfo $lock_info, $obj_id)
Creates an ILIAS lock object from a sabreDAV lock object.
+ Here is the call graph for this function:

◆ unlock()

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

See also
::unlock()

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

References user().

123  {
124  $ilias_lock = $this->db_manager->getLockObjectWithTokenFromDB($lockInfo->token);
125 
126  if ($ilias_lock && $ilias_lock->getIliasOwner() == $this->user->getId()) {
127  $this->db_manager->removeLockWithTokenFromDB($lockInfo->token);
128  } else {
129  throw new Exception\Forbidden();
130  }
131  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

Field Documentation

◆ $db_manager

ilWebDAVLockBackend::$db_manager
protected

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

Referenced by __construct().

◆ $obj_dav_helper

ilWebDAVLockBackend::$obj_dav_helper
protected

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

◆ $repo_helper

ilWebDAVLockBackend::$repo_helper
protected

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

Referenced by __construct().

◆ $uri_path_resolver

ilWebDAVLockBackend::$uri_path_resolver
protected

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


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