/** * register an Lock-request * * @param string name */ public function registerLock($owner, $lktype, $lkscope, $lktoken = NULL, $filename = NULL, $timeout, $depth) { with($lockprop = new WebdavLock($filename)); $lockprop->setOwner($owner); $lockprop->setLockType($lktype); $lockprop->setLockScope($lkscope); $lockprop->setLockToken($lktoken); $lockprop->setTimeout($timeout); $lockprop->setDepth($depth); $this->properties = $lockprop; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param WebdavLock $value A WebdavLock object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(WebdavLock $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getToken(); } // if key === null self::$instances[$key] = $obj; } }
/** * 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"; }
/** * Exclude object from result * * @param WebdavLock $webdavLock Object to remove from the list of results * * @return WebdavLockQuery The current query, for fluid interface */ public function prune($webdavLock = null) { if ($webdavLock) { $this->addUsingAlias(WebdavLockPeer::TOKEN, $webdavLock->getToken(), Criteria::NOT_EQUAL); } return $this; }