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 = NULL) {
  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();
  55. $data = update_status_calculate_project_data($info);
  56. // update_status for drupal 5 can only process modules,
  57. // so we need to add this here for backwards compatibility
  58. // or pm_get_project_path() will fail
  59. foreach ($data as $project_name => $project_data) {
  60. $data[$project_name]['project_type'] = 'module';
  61. }
  62. $data = pm_get_project_path($data, 'modules');
  63. return $data;
  64. }
  65. /**
  66. * Get project information from drupal.org.
  67. *
  68. * @param $projects An array of project names/**
  69. * Get project information from drupal.org.
  70. *
  71. * @param $projects An array of project names
  72. */
  73. function pm_get_project_info($projects) {
  74. $info = array();
  75. $data = array();
  76. foreach ($projects as $project_name => $project) {
  77. $url = UPDATE_STATUS_DEFAULT_URL. "/$project_name/". UPDATE_STATUS_CORE_VERSION;
  78. $xml = drupal_http_request($url);
  79. $data[] = $xml->data;
  80. }
  81. if ($data) {
  82. $parser = new update_status_xml_parser;
  83. $info = $parser->parse($data);
  84. }
  85. return $info;
  86. }