Index: modules/project/release/project_release.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/project_release.module,v
retrieving revision 1.7
diff -u -r1.7 project_release.module
--- modules/project/release/project_release.module	1 Jan 2007 23:56:12 -0000	1.7
+++ modules/project/release/project_release.module	4 Jan 2007 17:55:02 -0000
@@ -6,6 +6,9 @@
 define('PROJECT_RELEASE_VERSION_FORMAT_VALID_MSG', t("The version format string can only contain letters, numbers, and the characters . _ and - (in addition to the special characters used for identifying variables: % ! and #)."));
 define('PROJECT_RELEASE_VERSION_FORMAT_HELP', t('Available variables are:') .' %api, %major, %minor, %patch, %extra. '. t("The percent sign ('%') at the front of the variable name indicates that a period ('.') should be inserted as a delimiter before the value of the variable. The '%' can be replaced with a hash mark ('#') to use a hyphen ('-') delimiter, or with an exclaimation point ('!') to have the value printed without a delimiter. Any variable in the format string that has no value will be removed entirely from the final string.") .' '. PROJECT_RELEASE_VERSION_FORMAT_VALID_MSG);
 
+define('PROJECT_RELEASE_DATA_FORMAT_BASIC', 1);
+define('PROJECT_RELEASE_DATA_FORMAT_EXTENDED', 2);
+
 /**
  * @defgroup project_release_core Core Drupal hooks
  */
@@ -74,6 +77,79 @@
 }
 
 /**
+ * Implementation of hook_xmlrpc().
+ */
+function project_release_xmlrpc() {
+  $xmlrpc = array();
+  $xmlrpc[] = array(
+    'project.release.data',
+    'project_release_data',
+    array('array', 'string', 'string', 'int'),
+    t('Providing versioning data')
+  );
+  return $xmlrpc;
+}
+
+/**
+ * Callback for hook_xmlrpc().
+ *
+ * Return versioning data a given project or for all available projects.
+ * The version returned is the highest available for a given major and minor
+ * release. These data can be used e.g. by applications on client sites to
+ * determine whether the client sites have the latest available version.
+ *
+ * @param $project
+ *   The 'short name' (stored as 'url') of a project, or the keyword 'all'
+ *   for all projects.
+ * @param $version
+ *   A major and minor version, separated by a period, for the version to
+ *   load data for, or the keyword 'all' for all versions.
+ * @param $format
+ *   The format to return data in. PROJECT_RELEASE_DATA_FORMAT_BASIC for
+ *   basic data and PROJECT_RELEASE_DATA_FORMAT_EXTENDED for extended.
+ */
+function project_release_data($project = 'all', $version = 'all', $format = PROJECT_RELEASE_DATA_FORMAT_BASIC) {
+  $data = array();
+
+  $where[] = array();
+  $parameters = array();
+
+  // We load data for all versions if the 'all' keyword is used.
+  // So we need to filter by version only if we're not
+  // loading 'all'.
+  if ($version != 'all') {
+    $where[] = "pr.version LIKE '%s%'";
+    $parameters[] = $project;
+  }
+
+  // We load data for all projects if the 'all' keyword is used.
+  // So we need to filter by the project name (url) only if we're not
+  // loading 'all'.
+  if ($project != 'all') {
+    $where .= "AND p.url = '%s'";
+    $parameters[] = $project;
+  }
+
+  $where = count($where) ? 'WHERE '. implode(' AND ', $where) : '';
+
+  $result = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), p.uri, pr.version, pr.tag FROM {node} n INNER JOIN {project_projects} p ON n.nid = p.nid INNER JOIN {project_release_nodes} pr ON p.nid = pr.pid $where ORDER BY pr.version DESC, p.url", $parameters));
+  while ($project = db_fetch_array($result)) {
+    if (!array_key_exists($project['tag'], $data)) {
+      $data[$project['tag']] = array();
+    }
+    $data[$project['tag']][] = array(
+      'name' => $project['url'],
+      'version' => $project['version'],
+    );
+    if ($format == PROJECT_RELEASE_DATA_FORMAT_EXTENDED) {
+      // Add further parameters here.
+    }
+  }
+
+  return $data;
+}
+
+/**
  * Callback for the main settings page.
  * @ingroup project_release_core
  */
