diff --git a/mollom.admin.inc b/mollom.admin.inc
index 094664b..72d0136 100644
--- a/mollom.admin.inc
+++ b/mollom.admin.inc
@@ -801,6 +801,14 @@ function mollom_admin_settings($form, &$form_state) {
)),
);
+ $form['mollom_captcha_audio'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("Enable audio mode"),
+ '#return_value' => 1,
+ '#default_value' => variable_get('mollom_captcha_audio', 1),
+ '#description' => t('Allows users to pass captcha in an alternative way, writing letters that they hear from the speakers'),
+ );
+
$form['mollom_testing_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Enable testing mode'),
diff --git a/mollom.module b/mollom.module
index 05eb729..ffaf4e6 100644
--- a/mollom.module
+++ b/mollom.module
@@ -1550,6 +1550,12 @@ function mollom_theme() {
'render element' => 'form',
'file' => 'mollom.admin.inc',
),
+ 'mollom_image' => array(
+ 'variables' => array('url' => NULL),
+ ),
+ 'mollom_audio' => array(
+ 'variables' => array('url' => NULL),
+ ),
);
}
@@ -2573,33 +2579,14 @@ function mollom_get_captcha(&$form_state) {
return '';
}
- // @todo Convert these to actual theme functions?
$output = '';
switch ($form_state['mollom']['captcha_type']) {
case 'audio':
- $source = url(base_path() . drupal_get_path('module', 'mollom') . '/mollom-captcha-player.swf', array(
- 'query' => array('url' => $url),
- 'external' => TRUE,
- ));
- $output = '';
-
- $output = '' . $output . '';
- $output .= ' (' . t('verify using image') . ')';
+ $output = theme('mollom_audio', array('url' => $url));
break;
case 'image':
- $captcha = theme('image', array('path' => $url, 'alt' => t('Type the characters you see in this picture.'), 'getsize' => FALSE));
- $output = '' . $captcha . '';
- $output .= ' (' . t('verify using audio') . ')';
+ $output = theme('mollom_image', array('url' => $url));
break;
}
@@ -2607,6 +2594,53 @@ function mollom_get_captcha(&$form_state) {
}
/**
+ * Displays the mollom image.
+ *
+ * @ingroup themeable
+ */
+function theme_mollom_image($variables) {
+ $output = '';
+ $url = $variables['url'];
+ $captcha = theme('image', array('path' => $url, 'alt' => t('Type the characters you see in this picture.'), 'getsize' => FALSE));
+ $captcha = '' . $captcha . '';
+ $output = '' . $captcha . '';
+ if (variable_get('mollom_captcha_audio', 1)) {
+ $output .= ' (' . t('verify using audio') . ')';
+ }
+
+ return $output;
+}
+
+/**
+ * Displays the mollom audio.
+ *
+ * @ingroup themeable
+ */
+function theme_mollom_audio($variables) {
+ $output = '';
+ $url = $variables['url'];
+ $source = url(base_path() . drupal_get_path('module', 'mollom') . '/mollom-captcha-player.swf', array(
+ 'query' => array('url' => $url),
+ 'external' => TRUE,
+ ));
+ $output = '';
+
+ $output = '' . $output . '';
+ $output .= ' (' . t('verify using image') . ')';
+
+ return $output;
+}
+
+/**
* Implements hook_mail_alter().
*
* Adds a "report as inappropriate" link to e-mails sent after Mollom-protected