示例#1
0
    $step = 'i' . $istep;
} elseif ($istep > 1 && substr($_POST['install_type'], 0, 7) == 'upgrade') {
    $step = 'u' . $istep;
}
switch ($step) {
    case '1':
        $title = _T("Installation mode");
        //let's look for updates scripts
        $update_scripts = Install::getUpdateScripts($plugin['root'], TYPE_DB);
        if (count($update_scripts) > 0) {
            $tpl->assign('update_scripts', $update_scripts);
        }
        break;
    case 'i2':
    case 'u2':
        $install = new Install();
        if (!defined('GALETTE_THEME_DIR')) {
            define('GALETTE_THEME_DIR', GALETTE_TPL_SUBDIR);
        }
        $title = _T("Database access and permissions");
        /** FIXME: when tables already exists and DROP not allowed at this time
            the showed error is about CREATE, whenever CREATE is allowed */
        //We delete the table if exists, no error at this time
        $zdb->dropTestTable();
        $results = $zdb->grantCheck(substr($step, 0, 1));
        $result = array();
        $error = false;
        //test returned values
        if ($results['create'] instanceof Exception) {
            $result[] = array('message' => _T("CREATE operation not allowed"), 'debug' => $results['create']->getMessage(), 'image' => $install->getValidationImage(false));
            $error = true;
示例#2
0
 /**
  * Tests update scripts list
  *
  * @return void
  */
 public function testGetUpgradeScripts()
 {
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install', 'pgsql', '0.6');
     $knowns = array('0.60' => 'upgrade-to-0.60-pgsql.sql', '0.61' => 'upgrade-to-0.61-pgsql.sql', '0.62' => 'upgrade-to-0.62-pgsql.sql', '0.63' => 'upgrade-to-0.63-pgsql.sql', '0.70' => 'upgrade-to-0.70.php', '0.71' => 'upgrade-to-0.71-pgsql.sql', '0.74' => 'upgrade-to-0.74-pgsql.sql', '0.75' => 'upgrade-to-0.75-pgsql.sql', '0.76' => 'upgrade-to-0.76-pgsql.sql', '0.8' => 'upgrade-to-0.8.php', '0.81' => 'upgrade-to-0.81-pgsql.sql', '0.82' => 'upgrade-to-0.82-pgsql.sql');
     //as of 0.8, we got 10 update scripts total
     $this->array($update_scripts)->hasSize(count($knowns))->isIdenticalTo($knowns);
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install', 'pgsql', '0.7');
     //if we're from 0.7.0, there are only 6 update scripts left
     $this->array($update_scripts)->hasSize(count($knowns) - 4);
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install');
     //without specifying database nor version, we got 10 update scripts total
     $this->array(array_values($update_scripts))->hasSize(count($knowns))->isEqualTo(array_keys($knowns));
     $this->_install->setMode(\Galette\Core\Install::UPDATE);
     $errors = array();
     $this->_install->setDbType(\Galette\Core\Db::PGSQL, $errors);
     $this->_install->setInstalledVersion('0.6');
     $update_scripts = $this->_install->getScripts(GALETTE_BASE_PATH . '/install');
     $this->array($update_scripts)->hasSize(count($knowns))->isIdenticalTo($knowns);
     $this->_install->setMode(\Galette\Core\Install::INSTALL);
     $update_scripts = $this->_install->getScripts(GALETTE_BASE_PATH . '/install');
     $this->array($update_scripts)->hasSize(1)->hasKey('current')->strictlyContains(\Galette\Core\Db::PGSQL . '.sql');
 }
示例#3
0
//that way, in galette.inc.php, we'll only include relevant parts
$installer = true;
//specific logfile for installer
$logfile = 'galette_install';
define('GALETTE_BASE_PATH', '../');
define('GALETTE_THEME_DIR', GALETTE_BASE_PATH . 'templates/default/');
require_once '../includes/galette.inc.php';
//when upgrading, make sure that old objects in current session are destroyed
if (defined('PREFIX_DB') && defined('NAME_DB')) {
    unset($_SESSION['galette'][PREFIX_DB . '_' . NAME_DB]);
}
$install = null;
if (isset($session[md5(GALETTE_ROOT)]) && !isset($_GET['raz'])) {
    $install = unserialize($session[md5(GALETTE_ROOT)]);
} else {
    $install = new GaletteInstall();
}
$error_detected = array();
/**
 * Initialize database constants to connect
 *
 * @param Install $install Installer
 *
 * @return void
 */
function initDbConstants($install)
{
    define('TYPE_DB', $install->getDbType());
    define('PREFIX_DB', $install->getTablesPrefix());
    define('USER_DB', $install->getDbUser());
    define('PWD_DB', $install->getDbPass());