Exemplo n.º 1
0
    // if we still can't connect to a DB, we'll create a new one
    if (!$midgard->is_connected()) {
        $config = new midgard_config();
        $config->dbtype = 'SQLite';
        $config->database = 'openpsa_test';
        $config->blobdir = OPENPSA_TEST_ROOT . '__output/blobs';
        $config->logfilename = OPENPSA_TEST_ROOT . '__output/midgard2.log';
        $config->tablecreate = true;
        $config->tableupdate = true;
        $config->loglevel = 'warn';
        if (!$midgard->open_config($config)) {
            throw new Exception('Could not open Midgard connection to test database: ' . $midgard->get_error_string());
        }
        require_once dirname(__FILE__) . '/../tools/bootstrap.php';
        openpsa_prepare_database($config);
        $GLOBALS['midcom_config_local']['midcom_root_topic_guid'] = openpsa_prepare_topics();
    }
    $_MIDGARD = $mgd_defaults;
} else {
    if (extension_loaded('midgard')) {
        if (file_exists(OPENPSA_TEST_ROOT . 'mgd1-connection.inc.php')) {
            include OPENPSA_TEST_ROOT . 'mgd1-connection.inc.php';
        } else {
            include OPENPSA_TEST_ROOT . 'mgd1-connection-default.inc.php';
        }
        $_MIDGARD = array_merge($mgd_defaults, $_MIDGARD);
    } else {
        throw new Exception("OpenPSA requires Midgard PHP extension to run");
    }
}
if (!class_exists('midgard_topic')) {
Exemplo n.º 2
0
 public function run()
 {
     $config_file = "/etc/midgard2/conf.d/" . $this->_project_name;
     if (file_exists($config_file)) {
         switch ($this->prompt($config_file . " already exists, override?", 'n', array('y', 'n'))) {
             case 'y':
                 unlink($config_file);
                 $config = $this->_create_config($config_file);
                 break;
             default:
                 $config = new midgard_config();
                 if (!$config->read_file($this->_project_name, false)) {
                     $this->fail('Could not read config file ' . $config_file);
                 }
         }
     } else {
         $config = $this->_create_config($config_file);
     }
     // Open a DB connection with the config
     $midgard = midgard_connection::get_instance();
     if (!$midgard->open_config($config)) {
         $this->fail("Failed to open Midgard database connection to {$this->_project_name}: " . $midgard->get_error_string());
     }
     require_once 'tools/bootstrap.php';
     openpsa_prepare_database($config);
     openpsa_prepare_topics();
 }