Skip to content
Snippets Groups Projects
Commit 9ddca228 authored by Todd Nienkerk's avatar Todd Nienkerk
Browse files

initial 6.x release

parent ea8fee71
No related branches found
No related merge requests found
; $Id$
name = Mass Change
description = "Mass change the workflow and commenting status of nodes by content type."
core = 5.x
core = 6.x
......@@ -10,20 +10,18 @@
/**
* Implementation of hook_menu().
*/
function mass_change_menu($may_cache) {
function mass_change_menu() {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/content/mass_change',
'title' => t('Mass Change'),
'description' => t('Mass change the workflow and commenting status of nodes by content type.'),
'access' => user_access('mass change nodes'),
'callback' => 'drupal_get_form',
'callback arguments' => 'mass_change_page_form',
);
}
$items['admin/content/mass_change'] = array(
'title' => 'Mass Change',
'description' => 'Mass change the workflow and commenting status of nodes by content type.',
'page callback' => 'drupal_get_form',
'page arguments' => array('mass_change_page_form'),
'access callback' => 'user_access',
'access arguments' => array('mass change nodes'),
);
return $items;
}
......@@ -36,7 +34,7 @@ function mass_change_perm() {
}
function mass_change_page_form() {
function mass_change_page_form($form_state) {
$form = array();
$form['action'] = array(
......@@ -49,20 +47,23 @@ function mass_change_page_form() {
'unpromote' => t('Unpromote'),
'sticky' => t('Sticky'),
'unsticky' => t('Unsticky'),
'rwcomments' => t('Commenting: Read/Write'),
'rocomments' => t('Commenting: Read only'),
'nocomments' => t('Commenting: Disabled'),
),
'#required' => TRUE,
);
if (module_exists('comment')) {
$form['action']['#options']['rwcomments'] = t('Commenting: Read/Write');
$form['action']['#options']['rocomments'] = t('Commenting: Read only');
$form['action']['#options']['nocomments'] = t('Commenting: Disabled');
}
$form['content_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types to mass change'),
'#options' => node_get_types('names'),
);
$form[] = array(
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Mass change nodes'),
);
......@@ -71,57 +72,57 @@ function mass_change_page_form() {
}
function mass_change_page_form_submit($form_id, $form_values) {
function mass_change_page_form_submit($form, &$form_state) {
$change = '';
$message = '';
$content_types = array();
if ($form_values['action'] == 'publish') {
if ($form_state['values']['action'] == 'publish') {
$change = 'status = 1';
$message = t('<strong>Published</strong>');
}
else if ($form_values['action'] == 'unpublish') {
else if ($form_state['values']['action'] == 'unpublish') {
$change = 'status = 0';
$message = t('<strong>Unpublished</strong>');
}
else if ($form_values['action'] == 'promote') {
else if ($form_state['values']['action'] == 'promote') {
$change = 'promote = 1';
$message = t('<strong>Promoted</strong>');
$message = '<strong>Promoted</strong>';
}
else if ($form_values['action'] == 'unpromote') {
else if ($form_state['values']['action'] == 'unpromote') {
$change = 'promote = 0';
$message = t('<strong>Unpromoted</strong>');
}
else if ($form_values['action'] == 'sticky') {
else if ($form_state['values']['action'] == 'sticky') {
$change = 'sticky = 1';
$message = t('<strong>Stickied</strong>');
}
else if ($form_values['action'] == 'unsticky') {
else if ($form_state['values']['action'] == 'unsticky') {
$change = 'sticky = 0';
$message = t('<strong>Unstickied</strong>');
}
else if ($form_values['action'] == 'rwcomments') {
else if ($form_state['values']['action'] == 'rwcomments') {
$change = 'comment = 2';
$message = t('Set <strong>commenting status</strong> to <strong>read/write</strong> for');
}
else if ($form_values['action'] == 'rocomments') {
else if ($form_state['values']['action'] == 'rocomments') {
$change = 'comment = 1';
$message = t('Set <strong>commenting status</strong> to <strong>read only</strong> for');
}
else if ($form_values['action'] == 'nocomments') {
$change = 'comment = 0';
else if ($form_state['values']['action'] == 'nocomments') {
$change = 'comment = 0';
$message = t('Set <strong>commenting status</strong> to <strong>disabled</strong> for');
}
foreach ($form_values['content_types'] as $content_type => $actionable) {
foreach ($form_state['values']['content_types'] as $content_type => $actionable) {
if ($actionable) {
$content_types[] = $content_type;
db_query('UPDATE {node} SET '. $change .' WHERE type = "%s"', $content_type);
}
}
drupal_set_message($message . t(' all nodes of the following content types:') .'<strong>'. implode(', ', $content_types) .'</strong>');
drupal_set_message($message . t(' all nodes of the following content types: ') .'<strong>'. implode(', ', $content_types) .'</strong>');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment