File dav/method/COPY.class.php

Last commit: Mon Nov 4 23:56:38 2019 +0100	Jan Dankert	Refactoring: Renaming WebDAV to DAV base class.
1 <?php 2 3 class DAV_COPY extends DAV 4 { 5 6 /** 7 * Kopieren eines Objektes.<br> 8 * Momentan ist nur das Kopieren einer Datei implementiert.<br> 9 * Das Kopieren von Ordnern, Verkn�pfungen und Seiten ist nicht moeglich. 10 */ 11 public function execute() 12 { 13 if ( $this->readonly || !$this->create ) 14 { 15 error_log('WEBDAV: COPY request, but readonly or no creating'); 16 $this->httpMethodNotAllowed(); 17 } 18 elseif( $this->obj == null ) 19 { 20 // Was nicht da ist, laesst sich auch nicht verschieben. 21 error_log('WEBDAV: COPY request, but Source not found'); 22 $this->httpMethodNotAllowed(); 23 } 24 elseif ( $this->destination == null ) 25 { 26 error_log('WEBDAV: COPY request, but no "Destination:"-Header'); 27 // $this->httpStatus('405 Not Allowed' ); 28 $this->httpStatus('412 Precondition failed'); 29 } 30 else 31 { 32 // URL parsen. 33 $dest = $this->destination; 34 $destinationProject = $dest['project']; 35 $destinationFolder = $dest['folder' ]; 36 $destinationObject = $dest['object' ]; 37 38 if ( $dest['type'] != 'object' ) 39 { 40 Logger::debug('WEBDAV: COPY request, but "Destination:"-Header mismatch'); 41 $this->httpMethodNotAllowed(); 42 } 43 elseif ( $this->project->projectid != $destinationProject->projectid ) 44 { 45 // Kopieren in anderes Projekt nicht moeglich. 46 Logger::debug('WEBDAV: COPY request denied, project does not match'); 47 $this->httpStatus('403 Forbidden'); 48 } 49 elseif ( $destinationObject != null ) 50 { 51 Logger::debug('WEBDAV: COPY request denied, Destination exists. Overwriting is not supported'); 52 $this->httpStatus('403 Forbidden'); 53 } 54 elseif ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) ) 55 { 56 $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht 57 } 58 elseif ( is_object($destinationObject) && $destinationObject->isFolder) 59 { 60 Logger::debug('WEBDAV: COPY request denied, Folder-Copy not implemented'); 61 $this->httpMethodNotAllowed(); 62 } 63 elseif ( is_object($destinationObject) && $destinationObject->isLink) 64 { 65 Logger::debug('WEBDAV: COPY request denied, Link copy not implemented'); 66 $this->httpMethodNotAllowed(); 67 } 68 elseif ( is_object($destinationObject) && $destinationObject->isPage) 69 { 70 Logger::debug('WEBDAV: COPY request denied, Page copy not implemented'); 71 $this->httpMethodNotAllowed(); 72 } 73 else 74 { 75 $f = new File(); 76 $f->filename = basename($_SERVER['HTTP_DESTINATION']); 77 $f->name = ''; 78 $f->parentid = $destinationFolder->objectid; 79 $f->projectid = $this->project->projectid; 80 $f->add(); 81 $f->copyValueFromFile( $this->obj->objectid ); 82 83 Logger::debug('WEBDAV: COPY request accepted' ); 84 // Objekt wird in anderen Ordner kopiert. 85 $this->httpStatus('201 Created' ); 86 } 87 } 88 89 } 90 91 92 }
Download dav/method/COPY.class.php
History Mon, 4 Nov 2019 23:56:38 +0100 Jan Dankert Refactoring: Renaming WebDAV to DAV base class. Mon, 4 Nov 2019 23:54:13 +0100 Jan Dankert Refactoring: Splitting DAV methods into single files.