Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief iCalendar ICS Parser
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 19 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\Icalendar;
@@ -246,10 +245,11 @@ class _ICSParser
* @param int|\IPS\calendar\Calendar $calendar The calendar to import to
* @param int|\IPS\Member $member The member the imported events should be 'from'
* @param int $feed The feed we are importing (used to detect and prevent duplicate imports)
* @param int $venue The venue if provided
* @return array Number of events imported and skipped
* @throws \UnexpectedValueException
*/
public function parse( $content, $calendar, $member, $feed=NULL )
public function parse( $content, $calendar, $member, $feed=NULL, $venue=NULL )
{
/* Load the calendar */
$this->calendar = ( $calendar instanceof \IPS\calendar\Calendar ) ? $calendar : \IPS\calendar\Calendar::load( $calendar );
@@ -416,6 +416,12 @@ class _ICSParser
$newEvent->post_key = md5( uniqid() );
$newEvent->member_id = $this->member->member_id;
$newEvent->calendar_id = $this->calendar->id;
if( $venue )
{
$newEvent->venue = $venue;
}
$newEvent->approved = 1;
/* RSVP ? */
@@ -447,6 +453,19 @@ class _ICSParser
}
catch( \BadFunctionCallException $e ){}
}
elseif( isset( $event['location'] ) )
{
try
{
$location = new \IPS\GeoLocation;
$location->addressLines = array( $event['location'] );
$location->getLatLong();
/* We get by LatLong because getLatLong() does not populate the other address data. */
$newEvent->location = json_encode( \IPS\GeoLocation::getByLatLong( $location->lat, $location->long ) );
}
catch( \BadFunctionCallException $e ){}
}
/* Save */
$newEvent->save();
@@ -866,7 +885,6 @@ class _ICSParser
*
* @param string $text String to unencode
* @return string Unencoded string
* @link http://community.invisionpower.com/tracker/issue-33787-formatting-problem-with-imported-ics-file-calendar-app/
*/
protected function _unencodeSpecialCharacters( $text )
{
@@ -930,42 +948,50 @@ class _ICSParser
*/
protected function _unparseTimeInfo( $string )
{
if( mb_strpos( $string, '=' ) !== false )
/* init */
$value = NULL;
$rawTime = NULL;
$tzid = NULL;
/* split the timestamp from the properties */
$dt = explode( ':', $string );
/* Set the raw time value */
$rawTime = $dt[1];
/* Which properties do we have */
$properties = explode( ';', $dt[0] );
foreach( $properties as $property )
{
$_tmp = explode( '=', $string );
$_key = explode( ';', $_tmp[0] );
$tmp = explode( ':', $_tmp[1] );
}
else
{
$_tmp = array();
$_key = array();
$tmp = explode( ':', $string );
/* The date string may be in the format of "DTSTART;20160219T140000Z" (for example) */
if ( !isset( $tmp[1] ) )
if( mb_strpos( $property, '=' ) !== false )
{
if ( mb_strpos( $string, ';' ) !== false )
$_property = explode( '=', $property );
/* Grab our needed values from the given properties */
switch( $_property[0] )
{
$tmp = explode( ';', $string );
case 'VALUE':
$value = $_property[1];
break;
case 'TZID':
$tzid = $_property[1];
break;
}
}
}
/* Got a TZID? */
$tzid = ( count( $_key ) AND $_key[1] == 'TZID' ) ? $tmp[0] : '';
/* If the value is a date without a time, then type should be reset to date */
$type = ( mb_strlen( $tmp[1] ) === 8 ) ? 'DATE' : 'DATETIME';
$type = ( mb_strlen( $rawTime ) === 8 ) ? 'DATE' : 'DATETIME';
/* Format return array */
$return = array(
'type' => $type,
'raw' => $tmp[1],
'raw_ts' => strtotime( $tmp[1] ),
'tzid' => str_replace( '"', '', $tzid ),
'raw' => $rawTime,
'raw_ts' => strtotime( $rawTime ),
'tzid' => ( $tzid ) ? str_replace( '"', '', $tzid ) : '',
);
/* Is this the earliest or latest timestamp? */
if ( ( $this->_feedEarliest == 0 ) OR ( $return['raw_ts'] < $this->_feedEarliest ) )
{
@@ -1025,7 +1051,6 @@ class _ICSParser
*
* @param int $start Line number
* @return void
* @link http://community.invisionpower.com/resources/bugs.html/_/ip-calendar/recurring-events-can-sometimes-be-skipped-in-ics-r41033
*/
protected function _processEventObject( $start )
{
@@ -1070,7 +1095,6 @@ class _ICSParser
break;
case 'SUMMARY':
/* @link http://community.invisionpower.com/tracker/issue-32941-ical-summary/ */
if( mb_strpos( $_data, 'LANGUAGE=' ) === 0 )
{
$_data = preg_replace( "/^LANGUAGE=(.+?):(.+?)$/i", "\\2", $_data );
@@ -1290,7 +1314,7 @@ class _ICSParser
{
$event[ $method ]['utc_time'] = new \IPS\DateTime( $event[ $method ]['raw'], new \DateTimeZone( $event[ $method ]['tzid'] ) );
}
else
elseif( isset( $event[ $method ]['raw'] ) )
{
$event[ $method ]['utc_time'] = new \IPS\DateTime( $event[ $method ]['raw'] );
}