Fix character encoding when parsing ical data
This commit is contained in:
parent
66d822c79a
commit
c8c640dc0c
1 changed files with 10 additions and 2 deletions
|
@ -51,15 +51,19 @@ class calendar_ical
|
||||||
* Import events from iCalendar format
|
* Import events from iCalendar format
|
||||||
*
|
*
|
||||||
* @param string vCalendar input
|
* @param string vCalendar input
|
||||||
|
* @param string Input charset (from envelope)
|
||||||
* @return array List of events extracted from the input
|
* @return array List of events extracted from the input
|
||||||
*/
|
*/
|
||||||
public function import($vcal)
|
public function import($vcal, $charset = RCMAIL_CHARSET)
|
||||||
{
|
{
|
||||||
// use Horde:iCalendar to parse vcalendar file format
|
// use Horde:iCalendar to parse vcalendar file format
|
||||||
require_once 'Horde/iCalendar.php';
|
require_once 'Horde/iCalendar.php';
|
||||||
|
|
||||||
|
// set target charset for parsed events
|
||||||
|
$GLOBALS['_HORDE_STRING_CHARSET'] = RCMAIL_CHARSET;
|
||||||
|
|
||||||
$parser = new Horde_iCalendar;
|
$parser = new Horde_iCalendar;
|
||||||
$parser->parsevCalendar($vcal);
|
$parser->parsevCalendar($vcal, 'VCALENDAR', $charset);
|
||||||
$events = array();
|
$events = array();
|
||||||
if ($data = $parser->getComponents()) {
|
if ($data = $parser->getComponents()) {
|
||||||
foreach ($data as $comp) {
|
foreach ($data as $comp) {
|
||||||
|
@ -262,6 +266,10 @@ class calendar_ical
|
||||||
|
|
||||||
$vevent .= "TRANSP:" . ($event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE') . self::EOL;
|
$vevent .= "TRANSP:" . ($event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE') . self::EOL;
|
||||||
|
|
||||||
|
if ($event['priority'] != 1) {
|
||||||
|
$vevent .= "PRIORITY:" . ($event['priority'] == 2 ? '1' : '9') . self::EOL;
|
||||||
|
}
|
||||||
|
|
||||||
if ($event['cancelled'])
|
if ($event['cancelled'])
|
||||||
$vevent .= "STATUS:CANCELLED" . self::EOL;
|
$vevent .= "STATUS:CANCELLED" . self::EOL;
|
||||||
else if ($event['free_busy'] == 'tentative')
|
else if ($event['free_busy'] == 'tentative')
|
||||||
|
|
Loading…
Add table
Reference in a new issue