paranoia.install in Paranoia 8
Same filename and directory in other branches
Disable risky modules & set install message for Paranoia.
File
paranoia.installView source
<?php
/**
* @file
* Disable risky modules & set install message for Paranoia.
*
* @ingroup paranoia
*/
/**
* Implements hook_install().
*/
function paranoia_install() {
// Some day it should be possible to remove this require_once. Some day.
require_once dirname(__FILE__) . '/paranoia.module';
$defanger = \Drupal::service('paranoia.defanger');
// Disable the risky modules.
paranoia_remove_disabled_modules();
// Manually remove any enabled risky permissions.
_paranoia_remove_risky_permissions();
\Drupal::messenger()
->addMessage(t('Risky permissions have been automatically disabled.'));
// Unset the admin role.
$defanger
->unsetAdminRole();
}
/**
* Implements hook_requirements().
*/
function paranoia_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
// Ensure the PHP module is not enabled.
if (\Drupal::moduleHandler()
->moduleExists('php')) {
$requirements['paranoia_php'] = [
'title' => t('Paranoia'),
'description' => t('The PHP module is enabled. This module should be disabled (but paranoia module prevents it from showing in the module admin form). It may have been enabled in the database, circumventing the effectiveness of paranoia module.'),
'severity' => REQUIREMENT_ERROR,
'value' => '',
];
}
}
return $requirements;
}
/**
* Implements hook_modules_enabled().
*/
function paranoia_modules_enabled($modules) {
_paranoia_remove_risky_permissions();
}
Functions
Name | Description |
---|---|
paranoia_install | Implements hook_install(). |
paranoia_modules_enabled | Implements hook_modules_enabled(). |
paranoia_requirements | Implements hook_requirements(). |