~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to plugins/calendar/calendar_data.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2005-02-06 21:41:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050206214151-z4n1o8mnttgzuj0y
Tags: 2:1.4.4-3
* Move default_pref config file from /var to /etc, as per Debian policy
  (Closes: #293281)
* [JvW] (finally) override two lintian warnings about nonstandard
  permissions that are intentional (Closes: #293366)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/**
4
4
 * calendar_data.php
5
5
 *
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.
8
8
 *
9
9
 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
10
10
 *
11
11
 * functions to operate on calendar data files.
12
12
 *
13
 
 * $Id: calendar_data.php,v 1.11 2003/10/27 22:24:39 tassium Exp $
14
 
 * @package plugins
15
 
 * @subpackage calendar
 
13
 * $Id: calendar_data.php,v 1.7.2.8 2004/12/27 15:03:49 kink Exp $
16
14
 */
17
15
 
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();
22
20
 
23
 
/**
24
 
 * read events into array
25
 
 *
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;
32
28
 
46
42
            fclose ($fp);
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;
52
48
            }
53
 
            $calendardata = $new_calendardata;
 
49
            $calendardata = $new_calendardata;
54
50
        }
55
51
    }
56
52
}
57
53
 
58
54
//makes events persistant
59
55
function writecalendardata() {
60
 
    global $calendardata, $username, $data_dir, $year;
 
56
    global $calendardata, $username, $data_dir, $year, $color;
61
57
 
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);
 
68
                }
71
69
            }
72
70
 
73
71
        }