Aleksander Machniak
2013-01-10 4490d03649e1ce1a90274a0dce56fe8e5d2859ae
installer/rcube_install.php
@@ -109,12 +109,12 @@
   */
  function _load_config($suffix)
  {
    if (is_readable($main_inc = RCUBE_CONFIG_DIR . '/main.inc' . $suffix)) {
    if (is_readable($main_inc = RCUBE_CONFIG_DIR . 'main.inc' . $suffix)) {
      include($main_inc);
      if (is_array($rcmail_config))
        $this->config += $rcmail_config;
    }
    if (is_readable($db_inc = RCUBE_CONFIG_DIR . '/db.inc'. $suffix)) {
    if (is_readable($db_inc = RCUBE_CONFIG_DIR . 'db.inc'. $suffix)) {
      include($db_inc);
      if (is_array($rcmail_config))
        $this->config += $rcmail_config;
@@ -149,7 +149,7 @@
   */
  function create_config($which, $force = false)
  {
    $out = @file_get_contents(RCUBE_CONFIG_DIR . "/{$which}.inc.php.dist");
    $out = @file_get_contents(RCUBE_CONFIG_DIR . $which . '.inc.php.dist');
    if (!$out)
      return '[Warning: could not read the config template file]';
@@ -452,6 +452,7 @@
        '0.6-beta', '0.6',
        '0.7-beta', '0.7', '0.7.1', '0.7.2', '0.7.3',
        '0.8-beta', '0.8-rc', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4',
        '0.9-beta',
    ));
    return $select;
  }
@@ -625,46 +626,18 @@
  /**
   * Update database with SQL statements from SQL/*.update.sql
   * Update database schema
   *
   * @param object rcube_db Database connection
   * @param string Version to update from
   *
   * @return boolen True on success, False on error
   */
  function update_db($DB, $version)
  function update_db($version)
  {
    $version = strtolower($version);
    $engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
    system(INSTALL_PATH . "bin/updatedb.sh --label=roundcube --version=" . $version
      . " --dir=" . INSTALL_PATH . "SQL", $result);
    // read schema file from /SQL/*
    $fname = INSTALL_PATH . "SQL/$engine.update.sql";
    if ($lines = @file($fname, FILE_SKIP_EMPTY_LINES)) {
      $from = false; $sql = '';
      foreach ($lines as $line) {
        $is_comment = preg_match('/^--/', $line);
        if (!$from && $is_comment && preg_match('/from version\s([0-9.]+[a-z-]*)/', $line, $m)) {
          $v = strtolower($m[1]);
          if ($v == $version || version_compare($version, $v, '<='))
            $from = true;
        }
        if ($from && !$is_comment)
          $sql .= $line. "\n";
      }
      if ($sql)
        $this->exec_sql($sql, $DB);
    }
    else {
      $this->fail('DB Schema', "Cannot read the update file: $fname");
      return false;
    }
    if ($err = $this->get_error()) {
      $this->fail('DB Schema', "Error updating database: $err");
      return false;
    }
    return true;
    return !$result;
  }