25 require_once
"./Services/Object/classes/class.ilObject.php";
26 require_once
"Services/WebDAV/classes/class.ilObjNull.php";
76 public function lockRef($refId, $iliasUserId, $davUser, $token, $expires, $depth, $scope)
78 $this->
writelog(
'lockRef(' . $refId .
',' . $iliasUserId .
',' . $davUser .
',' . $token .
',' . $expires .
',' . $depth .
',' . $scope .
')');
84 $data = $tree->getNodeData($refId);
90 if ($scope ==
'exclusive' && count($locksOnPath) > 0) {
91 $result =
'couldnt create exclusive lock due to existing lock on path ' . var_export($locksOnPath,
true);
94 foreach ($locksOnPath as $lock) {
95 if ($lock[
'token'] == $token &&
96 $lock[
'obj_id'] ==
$data[
'obj_id'] &&
97 $lock[
'ilias_owner'] == $iliasUserId) {
101 return 'couldnt update lock';
107 foreach ($locksOnPath as $lock) {
108 if ($lock[
'scope'] ==
'exclusive' &&
109 ($lock[
'depth'] ==
'infinity' || $lock[
'obj_id'] ==
$data[
'obj_id']) &&
110 $lock[
'ilias_owner'] != $iliasUserId) {
111 $result =
'couldnt create lock due to exclusive lock on path ' . var_export($lock,
true);
119 if (
$result ===
true && $depth ==
'infinity') {
162 $objId = $objDAV->getObjectId();
163 $nodeId = $objDAV->getNodeId();
165 return $this->
lockWithoutCheckingObj($objId, $nodeId, $iliasUserId, $davUser, $token, $expires, $depth, $scope);
194 $ilDB = $DIC[
'ilDB'];
197 case 'infinity': $depth = -1;
203 trigger_error(
'invalid depth ' . $depth, E_ERROR);
208 case 'exclusive': $scope =
'x';
break;
209 case 'shared': $scope =
's';
break;
210 default: trigger_error(
'invalid scope ' . $scope, E_ERROR);
return;
213 $q =
'INSERT INTO ' . $this->table
214 .
' SET obj_id = ' .
$ilDB->quote($objId,
'integer')
215 .
', node_id = ' .
$ilDB->quote($nodeId,
'integer')
216 .
', ilias_owner = ' .
$ilDB->quote($iliasUserId,
'text')
217 .
', dav_owner = ' .
$ilDB->quote($davUser,
'text')
218 .
', token = ' .
$ilDB->quote($token,
'text')
219 .
', expires = ' .
$ilDB->quote($expires,
'integer')
220 .
', depth = ' .
$ilDB->quote($depth,
'integer')
222 .
', scope = ' .
$ilDB->quote($scope,
'text')
224 $this->
writelog(
'lock query=' . $q);
242 $ilDB = $DIC[
'ilDB'];
243 $objId = $objDAV->getObjectId();
244 $nodeId = $objDAV->getNodeId();
262 $ilDB = $DIC[
'ilDB'];
264 $q =
'UPDATE ' . $this->table
265 .
' SET expires = ' .
$ilDB->quote($expires,
'integer')
266 .
' WHERE token = ' .
$ilDB->quote($token,
'text')
267 .
' AND obj_id = ' .
$ilDB->quote($objId,
'integer')
268 .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer')
270 $aff =
$ilDB->manipulate($q);
287 $ilDB = $DIC[
'ilDB'];
288 $this->
writelog(
'unlock(' . $objDAV .
',' . $token .
')');
290 $objId = $objDAV->getObjectId();
291 $nodeId = $objDAV->getNodeId();
296 $q =
'DELETE FROM ' . $this->table
297 .
' WHERE token = ' .
$ilDB->quote($token,
'text')
298 .
' AND obj_id = ' .
$ilDB->quote($objId,
'integer')
299 .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer')
301 $this->
writelog(
'unlock query=' . $q);
302 $aff =
$ilDB->manipulate($q);
306 $random = new \ilRandom();
307 if ($random->int(1, 100) == 1) {
331 $ilDB = $DIC[
'ilDB'];
332 $this->
writelog(
'getLocks(' . $objDAV .
')');
333 $objId = $objDAV->getObjectId();
334 $nodeId = $objDAV->getNodeId();
336 $q =
'SELECT ilias_owner, dav_owner, expires, depth, scope' 337 .
' FROM ' . $this->table
338 .
' WHERE obj_id = ' .
$ilDB->quote($objId,
'integer')
339 .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer')
340 .
' AND token = ' .
$ilDB->quote($token,
'text')
342 $this->
writelog(
'getLocks(' . $objDAV .
') query=' . $q);
347 if (
$row[
'depth'] == -1) {
348 $row[
'depth'] =
'infinity';
350 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
351 $row[
'token'] = $token;
372 $objId = $objDAV->getObjectId();
373 $nodeId = $objDAV->getNodeId();
396 $ilDB = $DIC[
'ilDB'];
397 $this->
writelog(
'getLocks(' . $objDAV .
')');
399 $q =
'SELECT ilias_owner, dav_owner, token, expires, depth, scope' 400 .
' FROM ' . $this->table
401 .
' WHERE obj_id = ' .
$ilDB->quote($objId,
'integer')
402 .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer')
403 .
' AND expires > ' .
$ilDB->quote(
time(),
'integer')
405 $this->
writelog(
'getLocks(' . $objDAV .
') query=' . $q);
410 if (
$row[
'depth'] == -1) {
411 $row[
'depth'] =
'infinity';
413 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
436 $ilDB = $DIC[
'ilDB'];
437 $this->
writelog(
'getLocksOnPathDAV');
439 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope' 440 .
' FROM ' . $this->table
441 .
' WHERE expires > ' .
$ilDB->quote(
time(),
'integer')
445 foreach ($pathDAV as $objDAV) {
446 $objId = $objDAV->getObjectId();
447 $nodeId = $objDAV->getNodeId();
453 $q .=
'(obj_id = ' .
$ilDB->quote($objId,
'integer') .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer') .
')';
457 $this->
writelog(
'getLocksOnPathDAV(' . $objDAV .
') query=' . $q);
462 if (
$row[
'depth'] == -1) {
463 $row[
'depth'] =
'infinity';
465 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
489 $ilDB = $DIC[
'ilDB'];
490 $tree = $DIC[
'tree'];
491 $this->
writelog(
'getLocksOnPathRef(' . $refId .
')');
493 $pathFull = $tree->getPathFull($refId);
495 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope' 496 .
' FROM ' . $this->table
497 .
' WHERE expires > ' .
$ilDB->quote(
time(),
'integer')
501 foreach ($pathFull as $pathItem) {
502 $objId = $pathItem[
'obj_id'];
509 $q .=
'(obj_id = ' .
$ilDB->quote($objId,
'integer') .
' AND node_id = ' .
$ilDB->quote($nodeId,
'integer') .
')';
513 $this->
writelog(
'getLocksOnPathRef(' . $refId .
') query=' . $q);
518 if (
$row[
'depth'] == -1) {
519 $row[
'depth'] =
'infinity';
521 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
534 $ilDB = $DIC[
'ilDB'];
535 $tree = $DIC[
'tree'];
540 .
' FROM ' . $this->table
541 .
' WHERE expires < ' .
$ilDB->quote(
$old,
'integer')
543 $ilDB->manipulate($q);
548 $q =
'SELECT dat.obj_id ' 549 .
' FROM object_data AS dat' 550 .
' LEFT JOIN ' . $this->table .
' lck' 551 .
' ON dat.obj_id = lck.obj_id' 552 .
' WHERE dat.type = ' .
$ilDB->quote(
'null',
'text')
553 .
' AND lck.obj_id IS NULL' 561 if (count($references) == 0) {
564 foreach ($references as $refId) {
565 $obj->setRefId($refId);
567 $nodeData = $tree->getNodeData($refId);
568 $tree->deleteTree($nodeData);
583 $ilias = $DIC[
'ilias'];
584 if ($this->isDebug) {
586 $ilias->account->getLogin()
587 .
' DAV ilDAVLocks.' . str_replace(
"\n",
";",
$message)
updateLockWithoutCheckingObj($objId, $nodeId, $token, $expires)
Updates a write lock.
$isDebug
Set this to true, to get debug output in the ILIAS log.
lockWithoutCheckingObj($objId, $nodeId, $iliasUserId, $davUser, $token, $expires, $depth, $scope)
Creates a write lock.
unlockWithoutCheckingDAV(&$objDAV, $token)
Discards a write lock.
updateLockWithoutCheckingDAV(&$objDAV, $token, $expires)
Updates a write lock.
getLocksOnPathRef($refId)
Returns all locks on the specified object, specified by a reference id.
writelog($message)
Writes a message to the logfile.,.
getLocksOnObjectObj($objId, $nodeId=0)
Returns all locks on the specified object id.
static _getAllReferences($a_id)
get all reference ids of object
lockRef($refId, $iliasUserId, $davUser, $token, $expires, $depth, $scope)
Creates a lock an object, unless there are locks on the object or its parents, which prevent the crea...
cleanUp()
System maintenance: get rid of locks that have expired over an hour ago.
catch(Exception $e) $message
getLocksOnPathDAV(&$pathDAV)
Returns all locks on the specified object path.
lockWithoutCheckingDAV(&$objDAV, $iliasUserId, $davUser, $token, $expires, $depth, $scope)
Creates a write lock.
Create styles array
The data for the language used.
getLockDAV(&$objDAV, $token)
Returns the lock with the specified token on the specified DAV object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
isError($data, $code=null)
Tell whether a value is a PEAR error.
getLocksOnObjectDAV(&$objDAV)
Returns all locks on the specified object.