Add settings page to check which node types this applies to

Michelle - August 5, 2008 - 18:08
Project:Submit Again
Version:6.x-1.0
Component:User interface
Category:feature request
Priority:normal
Assigned:Michelle
Status:needs work
Description

This is a wonderful module and a great time saver... except for installing it. I've got 30 node types and didn't relish the thought of editing 30 pages to check a box. So I did what any good programmer does... I wrote some code. :) Sure, it probably took me just as long to write the code but I only need to write the code once. It would be nice to have this in the module itself. The form is a bit hacky, making a separate item for each node type, but I didn't know how else to get it to save to separate variables like the rest of the module is expecting and I didn't want to change existing code. At any rate, here is what I added:

<?php
/**
* Implementation of hook_perm().
*/
function submitagain_perm() {
  return array(
'administer submitagain');
}

/**
* Implementation of hook_menu().
*/
function submitagain_menu($may_cache) {
 
$items = array();
  if (
$may_cache) {
   
// Add menu entry for settings page
   
$items[] = array(
       
'path' => "admin/settings/submitagain",
       
'title' => t('Submit Again'),
       
'callback' => 'drupal_get_form',
       
'callback arguments' => array('submitagain_settings_page'),
       
'access' => user_access('administer submitagain'),
    );
  }

  return
$items;
}

/**
* Define settings form.
*/
function submitagain_settings_page() {
 
drupal_set_message(t('Enable each checkbox if you want to provide a "Submit and create another" button for your users for that type. Note that this can also be done on the node type settings page.'));
 
$types = node_get_types();
 
 
// Create a seperate form item for each checkbox because the existing module
  // is expecting one variable per node type.
 
foreach ($types as $type) {
   
$form['submission']['submitagain_' . $type->type] = array (
     
'#title' => $type->name,
     
'#type' => 'checkbox',
     
'#default_value' => variable_get('submitagain_' . $type->type, false),
     
'#options' => array(
       
$type->type => $type->name,
       ),
    );
  }

  return
system_settings_form($form);
}
?>

Yeah, I know, it's not a patch but I'm not changing anything that was there already, just adding this.

Michelle

#1

drewish - October 22, 2008 - 21:19
Version:5.x-1.x-dev» 6.x-1.0

I think it's a pretty useful request... The other thing I'd like would be an option to select the default for newly created node types.

Bumping this to D6 since it should probably happen there and be backported.

#2

Michelle - October 22, 2008 - 21:25

I haven't done much with D6 forms, yet. If you don't get to it before I port my site to D6 in a few months, I'll try to remember to update the "patch".

Thanks for considering it,

Michelle

#3

deekayen - November 12, 2008 - 17:47
Status:needs review» needs work

if it's gonna be 6.x, then code needs work

 
 

Drupal is a registered trademark of Dries Buytaert.