mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 07:22:11 +00:00
move rrmdir() into own class in inc.Utils.php
This commit is contained in:
parent
f6f7fe0ab6
commit
b9d5c31211
|
@ -490,19 +490,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
|
||||
*
|
||||
|
@ -518,7 +505,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";
|
||||
|
@ -538,7 +525,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;
|
||||
}
|
||||
|
||||
|
@ -549,11 +536,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.
|
||||
|
@ -575,7 +562,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1231,6 +1231,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
|
||||
*
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user