diff --git a/sites/all/modules/unl/cron.php b/sites/all/modules/unl/cron.php index 05f945594d561410bdf0ffd0373b98a3d2cb8488..eaebd21e6de1930386e714c002619770f4bbe7fb 100644 --- a/sites/all/modules/unl/cron.php +++ b/sites/all/modules/unl/cron.php @@ -327,6 +327,10 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) { $site_or_alias = 'SITE'; } + if (substr($site_path, -1) != '/') { + $site_path .= '/'; + } + $stub_token = ' # %UNL_CREATION_TOOL_STUB%'; $htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess'); $stub_pos = strpos($htaccess, $stub_token); @@ -336,7 +340,7 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) { $new_htaccess = substr($htaccess, 0, $stub_pos) . " # %UNL_START_{$site_or_alias}_ID_{$site_id}%\n"; foreach (array('misc', 'modules', 'sites', 'themes') as $drupal_dir) { - $new_htaccess .= " RewriteRule $site_path/$drupal_dir/(.*) $drupal_dir/$1\n"; + $new_htaccess .= " RewriteRule $site_path$drupal_dir/(.*) $drupal_dir/$1\n"; } $new_htaccess .= " # %UNL_END_{$site_or_alias}_ID_{$site_id}%\n\n" . $stub_token diff --git a/sites/all/modules/unl/unl.install b/sites/all/modules/unl/unl.install index aa93e9a6e1f077cc46f1a3c885f87fc1e717e3e8..338438c246bf582d2aae54fdcb2c9c58cd70f7d2 100644 --- a/sites/all/modules/unl/unl.install +++ b/sites/all/modules/unl/unl.install @@ -358,3 +358,14 @@ function unl_update_7109() { ->fields(array('title' => '<none>')) ->execute(); } + +/** + * Updates unl sites and site aliases to have trailing slashes. + */ +function unl_update_7110() +{ + db_query("UPDATE {unl_sites} SET site_path = CONCAT(site_path, '/') WHERE SUBSTRING(site_path, -1) != '/'"); + db_query("UPDATE {unl_sites} SET uri = CONCAT(uri, '/') WHERE SUBSTRING(uri, -1) != '/'"); + db_query("UPDATE {unl_sites_aliases} SET base_uri = CONCAT(base_uri, '/') WHERE SUBSTRING(base_uri, -1) != '/'"); + db_query("UPDATE {unl_sites_aliases} SET path = CONCAT(path, '/') WHERE SUBSTRING(path, -1) != '/' AND path != ''"); +} diff --git a/sites/all/modules/unl/unl_site_creation.php b/sites/all/modules/unl/unl_site_creation.php index 892e7e148dbcce223936d7b895661b6c54d14bd8..d082e12886e0af1bcfe2fb109d23fb3da39fce97 100644 --- a/sites/all/modules/unl/unl_site_creation.php +++ b/sites/all/modules/unl/unl_site_creation.php @@ -46,8 +46,8 @@ function unl_site_create_validate($form, &$form_state) { if (substr($site_path, 0, 1) == '/') { $site_path = substr($site_path, 1); } - if (substr($site_path, -1) == '/') { - $site_path = substr($site_path, 0, -1); + if (substr($site_path, -1) != '/') { + $site_path .= '/'; } $site_path_parts = explode('/', $site_path); @@ -312,7 +312,7 @@ function unl_site_alias_create($form, &$form_state) { ->execute() ->fetchAll(); foreach ($sites as $site) { - $site_list[$site->site_id] = $site->uri . '/'; + $site_list[$site->site_id] = $site->uri; } $form['root'] = array( @@ -331,7 +331,7 @@ function unl_site_alias_create($form, &$form_state) { $form['root']['base_uri'] = array( '#type' => 'textfield', '#title' => t('Alias Base URL'), - '#description' => t('The base URL for the new alias.'), + '#description' => t('The base URL for the new alias. (This should resolve to the directory containing drupal\'s .htaccess file'), '#default_value' => url('', array('https' => FALSE)), '#required' => TRUE, ); @@ -350,6 +350,23 @@ function unl_site_alias_create($form, &$form_state) { return $form; } +function unl_site_alias_create_validate($form, &$form_state) { + $form_state['values']['base_uri'] = trim($form_state['values']['base_uri']); + $form_state['values']['path'] = trim($form_state['values']['path']); + + if (substr($form_state['values']['base_uri'], -1) != '/') { + $form_state['values']['base_uri'] .= '/'; + } + + if (substr($form_state['values']['path'], -1) != '/') { + $form_state['values']['path'] .= '/'; + } + + if (substr($form_state['values']['path'], 0, 1) == '/') { + $form_state['values']['path'] = substr($form_state['values']['path'], 1); + } +} + function unl_site_alias_create_submit($form, &$form_state) { db_insert('unl_sites_aliases')->fields(array( 'site_id' => $form_state['values']['site'],