? calendar_weight.patch
Index: calendar_api.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/calendar/calendar_api.inc,v
retrieving revision 1.15.2.16
diff -u -r1.15.2.16 calendar_api.inc
--- calendar_api.inc	30 Mar 2007 16:57:38 -0000	1.15.2.16
+++ calendar_api.inc	27 Apr 2007 15:44:00 -0000
@@ -215,7 +215,29 @@
                 'colspan' => $colspan);
             }
             $rows[] = calendar_week_header($params['mini'], $params['with_weekno']);
-
+            
+            // Set a weight foreach singleday and start node on any given day.
+            foreach ($days as $daykey => $dayvalue) {
+              $weight = 0;
+              foreach ($dayvalue as $nodekey => $nodevalue) {
+                switch ($nodevalue->calendar_state) {
+                case 'singleday':
+                case 'start':
+                  // Save current weight in the global variable for this nid
+                  $GLOBALS['calendar_node_weight'][$nodevalue->nid] = $weight;
+                  $weight++;
+                  break;
+                case 'ongoing':
+                case 'end':
+                  // Set current weight as the previous weight dave in the global variable
+                  $weight = $GLOBALS['calendar_node_weight'][$nodevalue->nid];
+                  $weight++;
+                  break;
+                }
+                $nodes[$nodevalue->nid]->weight = $GLOBALS['calendar_node_weight'][$nodevalue->nid];
+              }
+            }     
+            
             while ($curstamp <= $lastday) {
             	for ($x = $start; $x < 7; $x++) {
                 $cur_day = (($week * 7) + ($x + 1) - $offset);
