summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-11-10 12:08:22 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-11-10 12:08:22 +0000
commit480c53b6dbcabba5dca76cfc24e1c284cff75c4c (patch)
tree8fabf241a251fea183f522b759f1b0df1af80b2d /modules
parentecf6c8de03e303e4da1bad39450483528ca136fd (diff)
downloadbrdo-480c53b6dbcabba5dca76cfc24e1c284cff75c4c.tar.gz
brdo-480c53b6dbcabba5dca76cfc24e1c284cff75c4c.tar.bz2
#154517 by chx and Desbeers: usability fixes for path module (required fields, permission info and resetting the filter made possible), and fixing language usage on nodeapi update in path_nodeapi
Diffstat (limited to 'modules')
-rw-r--r--modules/path/path.admin.inc38
-rw-r--r--modules/path/path.module11
2 files changed, 36 insertions, 13 deletions
diff --git a/modules/path/path.admin.inc b/modules/path/path.admin.inc
index 9e22dd705..d63d26c62 100644
--- a/modules/path/path.admin.inc
+++ b/modules/path/path.admin.inc
@@ -95,7 +95,8 @@ function path_admin_form(&$form_state, $edit = array('src' => '', 'dst' => '', '
'#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, $edit = array('src' => '', 'dst' => '', '
'#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(
@@ -136,6 +138,10 @@ function path_admin_form_validate($form, &$form_state) {
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,19 +201,37 @@ function path_admin_filter_form(&$form_state, $keys = '') {
'#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($form, &$form_state) {
- return 'admin/build/path/list/'. trim($form_state['values']['filter']);
+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_reset($form, &$form_state) {
+ $form_state['redirect'] = 'admin/build/path/list';
+}
+
+
+/**
* Helper function for grabbing filter keys.
*/
function path_admin_filter_get_keys() {
diff --git a/modules/path/path.module b/modules/path/path.module
index 76f81907c..f624eb787 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -139,18 +139,17 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = ''
*/
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.'));
}
break;
case 'load':
- $path = "node/$node->nid";
- $language = isset($node->language) ? $node->language : '';
+ $path = 'node/'. $node->nid;
$alias = drupal_get_path_alias($path, $language);
if ($path != $alias) {
$node->path = $alias;
@@ -161,16 +160,16 @@ 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);
}
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";
+ $path = 'node/'. $node->nid;
if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
}