- Patch #68418 by Moshe et al: clean up node submit hooks.

5.x
Dries Buytaert 2006-08-29 18:43:26 +00:00
parent 78ee75f1a2
commit 5524604a95
11 changed files with 356 additions and 407 deletions

View File

@ -187,18 +187,15 @@ function book_load($node) {
return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
} }
/** function book_form_alter($form_id, &$form) {
* Implementation of hook_insert(). if ($form_id == 'node_delete_confirm') {
*/ $form['#submit']['book_node_delete_confirm_submit'] = array();
function book_insert($node) { }
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
} }
/** function book_node_submit($form_id, $node) {
* Implementation of hook_update(). $node = (object)$node;
*/ if ($node->is_new || $node->revision) {
function book_update($node) {
if ($node->revision) {
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight); db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
} }
else { else {
@ -206,30 +203,16 @@ function book_update($node) {
} }
} }
/** function book_node_delete_confirm_submit($form_id, $form_values) {
* Implementation of hook_delete(). db_query('DELETE FROM {book} WHERE nid = %d OR parent = %d', $form_values['node']->nid, $form_values['node']->nid);
*/
function book_delete(&$node) {
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
}
/**
* Implementation of hook_submit().
*/
function book_submit(&$node) {
global $user;
// Set default values for non-administrators.
if (!user_access('administer nodes')) {
$node->revision = 1;
$book->uid = $user->uid;
$book->name = $user->uid ? $user->name : '';
}
} }
/** /**
* Implementation of hook_form(). * Implementation of hook_form().
*/ */
function book_form(&$node) { function book_form(&$node) {
global $user;
$type = node_get_types('type', $node); $type = node_get_types('type', $node);
if ($node->nid && !$node->parent && !user_access('create new books')) { if ($node->nid && !$node->parent && !user_access('create new books')) {
$form['parent'] = array('#type' => 'value', '#value' => $node->parent); $form['parent'] = array('#type' => 'value', '#value' => $node->parent);
@ -265,22 +248,23 @@ function book_form(&$node) {
'#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'), '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'),
); );
if (user_access('administer nodes')) {
$form['weight'] = array('#type' => 'weight', $form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'), '#title' => t('Weight'),
'#access' => user_access('administer nodes'),
'#default_value' => $node->weight, '#default_value' => $node->weight,
'#delta' => 15, '#delta' => 15,
'#weight' => 5, '#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'), '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
); );
}
else { if (!user_access('administer nodes')) {
// If a regular user updates a book page, we preserve the node weight; otherwise // If a regular user updates a book page, we preserve the node weight; otherwise
// we use 0 as the default for new pages // we use 0 as the default for new pages
$form['weight'] = array( $form['weight'] = array(
'#type' => 'value', '#type' => 'value',
'#value' => isset($node->weight) ? $node->weight : 0, '#value' => isset($node->weight) ? $node->weight : 0,
); );
$form['name'] = array('#type' => 'value', '#value' => $user->uid ? $user->name : '');
} }
return $form; return $form;
@ -481,9 +465,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
case 'delete revision': case 'delete revision':
db_query('DELETE FROM {book} WHERE vid = %d', $node->vid); db_query('DELETE FROM {book} WHERE vid = %d', $node->vid);
break; break;
case 'delete':
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
break;
} }
} }

View File

@ -280,6 +280,7 @@ function comment_form_alter($form_id, &$form) {
} }
elseif (isset($form['type'])) { elseif (isset($form['type'])) {
if ($form['type']['#value'] .'_node_form' == $form_id) { if ($form['type']['#value'] .'_node_form' == $form_id) {
$form['#submit']['comment_node_submit'] = array();
$node = $form['#node']; $node = $form['#node'];
$form['comment_settings'] = array( $form['comment_settings'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -297,6 +298,10 @@ function comment_form_alter($form_id, &$form) {
); );
} }
} }
if ($form_id == 'node_delete_confirm') {
$form['#submit']['comment_node_delete_confirm_submit'] = array();
}
} }
/** /**
@ -315,15 +320,6 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
} }
break; break;
case 'insert':
db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid);
break;
case 'delete':
db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
break;
case 'update index': case 'update index':
$text = ''; $text = '';
$comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED);
@ -346,6 +342,17 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
} }
} }
function comment_node_delete_confirm_submit($form_id, $form_values) {
db_query('DELETE FROM {comments} WHERE nid = %d', $form_values['node']->nid);
db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $form_values['node']->nid);
}
function comment_node_submit($form_id, $node) {
if ($node->is_new) {
db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid);
}
}
/** /**
* Implementation of hook_user(). * Implementation of hook_user().
* *

View File

@ -233,6 +233,31 @@ function forum_form_alter($form_id, &$form) {
unset($form['nodes']['forum']); unset($form['nodes']['forum']);
} }
} }
if ($form_id == 'node_delete_confirm' && $form['node']['#value']->type == 'forum') {
$form['#submit']['forum_node_delete_confirm_submit'] = array();
}
}
/**
* Check in particular that only a "leaf" term in the associated taxonomy
* vocabulary is selected, not a "container" term.
*/
function forum_node_validate($form_id, $node) {
$node = (object)$node;
if ($node->taxonomy) {
// Extract the node's proper topic ID.
$vocabulary = variable_get('forum_nav_vocabulary', '');
$containers = variable_get('forum_containers', array());
foreach ($node->taxonomy as $term) {
if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
if (in_array($term, $containers)) {
$term = taxonomy_get_term($term);
form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
}
}
}
}
} }
/** /**
@ -327,16 +352,15 @@ function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
} }
/** /**
* Implementation of hook_submit(). * An early submit handler of the forum_node_form. Runs before the node is saved.
*
* Check in particular that only a "leaf" term in the associated taxonomy
* vocabulary is selected, not a "container" term.
*/ */
function forum_submit(&$node) { function forum_node_submit_early($form_id, &$node) {
$node = (object)$node;
// Make sure all fields are set properly: // Make sure all fields are set properly:
$node->icon = $node->icon ? $node->icon : ''; $node->icon = $node->icon ? $node->icon : '';
if ($node->taxonomy) { if (!empty($node->taxonomy)) {
// Get the forum terms from the (cached) tree // Get the forum terms from the (cached) tree
$tree = taxonomy_get_tree(_forum_get_vid()); $tree = taxonomy_get_tree(_forum_get_vid());
if ($tree) { if ($tree) {
@ -357,35 +381,13 @@ function forum_submit(&$node) {
} }
} }
} }
$node = (array)$node;
} }
/** function forum_node_submit($form_id, $node) {
* Implementation of hook_validate(). $node = (object)$node;
* if ($node->is_new) {
* Check in particular that only a "leaf" term in the associated taxonomy
* vocabulary is selected, not a "container" term.
*/
function forum_validate($node) {
if ($node->taxonomy) {
// Extract the node's proper topic ID.
$vocabulary = variable_get('forum_nav_vocabulary', '');
$containers = variable_get('forum_containers', array());
foreach ($node->taxonomy as $term) {
if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
if (in_array($term, $containers)) {
$term = taxonomy_get_term($term);
form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
}
}
}
}
}
/**
* Implementation of hook_update().
*/
function forum_update($node) {
if ($node->revision) {
db_query("INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $node->tid); db_query("INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $node->tid);
} }
else { else {
@ -424,18 +426,8 @@ function forum_prepare(&$node) {
} }
} }
/** function forum_node_delete_confirm_submit($form_id, $form_values) {
* Implementation of hook_insert(). db_query('DELETE FROM {forum} WHERE nid = %d', $form_values['node']->nid);
*/
function forum_insert($node) {
db_query('INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $node->tid);
}
/**
* Implementation of hook_delete().
*/
function forum_delete(&$node) {
db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
} }
/** /**

View File

@ -147,15 +147,12 @@ function menu_block($op = 'list', $delta = 0) {
} }
} }
/** function menu_node_delete_confirm_submit($form_id, $form_values) {
* Implementation of hook_nodeapi(). menu_node_form_delete($form_values['node']);
*/ menu_rebuild();
function menu_nodeapi(&$node, $op) { }
if (user_access('administer menu')) { function menu_node_submit($form_id, $node) {
switch ($op) {
case 'insert':
case 'update':
if ($node->menu['delete']) { if ($node->menu['delete']) {
menu_node_form_delete($node); menu_node_form_delete($node);
menu_rebuild(); menu_rebuild();
@ -165,14 +162,6 @@ function menu_nodeapi(&$node, $op) {
menu_edit_item_save($node->menu); menu_edit_item_save($node->menu);
menu_rebuild(); menu_rebuild();
} }
break;
case 'delete':
menu_node_form_delete($node);
menu_rebuild();
break;
}
}
} }
/** /**
@ -199,6 +188,8 @@ function menu_form_alter($form_id, &$form) {
} }
} }
$form['#submit']['menu_node_submit'] = array();
$form['menu'] = array('#type' => 'fieldset', $form['menu'] = array('#type' => 'fieldset',
'#title' => t('Menu settings'), '#title' => t('Menu settings'),
'#access' => user_access('administer menu'), '#access' => user_access('administer menu'),
@ -259,6 +250,10 @@ function menu_form_alter($form_id, &$form) {
); );
} }
} }
if ($form_id == 'node_delete_confirm') {
$form['#submit']['menu_node_delete_confirm_submit'] = array();
}
} }
/** /**

View File

@ -3,7 +3,27 @@
/** /**
* @file * @file
* The core that allows content to be submitted to the site. * The core that allows content to be submitted to the site. Modules and scripts may
* programmatically submit nodes using the usual form API pattern.
* CREATE/EDIT NODE EXAMPLE
* $type = 'story';
* $node = array('type' => $type);
* $form = drupal_retrieve_form($type. '_node_form', $node);
* $form['#post']['edit']['nid'] = 112; // send this if performing an edit
* $form['#post']['edit']['name'] = 'amy';
* $form['#post']['edit']['title'] = 'robotitle';
* $form['#post']['edit']['body'] = 'hello world';
* $goto = drupal_process_form($type. '_node_form', $form);
*
* DELETE SINGLE NODE EXAMPLE
* $node = node_load(112);
* $form = drupal_retrieve_form('node_delete_confirm', $node);
* $form['#post']['op'] = t('Delete');
* $goto = drupal_process_form('node_delete_confirm', $form);
*
* Calling form_get_errors() will list any validation errors that prevented the
* form from being submitted.
*/ */
define('NODE_NEW_LIMIT', time() - 30 * 24 * 60 * 60); define('NODE_NEW_LIMIT', time() - 30 * 24 * 60 * 60);
@ -601,16 +621,6 @@ function node_save(&$node) {
db_query($node_query, $node_table_values); db_query($node_query, $node_table_values);
db_query($revisions_query, $revisions_table_values); db_query($revisions_query, $revisions_table_values);
// Call the node specific callback (if any):
if ($node->is_new) {
node_invoke($node, 'insert');
node_invoke_nodeapi($node, 'insert');
}
else {
node_invoke($node, 'update');
node_invoke_nodeapi($node, 'update');
}
// Update the node access table for this node. // Update the node access table for this node.
node_access_acquire_grants($node); node_access_acquire_grants($node);
@ -1072,6 +1082,8 @@ function node_menu($may_cache) {
'path' => 'node/add/'. $type_url_str, 'path' => 'node/add/'. $type_url_str,
'title' => t($name), 'title' => t($name),
'access' => node_access('create', $type->type), 'access' => node_access('create', $type->type),
'callback' => 'drupal_get_form',
'callback arguments' => array($type->type. '_node_form', array('type' => $type->type))
); );
} }
} }
@ -1100,7 +1112,7 @@ function node_menu($may_cache) {
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'), $items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'),
'callback' => 'drupal_get_form', 'callback' => 'drupal_get_form',
'callback arguments' => array('node_delete_confirm'), 'callback arguments' => array('node_delete_confirm', $node),
'access' => node_access('delete', $node), 'access' => node_access('delete', $node),
'weight' => 1, 'weight' => 1,
'type' => MENU_CALLBACK); 'type' => MENU_CALLBACK);
@ -1757,53 +1769,9 @@ function node_feed($nodes = 0, $channel = array()) {
} }
/** /**
* Prepare node for save and allow modules to make changes. * A form validate handler. Perform checks on the given node.
*/ */
function node_submit($node) { function node_form_validate($form_id, $node) {
global $user;
// Convert the node to an object, if necessary.
$node = (object)$node;
// Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
if (!isset($node->teaser)) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
$access = user_access('administer nodes');
if ($access) {
// Populate the "authored by" field.
if ($account = user_load(array('name' => $node->name))) {
$node->uid = $account->uid;
}
else {
$node->uid = 0;
}
$node->created = $node->date ? strtotime($node->date) : NULL;
}
// Force defaults in case people modify the form:
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options);
}
}
// Do node-type-specific validation checks.
node_invoke($node, 'submit');
node_invoke_nodeapi($node, 'submit');
$node->validated = TRUE;
return $node;
}
/**
* Perform validation checks on the given node.
*/
function node_validate($node, $form = array()) {
// Convert the node to an object, if necessary. // Convert the node to an object, if necessary.
$node = (object)$node; $node = (object)$node;
$type = node_get_types('type', $node); $type = node_get_types('type', $node);
@ -1832,14 +1800,6 @@ function node_validate($node, $form = array()) {
form_set_error('date', t('You have to specify a valid date.')); form_set_error('date', t('You have to specify a valid date.'));
} }
} }
// Do node-type-specific validation checks.
node_invoke($node, 'validate', $form);
node_invoke_nodeapi($node, 'validate', $form);
}
function node_form_validate($form_id, $form_values, $form) {
node_validate($form_values, $form);
} }
function node_object_prepare(&$node) { function node_object_prepare(&$node) {
@ -1858,9 +1818,11 @@ function node_object_prepare(&$node) {
} }
/** /**
* Generate the node editing form array * Generate the node add/edit form array.
*/ */
function node_form($node) { function node_form($node) {
global $user;
$node = (object)$node; $node = (object)$node;
node_object_prepare($node); node_object_prepare($node);
@ -1884,14 +1846,13 @@ function node_form($node) {
$form['title']['#weight'] = -5; $form['title']['#weight'] = -5;
} }
// Populate $node so we can assign it to $form['#node].
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
// If this is a new node, fill in the default values. // If this is a new node, fill in the default values.
if (!isset($node->nid)) { if (!isset($node->nid)) {
foreach (array('status', 'promote', 'sticky', 'revision') as $key) { foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
$node->$key = in_array($key, $node_options); $node->$key = in_array($key, $node_options);
} }
global $user;
$node->uid = $user->uid;
} }
else { else {
// Nodes being edited should always be preset with the default revision setting. // Nodes being edited should always be preset with the default revision setting.
@ -1899,39 +1860,17 @@ function node_form($node) {
} }
$form['#node'] = $node; $form['#node'] = $node;
// Node author information for administrators // Node author information is editable only by administrators.
$form['author'] = array( $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#access' => user_access('administer nodes'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20);
'#type' => 'fieldset', $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->nid ? $node->name : $user->name, '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', 'Anonymous'))));
'#access' => user_access('administer nodes'), $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#default_value' => $node->date, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date)));
'#title' => t('Authoring information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 20,
);
$form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', 'Anonymous'))));
$form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date)));
if (isset($node->nid)) { // Node options are editable only by administrators.
$form['author']['date']['#default_value'] = $node->date; $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#access' => user_access('administer nodes'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);
}
// Node options for administrators
$form['options'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer nodes'),
'#title' => t('Publishing options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 25,
);
$form['options']['status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status); $form['options']['status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status);
$form['options']['promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote); $form['options']['promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote);
$form['options']['sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky); $form['options']['sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky);
$form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision); $form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision);
// These values are used when the user has no administrator accesss.
foreach (array('uid', 'created') as $key) {
$form[$key] = array('#type' => 'value', '#value' => $node->$key);
}
// Add the buttons. // Add the buttons.
$form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40); $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40);
@ -1940,6 +1879,15 @@ function node_form($node) {
$form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50); $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
} }
$form['#after_build'] = array('node_form_add_preview'); $form['#after_build'] = array('node_form_add_preview');
$form['#validate'] = array(
'node_form_validate' => array(),
$node->type .'_node_validate' => array(),
);
$form['#submit'] = array(
$node->type .'_node_submit_early' => array(),
'node_form_submit' => array(),
$node->type .'_node_submit' => array(),
);
$form['#base'] = 'node_form'; $form['#base'] = 'node_form';
return $form; return $form;
} }
@ -2003,23 +1951,14 @@ function theme_node_form($form) {
} }
/** /**
* Present a node submission form or a set of links to such forms. * Present set of list of node creation links
*/ */
function node_add($type = NULL) { function node_add() {
global $user; global $user;
$types = node_get_types(); $types = node_get_types();
$type = isset($type) ? str_replace('-', '_', $type) : NULL; $type = isset($type) ? str_replace('-', '_', $type) : NULL;
// If a node type has been specified, validate its existence.
if (isset($types[$type]) && node_access('create', $type)) {
// Initialize settings:
$node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
$output = drupal_get_form($type .'_node_form', $node);
drupal_set_title(t('Submit @name', array('@name' => $types[$type]->name)));
}
else {
// If no (valid) node type has been provided, display a node type overview.
foreach ($types as $type) { foreach ($types as $type) {
if (function_exists($type->module .'_form') && node_access('create', $type->type)) { if (function_exists($type->module .'_form') && node_access('create', $type->type)) {
$type_url_str = str_replace('_', '-', $type->type); $type_url_str = str_replace('_', '-', $type->type);
@ -2037,7 +1976,6 @@ function node_add($type = NULL) {
else { else {
$output = t('No content types available.'); $output = t('No content types available.');
} }
}
return $output; return $output;
} }
@ -2116,31 +2054,27 @@ function theme_node_log_message($log) {
return '<div class="log"><div class="title">'. t('Log') .':</div>'. $log .'</div>'; return '<div class="log"><div class="title">'. t('Log') .':</div>'. $log .'</div>';
} }
function node_form_submit($form_id, $edit) { function node_form_submit($form_id, &$node) {
global $user; global $user;
// Fix up the node when required: $node = (object)$node;
$node = node_submit($edit); // Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
if (!isset($node->teaser)) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
// Prepare the node's body: // Populate the uid based on name field.
if ($node->nid) { $account = user_load(array('name' => $node->name));
// Check whether the current user has the proper access rights to $node->uid = $account->uid;
// perform this operation: $node->created = strtotime($node->date);
if (node_access('update', $node)) {
$action = $node->nid ? 'updated' : 'created';
node_save($node); node_save($node);
watchdog('content', t('@type: updated %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); watchdog('content', t("@type: $action %title.", array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
drupal_set_message(t('The %post was updated.', array ('%post' => node_get_types('name', $node)))); drupal_set_message(t("The %post was $action.", array ('%post' => node_get_types('name', $node))));
}
} // redirect the submitter as needed
else {
// Check whether the current user has the proper access rights to
// perform this operation:
if (node_access('create', $node)) {
node_save($node);
watchdog('content', t('@type: added %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
drupal_set_message(t('Your %post was created.', array ('%post' => node_get_types('name', $node))));
}
}
if ($node->nid) { if ($node->nid) {
if (node_access('view', $node)) { if (node_access('view', $node)) {
return 'node/'. $node->nid; return 'node/'. $node->nid;
@ -2156,13 +2090,9 @@ function node_form_submit($form_id, $edit) {
/** /**
* Menu callback -- ask for confirmation of node deletion * Menu callback -- ask for confirmation of node deletion
*/ */
function node_delete_confirm() { function node_delete_confirm($node) {
$edit = $_POST;
$edit['nid'] = $edit['nid'] ? $edit['nid'] : arg(1);
$node = node_load($edit['nid']);
if (node_access('delete', $node)) { if (node_access('delete', $node)) {
$form['nid'] = array('#type' => 'value', '#value' => $node->nid); $form['node'] = array('#type' => 'value', '#value' => $node);
$output = confirm_form($form, $output = confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $node->title)), t('Are you sure you want to delete %title?', array('%title' => $node->title)),
$_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid, t('This action cannot be undone.'), $_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid, t('This action cannot be undone.'),
@ -2176,10 +2106,7 @@ function node_delete_confirm() {
* Execute node deletion * Execute node deletion
*/ */
function node_delete_confirm_submit($form_id, $form_values) { function node_delete_confirm_submit($form_id, $form_values) {
if ($form_values['confirm']) { node_delete($form_values['node']->nid);
node_delete($form_values['nid']);
}
return ''; return '';
} }
@ -2194,10 +2121,6 @@ function node_delete($nid) {
db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
// Call the node-specific callback (if any):
node_invoke($node, 'delete');
node_invoke_nodeapi($node, 'delete');
// Clear the cache so an anonymous poster can see the node being deleted. // Clear the cache so an anonymous poster can see the node being deleted.
cache_clear_all(); cache_clear_all();

View File

@ -209,16 +209,6 @@ function path_form($edit = '') {
function path_nodeapi(&$node, $op, $arg) { function path_nodeapi(&$node, $op, $arg) {
if (user_access('create url aliases') || user_access('administer url aliases')) { if (user_access('create url aliases') || user_access('administer url aliases')) {
switch ($op) { 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': case 'load':
$path = "node/$node->nid"; $path = "node/$node->nid";
// We don't use drupal_get_path_alias() to avoid custom rewrite functions. // We don't use drupal_get_path_alias() to avoid custom rewrite functions.
@ -228,26 +218,36 @@ function path_nodeapi(&$node, $op, $arg) {
$node->path = db_result($result); $node->path = db_result($result);
} }
break; break;
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; }
}
case 'update': function path_node_delete_confirm_submit($form_id, $form_values) {
path_set_alias("node/$node->nid", $node->path, $node->pid); $path = 'node/'. $form_values['node']->nid;
break;
case 'delete':
$path = "node/$node->nid";
if (drupal_get_path_alias($path) != $path) { if (drupal_get_path_alias($path) != $path) {
path_set_alias($path); path_set_alias($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);
}
}
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.'));
} }
} }
@ -256,6 +256,12 @@ function path_nodeapi(&$node, $op, $arg) {
*/ */
function path_form_alter($form_id, &$form) { function path_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { 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; $path = $form['#node']->path;
$form['path'] = array( $form['path'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -280,6 +286,10 @@ function path_form_alter($form_id, &$form) {
); );
} }
} }
if ($form_id == 'node_delete_confirm') {
$form['#submit']['path_node_delete_confirm_submit'] = array();
}
} }

View File

@ -78,29 +78,24 @@ function poll_cron() {
} }
} }
/** function poll_node_delete_confirm_submit($form_id, $form_values) {
* Implementation of hook_delete(). db_query("DELETE FROM {poll} WHERE nid = %d", $form_values['node']->nid);
*/ db_query("DELETE FROM {poll_choices} WHERE nid = %d", $form_values['node']->nid);
function poll_delete($node) { db_query("DELETE FROM {poll_votes} WHERE nid = %d", $form_values['node']->nid);
db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid);
} }
/** /**
* Implementation of hook_submit(). * An early submit handler of the poll_node_form. Runs before the node is saved.
*/ */
function poll_submit(&$node) { function poll_node_submit_early($form_id, &$node) {
$node = (object)$node;
// Renumber fields // Renumber fields
$node->choice = array_values($node->choice); $node->choice = array_values($node->choice);
$node->teaser = poll_teaser($node); $node->teaser = poll_teaser($node);
} }
/** function poll_node_validate($form_id, $node) {
* Implementation of hook_validate(). $node = (object)$node;
*/
function poll_validate($node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes: // Check for at least two options and validate amount of votes:
$realchoices = 0; $realchoices = 0;
// Renumber fields // Renumber fields
@ -118,6 +113,11 @@ function poll_validate($node) {
form_set_error("choice][$realchoices][chtext", t('You must fill in at least two choices.')); form_set_error("choice][$realchoices][chtext", t('You must fill in at least two choices.'));
} }
} }
function poll_form_alter($form_id, &$form) {
if ($form_id == 'node_delete_confirm' && $form['node']['#value']->type == 'poll') {
$form['#submit']['poll_node_delete_confirm_submit'] = array();
}
} }
/** /**
@ -582,9 +582,16 @@ function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
return $node; return $node;
} }
/** function poll_node_submit($form_id, $node) {
* Implementation of hook_update(). $node = (object)$node;
*/ if ($node->is_new) {
poll_insert($node);
}
else {
poll_update($node);
}
}
function poll_update($node) { function poll_update($node) {
db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid);

View File

@ -533,14 +533,13 @@ function _statistics_format_item($title, $path) {
return $output; return $output;
} }
/** function statistics_node_delete_confirm_submit($form_id, $form_values) {
* Implementation of hook_nodeapi(). db_query('DELETE FROM {node_counter} WHERE nid = %d', $form_values['node']->nid);
*/ }
function statistics_nodeapi(&$node, $op, $arg = 0) {
switch ($op) { function statistics_form_alter($form_id, &$form) {
case 'delete': if ($form_id == 'node_delete_confirm') {
// clean up statistics table when node is deleted $form['#submit']['statistics_node_delete_confirm_submit'] = array();
db_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid);
} }
} }

View File

@ -550,35 +550,69 @@ function system_clean_url_settings() {
} }
function system_error_reporting_settings() { function system_error_reporting_settings() {
$form['403'] = array(
$form['site_403'] = array( '#type' => 'fieldset',
'#title' => t('Access denied page (403)'),
'#description' => t('These settings apply when the requested document is denied to the current user, i.e. a <em>403 error</em>.'),
);
$form['403']['site_403'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default 403 (access denied) page'), '#title' => t('Page to display'),
'#default_value' => variable_get('site_403', ''), '#default_value' => variable_get('site_403', ''),
'#description' => t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "<code>?q=</code>". If unsure, specify nothing.') '#description' => t('This page is displayed when a 403 error occurs. If you are not using clean URLs, specify the part after "<code>?q=</code>". If unsure, leave blank.'),
); );
$form['403']['site_403_message_show'] = array(
$form['site_404'] = array( '#type' => 'checkbox',
'#title' => t('Enable error message'),
'#description' => t('Displays the message below.'),
'#default_value' => variable_get('site_403_message_show', TRUE),
);
$form['403']['site_403_message'] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#description' => t('This message is shown when a 403 error occurs, if enabled. "%path" will be replaced with the path of the requested document.'),
'#default_value' => variable_get('site_403_message', t('We are sorry, the requested page (%path) was not found on this webserver. Either the URL does not exist or the page you were looking has been deleted.')),
);
$form['404'] = array(
'#type' => 'fieldset',
'#title' => t('File not found page (404)'),
'#description' => t('These settings apply when the requested document could not be found, i.e. a <em>404 error</em>.'),
);
$form['404']['site_404'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default 404 (not found) page'), '#title' => t('Page to display'),
'#default_value' => variable_get('site_404', ''), '#default_value' => variable_get('site_404', ''),
'#description' => t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "<code>?q=</code>". If unsure, specify nothing.') '#description' => t('This page is displayed when a 404 error occurs. If you are not using clean URLs, specify the part after "<code>?q=</code>". If unsure, leave blank.'),
); );
$form['404']['site_404_message_show'] = array(
$form['error_level'] = array( '#type' => 'checkbox',
'#title' => t('Enable error message'),
'#description' => t('Displays the message below.'),
'#default_value' => variable_get('site_404_message_show', TRUE),
);
$form['404']['site_404_message'] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#description' => t('This message is shown when a 404 error occurs, if enabled. "%path" will be replaced with the path of the requested document.'),
'#default_value' => variable_get('site_404_message', t('We are sorry, %path could not be found. Please check the spelling and punctuation. This website is case sensitive, so also make sure that the address has the correct case.')),
);
$form['error'] = array(
'#type' => 'fieldset',
'#title' => t('Other error handling'),
);
$form['error']['error_level'] = array(
'#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1), '#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
'#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')), '#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
'#description' => t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.') '#description' => t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.'),
); );
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
$period['1000000000'] = t('Never'); $period['1000000000'] = t('Never');
$form['watchdog_clear'] = array( $form['error']['watchdog_clear'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Discard log entries older than'), '#title' => t('Discard log entries older than'),
'#default_value' => variable_get('watchdog_clear', 604800), '#default_value' => variable_get('watchdog_clear', 604800),
'#options' => $period, '#options' => $period,
'#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.') '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.'),
); );
return system_settings_form($form); return system_settings_form($form);

View File

@ -606,6 +606,10 @@ function taxonomy_get_vocabularies($type = NULL) {
*/ */
function taxonomy_form_alter($form_id, &$form) { function taxonomy_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
// inject custom validate and submit handlers
$form['#validate']['taxonomy_node_validate'] = array();
$form['#submit']['taxonomy_node_submit'] = array();
$node = $form['#node']; $node = $form['#node'];
if (!isset($node->taxonomy)) { if (!isset($node->taxonomy)) {
@ -672,6 +676,10 @@ function taxonomy_form_alter($form_id, &$form) {
$form['taxonomy'] += array('#type' => 'fieldset', '#title' => t('Categories'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#weight' => -3); $form['taxonomy'] += array('#type' => 'fieldset', '#title' => t('Categories'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#weight' => -3);
} }
} }
if ($form_id == 'node_delete_confirm') {
$form['#submit']['taxonomy_node_delete_confirm_submit'] = array();
}
} }
/** /**
@ -705,9 +713,9 @@ function taxonomy_node_get_terms($nid, $key = 'tid') {
/** /**
* Make sure incoming vids are free tagging enabled. * Make sure incoming vids are free tagging enabled.
*/ */
function taxonomy_node_validate(&$node) { function taxonomy_node_validate($form_id, $node) {
if ($node->taxonomy) { if ($node['taxonomy']) {
$terms = $node->taxonomy; $terms = $node['taxonomy'];
if ($terms['tags']) { if ($terms['tags']) {
foreach ($terms['tags'] as $vid => $vid_value) { foreach ($terms['tags'] as $vid => $vid_value) {
$vocabulary = taxonomy_get_vocabulary($vid); $vocabulary = taxonomy_get_vocabulary($vid);
@ -724,14 +732,14 @@ function taxonomy_node_validate(&$node) {
/** /**
* Save term associations for a given node. * Save term associations for a given node.
*/ */
function taxonomy_node_save($nid, $terms) { function taxonomy_node_submit($form_id, $node) {
taxonomy_node_delete($nid); taxonomy_node_delete($node->nid);
// Free tagging vocabularies do not send their tids in the form, // Free tagging vocabularies do not send their tids in the form,
// so we'll detect them here and process them independently. // so we'll detect them here and process them independently.
if (isset($terms['tags'])) { if (isset($node->taxonomy['tags'])) {
$typed_input = $terms['tags']; $typed_input = $node->taxonomy['tags'];
unset($terms['tags']); unset($node->taxonomy['tags']);
foreach ($typed_input as $vid => $vid_value) { foreach ($typed_input as $vid => $vid_value) {
// This regexp allows the following types of user input: // This regexp allows the following types of user input:
@ -767,27 +775,27 @@ function taxonomy_node_save($nid, $terms) {
// Defend against duplicate, different cased tags // Defend against duplicate, different cased tags
if (!isset($inserted[$typed_term_tid])) { if (!isset($inserted[$typed_term_tid])) {
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $typed_term_tid);
$inserted[$typed_term_tid] = TRUE; $inserted[$typed_term_tid] = TRUE;
} }
} }
} }
} }
if (is_array($terms)) { if (is_array($node->taxonomy)) {
foreach ($terms as $term) { foreach ($node->taxonomy as $term) {
if (is_array($term)) { if (is_array($term)) {
foreach ($term as $tid) { foreach ($term as $tid) {
if ($tid) { if ($tid) {
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $tid); db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $tid);
} }
} }
} }
else if (is_object($term)) { else if (is_object($term)) {
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term->tid); db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $term->tid);
} }
else if ($term) { else if ($term) {
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term); db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $term);
} }
} }
} }
@ -1157,18 +1165,6 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
case 'load': case 'load':
$output['taxonomy'] = taxonomy_node_get_terms($node->nid); $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
return $output; return $output;
case 'insert':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
case 'update':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
case 'delete':
taxonomy_node_delete($node->nid);
break;
case 'validate':
taxonomy_node_validate($node);
break;
case 'rss item': case 'rss item':
return taxonomy_rss_item($node); return taxonomy_rss_item($node);
case 'update index': case 'update index':
@ -1176,6 +1172,10 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
} }
} }
function taxonomy_node_confirm_delete_submit($form_id, $form_values) {
taxonomy_node_delete($form_values['node']->nid);
}
/** /**
* Implementation of hook_nodeapi('update_index'). * Implementation of hook_nodeapi('update_index').
*/ */

View File

@ -363,7 +363,13 @@ function upload_form_alter($form_id, &$form) {
if (isset($form['type'])) { if (isset($form['type'])) {
$node = $form['#node']; $node = $form['#node'];
if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) { if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) {
if (user_access('upload files')) {
$form['#validate']['upload_node_validate'] = array();
$form['#submit']['upload_node_submit'] = array();
}
drupal_add_js('misc/progress.js'); drupal_add_js('misc/progress.js');
drupal_add_js('misc/upload.js'); drupal_add_js('misc/upload.js');
@ -389,9 +395,14 @@ function upload_form_alter($form_id, &$form) {
$form['#attributes']['enctype'] = 'multipart/form-data'; $form['#attributes']['enctype'] = 'multipart/form-data';
} }
} }
if ($form_id == 'node_delete_confirm') {
$form['#submit']['upload_node_delete_confirm_submit'] = array();
}
} }
function _upload_validate(&$node) { function upload_node_validate($form_id, $node) {
$node = (object)$node;
// Accumulator for disk space quotas. // Accumulator for disk space quotas.
$filesize = 0; $filesize = 0;
@ -483,10 +494,6 @@ function upload_nodeapi(&$node, $op, $teaser) {
_upload_prepare($node); _upload_prepare($node);
break; break;
case 'validate':
_upload_validate($node);
break;
case 'view': case 'view':
if (isset($node->files) && user_access('view uploaded files')) { if (isset($node->files) && user_access('view uploaded files')) {
// Add the attachments list to node body with a heavy // Add the attachments list to node body with a heavy
@ -521,18 +528,6 @@ function upload_nodeapi(&$node, $op, $teaser) {
} }
} }
break; break;
case 'insert':
case 'update':
if (user_access('upload files')) {
upload_save($node);
}
break;
case 'delete':
upload_delete($node);
break;
case 'delete revision': case 'delete revision':
upload_delete_revision($node); upload_delete_revision($node);
break; break;
@ -579,6 +574,12 @@ function upload_fix_preview_urls($elements, &$content) {
} }
} }
function upload_node_submit($form_id, $node) {
if (user_access('upload files')) {
upload_save($node);
}
}
/** /**
* Displays file attachments in table * Displays file attachments in table
*/ */
@ -730,9 +731,9 @@ function upload_save($node) {
} }
} }
function upload_delete($node) { function upload_node_delete_confirm_submit($form_id, $form_values) {
$files = array(); $files = array();
$result = db_query('SELECT * FROM {files} WHERE nid = %d', $node->nid); $result = db_query('SELECT * FROM {files} WHERE nid = %d', $form_values['node']->nid);
while ($file = db_fetch_object($result)) { while ($file = db_fetch_object($result)) {
$files[$file->fid] = $file; $files[$file->fid] = $file;
} }
@ -744,7 +745,7 @@ function upload_delete($node) {
} }
// Delete all files associated with the node // Delete all files associated with the node
db_query('DELETE FROM {files} WHERE nid = %d', $node->nid); db_query('DELETE FROM {files} WHERE nid = %d', $form_values['node']->nid);
} }
function upload_delete_revision($node) { function upload_delete_revision($node) {
@ -884,7 +885,7 @@ function upload_js() {
// Handle new uploads, and merge tmp files into node-files. // Handle new uploads, and merge tmp files into node-files.
_upload_prepare($node); _upload_prepare($node);
_upload_validate($node); upload_node_validate(NULL, $node);
$form = _upload_form($node); $form = _upload_form($node);
foreach (module_implements('form_alter') as $module) { foreach (module_implements('form_alter') as $module) {