views_rss_media.install 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @file
  4. * (Un)installation functions for Views RSS: Media Elements module.
  5. */
  6. /**
  7. * Required minimum Views RSS module build.
  8. */
  9. define('VIEWS_RSS_MEDIA_REQUIRED_BUILD', '7.x-2.x-dev-20120314');
  10. /**
  11. * Implements hook_requirements().
  12. */
  13. function views_rss_media_requirements($phase) {
  14. $requirements = array();
  15. $t = get_t();
  16. $vrb_array = explode('-', VIEWS_RSS_BUILD);
  17. $vrmrb_array = explode('-', VIEWS_RSS_MEDIA_REQUIRED_BUILD);
  18. if (!defined('VIEWS_RSS_BUILD')) {
  19. $requirements['views_rss_media'] = array(
  20. 'title' => $t('Views RSS: Media (MRSS) Elements'),
  21. 'description' => $t('<a href="@views_rss_url">Views RSS</a> module does not seem to be enabled. Please make sure it is enabled before enabling <em>Views RSS: Media (MRSS) Elements</em> module.', array(
  22. '@views_rss_url' => url('http://drupal.org/project/views_rss'),
  23. )),
  24. 'severity' => REQUIREMENT_ERROR,
  25. 'value' => NULL,
  26. );
  27. }
  28. elseif (array_pop($vrb_array) < array_pop($vrmrb_array)) {
  29. $requirements['views_rss_media'] = array(
  30. 'title' => $t('Views RSS: Media (MRSS) Elements'),
  31. 'description' => $t('Your current build of <a href="@views_rss_url">Views RSS</a> module (!views_rss_build) is too old for this version of <em>Views RSS: Media (MRSS) Elements</em> module to work properly. Minimum version required is <strong>!views_rss_required</strong>. Please upgrade.', array(
  32. '@views_rss_url' => url('http://drupal.org/project/views_rss'),
  33. '!views_rss_build' => VIEWS_RSS_BUILD,
  34. '!views_rss_required' => VIEWS_RSS_MEDIA_REQUIRED_BUILD,
  35. )),
  36. 'severity' => REQUIREMENT_ERROR,
  37. 'value' => NULL,
  38. );
  39. }
  40. return $requirements;
  41. }
  42. /**
  43. * Implements hook_install().
  44. */
  45. function views_rss_media_install() {
  46. // Clear Views cache to force-rebuild namespaces and feed elements.
  47. cache_clear_all('views_rss:', 'cache_views', TRUE);
  48. }
  49. /**
  50. * Implements hook_uninstall().
  51. */
  52. function views_rss_media_uninstall() {
  53. if (db_table_exists('cache_views')) {
  54. cache_clear_all('views_rss:', 'cache_views', TRUE);
  55. }
  56. }