openrat-webdav

git clone http://git.code.weiherhei.de/openrat-webdav.git
Log | Files | Refs | README

MKCOL.class.php (1089B)


      1 <?php
      2 
      3 class DAV_MKCOL extends DAV
      4 {
      5 
      6 	/**
      7 	 * Verzeichnis anlegen.
      8 	 */		
      9 	public function execute()
     10 	{
     11 
     12 		if	( $this->data )
     13 		{
     14 			$this->httpStatus('415 Unsupported Media Type' ); // Kein Body erlaubt
     15 		}
     16 		elseif	( $this->readonly )
     17 		{
     18 			$this->httpForbidden(); // Kein Schreibzugriff erlaubt
     19 		}
     20 		elseif	( $this->request->type == URIParser::PROJECT && ! $this->request->exists() )
     21 		{
     22 		    // Create a new empty project.
     23 		    $this->client->projectAdd( $this->request->basename);
     24 		}
     25         elseif	( $this->request->type == URIParser::FOLDER && ! $this->request->exists() )
     26         {
     27             // Create a new folder
     28             $this->client->folderAdd( $this->request->folderid, $this->request->basename );
     29             $this->httpStatus('201 Created');
     30         }
     31 		elseif   ( $this->request->exists() )
     32 		{
     33 			// MKCOL ist nicht moeglich, wenn die URI schon existiert.
     34 			Logger::warn('MKCOL-Request to an existing resource');
     35 			$this->httpMethodNotAllowed();
     36 		}
     37 		else
     38 		{
     39 			Logger::warn('MKCOL failed');
     40 			throw new InalidArgumentException('Unknown type');
     41 		}
     42 	}
     43 
     44 }