/** * Implements hook_init(). */ function onRequest() { // On all Mollom administration pages, check the module configuration and // display the corresponding requirements error, if invalid. $url = Url::fromRoute('<current>'); $current_path = $url->toString(); if (empty($_POST) && strpos($current_path, 'admin/config/content/mollom') === 0 && \Drupal::currentUser()->hasPermission('administer mollom')) { // Re-check the status on the settings form only. $status = \Drupal\mollom\Utility\MollomUtilities::getAPIKeyStatus($current_path == 'admin/config/content/mollom/settings'); if ($status !== TRUE) { // Fetch and display requirements error message, without re-checking. module_load_install('mollom'); $requirements = mollom_requirements('runtime', FALSE); if (isset($requirements['mollom']['description'])) { drupal_set_message($requirements['mollom']['description'], 'error'); } } } }
/** * Gets the status of Mollom's API key configuration and also displays a * warning message if the Mollom API keys are not configured. * * To be used within the Mollom administration pages only. * * @param bool $force * (optional) Boolean whether to ignore the cached state and re-check. * Defaults to FALSE. * @param bool $update * (optional) Whether to update Mollom with locally stored configuration. * Defaults to FALSE. * * @return array * An associative array describing the current status of the module: * - isConfigured: Boolean whether Mollom API keys have been configured. * - isVerified: Boolean whether Mollom API keys have been verified. * - response: The response error code of the API verification request. * - ...: The full site resource, as returned by the Mollom API. * * @see Mollom::getAPIKeyStatus(). */ public static function getAdminAPIKeyStatus($force = FALSE, $update = FALSE) { $status = MollomUtilities::getAPIKeyStatus($force, $update); if (empty($_POST) && !$status['isVerified']) { // Fetch and display requirements error message, without re-checking. module_load_install('mollom'); $requirements = mollom_requirements('runtime', FALSE); if (isset($requirements['mollom']['description'])) { drupal_set_message($requirements['mollom']['description'], 'error'); } } return $status; }