--- auto_nodetitle.module 2009-02-10 11:06:09.000000000 +0100 +++ auto_nodetitle.module.new 2009-04-08 00:02:00.000000000 +0200 @@ -9,6 +9,7 @@ define('AUTO_NODETITLE_DISABLED', 0); define('AUTO_NODETITLE_ENABLED', 1); define('AUTO_NODETITLE_OPTIONAL', 2); +define('AUTO_NODETITLE_OPTIONAL_HIDE', 3); /** * Implementation of hook_perm() @@ -38,6 +39,10 @@ function auto_nodetitle_form_alter(&$for // we will make the title optional $form['title']['#required'] = FALSE; $form['#submit'][] = 'auto_nodetitle_node_form_submit'; + } else if (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_OPTIONAL_HIDE) { + $form['title']['#access'] = FALSE; + $form['title']['#required'] = FALSE; + $form['#submit'][] = 'auto_nodetitle_node_form_submit'; } } } @@ -50,7 +55,7 @@ function auto_nodetitle_node_form_submit // Only do something, if the user clicked the preview button. if (isset($form_state['clicked_button']['#submit']) && in_array('node_form_build_preview', $form_state['clicked_button']['#submit'])) { $setting = auto_nodetitle_get_setting($form_state['values']['type']); - if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title']))) { + if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title'])) || ($setting == AUTO_NODETITLE_OPTIONAL_HIDE && empty($form_state['values']['nid'])) ) { $node = node_submit($form_state['values']); auto_nodetitle_set_title($node); $form_state['values'] = (array)$node; @@ -71,7 +76,7 @@ function auto_nodetitle_nodeapi($node, $ * Returns whether the auto nodetitle has to be set. */ function auto_nodetitle_is_needed($node) { - return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title)); + return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title)) && !($setting == AUTO_NODETITLE_OPTIONAL_HIDE && !empty($node->title)); } /** @@ -160,6 +165,7 @@ function auto_nodetitle_node_settings_fo t('Disabled'), t('Automatically generate the title and hide the title field'), t('Automatically generate the title if the title field is left empty'), + t('Automatically generate the title if the title field is left empty and hide the title field'), ) );