summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-08-10 06:29:01 +0000
committerDries Buytaert <dries@buytaert.net>2007-08-10 06:29:01 +0000
commitcf83099de10350adbd7868f729699e199a8d55c1 (patch)
tree335df00fd6c25d24166e701c6f508919f47a0a11 /modules
parent54882f994a9c2249fddd204648dc185f768d70dd (diff)
downloadbrdo-cf83099de10350adbd7868f729699e199a8d55c1.tar.gz
brdo-cf83099de10350adbd7868f729699e199a8d55c1.tar.bz2
- Patch #153425 by pwolanin: fix use of raw in node module.
Diffstat (limited to 'modules')
-rw-r--r--modules/node/node.module69
1 files changed, 45 insertions, 24 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 01b2b1280..4a9e2aa2c 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -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,7 +2236,12 @@ 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';
@@ -2232,6 +2249,19 @@ function node_form(&$form_state, $node) {
}
/**
+ * 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.
*/
function node_form_submit_build_node($form, &$form_state) {
@@ -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);