File dav/method/MOVE.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_MOVE extends DAV 4 { 5 /** 6 * Verschieben eines Objektes.<br> 7 * <br> 8 * Folgende Operationen sind m�glich:<br> 9 * - Unbenennen eines Objektes (alle Typen)<br> 10 * - Verschieben eines Objektes (alle Typen) in einen anderen Ordner.<br> 11 */ 12 public function execute() 13 { 14 if ( $this->readonly ) 15 { 16 $this->httpStatus('403 Forbidden - Readonly Mode' ); // Schreibgeschuetzt 17 } 18 elseif ( !$this->create ) 19 { 20 $this->httpStatus('403 Forbidden - No creation' ); // Schreibgeschuetzt 21 } 22 elseif( $this->obj == null ) 23 { 24 // Was nicht da ist, laesst sich auch nicht verschieben. 25 $this->httpStatus('404 Not Found' ); 26 } 27 elseif( is_object($this->obj) && ! $this->obj->hasRight( ACL_WRITE ) ) 28 { 29 // Was nicht da ist, laesst sich auch nicht verschieben. 30 Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden'); 31 $this->httpStatus('403 Forbidden' ); 32 } 33 elseif ( $this->destination == null ) 34 { 35 Logger::error('WEBDAV: MOVE request, but no "Destination:"-Header'); 36 // $this->httpStatus('405 Not Allowed' ); 37 $this->httpStatus('412 Precondition failed'); 38 } 39 else 40 { 41 $dest = $this->destination; 42 $destinationProject = $dest['project']; 43 $destinationFolder = $dest['folder' ]; 44 $destinationObject = $dest['object' ]; 45 46 if ( $dest['type'] != 'object' ) 47 { 48 Logger::debug('WEBDAV: MOVE request, but "Destination:"-Header mismatch'); 49 $this->httpMethodNotAllowed(); 50 return; 51 } 52 53 if ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) ) 54 { 55 Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden'); 56 $this->httpStatus('403 Forbidden' ); 57 } 58 59 if ( $destinationObject != null ) 60 { 61 Logger::debug('WEBDAV: MOVE request denied, destination exists'); 62 $this->httpStatus('412 Precondition Failed'); 63 return; 64 } 65 66 if ( $this->project->projectid != $destinationProject->projectid ) 67 { 68 // Verschieben in anderes Projekt nicht moeglich. 69 Logger::debug('WEBDAV: MOVE request denied, project does not match'); 70 $this->httpMethodNotAllowed(); 71 return; 72 } 73 74 if ( $this->folder->objectid == $destinationFolder->objectid ) 75 { 76 Logger::debug('WEBDAV: MOVE request accepted, object renamed'); 77 // Resource bleibt in gleichem Ordner. 78 $this->obj->filename = basename($_SERVER['HTTP_DESTINATION']); 79 $this->obj->objectSave(false); 80 $this->httpStatus('201 Created' ); 81 return; 82 } 83 84 if ( $destinationFolder->isFolder ) 85 { 86 Logger::debug('WEBDAV: MOVE request accepted, Destination: '.$destinationFolder->filename ); 87 // Objekt wird in anderen Ordner verschoben. 88 $this->obj->setParentId( $destinationFolder->objectid ); 89 $this->httpStatus('201 Created' ); 90 return; 91 } 92 93 Logger::warn('WEBDAV: MOVE request failed' ); 94 $this->httpStatus('500 Internal Server Error' ); 95 } 96 } 97 }
Downloaddav/method/MOVE.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.