? balloon ? content_type.php ? select.html ? misc/theme.js ? modules/user/access_control.js ? sites/all/modules ? sites/all/modules_repository ? themes/garland/script.js Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.280 diff -u -d -F^\s*function -r1.280 blog.module --- modules/blog/blog.module 30 Apr 2007 17:03:23 -0000 1.280 +++ modules/blog/blog.module 13 May 2007 15:59:21 -0000 @@ -211,7 +211,7 @@ function blog_form(&$node) { } $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5); - $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); + $form['body_field'] = node_body_field($node, $type->body_label, $type->settings['min_word_count']); return $form; } Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.541 diff -u -d -F^\s*function -r1.541 comment.module --- modules/comment/comment.module 30 Apr 2007 17:03:24 -0000 1.541 +++ modules/comment/comment.module 13 May 2007 15:59:23 -0000 @@ -427,7 +427,7 @@ function comment_form_alter(&$form, $for $form['workflow']['comment'] = array( '#type' => 'radios', '#title' => t('Default comment setting'), - '#default_value' => variable_get('comment_'. $form['#node_type']->type, COMMENT_NODE_READ_WRITE), + '#default_value' => $form['#node_type']->settings['comment'], '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the administer comments permission will be able to override this setting.'), ); @@ -501,6 +501,19 @@ function comment_nodeapi(&$node, $op, $a } /** + * Implementation of hook_node_type(). + */ +function comment_node_type($op, $info) { + switch ($op) { + case 'defaults': + return array( + 'comment' => COMMENT_NODE_READ_WRITE, + ); + break; + } +} + +/** * Implementation of hook_user(). */ function comment_user($type, $edit, &$user, $category = NULL) { Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.30 diff -u -d -F^\s*function -r1.30 content_types.inc --- modules/node/content_types.inc 7 May 2007 12:32:55 -0000 1.30 +++ modules/node/content_types.inc 13 May 2007 15:59:23 -0000 @@ -52,18 +52,14 @@ function node_overview_types() { function node_type_form($type = NULL) { if (!isset($type->type)) { $type = new stdClass(); - $type->type = $type->name = $type->module = $type->description = $type->help = ''; - $type->min_word_count = 0; - $type->has_title = TRUE; - $type->has_body = TRUE; - $type->title_label = t('Title'); - $type->body_label = t('Body'); + $type->type = ''; $type->custom = TRUE; - $type->modified = FALSE; $type->locked = FALSE; } + $type = _node_type_set_defaults($type); - $form['#node_type'] = $type; // Make the type object available to implementations of hook_form_alter. + // Make the type object available to implementations of hook_form_alter. + $form['#node_type'] = $type; $form['identity'] = array( '#type' => 'fieldset', @@ -135,7 +131,7 @@ function node_type_form($type = NULL) { $form['submission']['min_word_count'] = array( '#type' => 'select', '#title' => t('Minimum number of words'), - '#default_value' => $type->min_word_count, + '#default_value' => $type->settings['min_word_count'], '#options' => drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), '#description' => t('The minimum number of words for the body field to be considered valid for this content type. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.') ); @@ -150,9 +146,16 @@ function node_type_form($type = NULL) { '#title' => t('Workflow'), '#collapsible' => TRUE, ); + + $node_options = array(); + foreach ($type->settings['node_options'] as $key => $value) { + if ($value) { + $node_options[] = $key; + } + } $form['workflow']['node_options'] = array('#type' => 'checkboxes', '#title' => t('Default options'), - '#default_value' => variable_get('node_options_'. $type->type, array('status', 'promote')), + '#default_value' => $node_options, '#options' => array( 'status' => t('Published'), 'promote' => t('Promoted to front page'), @@ -255,68 +258,45 @@ function node_type_form_validate($form_i function node_type_form_submit($form_id, $form_values) { $op = isset($form_values['op']) ? $form_values['op'] : ''; - $type = new stdClass(); + if ($op == t('Delete content type') && isset($form_values['old_type'])) { + return 'admin/content/types/'. str_replace('_', '-', $form_values['old_type']) .'/delete'; + } - $type->type = trim($form_values['type']); - $type->name = trim($form_values['name']); - $type->orig_type = trim($form_values['orig_type']); - $type->old_type = isset($form_values['old_type']) ? $form_values['old_type'] : $type->type; + if (!empty($form_values['old_type'])) { + $type = node_get_types('type', $form_values['old_type']); + } + else { + $type = new stdClass(); + $type->custom = TRUE; + $type->locked = FALSE; + $type = _node_type_set_defaults($type); + } - $type->description = $form_values['description']; - $type->help = $form_values['help']; - $type->min_word_count = $form_values['min_word_count']; - $type->title_label = $form_values['title_label']; - $type->body_label = $form_values['body_label']; + foreach (array('type', 'name', 'orig_type', 'description', 'help', 'title_label', 'body_label', 'module', 'custom', 'locked', 'old_type') as $property) { + if (isset($form_values[$property])) { + $type->$property = $form_values[$property]; + unset($form_values[$property]); + } + } // title_label is required in core; has_title will always be true, unless a // module alters the title field. - $type->has_title = ($type->title_label != ''); - $type->has_body = ($type->body_label != ''); - - $type->module = !empty($form_values['module']) ? $form_values['module'] : 'node'; - $type->custom = $form_values['custom']; + $type->has_title = !empty($type->title_label); + $type->has_body = !empty($type->body_label); $type->modified = TRUE; - $type->locked = $form_values['locked']; if ($op == t('Reset to defaults')) { node_type_reset($type); + drupal_set_message(t('The content type %name has been reset to its default values.', $t_args)); } - elseif ($op == t('Delete content type')) { - return 'admin/content/types/'. str_replace('_', '-', $type->old_type) .'/delete'; - } - - $status = node_type_save($type); - - $variables = $form_values; + else { + unset($form_values['form_token'], $form_values['op'], $form_values['submit'], $form_values['delete'], $form_values['reset'], $form_values['form_id']); - // Remove everything that's been saved already - whatever's left is assumed - // to be a persistent variable. - foreach ($variables as $key => $value) { - if (isset($type->$key)) { - unset($variables[$key]); - } + // Save or reset persistent variable values. + $type->settings = array_merge($type->settings, $form_values); } - unset($variables['form_token'], $variables['op'], $variables['submit'], $variables['delete'], $variables['reset'], $variables['form_id']); - - // Save or reset persistent variable values. - foreach ($variables as $key => $value) { - $key .= '_'. $type->type; - if ($op == t('Reset to defaults')) { - variable_del($key); - } - else { - if (is_array($value)) { - $value = array_keys(array_filter($value)); - } - variable_set($key, $value); - - if ($type->old_type != $type->type) { - $key = str_replace($type->type, $type->old_type, $key); - variable_del($key); - } - } - } + $status = node_type_save($type); node_types_rebuild(); // menu_rebuild clears the cache, too @@ -324,11 +304,9 @@ function node_type_form_submit($form_id, $t_args = array('%name' => $type->name); if ($op == t('Reset to defaults')) { - drupal_set_message(t('The content type %name has been reset to its default values.', $t_args)); return; } - - if ($status == SAVED_UPDATED) { + elseif ($status == SAVED_UPDATED) { drupal_set_message(t('The content type %name has been updated.', $t_args)); } elseif ($status == SAVED_NEW) { @@ -340,19 +318,6 @@ function node_type_form_submit($form_id, } /** - * Implementation of hook_node_type(). - */ -function node_node_type($op, $info) { - if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) { - $update_count = node_type_update_nodes($info->old_type, $info->type); - - if ($update_count) { - drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type))); - } - } -} - -/** * Resets all of the relevant fields of a module-defined node type to their * default values. * @@ -364,13 +329,14 @@ function node_node_type($op, $info) { function node_type_reset(&$type) { $info_array = module_invoke_all('node_info'); if (isset($info_array[$type->orig_type])) { - $info = _node_type_set_defaults($info_array[$type->orig_type]); - $info['type'] = $type->orig_type; + $info = _node_type_set_defaults((object) $info_array[$type->orig_type]); + $info->type = $type->orig_type; foreach ($info as $field => $value) { $type->$field = $value; } } + $type->settings = module_invoke_all('node_type', 'defaults', $info); } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.811 diff -u -d -F^\s*function -r1.811 node.module --- modules/node/node.module 11 May 2007 16:55:58 -0000 1.811 +++ modules/node/node.module 13 May 2007 15:59:25 -0000 @@ -341,27 +341,21 @@ function node_types_rebuild() { * Status flag indicating outcome of the operation. */ function node_type_save($info) { - $is_existing = FALSE; $existing_type = !empty($info->old_type) ? $info->old_type : $info->type; $is_existing = db_num_rows(db_query("SELECT * FROM {node_type} WHERE type = '%s'", $existing_type)); - if (!isset($info->help)) { - $info->help = ''; - } - if (!isset($info->min_word_count)) { - $info->min_word_count = 0; - } - if (!isset($info->body_label)) { - $info->body_label = ''; - } if ($is_existing) { - db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); + db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', custom = %d, modified = %d, locked = %d, settings = '%s' WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->custom, $info->modified, $info->locked, serialize($info->settings), $existing_type); + + if (!empty($info->old_type) && $info->type != $info->old_type) { + module_invoke_all('node_type', 'rename', $info); + } module_invoke_all('node_type', 'update', $info); return SAVED_UPDATED; } else { - db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, min_word_count, custom, modified, locked, orig_type) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type); + db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, custom, modified, locked, orig_type, settings) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->custom, $info->modified, $info->locked, $info->orig_type, serialize($info->settings)); module_invoke_all('node_type', 'insert', $info); return SAVED_NEW; @@ -403,29 +397,37 @@ function node_type_update_nodes($old_typ * */ function _node_types_build() { - $_node_types = array(); - $_node_names = array(); + // Query all modules for node type definitions. + $_node_types = module_invoke_all('node_info'); - $info_array = module_invoke_all('node_info'); - foreach ($info_array as $type => $info) { - $info['type'] = $type; - $_node_types[$type] = (object) _node_type_set_defaults($info); - $_node_names[$type] = $info['name']; + // Initialize the module defined node types. + foreach ($_node_types as $type => $info) { + $_node_types[$type] = (object) $info; + $_node_types[$type]->type = $type; + // When the node is already in the database, this will get overwritten below. + $_node_types[$type]->is_new = TRUE; } $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type')); - while ($type_object = db_fetch_object($type_result)) { - if (!isset($_node_types[$type_object->type]) || $type_object->modified) { - $_node_types[$type_object->type] = $type_object; - $_node_names[$type_object->type] = $type_object->name; + while ($info = db_fetch_object($type_result)) { + if (!isset($_node_types[$info->type]) || $info->modified) { + $_node_types[$info->type] = $info; - if ($type_object->type != $type_object->orig_type) { - unset($_node_types[$type_object->orig_type]); - unset($_node_names[$type_object->orig_type]); + // Delete node types from the node info hook that have been renamed. + if ($info->type != $info->orig_type) { + unset($_node_types[$info->orig_type]); } } + else { + unset($_node_types[$info->type]->is_new); + } } + $_node_names = array(); + foreach ($_node_types as $type => $info) { + $_node_types[$type] = _node_type_set_defaults($info); + $_node_names[$type] = $_node_types[$type]->name; + } asort($_node_names); return array($_node_types, $_node_names); @@ -435,43 +437,56 @@ function _node_types_build() { * Set default values for a node type defined through hook_node_info(). */ function _node_type_set_defaults($info) { - if (!isset($info['has_title'])) { - $info['has_title'] = TRUE; - } - if ($info['has_title'] && !isset($info['title_label'])) { - $info['title_label'] = t('Title'); - } - - if (!isset($info['has_body'])) { - $info['has_body'] = TRUE; - } - if ($info['has_body'] && !isset($info['body_label'])) { - $info['body_label'] = t('Body'); + // Fill in default values if they don't exist + foreach (array('name' => '', 'module' => 'node', 'description' => '', 'help' => '', 'has_title' => TRUE, 'title_label' => t('Title'), 'has_body' => TRUE, 'body_label' => t('Body'), 'custom' => FALSE, 'modified' => FALSE, 'locked' => TRUE, 'orig_type' => $info->type) as $property => $value) { + if (!isset($info->$property)) { + $info->$property = $value; + } } - if (!isset($info['help'])) { - $info['help'] = ''; - } - if (!isset($info['min_word_count'])) { - $info['min_word_count'] = 0; - } - if (!isset($info['custom'])) { - $info['custom'] = FALSE; - } - if (!isset($info['modified'])) { - $info['modified'] = FALSE; + // Unserialize the settings if they are in serialized form + if (isset($info->settings) && is_string($info->settings)) { + $info->settings = unserialize($info->settings); } - if (!isset($info['locked'])) { - $info['locked'] = TRUE; + if (!isset($info->settings) || !is_array($info->settings)) { + $info->settings = array(); } - $info['orig_type'] = $info['type']; - $info['is_new'] = TRUE; + // Allow modules to set default values in the node type object. + $settings = module_invoke_all('node_type', 'defaults', $info); + $info->settings = $info->settings + $settings; return $info; } /** + * Implementation of hook_node_type(). + */ +function node_node_type($op, $info) { + switch ($op) { + case 'defaults': + return array( + 'node_options' => array( + 'status' => TRUE, + 'promote' => TRUE, + 'sticky' => FALSE, + 'revision' => FALSE, + ), + 'min_word_count' => 0, + ); + break; + case 'rename': + // Change the type of nodes in the node table when the node type changes. + $update_count = node_type_update_nodes($info->old_type, $info->type); + + if ($update_count) { + drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type))); + } + break; + } +} + +/** * Determine whether a node hook exists. * * @param &$node @@ -1975,8 +1990,8 @@ function node_validate($node, $form = ar // Make sure the body has the minimum number of words. // todo use a better word counting algorithm that will work in other languages - if (!empty($type->min_word_count) && isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) { - form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name))); + if (!empty($type->settings['min_word_count']) && isset($node->body) && count(explode(' ', $node->body)) < $type->settings['min_word_count']) { + form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->settings['min_word_count'], '@type' => $type->name))); } if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) { @@ -2057,17 +2072,19 @@ function node_form($node, $form_values = $form['title']['#weight'] = -5; } - $node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); + // Fill in the default node options + $type = node_get_types('type', $node->type); + foreach ($type->settings['node_options'] as $key => $value) { + if (!isset($node->$key)) { + $node->$key = (bool) $value; + } + } + // If this is a new node, fill in the default values. if (!isset($node->nid)) { - foreach (array('status', 'promote', 'sticky') as $key) { - $node->$key = in_array($key, $node_options); - } global $user; $node->uid = $user->uid; } - // Always use the default revision setting. - $node->revision = in_array('revision', $node_options); $form['#node'] = $node; @@ -3058,7 +3075,7 @@ function node_content_form($node) { } if ($type->has_body) { - $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); + $form['body_field'] = node_body_field($node, $type->body_label, $type->settings['min_word_count']); } return $form; Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.105 diff -u -d -F^\s*function -r1.105 system.install --- modules/system/system.install 11 May 2007 07:33:46 -0000 1.105 +++ modules/system/system.install 13 May 2007 15:59:27 -0000 @@ -438,11 +438,11 @@ function system_install() { title_label varchar(255) NOT NULL default '', has_body tinyint unsigned NOT NULL, body_label varchar(255) NOT NULL default '', - min_word_count smallint unsigned NOT NULL, custom tinyint NOT NULL DEFAULT '0', modified tinyint NOT NULL DEFAULT '0', locked tinyint NOT NULL DEFAULT '0', orig_type varchar(255) NOT NULL default '', + settings longtext NOT NULL, PRIMARY KEY (type) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); @@ -924,11 +924,11 @@ function system_install() { title_label varchar(255) NOT NULL default '', has_body smallint_unsigned NOT NULL, body_label varchar(255) NOT NULL default '', - min_word_count smallint_unsigned NOT NULL, custom smallint NOT NULL DEFAULT '0', modified smallint NOT NULL DEFAULT '0', locked smallint NOT NULL DEFAULT '0', orig_type varchar(255) NOT NULL default '', + settings text NO NULL, PRIMARY KEY (type) )"); @@ -3301,7 +3301,7 @@ function system_update_1005() { ); foreach ($types as $type) { - $type = (object) _node_type_set_defaults($type); + $type = _node_type_set_defaults((object) $type); node_type_save($type); } @@ -3885,6 +3885,69 @@ function system_update_6014() { return array(); } +/** + * Moves content types settings into a dedicated storage in the {node_type} + * table rather than storing them in the {variable} table. + */ +function system_update_6015() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {node_type} ADD settings longtext NOT NULL"); + break; + case 'pgsql': + db_add_column($ret, 'node_type', 'settings', 'text', array('default' => "''", 'not null' => TRUE)); + break; + } + + // Move old content type settings into the new settings column. + $types = node_get_types(); + foreach ($types as $type) { + // Migrate comment settings + $comment = variable_get('comment_'. $type->type, NULL); + if (isset($comment)) { + $type->settings['comment'] = $comment; + variable_del('comment_'. $type); + } + + // Migrate node options + $node_options = variable_get('node_options_'. $type->type, NULL); + if (isset($node_options)) { + foreach ($node_options as $option) { + $type->settings['node_options'][$option] = TRUE; + } + variable_del('node_options_'. $type->type); + } + + // Migrate upload.module settings + $upload = variable_get('upload_'. $type->type, NULL); + if (isset($upload)) { + $type->settings['upload'] = $upload; + variable_del('upload_'. $type); + } + + // Move the min_word_count column into the settings array. + $type->settings['min_word_count'] = $type->min_word_count; + + // And save the node type back to the database. + node_type_save($type); + } + + // Drop the min_word_count column as it has been moved into the settings column. + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {node_type} DROP min_word_count"); + break; + case 'pgsql': + $ret[] = update_sql("ALTER TABLE {node_type} DROP COLUMN min_word_count"); + break; + } + + + return $ret; +} /** * @} End of "defgroup updates-5.x-to-6.x" Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.474 diff -u -d -F^\s*function -r1.474 system.module --- modules/system/system.module 6 May 2007 05:47:52 -0000 1.474 +++ modules/system/system.module 13 May 2007 15:59:29 -0000 @@ -2225,16 +2225,19 @@ function system_theme_settings($key = '' * Updates theme settings after a node type change. */ function system_node_type($op, $info) { - if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) { - $old = 'toggle_node_info_'. $info->old_type; - $new = 'toggle_node_info_'. $info->type; + switch ($op) { + case 'rename': + // Move the theme settings over to the new content type. + $old = 'toggle_node_info_'. $info->old_type; + $new = 'toggle_node_info_'. $info->type; - $theme_settings = variable_get('theme_settings', array()); - if (isset($theme_settings[$old])) { - $theme_settings[$new] = $theme_settings[$old]; - unset($theme_settings[$old]); - variable_set('theme_settings', $theme_settings); - } + $theme_settings = variable_get('theme_settings', array()); + if (isset($theme_settings[$old])) { + $theme_settings[$new] = $theme_settings[$old]; + unset($theme_settings[$old]); + variable_set('theme_settings', $theme_settings); + } + break; } } Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.354 diff -u -d -F^\s*function -r1.354 taxonomy.module --- modules/taxonomy/taxonomy.module 4 May 2007 08:38:34 -0000 1.354 +++ modules/taxonomy/taxonomy.module 13 May 2007 15:59:30 -0000 @@ -883,11 +883,13 @@ function taxonomy_node_delete_revision($ * Implementation of hook_node_type(). */ function taxonomy_node_type($op, $info) { - if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) { - db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type); - } - elseif ($op == 'delete') { - db_query("DELETE FROM {vocabulary_node_types} WHERE type = '%s'", $info->type); + switch ($op) { + case 'rename': + db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type); + break; + case 'delete': + db_query("DELETE FROM {vocabulary_node_types} WHERE type = '%s'", $info->type); + break; } } Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.159 diff -u -d -F^\s*function -r1.159 upload.module --- modules/upload/upload.module 30 Apr 2007 17:03:29 -0000 1.159 +++ modules/upload/upload.module 13 May 2007 15:59:31 -0000 @@ -355,14 +355,15 @@ function upload_form_alter(&$form, $form $form['workflow']['upload'] = array( '#type' => 'radios', '#title' => t('Attachments'), - '#default_value' => variable_get('upload_'. $form['#node_type']->type, 1), + '#default_value' => $form['#node_type']->settings['upload'], '#options' => array(t('Disabled'), t('Enabled')), ); } if (isset($form['type']) && isset($form['#node'])) { $node = $form['#node']; - if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) { + $type = node_get_types('type', $node); + if ($form['type']['#value'] .'_node_form' == $form_id && $type->settings['upload']) { drupal_add_js('misc/progress.js'); drupal_add_js('misc/upload.js'); @@ -588,6 +589,19 @@ function upload_nodeapi(&$node, $op, $te } /** + * Implementation of hook_node_type(). + */ +function upload_node_type($op, $info) { + switch ($op) { + case 'defaults': + return array( + 'upload' => TRUE, + ); + break; + } +} + +/** * Displays file attachments in table */ function theme_upload_attachments($files) { Index: profiles/default/default.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/default/default.profile,v retrieving revision 1.10 diff -u -d -F^\s*function -r1.10 default.profile --- profiles/default/default.profile 10 May 2007 19:55:24 -0000 1.10 +++ profiles/default/default.profile 13 May 2007 15:59:31 -0000 @@ -96,7 +96,7 @@ function default_profile_final(&$task) { ); foreach ($types as $type) { - $type = (object) _node_type_set_defaults($type); + $type = _node_type_set_defaults((object) $type); node_type_save($type); }