6
* Copyright (c) 2002-2003 The SquirrelMail Project Team
6
* Copyright (c) 2002-2005 The SquirrelMail Project Team
7
7
* Licensed under the GNU GPL. For full terms see the file COPYING.
9
9
* Originally contrubuted by Michal Szczotka <michal@tuxy.org>
11
11
* functions to operate on calendar data files.
13
* $Id: calendar_data.php,v 1.11 2003/10/27 22:24:39 tassium Exp $
15
* @subpackage calendar
13
* $Id: calendar_data.php,v 1.7.2.8 2004/12/27 15:03:49 kink Exp $
18
/** this is array that contains all events
19
* it is three dimensional array with fallowing structure
20
* $calendardata[date][time] = array(length,priority,title,message); */
16
// this is array that contains all events
17
// it is three dimensional array with fallowing structure
18
// $calendardata[date][time] = array(length,priority,title,message);
21
19
$calendardata = array();
24
* read events into array
26
* data is | delimited, just like addressbook
27
* files are structured like this:
28
* date|time|length|priority|title|message
29
* files are divided by year for performance increase */
21
//read events into array
22
//data is | delimited, just like addresbook
23
//files are structured like this:
24
//date|time|length|priority|title|message);
25
//files are divide by year for performance increase
30
26
function readcalendardata() {
31
27
global $calendardata, $username, $data_dir, $year;
47
43
// this is to sort the events within a day on starttime
48
44
$new_calendardata = array();
49
foreach($calendardata as $day => $data) {
45
foreach($calendardata as $day => $data) {
50
46
ksort($data, SORT_NUMERIC);
51
47
$new_calendardata[$day] = $data;
53
$calendardata = $new_calendardata;
49
$calendardata = $new_calendardata;
58
54
//makes events persistant
59
55
function writecalendardata() {
60
global $calendardata, $username, $data_dir, $year;
56
global $calendardata, $username, $data_dir, $year, $color;
62
58
$filetmp = getHashedFile($username, $data_dir, "$username.$year.cal.tmp");
63
59
$filename = getHashedFile($username, $data_dir, "$username.$year.cal");
67
63
while ( $calbar = each ($calfoo['value'])) {
68
64
$calfoobar = $calendardata[$calfoo['key']][$calbar['key']];
69
65
$calstr = "$calfoo[key]|$calbar[key]|$calfoobar[length]|$calfoobar[priority]|$calfoobar[title]|$calfoobar[message]|$calfoobar[reminder]\n";
70
fwrite($fp, $calstr, 4096);
66
if(sq_fwrite($fp, $calstr, 4096) === FALSE) {
67
error_box(_("Could not write calendar file %s", "$username.$year.cal.tmp"), $color);