From 0cd4c9b727b786137457e0caae1585cffbbeb436 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 17 Sep 2021 18:24:32 +0200 Subject: [PATCH] check if the folder set by setRootFolderID() actually exists --- SeedDMS_Core/Core/inc.ClassDMS.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 6caa49f82..a725ee8db 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -527,13 +527,23 @@ class SeedDMS_Core_DMS { /** * Set id of root folder + * * This function must be called right after creating an instance of * {@link SeedDMS_Core_DMS} * + * The new root folder id will only be set if the folder actually + * exists. In that case the old root folder id will be returned. + * If it does not exists, the method will return false; * @param integer $id id of root folder + * @return boolean/int old root folder id if new root folder exists, otherwise false */ function setRootFolderID($id) { /* {{{ */ - $this->rootFolderID = $id; + if($this->getFolder($id)) { + $oldid = $this->rootFolderID; + $this->rootFolderID = $id; + return $oldid; + } + return false; } /* }}} */ /**