DataObjects/Core_notify_recur.php
[Pman.Core] / UpdateDatabase.php
index ed9d357..068c1c7 100644 (file)
@@ -155,6 +155,8 @@ class Pman_Core_UpdateDatabase extends Pman
            
             DB_DataObject::factory('companies')->initCompanies($this, $opts);
         }
+        $this->fixLinks();
+         
          
     }
     function output() {
@@ -178,7 +180,7 @@ class Pman_Core_UpdateDatabase extends Pman
         //$this->{'import' . $url['scheme']}($url);
         
         $dbtype = $dburl['scheme'];
-        $dirmethod = 'import' . $dburl['scheme'] . '.dir';
+        $dirmethod = 'import' . $dburl['scheme'] . 'dir';
         
         
        
@@ -197,15 +199,15 @@ class Pman_Core_UpdateDatabase extends Pman
             
             
             
-            $file = $this->rootDir. "/Pman/$module/UpdateDatabase.php";
-            if($module != 'Core' && file_exists($file)){
+            $file = $this->rootDir. "/Pman/$m/UpdateDatabase.php";
+            if($m != 'Core' && file_exists($file)){
                 
                 require_once $file;
-                $class = "Pman_{$module}_UpdateDatabase";
+                $class = "Pman_{$m}_UpdateDatabase";
                 $x = new $class;
                 if(method_exists($x, 'importModuleSQL')){
                     echo "Importing SQL from module $m using Module::importModuleSQL\n";
-                    $x->opts = $this->opts();
+                    $x->opts = $this->opts;
                     $x->rootDir = $this->rootDir;
                     $x->importModuleSQL($dburl);
                     continue;
@@ -258,6 +260,8 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function importpgsqldir($url, $dir, $disable_triggers = false)
     {
+        $ff = HTML_FlexyFramework::get();
+        
         require_once 'System.php';
         $cat = System::which('cat');
         $psql = System::which('psql');
@@ -275,6 +279,7 @@ class Pman_Core_UpdateDatabase extends Pman
         
         echo $psql_cmd . "\n" ;
         echo "scan : $dir\n";
+        
         if (is_file($dir)) {
             $files = array($dir);
 
@@ -288,7 +293,6 @@ class Pman_Core_UpdateDatabase extends Pman
         //usort($files, $lsort);
         
         
-        
         foreach($files as $bfn) {
 
 
@@ -313,8 +317,7 @@ class Pman_Core_UpdateDatabase extends Pman
 
             $cmd = "$psql_cmd  < " . escapeshellarg($fn ? $fn : $bfn) . ' 2>&1' ;
 
-            echo "$bfn:   $cmd ". ($this->cli ? "\n" : "<BR>\n");
-
+            echo "$bfn:   $cmd ". ($ff->cli ? "\n" : "<BR>\n");
 
             passthru($cmd);
 
@@ -338,6 +341,9 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function importmysqldir($dburl, $dir)
     {
+        
+        $this->fixMysqlInnodb(); /// run once 
+        
         echo "Import MYSQL :: $dir\n";
         
         
@@ -655,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
+            ),
         ));
         
     }
@@ -714,6 +724,33 @@ 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();
+        if ($db->Value == 'OFF') {
+            die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+        }
+        
+        $done_check = true;;
+
+        
+        
+        
+        
+        
+    }
+    
+    
     /** ------------- schema fixing ... there is an issue with data imported having the wrong sequence names... --- */
     
     function fixSequencesMysql()
@@ -804,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