? mollom-client-api.pdf ? mollom.temp.inc.txt ? mollom.token.inc ? mollom.token.inc.txt ? molstats ? xmlrpc calls.txt ? translations/pt.po ? translations/th.po Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.2.2.64 diff -u -p -r1.2.2.64 mollom.module --- mollom.module 18 Jun 2009 10:04:46 -0000 1.2.2.64 +++ mollom.module 14 Jul 2009 22:14:51 -0000 @@ -73,6 +73,7 @@ function mollom_menu() { 'title' => 'Report and delete', 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_comment'), + 'access callback' => '_mollom_access', 'access arguments' => array('administer comments'), 'type' => MENU_CALLBACK, ); @@ -80,6 +81,7 @@ function mollom_menu() { 'title' => 'Report and delete', 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_node'), + 'access callback' => '_mollom_access', 'access arguments' => array('administer nodes'), 'type' => MENU_CALLBACK, ); @@ -87,23 +89,30 @@ function mollom_menu() { 'title' => 'Report and delete', 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_contact'), - 'access callback' => TRUE, // Everyone can report contact form feedback. + 'access callback' => '_mollom_access', 'type' => MENU_CALLBACK, ); $items['admin/settings/mollom'] = array( - 'description' => 'Mollom is a web service that helps you manage your community.', 'title' => 'Mollom', + 'description' => 'Mollom is a web service that helps you manage your community.', 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_admin_settings'), 'access arguments' => array('administer mollom'), ); + $items['admin/reports/mollom'] = array( + 'title' => 'Mollom usage', + 'description' => 'Reports and usage statistics for the Mollom module.', + 'page callback' => 'mollom_reports_page', + 'access callback' => '_mollom_access', + 'access arguments' => array('administer mollom'), + ); // Menu callback used for AJAX purposes: $items['mollom/captcha/%/%'] = array( 'title' => 'Request CAPTCHA', 'page callback' => 'mollom_captcha_js', 'page arguments' => array(2, 3), - 'access callback' => TRUE, + 'access callback' => '_mollom_access', 'type' => MENU_CALLBACK, ); @@ -111,6 +120,16 @@ function mollom_menu() { } /** + * Access calback; checks if the module is configured and an optional permission. + * + * @param $permission + * An optional permission string to check with user_access(). + */ +function _mollom_access($permission = FALSE) { + return (!$permission || user_access($permission)) && variable_get('mollom_public_key', '') && variable_get('mollom_private_key', ''); +} + +/** * Implementation of hook_perm(). */ function mollom_perm() { @@ -276,8 +295,8 @@ function mollom_report_node_submit($form function mollom_mail_alter(&$message) { if (isset($GLOBALS['mollom_response']) && isset($GLOBALS['mollom_response']['session_id'])) { $report_link = t('Report as inappropriate: @link', array('@link' => url('mollom/contact/'. $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)))); - // The _mail_alter hook seems to accept both arrays as strings so we - // need to handle both. TODO: it seems like something we want to clean + // The _mail_alter hook seems to accept both arrays as strings so we + // need to handle both. TODO: it seems like something we want to clean // up upstream. if (is_array($message['body'])) { $message['body'][] = $report_link; @@ -655,13 +674,22 @@ function _mollom_update_comments() { } } -function mollom_admin_settings() { - - // _mollom_update_comments(); - - $keys = variable_get('mollom_public_key', '') && variable_get('mollom_private_key', ''); +/** + * Display a reports page. + */ +function mollom_reports_page() { + $form['statistics'] = array( + '#type' => 'item', + '#value' => '', + ); + return drupal_render($form); +} - if ($keys) { +/** + * Form builder; administration options. + */ +function mollom_admin_settings() { + if ($keys = _mollom_access()) { // Print a status message about the key: if (!$_POST) { // When a user visits the Mollom administration page, automatically @@ -673,15 +701,6 @@ function mollom_admin_settings() { _mollom_verify_key(); } - $form['statistics'] = array( - '#type' => 'fieldset', - '#title' => t('Site usage statistics'), - '#collapsible' => TRUE, - ); - $form['statistics']['message'] = array( - '#value' => '
', - ); - $form['spam'] = array( '#type' => 'fieldset', '#title' => t('Spam protection settings'), @@ -1092,9 +1111,9 @@ function _mollom_retrieve_server_list() * Call a remote procedure at the Mollom server. This function * automatically adds the information required to authenticate against * Mollom. - * + * * TODO: currently this function's return value mixes actual values and - * error values. We should rewrite the error handling so that calling + * error values. We should rewrite the error handling so that calling * functions can properly handle error situations. */ function mollom($method, $data = array()) { @@ -1181,7 +1200,7 @@ function mollom($method, $data = array() // Report this error: watchdog('mollom', 'No Mollom servers could be reached or all servers returned an error -- the server list was emptied.', NULL, WATCHDOG_ERROR); - + return NETWORK_ERROR; }