diff --git a/inc/inc.ClassExtensionMgr.php b/inc/inc.ClassExtensionMgr.php index 8b86b3fb5..3eaa825fb 100644 --- a/inc/inc.ClassExtensionMgr.php +++ b/inc/inc.ClassExtensionMgr.php @@ -494,19 +494,6 @@ class SeedDMS_Extension_Mgr { return $this->configcache[$extname]; } /* }}} */ - static protected function rrmdir($dir) { /* {{{ */ - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (filetype($dir."/".$object) == "dir") self::rrmdir($dir."/".$object); else unlink($dir."/".$object); - } - } - reset($objects); - rmdir($dir); - } - } /* }}} */ - /** * Update an extension * @@ -522,7 +509,7 @@ class SeedDMS_Extension_Mgr { $newdir = addDirSep($this->cachedir)."ext.new"; /* First remove a left over from a previous extension */ if(file_exists($newdir)) { - self::rrmdir($newdir); + SeedDMS_Utils::rrmdir($newdir); } if(!mkdir($newdir, 0755)) { $this->errmsgs[] = "Cannot create temp. extension directory"; @@ -542,7 +529,7 @@ class SeedDMS_Extension_Mgr { /* Check if extension is complete and fullfills the constraints */ if(!self::checkExtensionByDir($newdir)) { - self::rrmdir($newdir); + SeedDMS_Utils::rrmdir($newdir); return false; } @@ -553,11 +540,11 @@ class SeedDMS_Extension_Mgr { if(!is_dir($this->extdir)) { if(!mkdir($this->extdir, 0755)) { $this->errmsgs[] = "Cannot create extension directory"; - self::rrmdir($newdir); + SeedDMS_Utils::rrmdir($newdir); return false; } } elseif(is_dir($this->extdir ."/". $extname)) { - $this->rrmdir($this->extdir ."/". $extname); + SeedDMS_Utils::rrmdir($this->extdir ."/". $extname); } /* Move the temp. created ext directory to the final location */ /* rename() may fail if dirs are moved from one device to another. @@ -579,7 +566,7 @@ class SeedDMS_Extension_Mgr { * has been copied. */ $this->errmsgs[] = "Cannot move temp. extension directory to final destination"; - $this->rrmdir($this->extdir ."/". $extname); + SeedDMS_Utils::rrmdir($this->extdir ."/". $extname); return false; } diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index a67fca0b7..abdaf04e7 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -1256,6 +1256,34 @@ function getMandatoryApprovers($folder, $document, $user) { /* {{{ */ return $approvers; } /* }}} */ +/** + * Class with various utility methods + * + * This class will sooner or later comprise the functions above + * + */ +class SeedDMS_Utils { /* {{{ */ + + /** + * Recursively remove a directory on disc + * + * @param string $dir name of directory + */ + static public function rrmdir($dir) { /* {{{ */ + if (is_dir($dir)) { + $objects = scandir($dir); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (filetype($dir."/".$object) == "dir") self::rrmdir($dir."/".$object); else unlink($dir."/".$object); + } + } + reset($objects); + rmdir($dir); + } + } /* }}} */ + +} /* }}} */ + /** * Class for creating encrypted api keys * diff --git a/op/op.ImportFS.php b/op/op.ImportFS.php index d5f3f90c2..0ebd62aa5 100644 --- a/op/op.ImportFS.php +++ b/op/op.ImportFS.php @@ -239,9 +239,10 @@ if($newfolder) { $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_importfs'))); else { if(isset($_GET['remove']) && $_GET["remove"]) { - $cmd = 'rm -rf '.$dirname; - $ret = null; - system($cmd, $ret); + SeedDMS_Utils::rrmdir($dirname); +// $cmd = 'rm -rf '.$dirname; +// $ret = null; +// system($cmd, $ret); } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_importfs', array('docs'=>$doccount, 'folders'=>$foldercount)))); }