File: prefs.php

package info (click to toggle)
kronolith2 2.1.4-1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 5,560 kB
  • ctags: 2,171
  • sloc: php: 8,755; xml: 1,049; sql: 258; makefile: 65
file content (97 lines) | stat: -rw-r--r-- 2,999 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
 * $Horde: kronolith/lib/prefs.php,v 1.5.10.5 2006/01/01 21:29:03 jan Exp $
 *
 * Copyright 2001-2006 Jon Parise <jon@horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

function handle_remote_cal_management($updated)
{
    global $prefs;

    $calName = Util::getFormData('remote_name');
    $calUrl  = trim(Util::getFormData('remote_url'));
    $calActionID = Util::getFormData('remote_action', 'add');

    if ($calActionID == 'add') {
        if (!empty($calName) && !empty($calUrl)) {
            $cals = unserialize($prefs->getValue('remote_cals'));
            $cals[] = array('name' => $calName,
                            'url'  => $calUrl);
            $prefs->setValue('remote_cals', serialize($cals));
            $updated = true;
            return false;
        }
    } elseif ($calActionID == 'delete') {
        $cals = unserialize($prefs->getValue('remote_cals'));
        foreach ($cals as $key => $cal) {
            if ($cal['url'] == $calUrl) {
                unset($cals[$key]);
                break;
            }
        }
        $prefs->setValue('remote_cals', serialize($cals));
        $updated = true;
        return false;
    }
    return true;
}

function handle_shareselect($updated)
{
    $default_share = Util::getFormData('default_share');
    if (!is_null($default_share)) {
        $sharelist = Kronolith::listCalendars();
        if ((is_array($sharelist)) > 0 && isset($sharelist[$default_share])) {
            $GLOBALS['prefs']->setValue('default_share', $default_share);
            return true;
        }
    }

    return false;
}

function handle_search_abook_select($updated)
{
    $address_bookSelected = Util::getFormData('search_abook');
    $address_books = $GLOBALS['registry']->call('contacts/sources');
    $address_bookFiltered = array();

    if (isset($address_bookSelected) && is_array($address_bookSelected)) {
        foreach ($address_bookSelected as $address_book) {
            $address_bookFiltered[] = $address_book;
        }
    }

    $GLOBALS['prefs']->setValue('search_abook', serialize($address_bookFiltered));

    return true;
}

if (!$prefs->isLocked('day_hour_start') || !$prefs->isLocked('day_hour_end')) {
    $day_hour_start_options = array();
    for ($i = 0; $i <= 48; $i++) {
        $day_hour_start_options[$i] = date(($prefs->getValue('twentyFour')) ? 'G:i' : 'g:ia', mktime(0, $i * 30, 0));
    }
    $day_hour_end_options = $day_hour_start_options;
}

function handle_fb_cals_select($updated)
{
    $fb_calsSelected = Util::getFormData('fb_cals');
    $fb_cals = Kronolith::listCalendars();
    $fb_calsFiltered = array();

    if (isset($fb_calsSelected) && is_array($fb_calsSelected)) {
        foreach ($fb_calsSelected as $fb_cal) {
            $fb_calsFiltered[] = $fb_cal;
        }
    }

    $GLOBALS['prefs']->setValue('fb_cals', serialize($fb_calsFiltered));

    return true;
}