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.
')');
82 $data = $tree->getNodeData($refId);
88 if ($scope ==
'exclusive' && count($locksOnPath) > 0) {
89 $result =
'couldnt create exclusive lock due to existing lock on path '.var_export($locksOnPath,
true);
92 foreach ($locksOnPath as $lock)
94 if ($lock[
'token'] == $token &&
95 $lock[
'obj_id'] ==
$data[
'obj_id'] &&
96 $lock[
'ilias_owner'] == $iliasUserId)
104 return 'couldnt update lock';
111 foreach ($locksOnPath as $lock)
113 if ($lock[
'scope'] ==
'exclusive' &&
114 ($lock[
'depth'] ==
'infinity' || $lock[
'obj_id'] ==
$data[
'obj_id']) &&
115 $lock[
'ilias_owner'] != $iliasUserId)
117 $result =
'couldnt create lock due to exclusive lock on path '.var_export($lock,
true);
125 if (
$result ===
true && $depth ==
'infinity')
134 $iliasUserId, $davUser, $token, $expires, $depth, $scope
164 $objId = $objDAV->getObjectId();
165 $nodeId = $objDAV->getNodeId();
167 return $this->
lockWithoutCheckingObj($objId, $nodeId, $iliasUserId, $davUser, $token, $expires, $depth, $scope);
199 case 'infinity' : $depth = -1;
205 trigger_error(
'invalid depth '.$depth,E_ERROR);
211 case 'exclusive' : $scope =
'x';
break;
212 case 'shared' : $scope =
's';
break;
213 default : trigger_error(
'invalid scope '.$scope,E_ERROR);
return;
216 $q =
'INSERT INTO '.$this->table
217 .
' SET obj_id = '.$ilDB->quote($objId,
'integer')
218 .
', node_id = '.$ilDB->quote($nodeId,
'integer')
219 .
', ilias_owner = '.$ilDB->quote($iliasUserId,
'text')
220 .
', dav_owner = '.$ilDB->quote($davUser,
'text')
221 .
', token = '.$ilDB->quote($token,
'text')
222 .
', expires = '.$ilDB->quote($expires,
'integer')
223 .
', depth = '.$ilDB->quote($depth,
'integer')
225 .
', scope = '.$ilDB->quote($scope,
'text')
228 $result = $ilDB->manipulate($q);
245 $objId = $objDAV->getObjectId();
246 $nodeId = $objDAV->getNodeId();
265 $q =
'UPDATE '.$this->table
266 .
' SET expires = '.$ilDB->quote($expires,
'integer')
267 .
' WHERE token = '.$ilDB->quote($token,
'text')
268 .
' AND obj_id = '.$ilDB->quote($objId,
'integer')
269 .
' AND node_id = '.$ilDB->quote($nodeId,
'integer')
271 $aff = $ilDB->manipulate($q);
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 if (rand(1,100) == 1)
331 $this->
writelog(
'getLocks('.$objDAV.
')');
332 $objId = $objDAV->getObjectId();
333 $nodeId = $objDAV->getNodeId();
335 $q =
'SELECT ilias_owner, dav_owner, expires, depth, scope'
336 .
' FROM '.$this->table
337 .
' WHERE obj_id = '.$ilDB->quote($objId,
'integer')
338 .
' AND node_id = '.$ilDB->quote($nodeId,
'integer')
339 .
' AND token = '.$ilDB->quote($token,
'text')
341 $this->
writelog(
'getLocks('.$objDAV.
') query='.$q);
342 $r = $ilDB->query($q);
347 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
348 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
349 $row[
'token'] = $token;
370 $objId = $objDAV->getObjectId();
371 $nodeId = $objDAV->getNodeId();
394 $this->
writelog(
'getLocks('.$objDAV.
')');
396 $q =
'SELECT ilias_owner, dav_owner, token, expires, depth, scope'
397 .
' FROM '.$this->table
398 .
' WHERE obj_id = '.$ilDB->quote($objId,
'integer')
399 .
' AND node_id = '.$ilDB->quote($nodeId,
'integer')
400 .
' AND expires > '.$ilDB->quote(time(),
'integer')
402 $this->
writelog(
'getLocks('.$objDAV.
') query='.$q);
403 $r = $ilDB->query($q);
408 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
409 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
432 $this->
writelog(
'getLocksOnPathDAV');
434 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope'
435 .
' FROM '.$this->table
436 .
' WHERE expires > '.$ilDB->quote(time(),
'integer')
440 foreach ($pathDAV as $objDAV)
442 $objId = $objDAV->getObjectId();
443 $nodeId = $objDAV->getNodeId();
450 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.$ilDB->quote($nodeId,
'integer').
')';
454 $this->
writelog(
'getLocksOnPathDAV('.$objDAV.
') query='.$q);
455 $r = $ilDB->query($q);
460 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
461 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
485 $this->
writelog(
'getLocksOnPathRef('.$refId.
')');
487 $pathFull = $tree->getPathFull($refId);
489 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope'
490 .
' FROM '.$this->table
491 .
' WHERE expires > '.$ilDB->quote(time(),
'integer')
495 foreach ($pathFull as $pathItem)
497 $objId = $pathItem[
'obj_id'];
505 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.$ilDB->quote($nodeId,
'integer').
')';
509 $this->
writelog(
'getLocksOnPathRef('.$refId.
') query='.$q);
510 $r = $ilDB->query($q);
515 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
516 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
531 $old = time() - 3600;
533 .
' FROM '.$this->table
534 .
' WHERE expires < '.$ilDB->quote($old,
'integer')
536 $ilDB->manipulate($q);
541 $q =
'SELECT dat.obj_id '
542 .
' FROM object_data AS dat'
543 .
' LEFT JOIN '.$this->table.
' lck'
544 .
' ON dat.obj_id = lck.obj_id'
545 .
' WHERE dat.type = '.$ilDB->quote(
'null',
'text')
546 .
' AND lck.obj_id IS NULL'
550 $r = $ilDB->query($q);
555 if (count($references) == 0)
559 foreach ($references as $refId)
561 $obj->setRefId($refId);
563 $nodeData = $tree->getNodeData($refId);
564 $tree->deleteTree($nodeData);
581 $ilias->account->getLogin()
582 .
' DAV ilDAVLocks.'.str_replace(
"\n",
";",$message)