ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilWebDAVLocksBackend Class Reference
+ Inheritance diagram for ilWebDAVLocksBackend:
+ Collaboration diagram for ilWebDAVLocksBackend:

Public Member Functions

 __construct (protected ilWebDAVLocksRepository $wedav_locks_repository, protected ilWebDAVRepositoryHelper $webdav_repository_helper, protected ilWebDAVObjFactory $webdav_object_factory, protected ilWebDAVLockUriPathResolver $webdav_path_resolver, protected ilObjUser $user)
 
 getLocks ($uri, $returnChildLocks)
 
 unlock ($uri, LockInfo $lockInfo)
 
 lock ($uri, LockInfo $lock_info)
 
 getLocksOnObjectId (int $obj_id)
 

Protected Member Functions

 getLocksRecursive (array $sabre_locks, int $ref_id, string $uri)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVLocksBackend::__construct ( protected ilWebDAVLocksRepository  $wedav_locks_repository,
protected ilWebDAVRepositoryHelper  $webdav_repository_helper,
protected ilWebDAVObjFactory  $webdav_object_factory,
protected ilWebDAVLockUriPathResolver  $webdav_path_resolver,
protected ilObjUser  $user 
)

Definition at line 32 of file class.ilWebDAVLocksBackend.php.

38  {
39  }

Member Function Documentation

◆ getLocks()

ilWebDAVLocksBackend::getLocks (   $uri,
  $returnChildLocks 
)
Parameters
string$uri
bool$returnChildLocks
Returns
LockInfo[]

Definition at line 46 of file class.ilWebDAVLocksBackend.php.

References $ref_id, getLocksOnObjectId(), and getLocksRecursive().

46  : array
47  {
48  $sabre_locks = [];
49 
50  try {
51  $ref_id = $this->webdav_path_resolver->getRefIdForWebDAVPath($uri);
52 
53  $obj_id = $this->webdav_repository_helper->getObjectIdFromRefId($ref_id);
54  $lock_on_obj = $this->getLocksOnObjectId($obj_id);
55 
56  if (!is_null($lock_on_obj)) {
57  $sabre_locks[] = $lock_on_obj->getAsSabreDavLock($uri);
58  }
59 
60  if ($returnChildLocks) {
61  $sabre_locks = $this->getLocksRecursive($sabre_locks, $ref_id, $uri);
62  }
63  } catch (NotFound) {
64  return [];
65  }
66 
67  return $sabre_locks;
68  }
getLocksRecursive(array $sabre_locks, int $ref_id, string $uri)
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ getLocksOnObjectId()

ilWebDAVLocksBackend::getLocksOnObjectId ( int  $obj_id)

Definition at line 149 of file class.ilWebDAVLocksBackend.php.

Referenced by getLocks(), and getLocksRecursive().

150  {
151  // return null;
152  try {
153  return $this->wedav_locks_repository->getLockObjectWithObjIdFromDB($obj_id);
154  } catch (Exception) {
155  }
156  }
+ Here is the caller graph for this function:

◆ getLocksRecursive()

ilWebDAVLocksBackend::getLocksRecursive ( array  $sabre_locks,
int  $ref_id,
string  $uri 
)
protected
Parameters
LockInfo[]$sabre_locks
Returns
LockInfo[]

Definition at line 74 of file class.ilWebDAVLocksBackend.php.

References getLocksOnObjectId().

Referenced by getLocks().

74  : array
75  {
76  foreach ($this->webdav_repository_helper->getChildrenOfRefId($ref_id) as $child_ref) {
77  try {
78  $child_obj_id = $this->webdav_repository_helper->getObjectIdFromRefId($child_ref);
79  $child_obj = $this->webdav_object_factory->retrieveDAVObjectByRefID($child_ref);
80 
81  $child_ilias_lock = $this->getLocksOnObjectId($child_obj_id);
82  if (!is_null($child_ilias_lock)) {
83  $sabre_locks[] = $child_ilias_lock->getAsSabreDavLock($uri . '/' . $child_obj->getName());
84  }
85 
86  $sabre_locks = $this->getLocksRecursive($sabre_locks, $child_ref, $uri . $child_obj->getName() . '/');
88  }
89  }
90 
91  return $sabre_locks;
92  }
getLocksRecursive(array $sabre_locks, int $ref_id, string $uri)
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock()

ilWebDAVLocksBackend::lock (   $uri,
LockInfo  $lock_info 
)

See also
::lock()

Definition at line 116 of file class.ilWebDAVLocksBackend.php.

References Vendor\Package\$e, and $ref_id.

116  : bool
117  {
118  try {
119  $ref_id = $this->webdav_path_resolver->getRefIdForWebDAVPath($uri);
120 
121  if ($ref_id > 0 && $this->webdav_repository_helper->checkAccess('write', $ref_id)) {
122  $obj_id = $this->webdav_repository_helper->getObjectIdFromRefId($ref_id);
123  $ilias_lock = new ilWebDAVLockObject(
124  $lock_info->token,
125  $obj_id,
126  $this->user->getId(),
127  $lock_info->owner,
128  time() + 360,
129  $lock_info->depth,
130  'w',
131  $lock_info->scope
132  );
133  $this->wedav_locks_repository->saveLockToDB($ilias_lock);
134  return true;
135  }
136 
137  return false;
138  // throw new Exception\Forbidden();
139  } catch (NotFound $e) {
140  if ($e->getCode() == -1) {
141  return false;
142  }
143 
144  throw $e;
145  }
146  return false;
147  }
$ref_id
Definition: ltiauth.php:65

◆ unlock()

ilWebDAVLocksBackend::unlock (   $uri,
LockInfo  $lockInfo 
)

See also
::unlock()

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

References ILIAS\Repository\user().

98  : bool
99  {
100  $ilias_lock = $this->wedav_locks_repository->getLockObjectWithTokenFromDB($lockInfo->token);
101 
102  if (!is_null($ilias_lock) && $ilias_lock->getIliasOwner() === $this->user->getId()) {
103  $this->wedav_locks_repository->removeLockWithTokenFromDB($lockInfo->token);
104  return true;
105  }
106  return false;
107 
108  throw new Forbidden();
109  }
+ Here is the call graph for this function:

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