Initial groundwork to use phpdocumentor.
[squirrelmail.git] / plugins / calendar / calendar_data.php
index 8e724547e59486462fd12c08173a15e076d4b234..705e8a7168adce2782369bc4e57eae664a4ee470 100644 (file)
  * functions to operate on calendar data files.
  *
  * $Id$
+ * @package plugins
+ * @subpackage calendar
  */
 
-// this is array that contains all events
-// it is three dimensional array with fallowing structure
-// $calendardata[date][time] = array(length,priority,title,message);
+/** this is array that contains all events
+ *  it is three dimensional array with fallowing structure
+ *  $calendardata[date][time] = array(length,priority,title,message); */
 $calendardata = array();
 
-//read events into array
-//data is | delimited, just like addresbook
-//files are structured like this:
-//date|time|length|priority|title|message);
-//files are divide by year for performance increase
+/**
+ * read events into array
+ *
+ * data is | delimited, just like addressbook
+ * files are structured like this:
+ * date|time|length|priority|title|message
+ * files are divided by year for performance increase */
 function readcalendardata() {
     global $calendardata, $username, $data_dir, $year;
 
@@ -40,6 +44,13 @@ function readcalendardata() {
                                                             'reminder' => $fdata[6] );
             }
             fclose ($fp);
+            // this is to sort the events within a day on starttime
+            $new_calendardata = array();
+           foreach($calendardata as $day => $data) {
+                ksort($data, SORT_NUMERIC);
+                $new_calendardata[$day] = $data;
+            }
+           $calendardata = $new_calendardata;
         }
     }
 }
@@ -61,6 +72,7 @@ function writecalendardata() {
 
         }
         fclose ($fp);
+        @unlink($filename);
         rename($filetmp,$filename);
     }
 }