diff --git a/mollom.admin.inc b/mollom.admin.inc index 4bceeed..5c2606a 100644 --- a/mollom.admin.inc +++ b/mollom.admin.inc @@ -800,7 +800,14 @@ function mollom_admin_settings($form, &$form_state) { '@terms-of-service-url' => '//mollom.com/terms-of-service', )), ); - + + $form['mollom_include_author_info'] = array( + '#type' => 'checkbox', + '#title' => t('Include author information'), + '#default_value' => variable_get('mollom_include_author_info', 1), + '#description' => t('Information about the author of the content (e.g. user id, email address, ip address) included when content is sent to Mollom services for analysis.'), + ); + $form['mollom_testing_mode'] = array( '#type' => 'checkbox', '#title' => t('Enable testing mode'), diff --git a/mollom.module b/mollom.module index 93fdd3c..f373da3 100644 --- a/mollom.module +++ b/mollom.module @@ -1242,59 +1242,61 @@ function mollom_form_get_values(&$form_state, $fields, $mapping) { $data['postBody'] = $post_body; } - // Author ID. - // If a non-anonymous user ID was mapped via form values, use that. - if (!empty($mapping['author_id'])) { - $data['authorId'] = $mapping['author_id']; + if (variable_get('mollom_include_author_info', 1)) { + // Author ID. + // If a non-anonymous user ID was mapped via form values, use that. + if (!empty($mapping['author_id'])) { + $data['authorId'] = $mapping['author_id']; + } + // Otherwise, the currently logged-in user is the author. + elseif (!empty($user->uid)) { + $data['authorId'] = $user->uid; + } + + // Load the user account of the author, if any, for the following author* + // property assignments. + $account = FALSE; + if (isset($data['authorId'])) { + $account = user_load($data['authorId']); + } + + // Author name. + // A form value mapping always has precedence. + if (!empty($mapping['author_name'])) { + $data['authorName'] = $mapping['author_name']; + } + // In case a post of a registered user is edited and a form value mapping + // exists for author_id, but no form value mapping exists for author_name, + // use the name of the user account associated with author_id. + // $account may be the same as the currently logged-in $user at this point. + elseif (!empty($account->name)) { + $data['authorName'] = $account->name; + } + + // Author e-mail. + if (!empty($mapping['author_mail'])) { + $data['authorMail'] = $mapping['author_mail']; + } + elseif (!empty($account->mail)) { + $data['authorMail'] = $account->mail; + } + + // Author homepage. + if (!empty($mapping['author_url'])) { + $data['authorUrl'] = $mapping['author_url']; + } + + // Author OpenID. + if (!empty($mapping['author_openid'])) { + $data['authorOpenid'] = $mapping['author_openid']; + } + elseif (!empty($account) && ($openid = _mollom_get_openid($account))) { + $data['authorOpenid'] = $openid; + } + + // Author IP. + $data['authorIp'] = ip_address(); } - // Otherwise, the currently logged-in user is the author. - elseif (!empty($user->uid)) { - $data['authorId'] = $user->uid; - } - - // Load the user account of the author, if any, for the following author* - // property assignments. - $account = FALSE; - if (isset($data['authorId'])) { - $account = user_load($data['authorId']); - } - - // Author name. - // A form value mapping always has precedence. - if (!empty($mapping['author_name'])) { - $data['authorName'] = $mapping['author_name']; - } - // In case a post of a registered user is edited and a form value mapping - // exists for author_id, but no form value mapping exists for author_name, - // use the name of the user account associated with author_id. - // $account may be the same as the currently logged-in $user at this point. - elseif (!empty($account->name)) { - $data['authorName'] = $account->name; - } - - // Author e-mail. - if (!empty($mapping['author_mail'])) { - $data['authorMail'] = $mapping['author_mail']; - } - elseif (!empty($account->mail)) { - $data['authorMail'] = $account->mail; - } - - // Author homepage. - if (!empty($mapping['author_url'])) { - $data['authorUrl'] = $mapping['author_url']; - } - - // Author OpenID. - if (!empty($mapping['author_openid'])) { - $data['authorOpenid'] = $mapping['author_openid']; - } - elseif (!empty($account) && ($openid = _mollom_get_openid($account))) { - $data['authorOpenid'] = $openid; - } - - // Author IP. - $data['authorIp'] = ip_address(); // Honeypot. // For the Mollom backend, it only matters whether 'honeypot' is non-empty.