Only in ./: location-356059-2.diff
Only in ./: location-356059-3.diff
diff -urp ../../location/location.install ./location.install
--- ../../location/location.install	2008-12-09 13:52:01.000000000 -0800
+++ ./location.install	2009-01-22 20:02:25.000000000 -0800
@@ -39,6 +39,7 @@ function location_install() {
         uid int UNSIGNED DEFAULT NULL,
         genid varchar(255) NOT NULL default '',
         lid int UNSIGNED NOT NULL DEFAULT '0',
+        weight int NULL,
         INDEX {location_instance}_nid_idx (nid),
         INDEX {location_instance}_vid_idx (vid),
         INDEX {location_instance}_uid_idx (uid),
@@ -100,7 +101,8 @@ function location_install() {
         vid int DEFAULT NULL CHECK (vid >= 0 OR vid IS NULL),
         uid int DEFAULT NULL CHECK (uid >= 0 OR uid IS NULL),
         genid varchar(255) NOT NULL default '',
-        lid int NOT NULL DEFAULT '0' CHECK (lid >= 0)
+        lid int NOT NULL DEFAULT '0' CHECK (lid >= 0),
+        weight int DEFAULT NULL
       )");
       db_query('CREATE INDEX {location_instance}_nid_idx ON {location_instance} (nid)');
       db_query('CREATE INDEX {location_instance}_vid_idx ON {location_instance} (vid)');
@@ -854,3 +856,19 @@ function location_update_5308() {
 
   return $ret;
 }
+
+function location_update_5309() {
+  $ret = array();
+
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {location_instance} ADD COLUMN weight int NULL");
+      break;
+    case 'pgsql':
+      $ret[] = db_add_column($ret, 'location_instance', 'weight', 'int', array('null' => TRUE));
+  }
+  return $ret;
+}
+
+
diff -urp ../../location/location.module ./location.module
--- ../../location/location.module	2008-12-11 08:44:11.000000000 -0800
+++ ./location.module	2009-01-22 20:18:38.000000000 -0800
@@ -946,10 +946,10 @@ function location_load_locations($id, $k
     return array();
   }
   if ($key == 'genid') {
-    $result = db_query('SELECT lid FROM {location_instance} WHERE '. db_escape_table($key) ." = '%s'", $id);
+    $result = db_query('SELECT lid FROM {location_instance} WHERE '. db_escape_table($key) ." = '%s' ORDER BY weight", $id);
   }
   else {
-    $result = db_query('SELECT lid FROM {location_instance} WHERE '. db_escape_table($key) .' = %d', $id);
+    $result = db_query('SELECT lid FROM {location_instance} WHERE '. db_escape_table($key) .' = %d ORDER BY weight', $id);
   }
   $locations = array();
   while ($lid = db_fetch_object($result)) {
@@ -1003,6 +1003,7 @@ function location_save_locations(&$locat
     $columns[] = 'lid';
     $placeholders[] = '%d';
 
+    $weight = 0;
     foreach ($locations as $location) {
       // Don't save "empty" locations.
       // location_save() explicitly returns FALSE for empty locations,
@@ -1010,9 +1011,10 @@ function location_save_locations(&$locat
       if ($location['lid'] !== FALSE) {
         $args[] = $location['lid'];
         $newlids[] = $location['lid'];
-        db_query('INSERT INTO {location_instance} ('. implode(', ', $columns) .') VALUES ('. implode(', ', $placeholders) .')', $args);
+        db_query('INSERT INTO {location_instance} ('. implode(', ', $columns) .', weight) VALUES ('. implode(', ', $placeholders) .', '. $weight .')', $args);
         array_pop($args);
       }
+      $weight++;
     }
 
     // Check anything that dropped a reference during this operation.
