drupal_5.inc

  1. 3.x commands/pm/update_info/drupal_5.inc
  2. 4.x commands/pm/update_info/drupal_5.inc

Functions

Namesort descending Description
pm_get_project_info Get project information from drupal.org.
pm_update_filter
pm_update_last_check
_pm_get_update_info Get update information for all installed projects.
_pm_refresh Command callback. Refresh update status information.

File

commands/pm/update_info/drupal_5.inc
View source
  1. <?php
  2. function pm_update_filter(&$project) {
  3. $update = FALSE;
  4. switch($project['status']) {
  5. case UPDATE_STATUS_CURRENT:
  6. $status = dt('OK');
  7. $project['candidate_version'] = $project['recommended'];
  8. break;
  9. case UPDATE_STATUS_NOT_CURRENT:
  10. $status = dt('Update available');
  11. pm_release_recommended($project);
  12. break;
  13. case UPDATE_STATUS_NOT_SECURE:
  14. $status = dt('SECURITY UPDATE available');
  15. pm_release_recommended($project);
  16. break;
  17. case UPDATE_STATUS_REVOKED:
  18. $status = dt('Installed version REVOKED');
  19. pm_release_recommended($project);
  20. break;
  21. case UPDATE_STATUS_NOT_SUPPORTED:
  22. $status = dt('Installed version not supported');
  23. pm_release_recommended($project);
  24. break;
  25. default:
  26. $status = dt('Ignored: !reason', array('!reason' => $project['reason']));
  27. $project['title'] = $project['name'];
  28. $project['candidate_version'] = dt('Unknown');
  29. break;
  30. }
  31. return $status;
  32. }
  33. function pm_update_last_check() {
  34. return variable_get('update_status_last', 0);
  35. }
  36. /**
  37. * Command callback. Refresh update status information.
  38. */
  39. function _pm_refresh() {
  40. drush_print(dt("Refreshing update status information ..."));
  41. update_status_refresh();
  42. drush_print(dt("Done."));
  43. }
  44. /**
  45. * Get update information for all installed projects.
  46. *
  47. * @return An array containing remote and local versions for all installed projects
  48. */
  49. function _pm_get_update_info($projects) {
  50. // We force a refresh if the cache is not available.
  51. if (!cache_get('update_status_info', 'cache')) {
  52. _pm_refresh();
  53. }
  54. $info = update_status_get_available(TRUE);
  55. // Force to invalidate some update_status caches that are only cleared
  56. // when visiting update status report page.
  57. _update_status_cache_clear('update_status_project_data');
  58. _update_status_cache_clear('update_status_project_projects');
  59. $data = update_status_calculate_project_data($info);
  60. // update_status for drupal 5 can only process modules,
  61. // so we need to add this here for backwards compatibility
  62. // or pm_get_project_path() will fail
  63. foreach ($data as $project_name => $project_data) {
  64. $data[$project_name]['project_type'] = 'module';
  65. $data[$project_name]['modules'] = drupal_map_assoc($projects[$project_name]['extensions']);
  66. }
  67. $data = _pm_get_project_path($data, 'modules');
  68. return $data;
  69. }
  70. /**
  71. * Get project information from drupal.org.
  72. *
  73. * @param $projects An array of project names/**
  74. * Get project information from drupal.org.
  75. *
  76. * @param $projects An array of project names
  77. */
  78. function pm_get_project_info($projects) {
  79. $info = array();
  80. $data = array();
  81. foreach ($projects as $project_name => $project) {
  82. $url = UPDATE_STATUS_DEFAULT_URL. "/$project_name/". UPDATE_STATUS_CORE_VERSION;
  83. $xml = drupal_http_request($url);
  84. $data[] = $xml->data;
  85. }
  86. if ($data) {
  87. $parser = new update_status_xml_parser;
  88. $info = $parser->parse($data);
  89. }
  90. return $info;
  91. }