image_captcha.install 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Installation/uninstallation related functions for the image_captcha module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function image_captcha_requirements($phase) {
  10. $requirements = array();
  11. $t = get_t();
  12. if ($phase == 'install') {
  13. // _image_captcha_check_setup() is defined in image_captcha.module.
  14. module_load_include('module', 'image_captcha');
  15. // Check if the GD library is available and raise an error when not.
  16. if (_image_captcha_check_setup(FALSE) & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
  17. $requirements['image_captcha_requires_gd'] = array(
  18. 'title' => $t('Image CAPTCHA requires GD library'),
  19. 'description' => $t(
  20. 'The Image CAPTCHA module can not be installed because your PHP setup does not provide the <a href="!gddoc">GD library</a>, which is required to generate images.',
  21. array('!gddoc' => 'http://www.php.net/manual/en/book.image.php')
  22. ),
  23. 'severity' => REQUIREMENT_ERROR,
  24. );
  25. }
  26. }
  27. return $requirements;
  28. }
  29. /**
  30. * On uninstall: remove module variables and clear variable cache.
  31. */
  32. function image_captcha_uninstall() {
  33. db_delete('variable')
  34. ->condition('name', db_like('image_captcha_') . '%', 'LIKE')
  35. ->execute();
  36. cache_clear_all('variables', 'cache');
  37. }