Skip to content
Snippets Groups Projects
Commit 15521027 authored by Tim Steiner's avatar Tim Steiner
Browse files

Remove the not well understood Site path prefix parameter from unl site creation.

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@202 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 85ff0337
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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');
}
......@@ -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.'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment