Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -2,9 +2,9 @@
|
||||
|
||||
/**
|
||||
* @brief Converter Library Calendar Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package Invision Community
|
||||
* @subpackage Converter
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
@@ -50,6 +50,18 @@ class _Calendar extends Core
|
||||
'link_type' => 'calendar_calendars',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCalendarVenues':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_calendar_venues',
|
||||
'step_method' => 'convertCalendarVenues',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'calendar_venues' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertCalendarCalendars' ),
|
||||
'link_type' => 'calendar_venues',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCalendarEvents':
|
||||
$return[ $k ] = array(
|
||||
@@ -110,6 +122,18 @@ class _Calendar extends Core
|
||||
'link_type' => 'calendar_import_feeds',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCalendarReminders':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_calendar_reminders',
|
||||
'step_method' => 'convertCalendarReminders',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'calendar_event_reminders' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertCalendarEvents' ),
|
||||
'link_type' => 'calendar_reminders',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$return[ $k ] = array(
|
||||
@@ -148,7 +172,7 @@ class _Calendar extends Core
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertCalendarCalendars':
|
||||
$return['convertCalendarCalendars'] = array( 'calendar_calendars' => NULL );
|
||||
$return['convertCalendarCalendars'] = array( 'calendar_calendars' => NULL, 'core_clubs_node_map' => array( "node_class=?", "IPS\\calendar\\Calendar" ) );
|
||||
break;
|
||||
|
||||
case 'convertCalendarEvents':
|
||||
@@ -170,6 +194,14 @@ class _Calendar extends Core
|
||||
case 'convertCalendarFeeds':
|
||||
$return['convertCalendarFeeds'] = array( 'calender_import_feeds' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertCalendarVenues':
|
||||
$return['convertCalendarVenues'] = array( 'calender_venues' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertCalendarReminders':
|
||||
$return['convertCalendarReminders'] = array( 'calender_reminders' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$return['convertAttachments'] = array( 'core_attachments' => array( "location_key=?", 'calendar_Events' ) );
|
||||
@@ -257,6 +289,22 @@ class _Calendar extends Core
|
||||
$info['cal_color'] = $genericCalendar->_generateColor();
|
||||
}
|
||||
|
||||
if ( isset( $info['cal_club_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['cal_club_id'] = $this->software->app->getLink( $info['cal_club_id'], 'core_clubs', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['cal_club_id'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['cal_club_id'] = NULL;
|
||||
}
|
||||
|
||||
$id = $info['cal_id'];
|
||||
unset( $info['cal_id'] );
|
||||
|
||||
@@ -266,6 +314,18 @@ class _Calendar extends Core
|
||||
\IPS\Lang::saveCustom( 'calendar', "calendar_calendar_{$inserted_id}", $name );
|
||||
\IPS\Lang::saveCustom( 'calendar', "calendar_calendar_{$inserted_id}_desc", $desc );
|
||||
|
||||
if ( $info['cal_club_id'] )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_clubs_node_map', array(
|
||||
'node_id' => $inserted_id,
|
||||
'node_class' => "IPS\\calendar\\Calendar",
|
||||
'club_id' => $info['cal_club_id'],
|
||||
'name' => $name,
|
||||
) );
|
||||
|
||||
\IPS\calendar\Calendar::load( $inserted_id )->setPermissionsToClub( \IPS\Member\Club::load( $info['cal_club_id'] ) );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
@@ -318,6 +378,22 @@ class _Calendar extends Core
|
||||
{
|
||||
$info['event_member_id'] = 0;
|
||||
}
|
||||
|
||||
if ( isset( $info['event_venue'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['event_venue'] = $this->software->app->getLink( $info['event_venue'], 'calendar_venues', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['event_venue'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['event_venue'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['event_title'] ) )
|
||||
{
|
||||
@@ -1080,6 +1156,144 @@ class _Calendar extends Core
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Calendar Venue
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return integer|boolean The ID of the newly inserted venue, or FALSE on failure.
|
||||
*/
|
||||
public function convertCalendarVenue( $info=array() )
|
||||
{
|
||||
if ( !isset( $info['venue_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'calendar_venue_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['venue_title'] ) )
|
||||
{
|
||||
$info['venue_title'] = "Untitled Venue {$info['venue_id']}";
|
||||
$this->software->app->log( 'calendar_venue_missing_title', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['venue_id'] );
|
||||
}
|
||||
|
||||
if ( isset( $info['venue_enabled'] ) )
|
||||
{
|
||||
$info['venue_enabled'] = 1;
|
||||
}
|
||||
|
||||
if ( isset( $info['venue_address'] ) )
|
||||
{
|
||||
if ( is_array( $info['venue_address'] ) AND isset( $info['venue_address']['lat'] ) AND isset( $info['venue_address']['long'] ) )
|
||||
{
|
||||
$info['venue_address'] = (string) \IPS\GeoLocation::getFromLatLong( $info['venue_address']['lat'], $info['venue_address']['long'] );
|
||||
}
|
||||
else if ( $info['venue_address'] instanceof \IPS\GeoLocation )
|
||||
{
|
||||
$info['venue_address'] = (string) $info['venue_address'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'calendar_venue_missing_address', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'calendar_venue_missing_address', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['venue_position'] ) )
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(venue_position)', 'calendar_venues' )->first();
|
||||
$info['venue_position'] = $position + 1;
|
||||
}
|
||||
|
||||
$id = $info['venue_id'];
|
||||
unset( $info['venue_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'calendar_venues', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'calendar_venues' );
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Calendar Event Reminder
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return integer|boolean The ID of the newly inserted reminder, or FALSE on failure.
|
||||
*/
|
||||
public function convertCalendarReminder( $info=array() )
|
||||
{
|
||||
if ( !isset( $info['reminder_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'calendar_reminder_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['reminder_days_before'] ) )
|
||||
{
|
||||
$info['reminder_days_before'] = 1;
|
||||
}
|
||||
|
||||
if ( isset( $info['reminder_event_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['reminder_event_id'] = $this->software->app->getLink( $info['reminder_event_id'], 'calendar_events' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'calendar_reminder_missing_event', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reminder_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'calendar_reminder_missing_event', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reminder_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['reminder_member_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['reminder_member_id'] = $this->software->app->getLink( $info['reminder_member_id'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'calendar_reminder_missing_member', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reminder_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'calendar_reminder_missing_member', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reminder_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['reminder_date'] ) )
|
||||
{
|
||||
if ( $info['reminder_date'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['reminder_date'] = $info['reminder_date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['reminder_date'] = time();
|
||||
}
|
||||
|
||||
$id = $info['reminder_id'];
|
||||
unset( $info['reminder_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'calendar_event_reminders', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'calendar_event_reminders' );
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an attachment
|
||||
|
||||
Reference in new issue
Block a user