Index: modules/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.4 diff -u -p -r1.4 path.admin.inc --- modules/path/path.admin.inc 12 Aug 2007 16:34:56 -0000 1.4 +++ modules/path/path.admin.inc 9 Oct 2007 18:58:49 -0000 @@ -95,7 +95,8 @@ function path_admin_form(&$form_state, $ '#maxlength' => 64, '#size' => 45, '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=') + '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#required' => TRUE, ); $form['dst'] = array( '#type' => 'textfield', @@ -104,7 +105,8 @@ function path_admin_form(&$form_state, $ '#maxlength' => 64, '#size' => 45, '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=') + '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#required' => TRUE, ); // This will be a hidden value unless locale module is enabled $form['language'] = array( @@ -118,7 +120,6 @@ function path_admin_form(&$form_state, $ else { $form['submit'] = array('#type' => 'submit', '#value' => t('Create new alias')); } - return $form; } @@ -136,6 +137,10 @@ function path_admin_form_validate($form, if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) { form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst))); } + $item = menu_get_item($src); + if (!$item || !$item['access']) { + form_set_error('src', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $src))); + } } /** @@ -195,16 +200,33 @@ function path_admin_filter_form(&$form_s '#maxlength' => 64, '#size' => 25, ); - $form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Filter')); - + $form['basic']['inline']['submit'] = array( + '#type' => 'submit', + '#value' => t('Filter'), + '#submit' => array('path_admin_filter_form_submit_filter'), + ); + if ($keys) { + $form['basic']['inline']['reset'] = array( + '#type' => 'submit', + '#value' => t('Reset'), + '#submit' => array('path_admin_filter_form_submit_reset'), + ); + } return $form; } /** - * Process filter form submission. + * Process filter form submission when the Filter button is pressed. + */ +function path_admin_filter_form_submit_filter($form, &$form_state) { + $form_state['redirect'] = 'admin/build/path/list/'. trim($form_state['values']['filter']); +} + +/** + * Process filter form submission when the Reset button is pressed. */ -function path_admin_filter_form_submit($form, &$form_state) { - return 'admin/build/path/list/'. trim($form_state['values']['filter']); +function path_admin_filter_form_submit_reset($form, &$form_state) { + $form_state['redirect'] = 'admin/build/path/list'; } /** Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.131 diff -u -p -r1.131 path.module --- modules/path/path.module 12 Aug 2007 16:34:56 -0000 1.131 +++ modules/path/path.module 9 Oct 2007 18:58:49 -0000 @@ -111,19 +111,9 @@ function path_set_alias($path = NULL, $a db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language); } } - // The alias exists. + // The alias exist, update the path. else { - // This path has no alias yet, so we redirect the alias here. - if ($path_count == 0) { - db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s' AND language = '%s'", $path, $alias, $language); - } - else { - // This will delete the path that alias was originally pointing to. - path_set_alias(NULL, $alias, NULL, $language); - // This will remove the current aliases of the path. - path_set_alias($path, NULL, NULL, $language); - path_set_alias($path, $alias, NULL, $language); - } + db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s' AND language = '%s'", $path, $alias, $language); } if ($alias_count == 0 || $path_count == 0) { drupal_clear_path_cache(); @@ -139,10 +129,10 @@ function path_set_alias($path = NULL, $a */ function path_nodeapi(&$node, $op, $arg) { if (user_access('create url aliases') || user_access('administer url aliases')) { + $language = isset($node->language) ? $node->language : ''; switch ($op) { case 'validate': $node->path = trim($node->path); - $language = isset($node->language) ? $node->language : ''; if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s' AND language = '%s'", $node->path, "node/$node->nid", $language))) { form_set_error('path', t('The path is already in use.')); } @@ -150,7 +140,6 @@ function path_nodeapi(&$node, $op, $arg) case 'load': $path = "node/$node->nid"; - $language = isset($node->language) ? $node->language : ''; $alias = drupal_get_path_alias($path, $language); if ($path != $alias) { $node->path = $alias; @@ -161,17 +150,17 @@ function path_nodeapi(&$node, $op, $arg) // Don't try to insert if path is NULL. We may have already set // the alias ahead of time. if (isset($node->path)) { - path_set_alias("node/$node->nid", $node->path); + path_set_alias("node/$node->nid", $node->path, NULL, $language); } break; case 'update': - path_set_alias("node/$node->nid", isset($node->path) ? $node->path : NULL, isset($node->pid) ? $node->pid : NULL); + path_set_alias("node/$node->nid", isset($node->path) ? $node->path : NULL, isset($node->pid) ? $node->pid : NULL, $language); break; case 'delete': $path = "node/$node->nid"; - if (drupal_get_path_alias($path) != $path) { + if (drupal_get_path_alias($path, $language) != $path) { path_set_alias($path); } break; Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.193 diff -u -p -r1.193 locale.module --- modules/locale/locale.module 28 Sep 2007 18:11:27 -0000 1.193 +++ modules/locale/locale.module 9 Oct 2007 18:54:09 -0000 @@ -227,9 +227,8 @@ function locale_user($type, $edit, &$use */ function locale_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { - // Language field for paths - case 'path_admin_edit': + case 'path_admin_form': $form['language'] = array( '#type' => 'select', '#title' => t('Language'),