Index: nodetype.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/nodetype/nodetype.module,v retrieving revision 1.1 diff -u -r1.1 nodetype.module --- nodetype.module 3 Feb 2007 14:27:05 -0000 1.1 +++ nodetype.module 15 Jul 2007 19:05:53 -0000 @@ -1,6 +1,54 @@ 'admin/settings/nodetype', + 'title' => t('Nodetype'), + 'description' => t('Nodetype change restrictions by content type'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('nodetype_admin_settings'), + 'access' => user_access('administer site configuration') + ); + } + return $items; +} + +/** +* Define the settings form. +*/ +function nodetype_admin_settings() { +$types = node_get_types(); + foreach ($types as $type => $info) { + $opt_types = node_get_types('names'); + unset($opt_types[$type]); + $form[$type] = array( + '#type' => 'fieldset', + '#title' => t('') + ); + $form[$type][$type.'_nodetype_nodetypes'] = array( + '#type' => 'checkboxes', + '#title' => t($info->name.' node types can be converted to'), + '#options' => $opt_types, + '#default_value' => variable_get($type.'_nodetype_nodetypes', ''), + '#description' => t($type.' node type setting.'), + ); + $form[$type]['array_filter'] = array('#type' => 'hidden'); + } +return system_settings_form($form); +} /** * Implementation of hook_perm(). @@ -30,25 +78,25 @@ */ function nodetype_form_alter($form_id, &$form) { if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['#node']->nid) && user_access('change node types')) { - $types = node_get_types(); - + $types = node_get_types('names'); foreach ($types as $type => $info) { if ($form['type']['#value'] == $type) { - $current_type = $types[$type]; - unset($types[$type]); + $enabled_types = variable_get($type . '_nodetype_nodetypes', array('')); } - else { - $types[$type] = $info->name; } + if ($enabled_types[0] != '') { + foreach ($enabled_types as $name) { + $opt_types[$name] = $types[$name]; } $form['nodetype'] = array( '#type' => 'select', '#title' => t('Content type'), '#description' => t('Select a new content type that this post will be changed to. Only do that if you know what you are doing.'), - '#options' => array(0 => '<'. t('leave as is: @type', array('@type' => $current_type->name)) .'>') + $types, + '#options' => $opt_types, '#default_value' => 0, '#weight' => 10, ); } } +}