/[drupal]/contributions/modules/multisite_manager/multisite_manager.module
ViewVC logotype

Diff of /contributions/modules/multisite_manager/multisite_manager.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7, Fri Feb 8 20:25:25 2008 UTC revision 1.8, Fri Feb 8 22:11:51 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: multisite_manager.module,v 1.6 2007/09/04 20:24:16 schuyler1d Exp $  // $Id: multisite_manager.module,v 1.7 2008/02/08 20:25:25 schuyler1d Exp $
3    
4  /**  /**
5   * author: Schuyler Duveen   * author: Schuyler Duveen
# Line 319  function multisite_manager_validate(&$no Line 319  function multisite_manager_validate(&$no
319    
320      $already_exists = db_result(@db_query("SELECT shortname FROM {drupal_site} WHERE shortname = '%s'",$node->shortname));      $already_exists = db_result(@db_query("SELECT shortname FROM {drupal_site} WHERE shortname = '%s'",$node->shortname));
321      if ($already_exists) {      if ($already_exists) {
322        form_set_error('shortname', t('The shortname you have entered, %shortname, is already taken. Please use a different one.', array('%shortname' => $node->shortname)), 'error');        form_set_error('shortname', t('The shortname you have entered, %shortname, is already taken. Please use a different one.', array('%shortname' => $node->shortname)), 'error');
323      }      }
324      if (_multisite_manager_dbexists($node)) {      if (_multisite_manager_dbexists($node)) {
325        form_set_error('shortname', t('The database location the site would be installed already exists. Please use a different shortname or database path and prefix.'), 'error');        form_set_error('shortname', t('The database location the site would be installed already exists. Please use a different shortname or database path and prefix.'), 'error');
326      }      }
327    }    }
328    
# Line 469  function _multisite_manager_dbexists($no Line 469  function _multisite_manager_dbexists($no
469      case 'mysqli':      case 'mysqli':
470        $already_exists = db_result(@db_query("SHOW DATABASES LIKE '%s'", $new_db['path']));        $already_exists = db_result(@db_query("SHOW DATABASES LIKE '%s'", $new_db['path']));
471        if ($already_exists) {        if ($already_exists) {
472          $already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], $new_db['prefix']));          $already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], str_replace('_','\_',$new_db['prefix'])));
473          if (!$already_exists && $db_prefix != $new_db['prefix']) {          if (!$already_exists && $db_prefix != $new_db['prefix']) {
474            ///to avoid watchdog set_active_db() problems we install on the current prefix and then rename tables to the new one            ///to avoid watchdog set_active_db() problems we install on the current prefix and then rename tables to the new one
475            ///this needs to be doable, so we can't have tables hanging around that match the current prefix either            ///this needs to be doable, so we can't have tables hanging around that match the current prefix either
476            ///even (or especially!!!) if db_prefix == ''            ///even (or especially!!!) if db_prefix == ''
477            $already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], $new_db['prefix']));            $already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], str_replace('_','\_',$new_db['prefix'])));
478          }          }
479        }        }
480        break;        break;
# Line 485  function _multisite_manager_dbexists($no Line 485  function _multisite_manager_dbexists($no
485          $already_exists = db_result(@db_query("SELECT datname FROM pg_database WHERE datname = '%s'",$new_db['path']));          $already_exists = db_result(@db_query("SELECT datname FROM pg_database WHERE datname = '%s'",$new_db['path']));
486        }        }
487        elseif (!$new_db['new']) {        elseif (!$new_db['new']) {
488          $already_exists = db_result(db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", $new_db['prefix']));          $already_exists = db_result(db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", str_replace('_','\_',$new_db['prefix'])));
489        }        }
490        break;        break;
491    }    }
# Line 716  function _multisite_manager_tables_resul Line 716  function _multisite_manager_tables_resul
716    switch ($GLOBALS['db_type']) {    switch ($GLOBALS['db_type']) {
717      case 'mysql':      case 'mysql':
718      case 'mysqli':      case 'mysqli':
719        $result = @db_query("SHOW TABLES LIKE '%s%%'", $prefix);        $result = @db_query("SHOW TABLES LIKE '%s%%'", str_replace('_','\_',$prefix));
720        break;        break;
721      case 'pgsql':      case 'pgsql':
722        $result = @db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", $prefix);        $result = @db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", str_replace('_','\_',$prefix));
723        break;        break;
724    }    }
725    return $result;    return $result;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2