summaryrefslogtreecommitdiff
path: root/modules/path
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
commit49fa25fb7658ada5ee242853d3ed301d0a0b05a9 (patch)
tree12fb57e50398413cc420df5ed486b77b9c996aa2 /modules/path
parentc64db1da29a6b2067f09e66e5e85e8877b489cb0 (diff)
downloadbrdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.gz
brdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.bz2
- Rollback of patch #68418: clean up node submit hooks. Needs more thinkering.
Restores the old node API.
Diffstat (limited to 'modules/path')
-rw-r--r--modules/path/path.module64
1 files changed, 27 insertions, 37 deletions
diff --git a/modules/path/path.module b/modules/path/path.module
index 5b9fdbf43..6e08057d4 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -207,6 +207,16 @@ function path_form($edit = '') {
function path_nodeapi(&$node, $op, $arg) {
if (user_access('create url aliases') || user_access('administer url aliases')) {
switch ($op) {
+ case 'validate':
+ $node->path = trim($node->path);
+ if ($node->path && !valid_url($node->path)) {
+ form_set_error('path', t('The path is invalid.'));
+ }
+ else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
+ form_set_error('path', t('The path is already in use.'));
+ }
+ break;
+
case 'load':
$path = "node/$node->nid";
// We don't use drupal_get_path_alias() to avoid custom rewrite functions.
@@ -216,36 +226,26 @@ function path_nodeapi(&$node, $op, $arg) {
$node->path = db_result($result);
}
break;
- }
- }
-}
-function path_node_delete_confirm_submit($form_id, $form_values) {
- $path = 'node/'. $form_values['node']->nid;
- if (drupal_get_path_alias($path) != $path) {
- path_set_alias($path);
- }
-}
+ case 'insert':
+ // Don't try to insert if path is NULL. We may have already set
+ // the alias ahead of time.
+ if ($node->path) {
+ path_set_alias("node/$node->nid", $node->path);
+ }
+ break;
-function path_node_submit($form_id, $node) {
- if ($node->is_new) {
- // Don't try to insert if path is NULL. We may have already set the alias ahead of time.
- if ($node->path) {
- path_set_alias("node/$node->nid", $node->path);
- }
- }
- else {
- path_set_alias("node/$node->nid", $node->path, $node->pid);
- }
-}
+ case 'update':
+ path_set_alias("node/$node->nid", $node->path, $node->pid);
+ break;
-function path_node_validate($form_id, $node) {
- $node['path'] = trim($node['path']);
- if ($node['path'] && !valid_url($node['path'])) {
- form_set_error('path', t('The path is invalid.'));
- }
- else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node['path'], 'node/'. $node['nid']))) {
- form_set_error('path', t('The path is already in use.'));
+ case 'delete':
+ $path = "node/$node->nid";
+ if (drupal_get_path_alias($path) != $path) {
+ path_set_alias($path);
+ }
+ break;
+ }
}
}
@@ -254,12 +254,6 @@ function path_node_validate($form_id, $node) {
*/
function path_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
-
- if (user_access('create url aliases')) {
- $form['#validate']['path_node_validate'] = array();
- $form['#submit']['path_node_submit'] = array();
- }
-
$path = $form['#node']->path;
$form['path'] = array(
'#type' => 'fieldset',
@@ -284,10 +278,6 @@ function path_form_alter($form_id, &$form) {
);
}
}
-
- if ($form_id == 'node_delete_confirm') {
- $form['#submit']['path_node_delete_confirm_submit'] = array();
- }
}