drupal_6.inc

  1. 6.x commands/pm/update_info/drupal_6.inc
  2. 3.x commands/pm/update_info/drupal_6.inc
  3. 4.x commands/pm/update_info/drupal_6.inc
  4. 5.x commands/pm/update_info/drupal_6.inc

Implementation of 'drupal' update_info engine for Drupal 6.

Functions

Namesort descending Description
pm_update_filter Returns a human readable message based on update status of a project.
pm_update_last_check Returns time of last check of available updates.
_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_6.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Implementation of 'drupal' update_info engine for Drupal 6.
  5. */
  6. /**
  7. * Returns a human readable message based on update status of a project.
  8. *
  9. * It also may alter the project object and set $project['updateable']
  10. * and $project['candidate_version'].
  11. *
  12. * @see pm_release_recommended()
  13. *
  14. * Project statuses in Drupal 6 are:
  15. * - UPDATE_NOT_SECURE
  16. * - UPDATE_REVOKED
  17. * - UPDATE_NOT_SUPPORTED
  18. * - UPDATE_NOT_CURRENT
  19. * - UPDATE_CURRENT
  20. * - UPDATE_NOT_CHECKED
  21. * - UPDATE_UNKNOWN
  22. * - UPDATE_NOT_FETCHED
  23. *
  24. */
  25. function pm_update_filter(&$project) {
  26. switch($project['status']) {
  27. case UPDATE_NOT_SECURE:
  28. $status = dt('SECURITY UPDATE available');
  29. pm_release_recommended($project);
  30. break;
  31. case UPDATE_REVOKED:
  32. $status = dt('Installed version REVOKED');
  33. pm_release_recommended($project);
  34. break;
  35. case UPDATE_NOT_SUPPORTED:
  36. $status = dt('Installed version not supported');
  37. pm_release_recommended($project);
  38. break;
  39. case UPDATE_NOT_CURRENT:
  40. $status = dt('Update available');
  41. pm_release_recommended($project);
  42. break;
  43. case UPDATE_NOT_CHECKED:
  44. $status = dt('Unable to check status');
  45. break;
  46. case UPDATE_CURRENT:
  47. $status = dt('Up to date');
  48. $project['candidate_version'] = $project['recommended'];
  49. break;
  50. case UPDATE_UNKNOWN:
  51. case UPDATE_NOT_FETCHED:
  52. default:
  53. $status = dt('Unknown');
  54. break;
  55. }
  56. return $status;
  57. }
  58. /**
  59. * Returns time of last check of available updates.
  60. */
  61. function pm_update_last_check() {
  62. return variable_get('update_last_check', 0);
  63. }
  64. /**
  65. * Command callback. Refresh update status information.
  66. */
  67. function _pm_refresh() {
  68. drush_print(dt("Refreshing update status information ..."));
  69. update_refresh();
  70. drush_print(dt("Done."));
  71. }
  72. /**
  73. * Get update information for all installed projects.
  74. *
  75. * @return An array containing remote and local versions for all
  76. * installed projects.
  77. */
  78. function _pm_get_update_info($projects) {
  79. // We force a refresh if the cache is not available.
  80. if (!cache_get('update_available_releases', 'cache_update')) {
  81. _pm_refresh();
  82. }
  83. $info = update_get_available(TRUE);
  84. // Force to invalidate some update_status caches that are only cleared
  85. // when visiting update status report page.
  86. if (function_exists('_update_cache_clear')) {
  87. _update_cache_clear('update_project_data');
  88. _update_cache_clear('update_project_projects');
  89. }
  90. $data = update_calculate_project_data($info);
  91. foreach ($data as $project_name => $project) {
  92. // Discard custom projects.
  93. if ($project['status'] == UPDATE_UNKNOWN) {
  94. unset($data[$project_name]);
  95. continue;
  96. }
  97. // Discard projects with unknown installation path.
  98. if ($project_name != 'drupal' && !isset($projects[$project_name]['path'])) {
  99. unset($data[$project_name]);
  100. continue;
  101. }
  102. // Allow to update disabled projects.
  103. if (in_array($project['project_type'], array('disabled-module', 'disabled-theme'))) {
  104. $data[$project_name]['project_type'] = substr($project['project_type'], strpos($project['project_type'], '-') + 1);
  105. }
  106. // Add some info from the project to $data.
  107. $data[$project_name] += array(
  108. 'path' => isset($projects[$project_name]['path']) ? $projects[$project_name]['path'] : '',
  109. 'label' => $projects[$project_name]['label'],
  110. );
  111. }
  112. return $data;
  113. }