25 require_once
"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')
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')
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.
')');
397 $q =
'SELECT ilias_owner, dav_owner, token, expires, depth, scope'
398 .
' FROM '.$this->table
399 .
' WHERE obj_id = '.$ilDB->quote($objId,
'integer')
400 .
' AND node_id = '.$ilDB->quote($nodeId,
'integer')
401 .
' AND expires > '.$ilDB->quote(time(),
'integer')
403 $this->
writelog(
'getLocks('.$objDAV.
') query='.
$q);
404 $r = $ilDB->query(
$q);
409 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
410 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
433 $this->
writelog(
'getLocksOnPathDAV');
435 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope'
436 .
' FROM '.$this->table
437 .
' WHERE expires > '.$ilDB->quote(time(),
'integer')
441 foreach ($pathDAV as $objDAV)
443 $objId = $objDAV->getObjectId();
444 $nodeId = $objDAV->getNodeId();
451 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.$ilDB->quote($nodeId,
'integer').
')';
455 $this->
writelog(
'getLocksOnPathDAV('.$objDAV.
') query='.
$q);
456 $r = $ilDB->query(
$q);
461 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
462 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
486 $this->
writelog(
'getLocksOnPathRef('.$refId.
')');
488 $pathFull = $tree->getPathFull($refId);
490 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope'
491 .
' FROM '.$this->table
492 .
' WHERE expires > '.$ilDB->quote(time(),
'integer')
496 foreach ($pathFull as $pathItem)
498 $objId = $pathItem[
'obj_id'];
506 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.$ilDB->quote($nodeId,
'integer').
')';
510 $this->
writelog(
'getLocksOnPathRef('.$refId.
') query='.
$q);
511 $r = $ilDB->query(
$q);
516 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
517 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
532 $old = time() - 3600;
534 .
' FROM '.$this->table
535 .
' WHERE expires < '.$ilDB->quote($old,
'integer')
537 $ilDB->manipulate(
$q);
542 $q =
'SELECT dat.obj_id '
543 .
' FROM object_data AS dat'
544 .
' LEFT JOIN '.$this->table.
' lck'
545 .
' ON dat.obj_id = lck.obj_id'
546 .
' WHERE dat.type = '.$ilDB->quote(
'null',
'text')
547 .
' AND lck.obj_id IS NULL'
551 $r = $ilDB->query(
$q);
556 if (count($references) == 0)
560 foreach ($references as $refId)
562 $obj->setRefId($refId);
564 $nodeData = $tree->getNodeData($refId);
565 $tree->deleteTree($nodeData);
582 $ilias->account->getLogin()
583 .
' DAV ilDAVLocks.'.str_replace(
"\n",
";",$message)