DataObjects/Core_curr_rate.php
[Pman.Core] / UpdateDatabase.php
index 27103c8..068c1c7 100644 (file)
@@ -155,6 +155,8 @@ class Pman_Core_UpdateDatabase extends Pman
            
             DB_DataObject::factory('companies')->initCompanies($this, $opts);
         }
+        $this->fixLinks();
+         
          
     }
     function output() {
@@ -291,39 +293,38 @@ class Pman_Core_UpdateDatabase extends Pman
         //usort($files, $lsort);
         
         
-//        foreach($files as $bfn) {
-//
-//
-//            if (preg_match('/migrate/i', basename($bfn))) { // skip migration scripts at present..
-//                continue;
-//            }
-//            if (preg_match('#\.[a-z]{2}\.sql#i', basename($bfn))
-//                && !preg_match('#\.pg\.sql#i', basename($bfn))
-//            ) { // skip migration scripts at present..
-//                continue;
-//            }
-//            $fn = false;
-//
-//            if (!preg_match('/pgsql/', basename($dir) )) {
-//                 if ( !preg_match('#\.pg\.sql$#', basename($bfn))) {
-//                    $fn = $this->convertToPG($bfn);
-//                }
-//            }
-//
-//            // files ending in .pg.sql are native postgres files.. ## depricated
-//
-//
-//            $cmd = "$psql_cmd  < " . escapeshellarg($fn ? $fn : $bfn) . ' 2>&1' ;
-//
-//            echo "$bfn:   $cmd ". ($ff->cli ? "\n" : "<BR>\n");
-//
-//
-//            passthru($cmd);
-//
-//            if ($fn) {
-//                unlink($fn);
-//            }
-//        }
+        foreach($files as $bfn) {
+
+
+            if (preg_match('/migrate/i', basename($bfn))) { // skip migration scripts at present..
+                continue;
+            }
+            if (preg_match('#\.[a-z]{2}\.sql#i', basename($bfn))
+                && !preg_match('#\.pg\.sql#i', basename($bfn))
+            ) { // skip migration scripts at present..
+                continue;
+            }
+            $fn = false;
+
+            if (!preg_match('/pgsql/', basename($dir) )) {
+                 if ( !preg_match('#\.pg\.sql$#', basename($bfn))) {
+                    $fn = $this->convertToPG($bfn);
+                }
+            }
+
+            // files ending in .pg.sql are native postgres files.. ## depricated
+
+
+            $cmd = "$psql_cmd  < " . escapeshellarg($fn ? $fn : $bfn) . ' 2>&1' ;
+
+            echo "$bfn:   $cmd ". ($ff->cli ? "\n" : "<BR>\n");
+
+            passthru($cmd);
+
+            if ($fn) {
+                unlink($fn);
+            }
+        }
 
               
              
@@ -340,6 +341,9 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function importmysqldir($dburl, $dir)
     {
+        
+        $this->fixMysqlInnodb(); /// run once 
+        
         echo "Import MYSQL :: $dir\n";
         
         
@@ -657,6 +661,10 @@ class Pman_Core_UpdateDatabase extends Pman
                 'name' => 'system-email-from',
                 'type' => 0, // system
             ),
+            array(
+                'name' => 'core-person-signup-bcc',
+                'type' => 0, // system
+            ),
         ));
         
     }
@@ -718,20 +726,21 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function fixMysqlInnodb()
     {
+        
+        static $done_check = false;
+        if ($done_check) {
+            return;
+        }
         // innodb in single files is far more efficient that MYD or one big innodb file.
         // first check if database is using this format.
         $db = DB_DataObject::factory('core_enum');
         $db->query("show variables like 'innodb_file_per_table'");
         $db->fetch();
-        var_dump($db);
-        // Value should == ON
-        
-        // I think it needs to look in the mysql directory.... to see if the idb exists..
-        $db = DB_DataObject::factory('core_enum');
-        $db->query("SHOW TABLE STATUS");
-        // Engine should be InnoDB - and file XXX.idb should exist...
-        
+        if ($db->Value == 'OFF') {
+            die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+        }
         
+        $done_check = true;;
 
  
         
@@ -832,4 +841,25 @@ class Pman_Core_UpdateDatabase extends Pman
        
     }
     
+    function fixLinks()
+    {
+        
+        $ff = HTML_Flexyframework::get();
+        
+        $dburl = parse_url($ff->DB_DataObject['database']);
+        
+        $dbtype = $dburl['scheme'];
+       
+        $scls = ucfirst($dbtype). 'Links';
+        $cls = 'Pman_Core_UpdateDatabase_'. $scls;
+        $fn = implode('/',explode('_', $cls)).'.php';
+        if (!file_exists(__DIR__.'/UpdateDatabase/'. $scls .'.php')) {
+            return;
+        }
+        require_once $fn;
+        $c = new $cls();
+        
+        
+        
+    }
 }
\ No newline at end of file