function flag_requirements in Flag 6.2
Same name and namespace in other branches
- 8.4 flag.install \flag_requirements()
- 5 flag.install \flag_requirements()
- 6 flag.install \flag_requirements()
- 7.3 flag.install \flag_requirements()
- 7.2 flag.install \flag_requirements()
Implements hook_requirements().
Prevent installing this module if the "Flag content" module is installed as well.
File
- ./
flag.install, line 96 - Flag module install/schema/update hooks.
Code
function flag_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'install') {
if (!defined('MAINTENANCE_MODE') && _flag_flag_content_installed()) {
$requirements['flag_content_clash'] = array(
'title' => $t('Flag'),
'severity' => REQUIREMENT_ERROR,
'description' => _flag_flag_content_message(),
);
}
}
if ($phase == 'runtime') {
if (module_exists('translation') && !module_exists('translation_helpers')) {
$requirements['flag_translation'] = array(
'title' => $t('Flag'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('To have the flag module work with translations, you need to install and enable the <a href="http://drupal.org/project/translation_helpers">Translation helpers</a> module.'),
'value' => $t('Translation helpers module not found.'),
);
}
if (module_exists('session_api')) {
if (file_exists('./robots.txt')) {
$flag_path = url('flag') . '/';
$robots_string = 'Disallow: ' . $flag_path;
$contents = file_get_contents('./robots.txt');
if (strpos($contents, $robots_string) === FALSE) {
$requirements['flag_robots'] = array(
'title' => $t('Flag robots.txt problem'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('Flag module may currently be used with anonymous users, however the robots.txt file does not exclude the "@flag-path" path, which may cause search engines to randomly flag and unflag content when they index the site. It is highly recommended to add "@robots-string" to your robots.txt file (located in the root of your Drupal installation).', array(
'@flag-path' => $flag_path,
'@robots-string' => $robots_string,
)),
'value' => $t('Search engines flagging content'),
);
}
}
}
}
return $requirements;
}