Company directory was not deleted after company removal.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 1 Sep 2009 11:25:35 +0000 (11:25 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 1 Sep 2009 11:25:35 +0000 (11:25 +0000)
admin/create_coy.php
includes/main.inc

index 5200f2df910e1bce356ca3c4599c3f47eaad4e8f..684369c5e618245d4ffceafc624c7c69279a2ce1 100644 (file)
@@ -163,7 +163,7 @@ function handle_delete()
        $id = $_GET['id'];
 
        $cdir = $comp_path.'/'.$id;
-       @flush_dir($cdir);
+       @flush_dir($cdir, true);
        if (!rmdir($cdir))
        {
                display_error(_("Cannot remove company data directory ") . $cdir);
index 8c0fc8d3c9f42933f27cdcfb7d0fd9b692a35564..ee4417e24d86b661e4c95eded084fed79a992273 100644 (file)
@@ -57,17 +57,17 @@ function end_page($no_menu=false, $is_index=false)
        page_footer($no_menu, $is_index);
 }
 
-function flush_dir($path) 
+function flush_dir($path, $wipe = false
 {
        $dir = opendir($path);
        while(false !== ($fname = readdir($dir))) {
-               if($fname=='.' || $fname=='..' || $fname=='index.php') continue;
+               if($fname=='.' || $fname=='..' || (!$wipe && $fname=='index.php')) continue;
                if(is_dir($path.'/'.$fname)) {
-                   flush_dir($path.'/'.$fname);
-                   @rmdir($path.'/'.$fname);
+                   flush_dir($path.'/'.$fname, $wipe);
+                   if ($wipe) @rmdir($path.'/'.$fname);
                } else
                    @unlink($path.'/'.$fname);
-       }
+       }
 }
 
 function cache_js_file($fpath, $text)