prod_check.install 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function prod_check_install() {
  6. // Allow immediate fetching of module data by prod_mon after installation
  7. // for remote the module status update checking feature.
  8. variable_set('prod_check_module_list_lastrun', -1);
  9. }
  10. /**
  11. * Implementation of hook_uninstall().
  12. */
  13. function prod_check_uninstall() {
  14. // This beats multiple variable_del() calls.
  15. db_delete('variable')->condition('name', 'prod_check\_%', 'LIKE')->execute();
  16. }
  17. /**
  18. * Implementation of hook_requirements().
  19. */
  20. function prod_check_requirements($phase) {
  21. $requirements = array();
  22. switch ($phase) {
  23. case 'runtime':
  24. $sitemail = variable_get('prod_check_sitemail', '');
  25. if (empty($sitemail)) {
  26. $requirements['prod_check_email'] = array(
  27. 'title' => t('Production check'),
  28. 'value' => t('Site e-mail check not properly configured.'),
  29. 'severity' => REQUIREMENT_WARNING,
  30. 'description' => t('You have not changed the e-mail address on the prod-check !link. The Site e-mail check will not function properly. Please read the README.txt file.', prod_check_link_array('settings page', 'admin/config/system/prod-check')),
  31. );
  32. }
  33. if (function_exists('apc_cache_info') && variable_get('prod_check_apcpass', 'password') == 'password') {
  34. $requirements['prod_check_apc_opc'] = array(
  35. 'title' => t('Production check'),
  36. 'value' => t('APC password not configured.'),
  37. 'severity' => REQUIREMENT_WARNING,
  38. 'description' => t('You have not !link for the APC status page. The page will function, but advanced options require that you set a password. Please read the README.txt file.', prod_check_link_array('changed the password', 'admin/config/system/prod-check')),
  39. );
  40. }
  41. $nagios = variable_get('prod_check_enable_nagios', 0);
  42. if ($nagios && !module_exists('nagios')) {
  43. $requirements['prod_check_nagios'] = array(
  44. 'title' => t('Production check'),
  45. 'value' => t('Nagios module not installed/enabled.'),
  46. 'severity' => REQUIREMENT_ERROR,
  47. 'description' => t('You have enabled <em>Nagios integration</em> but you have not installed or enabled the !link module! Please install the !link module if you wish to use this functionality.', prod_check_link_array('Nagios', 'http://drupal.org/project/nagios')),
  48. );
  49. }
  50. break;
  51. }
  52. return $requirements;
  53. }
  54. /**
  55. * Update prod_check_nagios_checks settings if present.
  56. */
  57. function prod_check_update_7100() {
  58. if ($checks = variable_get('prod_check_nagios_checks', FALSE)) {
  59. $prefix = '_prod_check_';
  60. foreach ($checks as $set => &$calls) {
  61. foreach ($calls as $key => &$function) {
  62. if (stripos($function, $prefix) === FALSE) {
  63. $function = $prefix . $function;
  64. }
  65. }
  66. }
  67. variable_set('prod_check_nagios_checks', $checks);
  68. return t('Successfully updated prod_check_nagios_checks settings.');
  69. }
  70. return t('No prod_check_nagios_checks found that needed an update.');
  71. }
  72. /**
  73. * Remove obsolete memcache settings.
  74. */
  75. function prod_check_update_7101() {
  76. variable_del('prod_check_memcacheuser');
  77. variable_del('prod_check_memcachepass');
  78. return t('Obsolete memcache settings removed.');
  79. }