commit 7d660488371456dce00de7f40740d1b8cfb48af0
parent 16f24fc3c12cff7e6430d2331601836d4ce154e0
Author: Jan Dankert <develop@jandankert.de>
Date: Thu, 7 Nov 2019 22:23:10 +0100
New: Delete objects.
Diffstat:
3 files changed, 83 insertions(+), 44 deletions(-)
diff --git a/cms/CMS.class.php b/cms/CMS.class.php
@@ -94,6 +94,49 @@ class CMS
return $result;
}
+ function projectDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'project','remove',array('id'=>$id,'delete'=>'true') );
+ return $result;
+
+
+ }
+
+ function folderDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'folder','remove',array('id'=>$id,'delete'=>'true','withChildren'=>'true') );
+
+ return $result;
+ }
+
+
+ function pageDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'page','remove',array('id'=>$id,'delete'=>'true') );
+
+ return $result;
+ }
+ function fileDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'file','remove',array('id'=>$id,'delete'=>'true') );
+
+ return $result;
+ }
+
+ function imageDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'image','remove',array('id'=>$id,'delete'=>'true') );
+
+ return $result;
+ }
+
+ function textDelete($id)
+ {
+ $result = $this->call(CMS_WRITE,'text','remove',array('id'=>$id,'delete'=>'true') );
+
+ return $result;
+ }
+
function filevalue($id)
{
$result = $this->call(CMS_READ,'file','show',array('id'=>$id) );
diff --git a/dav/method/DELETE.class.php b/dav/method/DELETE.class.php
@@ -5,49 +5,57 @@ class DAV_DELETE extends DAV
/**
- * Objekt l�schen.
+ * Deletion.
*/
public function execute()
{
if ( $this->readonly )
{
- $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
+ $this->httpForbidden(); // Kein Schreibzugriff erlaubt
}
else
{
- if ( $this->obj == null )
+ if ( ! $this->request->exists() )
{
// Nicht existente URIs kann man auch nicht loeschen.
$this->httpStatus('404 Not Found' );
}
- elseif ( ! $this->obj->hasRight( ACL_DELETE ) )
+ else
{
- $this->httpStatus('403 Forbidden' ); // Benutzer darf die Resource nicht loeschen
- }
- elseif ( $this->obj->isFolder )
- {
- $f = new Folder( $this->obj->objectid );
- $f->deleteAll();
- $this->httpStatus( true ); // OK
- Logger::debug('Deleted folder with id '.$this->obj->objectid );
- }
- elseif ( $this->obj->isFile )
- {
- $f = new File( $this->obj->objectid );
- $f->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isPage )
- {
- $p = new Page( $this->obj->objectid );
- $p->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isLink )
- {
- $l = new Link( $this->obj->objectid );
- $l->delete();
- $this->httpStatus( true ); // OK
+ switch( $this->request->type )
+ {
+ case URIParser::ROOT:
+ $this->httpForbidden();
+ break;
+
+ case URIParser::PROJECT:
+ // Dangerous - but possible.
+ $this->client->projectDelete($this->request->projectid);
+ break;
+
+ case URIParser::FOLDER:
+ $this->client->folderDelete($this->request->objectid);
+ break;
+
+ case 'page':
+ $this->client->pageDelete($this->request->objectid);
+ break;
+
+ case 'file':
+ $this->client->fileDelete($this->request->objectid);
+ break;
+
+ case 'image':
+ $this->client->imageDelete($this->request->objectid);
+ break;
+
+ case 'text':
+ $this->client->textDelete($this->request->objectid);
+ break;
+
+ default:
+ $this->httpForbidden();
+ }
}
}
diff --git a/dav/method/HEAD.class.php b/dav/method/HEAD.class.php
@@ -8,23 +8,11 @@ class DAV_HEAD extends DAV
*/
public function execute()
{
- if ( ! $this->request->objectid )
+ if ( ! $this->request->exists() )
{
$this->httpStatus( '404 Not Found' );
}
- elseif ( $this->request->type == 'folder' )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isPage )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isLink )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isFile )
+ else
{
$this->httpStatus( '200 OK' );
}