diff --git a/sites/all/modules/unl/cron.php b/sites/all/modules/unl/cron.php index 1c0830a67d311f7428dc2bf9dbe608b355dfc149..be5c6be0d2c4d0d8e31fe26b7614e7f4d31bb83d 100644 --- a/sites/all/modules/unl/cron.php +++ b/sites/all/modules/unl/cron.php @@ -18,7 +18,7 @@ while ($row = $query->fetchAssoc()) { ->fields(array('installed' => 1)) ->condition('site_id', $row['site_id']) ->execute(); - unl_add_site($row['site_path_prefix'], $row['site_path'], $row['uri'], $row['clean_url']); + unl_add_site($row['site_path'], $row['uri'], $row['clean_url'], $row['db_prefix']); db_update('unl_sites') ->fields(array('installed' => 2)) ->condition('site_id', $row['site_id']) @@ -26,7 +26,7 @@ while ($row = $query->fetchAssoc()) { } -function unl_add_site($site_path_prefix, $site_path, $uri, $clean_url) +function unl_add_site($site_path, $uri, $clean_url, $db_prefix) { if (substr($site_path, 0, 1) == '/') { @@ -60,9 +60,7 @@ function unl_add_site($site_path_prefix, $site_path, $uri, $clean_url) . ($database['port'] ? ':' . $database['port'] : '') . '/' . $database['database'] ; - $db_prefix = explode('/', $site_path); - $db_prefix = array_reverse($db_prefix); - $db_prefix = implode('_', $db_prefix) . '_' . $database['prefix']; + $db_prefix .= '_' . $database['prefix']; $php_path = escapeshellarg($_SERVER['_']); $drupal_root = escapeshellarg(DRUPAL_ROOT); diff --git a/sites/all/modules/unl/unl.install b/sites/all/modules/unl/unl.install index 4476ed116594921a4d37f200c915240327cdbfa2..04381439272e9fa4b6ee5a4ef9bd02f87ef09fb1 100644 --- a/sites/all/modules/unl/unl.install +++ b/sites/all/modules/unl/unl.install @@ -60,12 +60,6 @@ function unl_update_7100() 'unsigned' => TRUE, 'not null' => TRUE ), - 'site_path_prefix' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '' - ), 'site_path' => array( 'type' => 'varchar', 'length' => 255, @@ -82,7 +76,18 @@ function unl_update_7100() 'type' => 'int', 'not null' => TRUE, 'default' => 0 - ) + ), + 'clean_url' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1 + ), + 'db_prefix' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '' + ), ), 'primary key' => array('site_id'), 'unique keys' => array( @@ -105,3 +110,20 @@ function unl_update_7101() ) ); } + +function unl_update_7102() +{ + db_add_field( + 'unl_sites', + 'db_prefix', + array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '' + ) + ); + db_query('UPDATE {unl_sites} SET db_prefix = site_path'); + db_query("UPDATE {unl_sites} SET site_path = CONCAT(site_path_prefix, '/', site_path) WHERE site_path_prefix != ''"); + db_drop_field('unl_sites', 'site_path_prefix'); +} diff --git a/sites/all/modules/unl/unl_site_creation.php b/sites/all/modules/unl/unl_site_creation.php index 2a779ffc5b4802d019f8a5909e284d32fc1fff21..5860ec74e539a10254941f064ef5da1888a91c6b 100644 --- a/sites/all/modules/unl/unl_site_creation.php +++ b/sites/all/modules/unl/unl_site_creation.php @@ -9,13 +9,6 @@ function unl_site_creation($form, &$form_state) '#title' => 'Site Creation Tool' ); - $form['root']['site_path_prefix'] = array( - '#type' => 'textfield', - '#title' => t('Site path prefix'), - '#description' => t('A URL path used to separate subsites from the main site.'), - '#default_value' => t('s') - ); - $form['root']['site_path'] = array( '#type' => 'textfield', '#title' => t('New site path'), @@ -43,7 +36,6 @@ function unl_site_creation_submit($form, &$form_state) { //$php_path = $form_state['values']['php_path']; $site_path = $form_state['values']['site_path']; - $site_path_prefix = $form_state['values']['site_path_prefix']; $clean_url = $form_state['values']['clean_url']; if (substr($site_path, 0, 1) == '/') { @@ -52,27 +44,19 @@ function unl_site_creation_submit($form, &$form_state) if (substr($site_path, -1) == '/') { $site_path = substr($site_path, 0, -1); } - if (substr($site_path_prefix, 0, 1) == '/') { - $site_path_prefix = substr($site_path_prefix, 1); - } - if (substr($site_path_prefix, -1) == '/') { - $site_path_prefix = substr($site_path_prefix, 0, -1); - } - - $full_path = $site_path; - if ($site_path_prefix) { - $full_path = $site_path_prefix . '/' . $full_path; - } - $uri = url($full_path, array('absolute' => TRUE)); + $uri = url($site_path, array('absolute' => TRUE)); $clean_url = intval($clean_url); + $db_prefix = explode('/', $site_path); + $db_prefix = implode('_', $db_prefix); + db_insert('unl_sites')->fields(array( - 'site_path_prefix' => $site_path_prefix, - 'site_path' => $site_path, - 'uri' => $uri, - 'clean_url' => $clean_url + 'site_path' => $site_path, + 'uri' => $uri, + 'clean_url' => $clean_url, + 'db_prefix' => $db_prefix, ))->execute(); drupal_set_message(t('The site '.$uri.' has been started, run unl/cron.php to finish setup.'));