--- forward.module +++ forward.module @@ -174,6 +174,13 @@ '#default_value' => variable_get('forward_allow_message', TRUE), '#description' => t('If checked, the user will be allowed to include a personal message in the body of the email'), ); + $form['forward_options']['forward_require_message'] = array( + '#type' => 'checkbox', + '#title' => t('Require personal messages'), + '#return_value' => 1, + '#default_value' => variable_get('forward_require_message', FALSE), + '#description' => t('If checked, the user will be forced to include a personal message in the body of the email'), + ); $form['forward_options']['forward_filter_html'] = array( '#type' => 'checkbox', '#title' => t('Allow HTML in personal messages'), @@ -520,7 +527,7 @@ '#value' => t(variable_get('forward_'. $emailtype .'message', '!name thought you would like to see the !site web site.'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))), '#description' => '', ); - if (variable_get('forward_allow_message', TRUE)) { + if (variable_get('forward_allow_message', TRUE) OR variable_get('forward_require_message', FALSE)) { $form['message']['message'] = array( '#type' => 'textarea', '#title' => t('Your Personal Message'), @@ -528,7 +535,7 @@ '#cols' => 50, '#rows' => 10, '#description' => '', - '#required' => TRUE, + '#required' => variable_get('forward_require_message', FALSE), ); } $form['message']['path'] = array( @@ -629,7 +636,7 @@ form_set_error('recipients', t(variable_get('forward_flood_error', 'You can\'t send more than %number messages per hour. Please try again later.'), array('%number' => variable_get('forward_flood_control', 10)))); } } - if ((variable_get('forward_allow_message', TRUE)) && (empty($form_state['values']['message']))) { + if ($form['message']['message']['#required'] == TRUE && (empty($form_state['values']['message']))) { form_set_error('message', t('You must enter a message.')); } }