Fixed a bug when creating subfolder for new companies. Should be company id and not...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 5 Apr 2008 08:54:12 +0000 (08:54 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 5 Apr 2008 08:54:12 +0000 (08:54 +0000)
CHANGELOG.txt
admin/create_coy.php

index bced906306776ccfdf6ee522b124d2368c8ed662..d8e59a4d6dc56dd1760cce7bbae24134911ce7cd 100644 (file)
@@ -19,6 +19,10 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+05-Apr-2008 Joe Hunt
+# Fixed a bug when creating subfolder for new companies. Should be company id and not the table pref counter.
+$ /admin/create_coy.php
+
 05-Apr-2008 Joe Hunt
 # Removed annoying warnings in several reports. 
 $ config.php 
index b43224abce6724db30095f0790540ca9cf0eee4b..ddce8db2ee0e18f46134b472f888e25c73cf19a8 100644 (file)
@@ -113,19 +113,22 @@ function handle_submit()
                display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
        else if ($error == -3)
                display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
-       if ($error != 0) {
+       if ($error != 0)
+       {
                return false;
        }
        $index = "<?php\nheader(\"Location: ../../index.php\");\n?>";
-       
-       if ($new) {
-           $cdir = $comp_path.'/'.($tb_pref_counter-1);
-           @mkdir($cdir); 
+
+       if ($new)
+       {
+           $cdir = $comp_path.'/'.$id;
+           @mkdir($cdir);
            save_to_file($cdir.'/'.'index.php', 0, $index);
-           
-           foreach($comp_subdirs as $dir) {
-               @mkdir($cdir.'/'.$dir);
-               save_to_file($cdir.'/'.$dir.'/'.'index.php', 0, $index);
+
+           foreach($comp_subdirs as $dir)
+           {
+                       @mkdir($cdir.'/'.$dir);
+                       save_to_file($cdir.'/'.$dir.'/'.'index.php', 0, $index);
            }
        }
        return true;
@@ -139,10 +142,6 @@ function handle_delete()
 
        $id = $_GET['id'];
 
-       $pref = $db_connections[$id]['tbpref'];
-       if($pref!='')
-           $pref = substr($pref, 0, strlen($pref)-1); 
-
        $err = remove_connection($id);
        if ($err == 0)
                display_error(_("Error removing Database: ") . $dbase . _(", please remove it manuallly"));
@@ -159,13 +158,14 @@ function handle_delete()
        if ($error != 0)
                return;
 
-       $cdir = $comp_path.'/'.$pref;
+       $cdir = $comp_path.'/'.$id;
        flush_dir($cdir);
-       if (!rmdir($cdir)) {
+       if (!rmdir($cdir))
+       {
                display_error(_("Cannot remove company data directory ") . $cdir);
                return;
        }
-       
+
        meta_forward($_SERVER['PHP_SELF']);
 }