Index: journal.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/journal/journal.module,v retrieving revision 1.1.2.13 diff -u -p -r1.1.2.13 journal.module --- journal.module 13 Aug 2008 17:48:52 -0000 1.1.2.13 +++ journal.module 15 Aug 2008 19:25:41 -0000 @@ -54,20 +54,30 @@ function journal_menu($may_cache) { /** * Add Journal fields to all forms. * - * Any form, except a few pre-defined form_ids, will be extended by a fieldset - * to enter a journal entry. + * Any form, except user-defined form_ids, will be extended by a fieldset + * to enter a journal entry. All journal form ids are stored in one variable + * array; having form_ids as keys and a boolean value whether to skip a form id + * (0) or force/require a journal entry for it (1). * - * @see journal_skip_form() + * @see journal_form_ids_default() */ function journal_form_alter($form_id, &$form) { if (!user_access('access journal')) { return; } - // Do not extend this form, if it is in the list of form_ids to skip. - if (journal_skip_form($form_id)) { - return; - } $entry_required = FALSE; + // Check whether form has to/must not be extended. + $journal_ids = variable_get('journal_form_ids', journal_form_ids_default()); + if (isset($journal_ids[$form_id]) || $form['#base'] == 'system_settings_form') { + if (isset($journal_ids[$form_id]) && !$journal_ids[$form_id]) { + // No journal entry for 'form_id' => 0. + return; + } + else { + // Require journal entry for 'form_id' => 1 or system settings forms. + $entry_required = TRUE; + } + } if (!isset($form['#submit'])) { $form['#submit'] = array(); } @@ -103,6 +113,7 @@ function journal_form_alter($form_id, &$ '#description' => t('If not empty, contents of this field will be logged to the system journal.'), '#required' => $entry_required, '#weight' => $journal_weight, + '#wysiwyg' => FALSE, ); } @@ -125,23 +136,19 @@ function journal_form_submit($form_id, & * @return bool * True if form should be skipped, false if form can be extended. * - * @todo Fetch custom form_ids from a variable. - * @todo Allow to define custom form_ids in a settings page? * @todo Introduce a new FAPI attribute #journal = TRUE to require a journal * entry if Journal module is enabled - OR - introduce a new hook_journal? */ -function journal_skip_form($form_id) { - $skip_ids = array( - 'devel_switch_user_form', - 'search_block_form', - 'search_theme_form', - 'user_filter_form', - 'user_login_block', +function journal_form_ids_default() { + return array( + 'devel_admin_settings' => 0, + 'devel_execute_form' => 0, + 'devel_switch_user_form' => 0, + 'search_block_form' => 0, + 'search_theme_form' => 0, + 'user_filter_form' => 0, + 'user_login_block' => 0, ); - if (in_array($form_id, $skip_ids)) { - return TRUE; - } - return FALSE; } /**