-
Notifications
You must be signed in to change notification settings - Fork 4
/
IcalendarAlarm.php
42 lines (36 loc) · 1.06 KB
/
IcalendarAlarm.php
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
<?php
// $Id: IcalendarAlarm.php,v 1.8 2005/07/21 22:31:44 defacer Exp $
class IcalendarAlarm extends IcalendarComponent
{
public $name = 'VALARM';
public $properties;
public $mapping_arr = [
'TRIGGER' => ['component' => 'reminder_time', 'function' => 'iCalendarEventTrigger'],
];
public function construct()
{
$this->valid_components = [];
$this->valid_properties = [
'TRIGGER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ACTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'X-WR-ALARMUID' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL,
];
parent::construct();
}
public function iCalendarEventTrigger($activity)
{
$reminder_time = $activity['reminder_time'];
if ($reminder_time > 60) {
$reminder_time = round($reminder_time / 60);
$reminder = $reminder_time . 'H';
} else {
$reminder = $reminder_time . 'M';
}
$this->addProperty('ACTION', 'DISPLAY');
$this->addProperty('TRIGGER', 'PT' . $reminder);
$this->addProperty('DESCRIPTION', 'Reminder');
return true;
}
}