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)
96 if ($lock[
'token'] == $token &&
97 $lock[
'obj_id'] ==
$data[
'obj_id'] &&
98 $lock[
'ilias_owner'] == $iliasUserId)
106 return 'couldnt update lock';
113 foreach ($locksOnPath as $lock)
115 if ($lock[
'scope'] ==
'exclusive' &&
116 ($lock[
'depth'] ==
'infinity' || $lock[
'obj_id'] ==
$data[
'obj_id']) &&
117 $lock[
'ilias_owner'] != $iliasUserId)
119 $result =
'couldnt create lock due to exclusive lock on path '.var_export($lock,
true);
127 if (
$result ===
true && $depth ==
'infinity')
136 $iliasUserId, $davUser, $token, $expires, $depth, $scope
166 $objId = $objDAV->getObjectId();
167 $nodeId = $objDAV->getNodeId();
169 return $this->
lockWithoutCheckingObj($objId, $nodeId, $iliasUserId, $davUser, $token, $expires, $depth, $scope);
198 $ilDB = $DIC[
'ilDB'];
202 case 'infinity' : $depth = -1;
208 trigger_error(
'invalid depth '.$depth,E_ERROR);
214 case 'exclusive' : $scope =
'x';
break;
215 case 'shared' : $scope =
's';
break;
216 default : trigger_error(
'invalid scope '.$scope,E_ERROR);
return;
219 $q =
'INSERT INTO '.$this->table
220 .
' SET obj_id = '.
$ilDB->quote($objId,
'integer')
221 .
', node_id = '.
$ilDB->quote($nodeId,
'integer')
222 .
', ilias_owner = '.
$ilDB->quote($iliasUserId,
'text')
223 .
', dav_owner = '.
$ilDB->quote($davUser,
'text')
224 .
', token = '.
$ilDB->quote($token,
'text')
225 .
', expires = '.
$ilDB->quote($expires,
'integer')
226 .
', depth = '.
$ilDB->quote($depth,
'integer')
228 .
', scope = '.
$ilDB->quote($scope,
'text')
248 $ilDB = $DIC[
'ilDB'];
249 $objId = $objDAV->getObjectId();
250 $nodeId = $objDAV->getNodeId();
268 $ilDB = $DIC[
'ilDB'];
270 $q =
'UPDATE '.$this->table
271 .
' SET expires = '.
$ilDB->quote($expires,
'integer')
272 .
' WHERE token = '.
$ilDB->quote($token,
'text')
273 .
' AND obj_id = '.
$ilDB->quote($objId,
'integer')
274 .
' AND node_id = '.
$ilDB->quote($nodeId,
'integer')
276 $aff =
$ilDB->manipulate($q);
293 $ilDB = $DIC[
'ilDB'];
294 $this->
writelog(
'unlock('.$objDAV.
','.$token.
')');
296 $objId = $objDAV->getObjectId();
297 $nodeId = $objDAV->getNodeId();
302 $q =
'DELETE FROM '.$this->table
303 .
' WHERE token = '.
$ilDB->quote($token,
'text')
304 .
' AND obj_id = '.
$ilDB->quote($objId,
'integer')
305 .
' AND node_id = '.
$ilDB->quote($nodeId,
'integer')
307 $this->
writelog(
'unlock query='.$q);
308 $aff =
$ilDB->manipulate($q);
312 if (rand(1,100) == 1)
337 $ilDB = $DIC[
'ilDB'];
338 $this->
writelog(
'getLocks('.$objDAV.
')');
339 $objId = $objDAV->getObjectId();
340 $nodeId = $objDAV->getNodeId();
342 $q =
'SELECT ilias_owner, dav_owner, expires, depth, scope' 343 .
' FROM '.$this->table
344 .
' WHERE obj_id = '.
$ilDB->quote($objId,
'integer')
345 .
' AND node_id = '.
$ilDB->quote($nodeId,
'integer')
346 .
' AND token = '.
$ilDB->quote($token,
'text')
348 $this->
writelog(
'getLocks('.$objDAV.
') query='.$q);
354 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
355 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
356 $row[
'token'] = $token;
377 $objId = $objDAV->getObjectId();
378 $nodeId = $objDAV->getNodeId();
401 $ilDB = $DIC[
'ilDB'];
402 $this->
writelog(
'getLocks('.$objDAV.
')');
404 $q =
'SELECT ilias_owner, dav_owner, token, expires, depth, scope' 405 .
' FROM '.$this->table
406 .
' WHERE obj_id = '.
$ilDB->quote($objId,
'integer')
407 .
' AND node_id = '.
$ilDB->quote($nodeId,
'integer')
408 .
' AND expires > '.
$ilDB->quote(
time(),
'integer')
410 $this->
writelog(
'getLocks('.$objDAV.
') query='.$q);
416 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
417 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
440 $ilDB = $DIC[
'ilDB'];
441 $this->
writelog(
'getLocksOnPathDAV');
443 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope' 444 .
' FROM '.$this->table
445 .
' WHERE expires > '.
$ilDB->quote(
time(),
'integer')
449 foreach ($pathDAV as $objDAV)
451 $objId = $objDAV->getObjectId();
452 $nodeId = $objDAV->getNodeId();
459 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.
$ilDB->quote($nodeId,
'integer').
')';
463 $this->
writelog(
'getLocksOnPathDAV('.$objDAV.
') query='.$q);
469 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
470 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
494 $ilDB = $DIC[
'ilDB'];
495 $tree = $DIC[
'tree'];
496 $this->
writelog(
'getLocksOnPathRef('.$refId.
')');
498 $pathFull = $tree->getPathFull($refId);
500 $q =
'SELECT obj_id, node_id, ilias_owner, dav_owner, token, expires, depth, scope' 501 .
' FROM '.$this->table
502 .
' WHERE expires > '.
$ilDB->quote(
time(),
'integer')
506 foreach ($pathFull as $pathItem)
508 $objId = $pathItem[
'obj_id'];
516 $q .=
'(obj_id = '.$ilDB->quote($objId,
'integer').
' AND node_id = '.
$ilDB->quote($nodeId,
'integer').
')';
520 $this->
writelog(
'getLocksOnPathRef('.$refId.
') query='.$q);
526 if (
$row[
'depth'] == -1)
$row[
'depth'] =
'infinity';
527 $row[
'scope'] = (
$row[
'scope'] ==
'x') ?
'exclusive' :
'shared';
540 $ilDB = $DIC[
'ilDB'];
541 $tree = $DIC[
'tree'];
546 .
' FROM '.$this->table
547 .
' WHERE expires < '.
$ilDB->quote(
$old,
'integer')
549 $ilDB->manipulate($q);
554 $q =
'SELECT dat.obj_id ' 555 .
' FROM object_data AS dat' 556 .
' LEFT JOIN '.$this->table.
' lck' 557 .
' ON dat.obj_id = lck.obj_id' 558 .
' WHERE dat.type = '.
$ilDB->quote(
'null',
'text')
559 .
' AND lck.obj_id IS NULL' 568 if (count($references) == 0)
572 foreach ($references as $refId)
574 $obj->setRefId($refId);
576 $nodeData = $tree->getNodeData($refId);
577 $tree->deleteTree($nodeData);
592 $ilias = $DIC[
'ilias'];
596 $ilias->account->getLogin()
597 .
' 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.
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.