--- drake/drake.module	2007-05-11 09:16:11.000000000 -0700
+++ drake/drake.module.NEW	2007-05-11 09:14:38.000000000 -0700
@@ -28,7 +28,7 @@ function drake_menu($may_cache)
 	if ($may_cache)
 	{
 		$items[] = array(
-			'path' => 'drake', 
+			'path' => variable_get('drake_uri', 'drake'), 
 			'title' => t('Drake Dispatcher'), 
 			'callback' => 'drake_dispatcher',
 			'access' => user_access('access content'),
@@ -61,6 +61,15 @@ function drake_menu($may_cache)
       'access' => user_access('administer site configuration'),
       'type' => MENU_LOCAL_TASK
      );
+     
+    $items[] = array(
+      'path' => 'admin/build/drake/settings',
+      'title' => t('Settings'),
+      'description' => t('Modify Drake settings.'),
+      'callback' => 'drake_admin_settings_page',
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_LOCAL_TASK
+     );
 	}
 	
 	return $items;
@@ -71,6 +80,8 @@ function drake_menu($may_cache)
  */
 function drake_admin_documentation_page()
 {
+    $drake_uri = variable_get('drake_uri', 'drake');
+    
 	$output = '';
 	
 	$output .= '
@@ -92,14 +103,14 @@ function drake_admin_documentation_page(
 		
 		<ol>
 			<li>Edit the file <code>' . DRAKE_CONFIGURATION_FILE . '</code> and modify its settings as instructed.</li>
-			<li>Go to ' . l(url('drake'), 'drake') . ' and you should see the default page of your CakePHP application inside Drupal.</li>
+			<li>Go to ' . l(url($drake_uri), $drake_uri) . ' and you should see the default page of your CakePHP application inside Drupal.</li>
 			<li>Read the <a href="http://dev.sypad.com/projects/drake">documentation</a> for notes and tips on how to take better advantage of Drake.</li>
 		</ol>
 		
 		<h3>Run Drake</h3>
 		
 		<p>
-			Load your default CakePHP application (once Drake has been set up) default page with the following URL: ' . l(url('drake'), 'drake') . '
+			Load your default CakePHP application (once Drake has been set up) default page with the following URL: ' . l(url($drake_uri), $drake_uri) . '
 		</p>
 		
 		<p>
@@ -219,7 +230,7 @@ function drake_admin_geturl_form_submit(
 	
 	$drakeCallable =& Drake::getInstance();
 
-	$drakeCallable->setDrupalUrl('drake');
+	$drakeCallable->setDrupalUrl(variable_get('drake_uri', 'drake'));
 	
 	// Generate URL
 	
@@ -241,7 +252,90 @@ function drake_admin_geturl_form_submit(
 	
 	// Leave Drake callable with correct URL
 	
-	$drakeCallable->setDrupalUrl(url('drake'));
+	$drakeCallable->setDrupalUrl(url(variable_get('drake_uri', 'drake')));
+}
+
+/**
+ * Displays Drake's Settings form
+ */
+function drake_admin_settings_page()
+{
+	$output = '';
+	
+	$output .= t('In the following form specify the URI you wish to use for Drake.');
+	$output .= drupal_get_form('drake_admin_settings_form');
+	
+	return $output;
+}
+
+/**
+ * Sets up the display of Drake's Settings form
+ */
+function theme_drake_admin_settings_form()
+{
+	$output = '';
+	
+	$output .= drupal_render($form['uri']);
+	$output .= drupal_render($form);
+	
+	return $output;
+}
+
+/**
+ * Builds Drake's Settings form elements
+ */
+function drake_admin_settings_form()
+{
+	$form = array();
+	
+	$form['drake_settings']['uri'] = array(
+		'#type' => 'textfield', 
+		'#title' => t('Drake URI'),
+		'#default_value' => variable_get('drake_uri', 'drake'),
+		'#size' => 60,
+		'#maxlength' => 64, 
+		'#description' => t('Enter a valid URI for Drake\'s dispatcher. E.g.: drake'),
+	);
+	
+	$form['drake_settings']['submit'] = array(
+		'#type' => 'submit',
+		'#value' => t('Save'),
+	);
+	
+	return $form;
+}
+
+/**
+ * Validates the submission of Drake's Settings form
+ *
+ * @parameter string $form_id	Drupal's Form ID
+ * @parameter array $form_values	Set of submitted values
+ */
+function drake_admin_settings_form_validate($form_id, $form_values)
+{
+	if (trim($form_values['uri']) == '')
+	{
+		form_set_error('', t('You must provide a valid URI.'));
+	}
+}
+
+/**
+ * Handles the submission of Drake's Settings form
+ *
+ * @parameter string $form_id	Drupal's Form ID
+ * @parameter array $form_values	Set of submitted values
+ */
+function drake_admin_settings_form_submit($form_id, $form_values)
+{
+    if (trim($form_values['uri']) != variable_get('drake_uri', 'drake'))
+    {
+        // Store the new URI
+        variable_set('drake_uri', trim($form_values['uri']));
+        // Clear the menu cache
+        cache_clear_all(NULL, 'cache_menu');
+    }
+    
+	drupal_set_message('Your settings have been saved.');
 }
 
 /**
@@ -251,6 +345,8 @@ function drake_admin_geturl_form_submit(
  */
 function drake_dispatcher($application = null)
 {
+    $drake_uri = variable_get('drake_uri', 'drake');
+    
 	$settings = _drake_parseConfiguration($application);
 	
 	$parameters = array();
@@ -263,7 +359,7 @@ function drake_dispatcher($application =
 		$parameters['send'] = $settings['application']['send'];
 	}
 
-	$parameters['drupal_url'] = url('drake' . (isset($application) ? '/' . $application : ''));	
+	$parameters['drupal_url'] = url($drake_uri . (isset($application) ? '/' . $application : ''));	
 	$parameters['clean'] = (isset($_REQUEST['task']) && strcasecmp($_REQUEST['task'], 'clean') == 0 ? true : false);
 	
 	if (isset($_REQUEST['run']))
@@ -283,7 +379,7 @@ function drake_dispatcher($application =
 	
 	$drakeCallable =& Drake::getInstance();
 
-	$drakeCallable->setDrupalUrl(url('drake'));
+	$drakeCallable->setDrupalUrl(url($drake_uri));
 	
 	if ($drakeCallable->isDrake() && isset($application))
 	{
