Index: connectors/l10n_drupalorg/l10n_drupalorg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_drupalorg/Attic/l10n_drupalorg.module,v
retrieving revision 1.1.2.8.2.2
diff -u -p -r1.1.2.8.2.2 l10n_drupalorg.module
--- connectors/l10n_drupalorg/l10n_drupalorg.module	14 Oct 2008 22:47:56 -0000	1.1.2.8.2.2
+++ connectors/l10n_drupalorg/l10n_drupalorg.module	15 Oct 2008 10:22:40 -0000
@@ -104,16 +104,15 @@ function l10n_drupalorg_scan($automated 
   // Always update full project list.
   l10n_drupalorg_sync_projects();
   
-  for ($i = 0; $i < variable_get('l10n_drupalorg_limit', 1); $i++) { 
-    // Pick the project we did not update for the longest period and sync fresh release list.
-    $uri = db_result(db_query_range("SELECT uri FROM {l10n_community_project} ORDER BY last_parsed ASC", 0, 1));
-    $project = l10n_community_get_projects($uri);
+  // Pick the projects we did not update for the longest period and sync fresh release list.
+  $result = db_query_range("SELECT * FROM {l10n_community_project} WHERE connector_module = 'l10n_drupalorg' ORDER BY last_parsed ASC", 0, variable_get('l10n_drupalorg_limit', 1));
+  while ($project = db_fetch_object($result)) {
     l10n_drupalorg_sync_releases($project);
     
     // Pick the release we did not update for the longest period, and sync the tarball.
     // We should only look for releases with downloads. Placeholder releases for later
     // versions should not be considered.
-    $release = db_fetch_object(db_query_range("SELECT r.* FROM {l10n_community_project} p LEFT JOIN {l10n_community_release} r ON p.pid = r.pid WHERE p.uri = '%s' AND r.download_link != '' ORDER BY r.last_parsed ASC", $uri, 0, 1));
+    $release = db_fetch_object(db_query_range("SELECT r.* FROM {l10n_community_project} p LEFT JOIN {l10n_community_release} r ON p.pid = r.pid WHERE p.pid = %d AND r.download_link != '' ORDER BY r.last_parsed ASC", $project->pid, 0, 1));
     $result = l10n_drupalorg_sync_files($release);
     
     if (!$automated) {
Index: connectors/l10n_drupalorg/projects.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_drupalorg/Attic/projects.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 projects.inc
--- connectors/l10n_drupalorg/projects.inc	25 Mar 2008 17:46:29 -0000	1.1.2.6
+++ connectors/l10n_drupalorg/projects.inc	15 Oct 2008 10:22:40 -0000
@@ -40,16 +40,28 @@ function l10n_drupalorg_sync_projects() 
   // Record all projects in the database.
   foreach ($projects as $uri => $project) {
     if ($existing_project = db_fetch_object(db_query("SELECT * FROM {l10n_community_project} WHERE uri = '%s'", $uri))) {
-      if ($project->title != $existing_project->title) {
-        // Update if title is different (uri should not change, other data is
-        // internal). Also set the parsed timestamp to the past, so we will
-        // reparse the releases later.
-        db_query("UPDATE {l10n_community_project} SET title = '%s', last_parsed = 0, home_link = '%s' WHERE uri = '%s'", $project->title, $uri, $project->link);
+      if ($existing_project->connector_module == 'l10n_drupalorg') {
+        if ($project->title != $existing_project->title) {
+          // Update if title is different (uri should not change, other data is
+          // internal). Also set the parsed timestamp to the past, so we will
+          // reparse the releases later.
+          db_query("UPDATE {l10n_community_project} SET title = '%s', last_parsed = 0, home_link = '%s' WHERE uri = '%s' AND connector_module = 'l10n_drupalorg'", $project->title, $uri, $project->link);
+        }
+      }
+      else {
+        // Log error on existing project with another connector and skip the rest of this function.
+        $t_args = array('%uri' => $uri, '%other_connector' => $existing_project->connector_module, '%this_connector' => 'l10n_drupalorg');
+        watchdog('l10n_drupalorg', 'An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args);
+        drupal_set_message(t('An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args), 'error');
+        return;
       }
     }
     else {
       // New project, not recorded before.
-      db_query("INSERT INTO {l10n_community_project} (uri, title, last_parsed, home_link) VALUES ('%s', '%s', 0, '%s')", $uri, $project->title, $project->link);
+      db_query(
+        "INSERT INTO {l10n_community_project} (uri, title, last_parsed, home_link, connector_module) VALUES ('%s', '%s', %d, '%s', '%s')",
+        $uri, $project->title, 0, $project->link, 'l10n_drupalorg'
+      );
     }
   }
 }
Index: connectors/l10n_localpacks/l10n_localpacks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_localpacks/Attic/l10n_localpacks.module,v
retrieving revision 1.1.2.9.2.1
diff -u -p -r1.1.2.9.2.1 l10n_localpacks.module
--- connectors/l10n_localpacks/l10n_localpacks.module	14 Oct 2008 22:13:49 -0000	1.1.2.9.2.1
+++ connectors/l10n_localpacks/l10n_localpacks.module	15 Oct 2008 10:22:40 -0000
@@ -215,15 +215,27 @@ function l10n_localpacks_scan($automated
 function l10n_localpacks_save_data($project_uri, $project_title, $release_version, $filepath, $filedate) {
   // Save project information first.
   if ($existing_project = db_fetch_object(db_query("SELECT * FROM {l10n_community_project} WHERE uri = '%s'", $project_uri))) {
-    // No need to update home_link here, as uri is not changed, and we base home_link on the uri.
-    db_query("UPDATE {l10n_community_project} SET title = '%s' WHERE uri = '%s'", $project_title, $project_uri);
+    if ($existing_project->connector_module == 'l10n_localpacks') {
+      // No need to update home_link here, as uri is not changed, and we base home_link on the uri.
+      db_query("UPDATE {l10n_community_project} SET title = '%s' WHERE uri = '%s' AND connector_module = 'l10n_localpacks'", $project_title, $project_uri);
+    }
+    else {
+      // Log error on existing project with another connector and skip the rest of this function.
+      $t_args = array('%uri' => $uri, '%other_connector' => $existing_project->connector_module, '%this_connector' => 'l10n_localpacks');
+      watchdog('l10n_localpacks', 'An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args);
+      drupal_set_message(t('An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args), 'error');
+      return;
+    }
   }
   else {
-    db_query("INSERT INTO {l10n_community_project} (uri, title, last_parsed, home_link) VALUES ('%s', '%s', 0, '%s')", $project_uri, $project_title, (variable_get('l10n_localpacks_home_link', 0) ? ('http://drupal.org/project/'. $project_uri) : ''));
+    db_query(
+      "INSERT INTO {l10n_community_project} (uri, title, last_parsed, home_link, connector_module) VALUES ('%s', '%s', %d, '%s', '%s')",
+      $project_uri, $project_title, 0, (variable_get('l10n_localpacks_home_link', 0) ? ('http://drupal.org/project/'. $project_uri) : ''), 'l10n_localpacks'
+    );
   }
   
   // Grab updated project data and save release information.
-  $project = db_fetch_object(db_query("SELECT * FROM {l10n_community_project} WHERE uri = '%s'", $project_uri));
+  $project = db_fetch_object(db_query("SELECT * FROM {l10n_community_project} WHERE uri = '%s' AND connector_module = 'l10n_localpacks'", $project_uri));
   if ($existing_release = db_fetch_object(db_query("SELECT * FROM {l10n_community_release} WHERE pid = %d AND title = '%s'", $project->pid, $release_version))) {
     if ($filedate != $existing_release->file_date) {
       // New file with possibly new date for the same release (dev snapshot
Index: l10n_community/l10n_community.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.install,v
retrieving revision 1.1.2.11.2.2
diff -u -p -r1.1.2.11.2.2 l10n_community.install
--- l10n_community/l10n_community.install	15 Oct 2008 00:09:30 -0000	1.1.2.11.2.2
+++ l10n_community/l10n_community.install	15 Oct 2008 10:22:40 -0000
@@ -56,12 +56,21 @@ function l10n_community_schema() {
         'type' => 'int',
         'not null' => FALSE,
         'disp-width' => '11'
+      ),
+      'connector_module' => array(
+        'description' => t('Connector module for this project, such as l10n_localpacks or l10n_drupalorg.'),
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
       )
     ),
     'primary key' => array('pid'),
     'indexes' => array(
       'l10n_community_project_uri' => array('uri')
     ),
+    'unique keys' => array(
+      'l10n_community_project_uri_connector_module', array('uri', 'connector_module')
+    ),
   );
 
   $schema['l10n_community_release'] = array(
@@ -416,3 +425,33 @@ function l10n_community_update_5003() {
 // -- Drupal 6 updates ---------------------------------------------------------
 // -- Use schema API from here -------------------------------------------------
 
+/**
+ * Add connector_module column and update existing projects to use the right one.
+ */
+function l10n_community_update_6000() {
+  $ret = array();
+
+  // Add connector_module column for use as a clue for modules to tap onto their projects.
+  db_add_field($ret, 'l10n_community_project', 'connector_module', array('type' => 'varchar', 'length' => '50', 'not null' => TRUE));
+  
+  if (!module_exists('l10n_drupalorg') && !module_exists('l10n_localpacks')) {
+    // Inform users if no known connector modules were turned on.
+    drupal_set_message("Neither l10n_drupalorg nor l10n_localpacks modules were turned on, while the updates ran. The newly updated Localization Server requires knowledge of connector modules associated to projects. If you run your own connector module, please update the database with the module's internal name.");
+  }
+  else {
+    // Update existing projects to our best guess on what they use. Give priority
+    // to l10n_localpacks, since l10n_drupalorg is often just used for a test-drive
+    // and possibly left turned on.
+    $connector_module = module_exists('l10n_localpacks') ? 'l10n_localpacks' : 'l10n_drupalorg';
+    $ret[] = update_sql("UPDATE {l10n_community_project} SET connector_module = '". $connector_module ."'");
+    if (module_exists('l10n_drupalorg') && module_exists('l10n_localpacks')) {
+      // Inform users if both modules were turned on.
+      drupal_set_message('Both l10n_drupalorg and l10n_localpacks modules were turned on, while the updates ran. We picked l10n_localpacks as the connector for existing projects. You might need to adjust your database if this was not the right choice.');
+    }
+  }
+
+  // The same URI should not appear with multiple connector modules.
+  db_add_unique_key($ret, 'l10n_community_project', 'l10n_community_project_uri_connector_module', array('uri', 'connector_module'));
+
+  return $ret;
+}
