/** * WebDAV HTTP COPY method * * This method copies one uri to a different uri, and works much like the MOVE request * A lot of the actual request processing is done in getCopyMoveInfo * * @param string $uri * @return bool */ protected function httpCopy($uri) { $copyInfo = $this->getCopyAndMoveInfo(); // If the destination is part of the source tree, we must fail if ($copyInfo['destination'] == $uri) { throw new Sabre_DAV_Exception_Forbidden('Source and destination uri are identical.'); } if (strpos($copyInfo['destination'], $uri) === 0) { throw new Sabre_DAV_Exception_Forbidden('destination is part of the source tree.'); } if ($this->tree->nodeExists($uri) == false) { throw new Sabre_DAV_Exception_NotFound('Source doesn\'t exists.'); } if ($copyInfo['destinationExists']) { if (!$this->broadcastEvent('beforeUnbind', array($copyInfo['destination']))) { return false; } $this->tree->delete($copyInfo['destination']); } if (!$this->broadcastEvent('beforeBind', array($copyInfo['destination']))) { return false; } $this->tree->copy($uri, $copyInfo['destination']); $this->broadcastEvent('afterBind', array($copyInfo['destination'])); // If a resource was overwritten we should send a 204, otherwise a 201 $this->httpResponse->setHeader('Content-Length', '0'); $this->httpResponse->sendStatus($copyInfo['destinationExists'] ? 204 : 201); }
/** * WebDAV HTTP COPY method * * This method copies one uri to a different uri, and works much like the MOVE request * A lot of the actual request processing is done in getCopyMoveInfo * * @param string $uri * @return void */ protected function httpCopy($uri) { $copyInfo = $this->getCopyAndMoveInfo(); if ($copyInfo['destinationExists']) { if (!$this->broadcastEvent('beforeUnbind', array($copyInfo['destination']))) { return false; } $this->tree->delete($copyInfo['destination']); } if (!$this->broadcastEvent('beforeBind', array($copyInfo['destination']))) { return false; } $this->tree->copy($uri, $copyInfo['destination']); $this->broadcastEvent('afterBind', array($copyInfo['destination'])); // If a resource was overwritten we should send a 204, otherwise a 201 $this->httpResponse->setHeader('Content-Length', '0'); $this->httpResponse->sendStatus($copyInfo['destinationExists'] ? 204 : 201); }