Index: potx.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/potx/Attic/potx.module,v
retrieving revision 1.1.2.12.2.2.2.10.4.2
diff -u -p -r1.1.2.12.2.2.2.10.4.2 potx.module
--- potx.module	24 Aug 2009 07:33:08 -0000	1.1.2.12.2.2.2.10.4.2
+++ potx.module	8 Dec 2009 17:04:15 -0000
@@ -41,6 +41,8 @@ function potx_menu() {
  */
 function potx_select_form() {
 
+  var_export(potx_get_projects());
+
   $form = array();
   $components = _potx_component_list();
   _potx_component_selector($form, $components);
@@ -297,6 +299,62 @@ function _potx_component_list() {
 }
 
 /**
+ * Fetch an array of installed projects.
+ *
+ * This is only responsible for generating an array of projects (taking into
+ * account projects that include more than one module or theme).
+ *
+ * This array is fairly expensive to construct, since it involves a lot of
+ * disk I/O, so we cache the results into the {cache_update} table using the
+ * 'update_potx_projects' cache ID. However, since this data is constructed from
+ * local information, it is ok to invalidate it somewhat quickly. If we keep
+ * this data for very long, site administrators are more likely to see incorrect
+ * results if they upgrade to a newer version of a module or theme but do not
+ * visit certain pages that automatically clear this cache.
+ *
+ * This is a slightly modified copy of update_get_projects() from
+ * update.module's update.compare.inc.
+ *
+ * @see update_process_project_info()
+ * @see update_calculate_project_data()
+ * @see update_project_cache()
+ */
+function potx_get_projects() {
+  static $projects = array();
+
+  if (empty($projects)) {
+    // Include underlying library.
+    include_once drupal_get_path('module', 'update') .'/update.compare.inc';
+
+    // Retrieve the projects from cache, if present.
+    $projects = update_project_cache('update_project_projects');
+    if (empty($projects)) {
+      // Still empty, so we have to rebuild the cache.
+      $modules = _potx_pretend_enabled(module_rebuild_cache());
+      _update_process_info_list($projects, $modules, 'module');
+      $themes = _potx_pretend_enabled(system_theme_data());
+      _update_process_info_list($projects, $themes, 'theme');
+      // Allow other modules to alter projects.
+      drupal_alter('update_projects', $projects);
+      // Cache the site's project data for at most 1 hour.
+      _update_cache_set('update_potx_projects', $projects, time() + 3600);
+    }
+  }
+  return $projects;
+}
+
+/**
+ * Set status to 1 on all items in $list.
+ */
+function _potx_pretend_enabled($list) {
+  foreach ($list as $key => $item) {
+    $item->status = 1;
+    $list[$key] = $item;
+  }
+  return $list;
+}
+
+/**
  * Implementation of hook_reviews(). Coder module integration.
  *
  * Provides the list of reviews provided by this module.
