Changed structure of tag_association table
[fa-stable.git] / admin / inst_module.php
index 11c30bfa5d2f62a6c53093e53a73331e4d01cff8..5bce6ba6c509bf96a51de8834e4b00ab0eb8fa02 100644 (file)
@@ -34,18 +34,6 @@ else
        $selected_id = -1;
 
 //---------------------------------------------------------------------------------------------
-function get_company_extensions($id = -1) {
-
-       global $path_to_root;
-
-       $file = $path_to_root.($id == -1 ? '' : '/company/'.$id).'/installed_extensions.php';
-       $installed_extensions = array();
-       if (is_file($file)) {
-               include($file);
-       }
-       return $installed_extensions;
-}
-
 function check_data($id, $exts)
 {
        if ($_POST['name'] == "") {
@@ -81,7 +69,7 @@ function handle_submit()
        global $path_to_root, $db_connections, $selected_id;
 
        $extensions = get_company_extensions();
-       if (!check_data($selected_id), $extensions)
+       if (!check_data($selected_id, $extensions))
                return false;
 
        $id = $_GET['id'];
@@ -142,7 +130,7 @@ function handle_submit()
 
 function handle_delete()
 {
-       global  $path_to_root;
+       global  $path_to_root, $db_connections;
        
        $extensions = get_company_extensions();
 
@@ -167,15 +155,27 @@ function handle_delete()
        }
        rmdir($filename);
 
+       $ident = $extensions[$id]['name'];
        unset($extensions[$id]);
        $mods = array_values($extensions);
        $extensions = $mods;
 
        if (!write_extensions($extensions))
                return;
-       
-       // should we also delete module form per company extension files?
-       
+
+       // update per company files
+       $cnt = count($db_connections);
+       for($i = 0; $i < $cnt; $i++) 
+       {
+               $exts = get_company_extensions($i);
+               foreach($exts as $key => $ext) {
+                       if ($ext['name'] == $ident) {
+                               unset($exts[$key]);
+                               break;
+                       }
+               }
+               write_extensions($exts, $i);
+       }
        meta_forward($_SERVER['PHP_SELF']);
 }