/** * LOCK method handler * * @param array general parameter passing array * @return bool true on success */ function LOCK(&$aOptions) { // get absolute fs path to requested resource $sFullPath = $this->absolutePath($aOptions["path"]); // TODO recursive locks on directories not supported yet if (is_dir($sFullPath) && !empty($aOptions["depth"])) { return "409 Conflict"; } if (!$this->hasWriteAccess($aOptions['path'])) { return '403 Forbidden'; } $aOptions["timeout"] = time() + 300; // 5min. hardcoded $aOptions['owner'] = Session::getSession()->getUser()->getUsername(); if (isset($aOptions["update"])) { // Lock Update $oCriteria = new Criteria(); $oCriteria->add(WebdavLockPeer::PATH, $aOptions[path]); $oCriteria->add(WebdavLockPeer::TOKEN, $aOptions[update]); $oLock = WebdavLockPeer::doSelectOne($oCriteria); if ($oLock === null) { return false; } $oLock->setExpiresAt($aOptions['timeout']); $aOptions['owner'] = $oLock->getUser()->getUsername(); $aOptions['scope'] = $oLock->getIsExclusive() ? "exclusive" : "shared"; $aOptions['type'] = $oLock->getIsExclusive() ? "write" : "read"; $oLock->save(); return true; } $oLock = new WebdavLock(); $oLock->setToken($aOptions['locktoken']); $oLock->setPath($aOptions['path']); $oLock->setExpiresAt($aOptions['timeout']); $oLock->setIsExclusive($aOptions['scope'] === "exclusive"); try { $oLock->save(); } catch (Exception $e) { return "409 Conflict"; } return "200 OK"; }