Commit cf83099d authored by Dries's avatar Dries
Browse files

- Patch #153425 by pwolanin: fix use of raw in node module.

parent 54882f99
......@@ -1200,7 +1200,8 @@ function node_menu() {
$items['admin/content/node'] = array(
'title' => 'Content',
'description' => "View, edit, and delete your site's content.",
'page callback' => 'node_admin_content',
'page callback' => 'drupal_get_form',
'page arguments' => array('node_admin_content'),
'access arguments' => array('administer nodes'),
);
......@@ -1373,6 +1374,7 @@ function node_node_operations() {
),
'delete' => array(
'label' => t('Delete'),
'callback' => NULL,
),
);
return $operations;
......@@ -1496,6 +1498,7 @@ function node_filter_form() {
'#title' => t('Show only items where'),
'#theme' => 'node_filters',
);
$form['#submit'][] = 'node_filter_form_submit';
foreach ($session as $filter) {
list($type, $value) = $filter;
if ($type == 'category') {
......@@ -1631,6 +1634,11 @@ function node_admin_nodes_submit($form, &$form_state) {
cache_clear_all();
drupal_set_message(t('The update has been performed.'));
}
else {
// We need to rebuild the form to go to a second step. For example, to
// show the confirmation form for the deletion of nodes.
$form_state['rebuild'] = TRUE;
}
}
function node_admin_nodes_validate($form, &$form_state) {
......@@ -1643,19 +1651,19 @@ function node_admin_nodes_validate($form, &$form_state) {
/**
* Menu callback: content administration.
*/
function node_admin_content() {
$output = drupal_get_form('node_filter_form');
if (isset($_POST['operation']) && ($_POST['operation'] == 'delete') && $_POST['nodes']) {
return drupal_get_form('node_multiple_delete_confirm');
function node_admin_content($form_state) {
if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
return node_multiple_delete_confirm($form_state, array_filter($form_state['values']['nodes']));
}
// Call the form first, to allow for the form_values array to be populated.
$output .= drupal_get_form('node_admin_nodes');
$form = node_filter_form();
return $output;
$form['admin'] = node_admin_nodes();
return $form;
}
function node_admin_nodes() {
$filter = node_build_filter_query();
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC'), 50, 0, NULL, $filter['args']);
......@@ -1674,7 +1682,11 @@ function node_admin_nodes() {
$options[$operation] = $array['label'];
}
$form['options']['operation'] = array('#type' => 'select', '#options' => $options, '#default_value' => 'approve');
$form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update'));
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#submit' => array('node_admin_nodes_submit'),
);
$destination = drupal_get_destination();
$nodes = array();
......@@ -1691,6 +1703,7 @@ function node_admin_nodes() {
}
$form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
$form['#theme'] = 'node_admin_nodes';
return $form;
}
......@@ -1737,17 +1750,16 @@ function theme_node_admin_nodes($form) {
return $output;
}
function node_multiple_delete_confirm(&$form_state) {
$edit = $form_state['post'];
function node_multiple_delete_confirm(&$form_state, $nodes) {
$form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter returns only elements with TRUE values
foreach (array_filter($edit['nodes']) as $nid => $value) {
foreach ($nodes as $nid => $value) {
$title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
$form['nodes'][$nid] = array('#type' => 'hidden', '#value' => $nid, '#prefix' => '<li>', '#suffix' => check_plain($title) ."</li>\n");
}
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
$form['#submit'][] = 'node_multiple_delete_confirm_submit';
return confirm_form($form,
t('Are you sure you want to delete these items?'),
'admin/content/node', t('This action cannot be undone.'),
......@@ -2224,13 +2236,31 @@ function node_form(&$form_state, $node) {
'#submit' => array('node_form_submit'),
);
if (!empty($node->nid) && node_access('delete', $node)) {
$form['buttons']['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 15);
$form['buttons']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 15,
'#submit' => array('node_form_delete_submit'),
);
}
$form['#validate'][] = 'node_form_validate';
$form['#theme'] = 'node_form';
return $form;
}
/**
* Button sumit function: handle the 'Delete' button on the node form.
*/
function node_form_delete_submit($form, &$form_state) {
$destination = '';
if (isset($_REQUEST['destination'])) {
$destination = drupal_get_destination();
unset($_REQUEST['destination']);
}
$node = $form['#node'];
$form_state['redirect'] = array('node/'. $node->nid .'/delete', $destination);
}
/**
* Build a node by processing submitted form values and prepare for a form rebuild.
*/
......@@ -2564,15 +2594,6 @@ function node_page_view($node, $cid = NULL) {
* Menu callback; presents the node editing form, or redirects to delete confirmation.
*/
function node_page_edit($node) {
if (isset($_POST['op']) && ($_POST['op'] == t('Delete'))) {
$destination = '';
// Note: we redirect from node/nid/edit to node/nid/delete to make the tabs disappear.
if (isset($_REQUEST['destination'])) {
$destination = drupal_get_destination();
unset($_REQUEST['destination']);
}
drupal_goto('node/'. $node->nid .'/delete', $destination);
}
drupal_set_title(t('Edit %title', array('%title' => $node->title)));
return drupal_get_form($node->type .'_node_form', $node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment