Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

+37 -49
View File
@@ -17,6 +17,7 @@ use ErrorException;
use Exception;
use IPS\blog\Blog as BlogClass;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -48,7 +49,7 @@ class Blog extends Core
/**
* @brief Application
*/
public $app = 'blog';
public string $app = 'blog';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -56,7 +57,7 @@ class Blog extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ): array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -213,11 +214,12 @@ class Blog extends Core
* @param string $method Method we are truncating
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -253,8 +255,7 @@ class Blog extends Core
break;
case 'convertAttachments':
$return['convertAttachments'] = array(
'core_attachments' => Db::i()->in( 'attach_id', (string) Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'blog_Entries' ) ) ),
$return['convertAttachments'] = array( 'core_attachments' => array( 'attach_id IN ( ' . Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'blog_Entries' ) ) . ')' ),
'core_attachments_map' => array( "location_key=?", 'blog_Entries' )
);
break;
@@ -264,11 +265,11 @@ class Blog extends Core
break;
case 'convertClubBlogEntries':
$return['convertClubBlogEntries'] = array( 'blog_entries' => array( 'entry_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_entries' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubBlogEntries'] = array( 'blog_entries' => array( 'entry_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_entries' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubBlogComments':
$return['convertClubBlogComments'] = array( 'blog_comments' => array( 'comment_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubBlogComments'] = array( 'blog_comments' => array( 'comment_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -295,11 +296,11 @@ class Blog extends Core
*
* @param array $info Array of blog information
* @param array|NULL $socialgroup Array of data to be stored in core_sys_social_groups and core_sys_social_group_members
* @param string|NULL|boolean $filepath URL/Path to cover photo, NULL to use raw file data, or FALSE to not convert
* @param string|NULL|bool $filepath URL/Path to cover photo, NULL to use raw file data, or FALSE to not convert
* @param string|NULL $filedata If $filepath is NULL, this should contain the raw contents of the cover photo
* @return integer|boolean The ID of the inserted blog, or FALSE on failure.
* @return int|bool The ID of the inserted blog, or FALSE on failure.
*/
public function convertBlog( array $info, $socialgroup=NULL, $filepath=FALSE, $filedata=NULL )
public function convertBlog( array $info, ?array $socialgroup=NULL, string|null|bool $filepath=FALSE, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['blog_id'] ) )
{
@@ -497,7 +498,7 @@ class Blog extends Core
/* Well update this later if we need too */
$info['blog_social_group'] = NULL;
if ( !is_null( $socialgroup ) AND is_array( $socialgroup ) )
if ( is_array( $socialgroup ) )
{
$socialGroupId = Db::i()->insert( 'core_sys_social_groups', array( 'owner_id' => $info['blog_member_id'] ) );
$members = array();
@@ -532,12 +533,7 @@ class Blog extends Core
$info['blog_cover_photo'] = (string) $file;
$info['blog_cover_photo_offset'] = 0;
}
catch( Exception $e )
{
$info['blog_cover_photo'] = NULL;
$info['blog_cover_photo_offset'] = NULL;
}
catch( ErrorException $e )
catch( Exception|ErrorException $e )
{
$info['blog_cover_photo'] = NULL;
$info['blog_cover_photo_offset'] = NULL;
@@ -609,9 +605,9 @@ class Blog extends Core
* Convert a Blog Category
*
* @param array $info Array of blog information
* @return integer|boolean The ID of the inserted category, or FALSE on failure.
* @return int|bool The ID of the inserted category, or FALSE on failure.
*/
public function convertBlogCategory( array $info )
public function convertBlogCategory( array $info ) : bool|int
{
if ( !isset( $info['category_id'] ) )
{
@@ -693,9 +689,9 @@ class Blog extends Core
* @param array $info Array of entry information
* @param string|NULL $filepath Path to the Cover Photo, or NULL
* @param string|NULL $filedata Binary data for cover photo, or NULL
* @return integer|boolean The ID of the inserted entry, or FALSE on failure
* @return int|bool The ID of the inserted entry, or FALSE on failure
*/
public function convertBlogEntry( array $info, $filepath=NULL, $filedata=NULL )
public function convertBlogEntry( array $info, ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['entry_id'] ) )
{
@@ -953,9 +949,9 @@ class Blog extends Core
* Convert a Blog Entry Category
*
* @param array $info Array of blog information
* @return integer|boolean The ID of the inserted category, or FALSE on failure.
* @return int|bool The ID of the inserted category, or FALSE on failure.
*/
public function convertBlogEntryCategory( array $info )
public function convertBlogEntryCategory( array $info ) : bool|int
{
if ( !isset( $info['entry_category_id'] ) )
{
@@ -969,19 +965,11 @@ class Blog extends Core
return FALSE;
}
if ( isset( $info['entry_category_blog_id'] ) )
try
{
try
{
$info['entry_category_blog_id'] = $this->software->app->getLink( $info['entry_category_blog_id'], 'blog_blogs' );
}
catch( OutOfRangeException $e )
{
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, App::LOG_WARNING, $info['entry_category_id'] );
return FALSE;
}
$info['entry_category_blog_id'] = $this->software->app->getLink( $info['entry_category_blog_id'], 'blog_blogs' );
}
else
catch( OutOfRangeException $e )
{
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, App::LOG_WARNING, $info['entry_category_id'] );
return FALSE;
@@ -1027,9 +1015,9 @@ class Blog extends Core
* Convert a blog comment
*
* @param array $info Array of comment information
* @return integer|boolean The ID of the inserted comment, or FALSE on failure.
* @return int|bool The ID of the inserted comment, or FALSE on failure.
*/
public function convertBlogComment( array $info )
public function convertBlogComment( array $info ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -1148,9 +1136,9 @@ class Blog extends Core
* Convert a blog RSS import
*
* @param array $info Array of RSS Import information
* @return integer|boolean The ID of the inserted RSS import, or FALSE on failure
* @return int|bool The ID of the inserted RSS import, or FALSE on failure
*/
public function convertBlogRssImport( array $info )
public function convertBlogRssImport( array $info ) : bool|int
{
$info['rss_import_class'] = 'IPS\\blogs\\Entry';
@@ -1165,13 +1153,13 @@ class Blog extends Core
* @param string|NULL $filepath URL/Path to attachment or NULL to use raw file data
* @param string|NULL $filedata If $filepath is NULL, this should contain the raw contents of the attachment
* @param string|NULL $thumbnailpath Path to thumbnail, or NULL
* @return integer|boolean The ID of the inserted attachment, or FALSE on failure.
* @return int|bool The ID of the inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath = NULL, $filedata = NULL, $thumbnailpath = NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath = NULL, ?string $filedata = NULL, ?string $thumbnailpath = NULL ) : bool|int
{
$map['id1_type'] = 'blog_entries';
$map['id1_from_parent'] = FALSE;
if ( !isset( $map['id2'] ) OR is_null( $map['id2'] ) )
if ( !isset( $map['id2'] ) OR empty( $map['id2'] ) )
{
$map['location_key'] = 'blog_Entries';
}
@@ -1194,9 +1182,9 @@ class Blog extends Core
* Convert Club Blog
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly insertd blog, or FALSE on failure.
* @return int|bool The ID of the newly insertd blog, or FALSE on failure.
*/
public function convertClubBlog( $info=array() )
public function convertClubBlog( array $info=array() ) : bool|int
{
$insertedId = $this->convertBlog( $info );
if ( $insertedId )
@@ -1210,9 +1198,9 @@ class Blog extends Core
* Convert a Club Blog Entry
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted entry, or FALSE on failure.
* @return int|bool The ID of the newly inserted entry, or FALSE on failure.
*/
public function convertClubBlogEntry( $info=array() )
public function convertClubBlogEntry( array $info=array() ) : bool|int
{
$insertedId = $this->convertBlogEntry( $info );
if ( $insertedId )
@@ -1226,9 +1214,9 @@ class Blog extends Core
* Convert a Club Blog Comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertClubBlogComment( $info=array() )
public function convertClubBlogComment( array $info=array() ) : bool|int
{
$insertedId = $this->convertBlogComment( $info );
if ( $insertedId )
@@ -1241,9 +1229,9 @@ class Blog extends Core
/**
* Get Parent ID for Orphaned Blogs
*
* @return integer The ID of the forum created for forums that do not have a parent forum.
* @return int The ID of the forum created for forums that do not have a parent forum.
*/
protected function _getOrphanedBlogCategory()
protected function _getOrphanedBlogCategory() : int
{
try
{
@@ -19,6 +19,7 @@ use IPS\calendar\Calendar as CalendarClass;
use IPS\calendar\Date;
use IPS\calendar\Icalendar\ICSParser;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -50,7 +51,7 @@ class Calendar extends Core
/**
* @brief Application
*/
public $app = 'calendar';
public string $app = 'calendar';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -58,7 +59,7 @@ class Calendar extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -204,11 +205,12 @@ class Calendar extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -285,9 +287,9 @@ class Calendar extends Core
* Convert a Calendar
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted calendar, or FALSE on failure.
* @return int|bool The ID of the newly inserted calendar, or FALSE on failure.
*/
public function convertCalendar( $info=array() )
public function convertCalendar( array $info=array() ) : bool|int
{
if ( !isset( $info['cal_id'] ) )
{
@@ -340,7 +342,7 @@ class Calendar extends Core
if ( !isset( $info['cal_color'] ) )
{
$genericCalendar = new Calendar;
$genericCalendar = new CalendarClass;
$info['cal_color'] = $genericCalendar->_generateColor();
}
@@ -392,9 +394,9 @@ class Calendar extends Core
* @param array $info Data to insert
* @param string|NULL $filepath Path to the event cover photo, or NULL.
* @param string|NULL $filedata Cover photo binary data, or NULL
* @return integer|boolean The ID of the newly inserted event, or FALSE on failure.
* @return int|bool The ID of the newly inserted event, or FALSE on failure.
*/
public function convertCalendarEvent( $info=array(), $filepath=NULL, $filedata=NULL )
public function convertCalendarEvent( array $info=array(), ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['event_id'] ) )
{
@@ -532,7 +534,7 @@ class Calendar extends Core
}
else if ( $info['event_start_date'] instanceof DateTime )
{
$info['event_start_date'] = Date::create( (string) $info['event_start_date'] )->mysqlDatetime();
$info['event_start_date'] = Date::ts( $info['event_start_date']->getTimestamp() )->mysqlDatetime();
}
}
else
@@ -549,7 +551,7 @@ class Calendar extends Core
}
else if ( $info['event_end_date'] instanceof DateTime )
{
$info['event_end_date'] = Date::create( (string) $info['event_end_date'] )->mysqlDatetime();
$info['event_end_date'] = Date::ts( $info['event_end_date']->getTimestamp() )->mySqlDatetime();
}
}
else
@@ -626,7 +628,7 @@ class Calendar extends Core
{
if ( is_array( $info['event_location'] ) AND isset( $info['event_location']['lat'] ) AND isset( $info['event_location']['long'] ) )
{
$info['event_location'] = (string) GeoLocation::getFromLatLong( $info['event_location']['lat'], $info['event_location']['long'] );
$info['event_location'] = (string) GeoLocation::getByLatLong( $info['event_location']['lat'], $info['event_location']['long'] );
}
else if ( $info['event_location'] instanceof GeoLocation )
{
@@ -671,11 +673,7 @@ class Calendar extends Core
$file = File::create( 'calendar_Events', $info['event_cover_photo'], $filedata );
$info['event_cover_photo'] = (string) $file;
}
catch( Exception $e )
{
$info['event_cover_photo'] = NULL;
}
catch( ErrorException $e )
catch( Exception|ErrorException $e )
{
$info['event_cover_photo'] = NULL;
}
@@ -725,9 +723,9 @@ class Calendar extends Core
* Convert a comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertCalendarComment( $info=array() )
public function convertCalendarComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -846,9 +844,9 @@ class Calendar extends Core
* Convert a review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted review, or FALSE on failure.
* @return int|bool The ID of the newly inserted review, or FALSE on failure.
*/
public function convertCalendarReview( $info=array() )
public function convertCalendarReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -1049,9 +1047,9 @@ class Calendar extends Core
* Convert an RSVP
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted RSVP, or FALSE on failure.
* @return int|bool The ID of the newly inserted RSVP, or FALSE on failure.
*/
public function convertCalendarRsvp( $info=array() )
public function convertCalendarRsvp( array $info=array() ) : bool|int
{
$hasId = TRUE;
if ( !isset( $info['rsvp_id'] ) )
@@ -1133,9 +1131,9 @@ class Calendar extends Core
* Convert a Calendar Import Feed
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted feed, or FALSE on failure.
* @return int|bool The ID of the newly inserted feed, or FALSE on failure.
*/
public function convertCalendarFeed( $info=array() )
public function convertCalendarFeed( array $info=array() ) : bool|int
{
if ( !isset( $info['feed_id'] ) )
{
@@ -1245,9 +1243,9 @@ class Calendar extends Core
* Convert a Calendar Venue
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted venue, or FALSE on failure.
* @return int|bool The ID of the newly inserted venue, or FALSE on failure.
*/
public function convertCalendarVenue( $info=array() )
public function convertCalendarVenue( array $info=array() ) : bool|int
{
if ( !isset( $info['venue_id'] ) )
{
@@ -1270,7 +1268,7 @@ class Calendar extends Core
{
if ( is_array( $info['venue_address'] ) AND isset( $info['venue_address']['lat'] ) AND isset( $info['venue_address']['long'] ) )
{
$info['venue_address'] = (string) GeoLocation::getFromLatLong( $info['venue_address']['lat'], $info['venue_address']['long'] );
$info['venue_address'] = (string) GeoLocation::getByLatLong( $info['venue_address']['lat'], $info['venue_address']['long'] );
}
else if ( $info['venue_address'] instanceof GeoLocation )
{
@@ -1307,9 +1305,9 @@ class Calendar extends Core
* 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.
* @return int|bool The ID of the newly inserted reminder, or FALSE on failure.
*/
public function convertCalendarReminder( $info=array() )
public function convertCalendarReminder( array $info=array() ) : bool|int
{
if ( !isset( $info['reminder_id'] ) )
{
@@ -1387,9 +1385,9 @@ class Calendar extends Core
* @param string|NULL $filepath Path to the file, or NULL.
* @param string|NULL $filedata Binary data for the file, or NULL.
* @param string|NULL $thumbnailpath Path to thumbnail, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
* @return int|bool The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath=NULL ) : bool|int
{
$map['location_key'] = 'calendar_Calendar';
$map['id1_type'] = 'calendar_events';
+48 -74
View File
@@ -22,9 +22,11 @@ use IPS\cms\Fields;
use IPS\cms\Pages\Folder;
use IPS\cms\Pages\Page;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Store;
use IPS\DateTime;
use IPS\Db;
use IPS\Db\Exception as DbException;
use IPS\File;
use IPS\Http\Url;
use IPS\IPS;
@@ -33,13 +35,11 @@ use IPS\Member;
use IPS\Patterns\ActiveRecordIterator;
use LogicException;
use OutOfRangeException;
use OutRangeException;
use UnderflowException;
use function count;
use function defined;
use function get_class;
use function in_array;
use function intval;
use function is_array;
use function is_null;
use function is_numeric;
@@ -61,14 +61,14 @@ class Cms extends Core
/**
* @brief Application
*/
public $app = 'cms';
public string $app = 'cms';
/**
* Returns a block of text, or a language string, that explains what the admin must do to complete this conversion
*
* @return string
*/
public function getPostConversionInformation()
public function getPostConversionInformation() : string
{
return parent::getPostConversionInformation() . Member::loggedIn()->language()->addToStack( 'convert_cms_info_message' );
}
@@ -79,7 +79,7 @@ class Cms extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -100,7 +100,7 @@ class Cms extends Core
'ips_rows' => Db::i()->select( 'COUNT(*)', 'cms_blocks' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'dependencies' => array(),
'dependencies' => $dependencies,
'link_type' => 'cms_blocks',
);
break;
@@ -318,10 +318,12 @@ class Cms extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
foreach( $classname::canConvert() as $k => $v )
{
switch( $k )
@@ -403,7 +405,7 @@ class Cms extends Core
}
}
return isset( $return[ $method ] ) ? $return[ $method ] : array();
return $return[$method] ?? array();
}
/**
@@ -424,9 +426,9 @@ class Cms extends Core
* Convert a Folder
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted folder, or FALSE on failure.
* @return int|bool The ID of the newly inserted folder, or FALSE on failure.
*/
public function convertCmsFolder( $info=array() )
public function convertCmsFolder( array $info=array() ) : bool|int
{
if ( !isset( $info['folder_id'] ) )
{
@@ -487,9 +489,9 @@ class Cms extends Core
* Convert a Page
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted page, or FALSE on failure.
* @return int|bool The ID of the newly inserted page, or FALSE on failure.
*/
public function convertCmsPage( $info=array() )
public function convertCmsPage( array $info=array() ) : bool|int
{
if ( !isset( $info['page_id'] ) )
{
@@ -569,7 +571,7 @@ class Cms extends Core
try
{
/* Check folder */
if ( intval( $info['page_folder_id'] ) == Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
if ( $info['page_folder_id'] == Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
{
$info['page_seo_name'] = Url::seoTitle( $info['page_name'] . '-' . $info['page_id'] );
}
@@ -624,9 +626,9 @@ class Cms extends Core
* Convert a block container
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted container, or FALSE on failure.
* @return int|bool The ID of the newly inserted container, or FALSE on failure.
*/
public function convertCmsContainer( $info=array() )
public function convertCmsContainer( array $info=array() ) : bool|int
{
if ( !isset( $info['container_id'] ) )
{
@@ -656,7 +658,7 @@ class Cms extends Core
$info['container_parent_id'] = 0;
}
if ( !isset( $info['container_type'] ) OR !in_array( $info['container_type'], array( 'block' ) ) )
if ( !isset( $info['container_type'] ) OR $info['container_type'] != 'block' )
{
$info['container_type'] = 'block';
}
@@ -689,9 +691,9 @@ class Cms extends Core
* @note These probably won't really work unless going from Invision Community to Invision Community, but we still support them anyway so they can be refactored.
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted block, or FALSE on failure.
* @return int|bool The ID of the newly inserted block, or FALSE on failure.
*/
public function convertCmsBlock( $info )
public function convertCmsBlock( array $info ) : bool|int
{
if ( !isset( $info['block_id'] ) )
{
@@ -809,14 +811,14 @@ class Cms extends Core
/**
* @brief Orphaned Blocks Container
*/
protected $orphanedBlockContainer = NULL;
protected ?int $orphanedBlockContainer = NULL;
/**
* Returns a category to store blocks that do not have one, creating one if needed.
*
* @return integer The ID.
* @return int The ID.
*/
protected function _orphanedBlocksCategory()
protected function _orphanedBlocksCategory() : int
{
if ( $this->orphanedBlockContainer === NULL )
{
@@ -841,9 +843,9 @@ class Cms extends Core
*
* @param array $info Data to insert
* @param array $fields Custom Field Data
* @return integer|boolean The ID of the newly inserted database, or FALSE on failure.
* @return int|bool The ID of the newly inserted database, or FALSE on failure.
*/
public function convertCmsDatabase( $info=array(), $fields=array() )
public function convertCmsDatabase( array $info=array(), array $fields=array() ) : bool|int
{
/* This is about to get caaaraaaaaazy */
if ( !isset( $info['database_id'] ) )
@@ -1097,10 +1099,6 @@ class Cms extends Core
$info['database_forum_prefix'] = '';
$info['database_forum_suffix'] = '';
}
catch( LogicException $e ) # a bug
{
throw $e;
}
if ( isset( $info['database_tags_predefined'] ) )
{
@@ -1439,7 +1437,7 @@ class Cms extends Core
Db::i()->createTable( $table );
}
}
catch( \IPS\Db\Exception $ex )
catch( DbException $ex )
{
throw new LogicException( $ex );
}
@@ -1553,8 +1551,7 @@ class Cms extends Core
Db::i()->update( 'cms_pages', array( 'page_content' => $page ), array( "page_id=?", $info['database_page_id'] ) );
}
catch( UnderflowException $e ) {}
catch( \IPS\Db\Exception $e ) {}
catch( UnderflowException|DbException $e ) {}
unset( Store::i()->cms_databases );
@@ -1566,9 +1563,9 @@ class Cms extends Core
* Convert a database category
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted category, or FALSE on failure.
* @return int|bool The ID of the newly inserted category, or FALSE on failure.
*/
public function convertCmsDatabaseCategory( $info=array() )
public function convertCmsDatabaseCategory( array $info=array() ) : bool|int
{
if ( !isset( $info['category_id'] ) )
{
@@ -1582,7 +1579,7 @@ class Cms extends Core
{
$info['category_database_id'] = $this->software->app->getLink( $info['category_database_id'], 'cms_databases' );
}
catch( OutRangeException $e )
catch( OutOfRangeException $e )
{
$this->software->app->log( 'cms_database_category_missing_database', __METHOD__, App::LOG_WARNING, $info['category_id'] );
return FALSE;
@@ -1770,7 +1767,7 @@ class Cms extends Core
}
}
}
catch( OutOfRangeException $e )
catch( OutOfRangeException|InvalidArgumentException $e )
{
$info['category_forum_override'] = 0;
$info['category_forum_record'] = 0;
@@ -1780,20 +1777,6 @@ class Cms extends Core
$info['category_forum_prefix'] = NULL;
$info['category_forum_suffix'] = NULL;
}
catch( InvalidArgumentException $e )
{
$info['category_forum_override'] = 0;
$info['category_forum_record'] = 0;
$info['category_forum_comments'] = 0;
$info['category_forum_delete'] = 0;
$info['category_forum_forum'] = 0;
$info['category_forum_prefix'] = NULL;
$info['category_forum_suffix'] = NULL;
}
catch( LogicException $e )
{
throw $e;
}
if ( !isset( $info['category_full_path'] ) )
{
@@ -1884,9 +1867,9 @@ class Cms extends Core
* @param array $fields Custom Field Data.
* @param string|NULL $imagepath Path to record image
* @param string|NULL $imagedata Image data
* @return integer|boolean The ID of the newly inserted record, or FALSE on failure.
* @return int|bool The ID of the newly inserted record, or FALSE on failure.
*/
public function convertCmsDatabaseRecord( $info=array(), $fields=array(), $imagepath=NULL, $imagedata=NULL )
public function convertCmsDatabaseRecord( array $info=array(), array $fields=array(), ?string $imagepath=NULL, ?string $imagedata=NULL ) : bool|int
{
if ( !isset( $info['record_id'] ) )
{
@@ -2028,10 +2011,6 @@ class Cms extends Core
{
$info['record_topicid'] = 0;
}
catch( LogicException $e )
{
throw $e;
}
}
else
{
@@ -2212,7 +2191,7 @@ class Cms extends Core
* @param array $fieldInfo The Field Information to format. This SHOULD be in $foreign_id => $content format, however field_$foreign_id => $content is also accepted.
* @return array An array of data formatted for cms_custom_database_*
*/
protected function _formatFieldsForSaving( $fieldInfo )
protected function _formatFieldsForSaving( array $fieldInfo ) : array
{
$return = array();
@@ -2254,9 +2233,9 @@ class Cms extends Core
* Convert a Comment
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertCmsDatabaseComment( $info=array() )
public function convertCmsDatabaseComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -2427,9 +2406,9 @@ class Cms extends Core
* Convert a review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted review, or FALSE on failure.
* @return int|bool The ID of the newly inserted review, or FALSE on failure.
*/
public function convertCmsDatabaseReview( $info=array() )
public function convertCmsDatabaseReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -2648,9 +2627,9 @@ class Cms extends Core
* Convert a Media Folder
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted folder, or FALSE on failure.
* @return int|bool The ID of the newly inserted folder, or FALSE on failure.
*/
public function convertCmsMediaFolder( $info=array() )
public function convertCmsMediaFolder( array $info=array() ) : bool|int
{
if ( !isset( $info['media_folder_id'] ) )
{
@@ -2701,9 +2680,9 @@ class Cms extends Core
* @param array $info Data to insert
* @param string|NULL $filepath The path to the file, or NULL.
* @param string|NULL $filedata The data for the file, or NULL.
* @return integer|boolean The ID of the newly inserted media file, or FALSE on failure.
* @return int|bool The ID of the newly inserted media file, or FALSE on failure.
*/
public function convertCmsMedia( $info=array(), $filepath=NULL, $filedata=NULL )
public function convertCmsMedia( array $info=array(), ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['media_id'] ) )
{
@@ -2798,17 +2777,12 @@ class Cms extends Core
}
}
}
catch( Exception $e )
catch( Exception|ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['media_id'] );
return FALSE;
}
catch( ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['media_id'] );
return FALSE;
}
$id = $info['media_id'];
unset( $info['media_id'] );
@@ -2826,9 +2800,9 @@ class Cms extends Core
* @param string|NULL $filepath Path to the file, or NULL.
* @param string|NULL $filedata Binary data for the file, or NULL.
* @param string|NULL $thumbnailpath Path to the thumbnail, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
* @return int|bool The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath = NULL ) : bool|int
{
$database = $this->software->app->getLink( str_replace( '-review', '', $map['id3'] ), 'cms_databases' );
@@ -2860,11 +2834,11 @@ class Cms extends Core
* Convert a Tag - CMS, we need to verify the database in a different way that doesn't require it to be on a page
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted tag, or FALSE on failure.
* @return bool|int The ID of the newly inserted tag, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
* @note core_tags_cache and core_tags_perms need to be populated by the converter.
*/
public function convertTag( $info=array() )
public function convertTag( array $info=array() ) : bool|int
{
$classname = 'IPS\cms\\' . ucfirst( $info['tag_meta_area'] );
+136 -153
View File
@@ -19,16 +19,15 @@ use ErrorException;
use InvalidArgumentException;
use IPS\Application;
use IPS\Content;
use IPS\Content\Reaction;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\core\Acronym;
use IPS\core\Announcements\Announcement;
use IPS\core\Ignore;
use IPS\core\ProfileFields\Field;
use IPS\core\StaffDirectory\User;
use IPS\Data\Store;
use IPS\Date\Time;
use IPS\DateTime;
use IPS\Db;
use IPS\Db\Exception;
@@ -46,7 +45,6 @@ use IPS\Request;
use IPS\Settings;
use IPS\Text\ConverterParser;
use IPS\Text\LegacyParser;
use IPS\Text\Parser;
use LogicException;
use OutOfRangeException;
use UnderflowException;
@@ -78,7 +76,7 @@ class Core extends Library
/**
* @brief Application
*/
public $app = 'core';
public string $app = 'core';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -86,7 +84,7 @@ class Core extends Library
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ): array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -570,11 +568,12 @@ class Core extends Library
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -757,7 +756,7 @@ class Core extends Library
}
}
return isset( $return[ $method ] ) ? $return[ $method ] : array();
return $return[$method] ?? array();
}
/**
@@ -768,9 +767,9 @@ class Core extends Library
/**
* A note on logging -
* If the data is missing and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing and it is required to convert the item, we should log a WARNING and return FALSE.
* If the data is missing, and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing, and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing, and it is required to convert the item, we should log a WARNING and return FALSE.
* If the conversion absolutely cannot proceed at all (filestorage locations not writable, for example), then we should log an ERROR and throw an \IPS\convert\Exception to completely halt the process and redirect to an error screen showing the last logged error.
*/
@@ -782,7 +781,7 @@ class Core extends Library
* @param string|NULL $imageData Binary image data, or NULL.
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
*/
public function convertAchievementBadge( array $info=[], string $imagePath=NULL, string $imageData=NULL )
public function convertAchievementBadge( array $info=[], ?string $imagePath=NULL, ?string $imageData=NULL ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -844,7 +843,7 @@ class Core extends Library
* @param string|NULL $imageData Binary image data, or NULL.
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
*/
public function convertAchievementRank( array $info=[], string $imagePath=NULL, string $imageData=NULL )
public function convertAchievementRank( array $info=[], ?string $imagePath=NULL, ?string $imageData=NULL ) : bool|int
{
/* We don't really need an ID for these, so if one isn't specified, then that's okay. */
$hasId = TRUE;
@@ -902,9 +901,9 @@ class Core extends Library
* Convert an Acronym
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted acronym, or FALSE on failure
* @return bool|int The ID of the newly inserted acronym, or FALSE on failure
*/
public function convertAcronym( $info=array() )
public function convertAcronym( array $info=array() ) : bool|int
{
/**
* The below are examples of when we should use an error or a notice, depending on the situation.
@@ -950,9 +949,9 @@ class Core extends Library
* Convert an Administrator
*
* @param array $info Data to insert
* @return boolean TRUE on success, FALSE on failure
* @return bool TRUE on success, FALSE on failure
*/
public function convertAdministrator( $info=array() )
public function convertAdministrator( array $info=array() ) : bool
{
if ( !isset( $info['row_id'] ) )
{
@@ -1019,15 +1018,16 @@ class Core extends Library
}
Db::i()->insert( 'core_admin_permission_rows', $info );
return true;
}
/**
* Convert an Announcement
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted announcement, or FALSE on failure
* @return bool|int The ID of the newly inserted announcement, or FALSE on failure
*/
public function convertAnnouncement( $info=array() )
public function convertAnnouncement( array $info=array() ) : bool|int
{
if ( !isset( $info['announce_id'] ) )
{
@@ -1152,9 +1152,9 @@ class Core extends Library
* @param NULL|string $filepath The path to the attachment files or NULL if loading from the database.
* @param NULL|string $filedata If loading from the database, the content of the Binary column.
* @param NULL|string $thumbnailpath Path to thumbnail image
* @return boolean|integer The ID of the newly inserted attachment, or FALSE on failure.
* @return bool|int The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath=NULL ) : bool|int
{
if ( !isset( $info['attach_id'] ) )
{
@@ -1476,9 +1476,9 @@ class Core extends Library
* Convert a Ban Filter
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted ban filter, or FALSE on failure
* @return bool|int The ID of the newly inserted ban filter, or FALSE on failure
*/
public function convertBanfilter( $info=array() )
public function convertBanfilter( array $info=array() ) : bool|int
{
if ( !isset( $info['ban_id'] ) )
{
@@ -1520,9 +1520,9 @@ class Core extends Library
* Convert Custom BBCode for the LegacyParser to use
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted BBCode, or FALSE on failure.
* @return bool|int The ID of the newly inserted BBCode, or FALSE on failure.
*/
public function convertCustomBbcode( $info=array() )
public function convertCustomBbcode( array $info=array() ) : bool|int
{
if ( !isset( $info['bbcode_id'] ) )
{
@@ -1586,9 +1586,9 @@ class Core extends Library
* Convert Display Name History
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Display Name History, or FALSE on failure.
* @return bool|int The ID of the newly inserted Display Name History, or FALSE on failure.
*/
public function convertDnameChange( $info=array() )
public function convertDnameChange( array $info=array() ) : bool|int
{
// not sure if we really need this?
if ( !isset( $info['old_id'] ) )
@@ -1658,9 +1658,9 @@ class Core extends Library
* Convert an Edit History Log
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Edit History, or FALSE on failure.
* @return bool|int The ID of the newly inserted Edit History, or FALSE on failure.
*/
public function convertEditHistory( $info=array() )
public function convertEditHistory( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -1668,7 +1668,7 @@ class Core extends Library
return FALSE;
}
if ( !isset( $info['class'] ) OR !in_array( $info['class'], \IPS\Content::routedClasses() ) )
if ( !isset( $info['class'] ) OR !in_array( $info['class'], Content::routedClasses() ) )
{
$this->software->app->log( 'edit_history_missing_class', __METHOD__, App::LOG_WARNING, $info['id'] );
return FALSE;
@@ -1752,7 +1752,7 @@ class Core extends Library
if ( isset( $info['public'] ) )
{
$info['public'] = (boolean) $info['public'];
$info['public'] = (bool) $info['public'];
}
else
{
@@ -1777,15 +1777,15 @@ class Core extends Library
*
* @param array $info Data to insert
* @param NULL|array $set Set to store this emoticon in.
* @param boolean $keepExisting If TRUE, then if an emoticon code already exists in our database, we'll keep that one. FALSE means overwrite it.
* @param bool $keepExisting If TRUE, then if an emoticon code already exists in our database, we'll keep that one. FALSE means overwrite it.
* @param NULL|string $filepath Path to files, or NULL if loading from the database.
* @param NULL|string $filedata If loading from the database, the content of the Binary column.
* @param NULL|string $filepathx2 Path to the x2 size emoticon, or NULL if it doesn't exist.
* @param NULL|string $filedatax2 File Data for the x2 size emoticon, or NULL if it doesn't exist.
* @return boolean|integer The ID of the newly inserted emoticon, or FALSE on failure.
* @return bool|int The ID of the newly inserted emoticon, or FALSE on failure.
* @todo Handle emoticons without a defined set.
*/
public function convertEmoticon( $info=array(), $set=NULL, $keepExisting=TRUE, $filepath=NULL, $filedata=NULL, $filepathx2=NULL, $filedatax2=NULL )
public function convertEmoticon( array $info=array(), ?array $set=NULL, bool $keepExisting=TRUE, ?string $filepath=NULL, ?string $filedata=NULL, ?string $filepathx2=NULL, ?string $filedatax2=NULL ) : bool|int
{
/* We don't really need an ID for these */
$haveID = TRUE;
@@ -1858,7 +1858,7 @@ class Core extends Library
$info['emo_set'] = $set['set'];
$info['emo_set_position'] = $set['position'];
if ( Member::loggedIn()->language()->checkKeyExists( "core_emoticon_group_{$info['emo_set']}" ) == FALSE )
if ( !Member::loggedIn()->language()->checkKeyExists( "core_emoticon_group_{$info['emo_set']}" ) )
{
Lang::saveCustom( 'core', "core_emoticon_group_{$info['emo_set']}", $set['title'] );
}
@@ -1904,11 +1904,7 @@ class Core extends Library
$filex2 = File::create( 'core_Emoticons', $info['filenamex2'], $filedatax2, 'emoticons', FALSE, NULL, static::$obscureFilenames );
$info['image_2x'] = (string) $filex2;
}
catch( \Exception $e )
{
$info['image_2x'] = NULL;
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['image_2x'] = NULL;
}
@@ -1935,10 +1931,10 @@ class Core extends Library
* Convert Follow Data
*
* @param array $info Data to insert
* @return boolean Unlike other methods, we do not need to return an ID for the converted follow - so simply return TRUE on success, or FALSE on failure.
* @return bool Unlike other methods, we do not need to return an ID for the converted follow - so simply return TRUE on success, or FALSE on failure.
* @note This method should not have an individual step, but rather be called during others (ex. when converting topics, insert any follows at that point)
*/
public function convertFollow( $info=array() )
public function convertFollow( array $info=array() ) : bool
{
if ( !isset( $info['follow_app'] ) )
{
@@ -2057,7 +2053,7 @@ class Core extends Library
/**
* @brief Bitwise are protected in \IPS\Member\Group, so copying here.
*/
protected static $groupBitOptions = array(
protected static array $groupBitOptions = array(
'gbw_mod_post_unit_type' => 1, // Lift moderation after x. 1 is days, 0 is posts. Corresponds to g_mod_post_unit
'gbw_ppd_unit_type' => 2, // Lift post-per-day limit after x. 1 is days, 0 is posts. Corresponds to g_ppd_unit
'gbw_displayname_unit_type' => 4, // Username change restrictions. 1 is days, 0 is posts. Corresponds to g_displayname_unit
@@ -2095,13 +2091,13 @@ class Core extends Library
* Convert a Member Group
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith THe ID of the group to merge this one into, or NULL to create new.
* @param int|NULL $mergeWith THe ID of the group to merge this one into, or NULL to create new.
* @param string|NULL $iconpath Path to Icon file for the group, or NULL.
* @param string|NULL $icondata Binary Icon Data, or NULL.
* @return boolean|integer The ID of the newly inserted group, or FALSE on failure.
* @return bool|int The ID of the newly inserted group, or FALSE on failure.
* @note Other libraries will handle their own settings
*/
public function convertGroup( $info=array(), $mergeWith=NULL, $iconpath=NULL, $icondata=NULL )
public function convertGroup( array $info=array(), ?int $mergeWith=NULL, ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
if ( !isset( $info['g_id'] ) )
{
@@ -2140,11 +2136,7 @@ class Core extends Library
$file = File::create( 'core_Theme', $info['g_icon'], $icondata );
$info['g_icon'] = (string) $file;
}
catch( \Exception $e )
{
$info['g_icon'] = NULL;
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['g_icon'] = NULL;
}
@@ -2209,7 +2201,7 @@ class Core extends Library
continue;
}
if ( isset( $info['g_bitoptions'][$key] ) AND $info['g_bitoptions'][$key] == TRUE )
if ( isset( $info['g_bitoptions'][$key] ) AND $info['g_bitoptions'][$key] )
{
$bitoptions += $value;
}
@@ -2256,10 +2248,6 @@ class Core extends Library
$info[$otherDefault] = '';
break;
case 'g_max_mass_pm':
$info[$otherDefault] = 10;
break;
case 'g_search_flood':
$info[$otherDefault] = 3;
break;
@@ -2270,6 +2258,7 @@ class Core extends Library
case 'g_rep_max_positive':
case 'g_rep_max_negative':
case 'g_max_mass_pm':
$info[$otherDefault] = 10;
break;
}
@@ -2338,15 +2327,15 @@ class Core extends Library
/**
* @brief Store group promotion values temporarily to convert after groups are done
*/
public $groupPromotions = array();
public array $groupPromotions = array();
/**
* Convert a group promotion rule
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted promotion rule, or FALSE on error.
* @return bool|int The ID of the newly inserted promotion rule, or FALSE on error.
*/
public function convertGroupPromotion( $info=array() )
public function convertGroupPromotion( array $info=array() ) : bool|int
{
if ( !isset( $info['newgroup'] ) OR !isset( $info['oldgroup'] ) )
{
@@ -2415,9 +2404,9 @@ class Core extends Library
* Convert an Ignored User
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Ignore, or FALSE on error.
* @return bool|int The ID of the newly inserted Ignore, or FALSE on error.
*/
public function convertIgnoredUser( $info=array() )
public function convertIgnoredUser( array $info=array() ) : bool|int
{
if ( !isset( $info['ignore_id'] ) )
{
@@ -2480,9 +2469,9 @@ class Core extends Library
* Convert a Staff Directory Entry
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Leader, or FALSE on failure.
* @return bool|int The ID of the newly inserted Leader, or FALSE on failure.
*/
public function convertLeader( $info=array() )
public function convertLeader( array $info=array() ) : bool|int
{
if ( !isset( $info['leader_id'] ) )
{
@@ -2548,7 +2537,7 @@ class Core extends Library
$info['leader_group_id'] = $this->software->app->getLink( $info['leader_group_id'], 'core_leader_groups' );
}
catch( LogicException $e ) /* LogicException here so as to accommodate for catching both OutOfRangeException and DomainException - we don't care which was thrown */
catch( LogicException $e ) /* LogicException here to accommodate for catching both OutOfRangeException and DomainException - we don't care which was thrown */
{
try
{
@@ -2585,9 +2574,9 @@ class Core extends Library
* Convert a Staff Directory Group
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Staff Directory Group, or FALSE on failure.
* @return bool|int The ID of the newly inserted Staff Directory Group, or FALSE on failure.
*/
public function convertLeaderGroup( $info=array() )
public function convertLeaderGroup( array $info=array() ) : bool|int
{
if ( !isset( $info['group_id'] ) )
{
@@ -2630,9 +2619,9 @@ class Core extends Library
* @param array $info Data to insert
* @param string|NULL $iconpath Icon File Path, or NULL
* @param string|NULL $icondata Icon File Data, or NULL
* @return boolean|integer The ID of the newly inserted Rank, or FALSE on failure.
* @return bool|int The ID of the newly inserted Rank, or FALSE on failure.
*/
public function convertRank( $info=array(), $iconpath=NULL, $icondata=NULL )
public function convertRank( array $info=array(), ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
$this->software->app->log( 'method_deprecated', __METHOD__, App::LOG_WARNING );
return FALSE;
@@ -2641,7 +2630,7 @@ class Core extends Library
/**
* @brief Cache login handlers
*/
protected static $_loginMethods = NULL;
protected static ?array $_loginMethods = NULL;
/**
* Convert a Member
@@ -2654,10 +2643,10 @@ class Core extends Library
* @param NULL|string $coverPhotoName Filename for the users Cover Photo or NULL if none set.
* @param NULL|string $coverPhotoPath Path to Cover Photos, or NULL to load from the database.
* @param NULL|string $coverFileData If loading from the database, the filedatafor the cover photo from the Binary column.
* @return boolean|integer The ID of the newly inserted member, or FALSE on failure.
* @return bool|int The ID of the newly inserted member, or FALSE on failure.
* @todo Work out if we can convert Social Login Stuff.
*/
public function convertMember( $info=array(), $profileFields=array(), $profilePhotoName=NULL, $profilePhotoPath=NULL, $profileFileData=NULL, $coverPhotoName=NULL, $coverPhotoPath=NULL, $coverFileData=NULL )
public function convertMember( array $info=array(), array $profileFields=array(), ?string $profilePhotoName=NULL, ?string $profilePhotoPath=NULL, ?string $profileFileData=NULL, ?string $coverPhotoName=NULL, ?string $coverPhotoPath=NULL, ?string $coverFileData=NULL ) : bool|int
{
if ( !isset( $info['member_id'] ) )
{
@@ -3078,7 +3067,7 @@ class Core extends Library
{
foreach( Member::$bitOptions['members_bitoptions']['members_bitoptions'] AS $key => $value )
{
if ( isset( $info['members_bitoptions'][$key] ) AND $info['members_bitoptions'][$key] == TRUE )
if ( isset( $info['members_bitoptions'][$key] ) AND $info['members_bitoptions'][$key] )
{
$bitoptions += $value;
}
@@ -3096,7 +3085,7 @@ class Core extends Library
{
foreach( Member::$bitOptions['members_bitoptions']['members_bitoptions2'] AS $key => $value )
{
if ( isset( $info['members_bitoptions2'][$key] ) AND $info['members_bitoptions2'] == TRUE )
if ( isset( $info['members_bitoptions2'][$key] ) AND $info['members_bitoptions2'] )
{
$bitoptions2 += $value;
}
@@ -3214,7 +3203,7 @@ class Core extends Library
$cover = File::create( 'core_Profile', $coverPhotoName, $coverFileData );
$info['pp_cover_photo'] = (string) $cover;
/* Designs are different so this will never likely be correct, we'll try it if one is supplied though */
$info['pp_cover_offset'] = isset( $info['pp_cover_offset'] ) ? $info['pp_cover_offset'] : 0;
$info['pp_cover_offset'] = $info['pp_cover_offset'] ?? 0;
}
catch( ErrorException | \Exception $e )
{
@@ -3270,7 +3259,7 @@ class Core extends Library
if ( isset( $info['allow_admin_mails'] ) )
{
$info['allow_admin_mails'] = (boolean) $info['allow_admin_mails'];
$info['allow_admin_mails'] = (bool) $info['allow_admin_mails'];
}
else
{
@@ -3354,9 +3343,9 @@ class Core extends Library
* Convert member history
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted member history record, or FALSE on failure
* @return bool|int The ID of the newly inserted member history record, or FALSE on failure
*/
public function convertMemberHistory( $info=array() )
public function convertMemberHistory( array $info=array() ) : bool|int
{
if ( !isset( $info['log_id'] ) )
{
@@ -3492,9 +3481,9 @@ class Core extends Library
* Convert a Warning Action
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning action, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning action, or FALSE on failure.
*/
public function convertWarnAction( $info=array() )
public function convertWarnAction( array $info=array() ) : bool|int
{
/* We do not really need an ID here */
$hasId = TRUE;
@@ -3564,10 +3553,10 @@ class Core extends Library
* Convert a Warning Log
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning log, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning log, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertWarnLog( $info=array() )
public function convertWarnLog( array $info=array() ) : bool|int
{
if ( !isset( $info['wl_id'] ) )
{
@@ -3745,9 +3734,9 @@ class Core extends Library
* Convert a Warning Reason
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning reason, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning reason, or FALSE on failure.
*/
public function convertWarnReason( $info=array() )
public function convertWarnReason( array $info=array() ) : bool|int
{
if ( !isset( $info['wr_id'] ) )
{
@@ -3811,9 +3800,9 @@ class Core extends Library
*
* @param array $topic The Message Topic Data to insert
* @param array $maps The User Map Data to insert. Example: array( memberId => array( data ) )
* @return boolean|integer The ID of the newly inserted Message Topic, or FALSE on failure.
* @return bool|int The ID of the newly inserted Message Topic, or FALSE on failure.
*/
public function convertPrivateMessage( $topic=array(), $maps=array() )
public function convertPrivateMessage( array $topic=array(), array $maps=array() ) : bool|int
{
if ( !isset( $topic['mt_id'] ) )
{
@@ -3949,7 +3938,7 @@ class Core extends Library
/* We already know this */
$map['map_topic_id'] = $topicInsertedId;
if ( !isset( $map['map_folder_id'] ) OR ( isset( $map['map_folder_id'] ) AND empty( $map['map_folder_id'] ) ) )
if ( !isset( $map['map_folder_id'] ) OR empty( $map['map_folder_id'] ) )
{
$map['map_folder_id'] = 'myconvo';
}
@@ -4079,7 +4068,7 @@ class Core extends Library
* @param array $info Data to insert
* @return bool|int The ID of the newly inserted reply, or FALSE on failure.
*/
public function convertPrivateMessageReply( $info=array() )
public function convertPrivateMessageReply( array $info=array() ) : bool|int
{
if ( !isset( $info['msg_id'] ) )
{
@@ -4155,9 +4144,9 @@ class Core extends Library
* Convert a Moderator
*
* @param array $info Data to insert
* @return boolean TRUE on success, or FALSE on failure.
* @return bool TRUE on success, or FALSE on failure.
*/
public function convertModerator( $info=array() )
public function convertModerator( array $info=array() ) : bool
{
if ( !isset( $info['type'] ) OR !in_array( $info['type'], array( 'g', 'm' ) ) )
{
@@ -4224,10 +4213,10 @@ class Core extends Library
* Convert Permissions
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted permission row, or FALSE on failure.
* @return bool|int The ID of the newly inserted permission row, or FALSE on failure.
* @note These should be converted when the relevant node is converted.
*/
public function convertPermission( $info=array() )
public function convertPermission( array $info=array() ) : bool|int
{
/* Valid app? */
if ( !isset( $info['app'] ) )
@@ -4240,7 +4229,7 @@ class Core extends Library
{
$application = Application::load( $info['app'] );
if ( Application::appIsEanbled( $info['app'] ) === FALSE )
if ( Application::appIsEnabled( $info['app'] ) === FALSE )
{
throw new UnexpectedValueException;
}
@@ -4392,7 +4381,7 @@ class Core extends Library
continue;
}
if ( !in_array( $currentGroups ) )
if ( !in_array( $group, $currentGroups ) )
{
$groupsToAdd[] = $group;
}
@@ -4418,10 +4407,10 @@ class Core extends Library
* Convert a Profile Field Group
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith The group we are merging with, or NULL to not merge.
* @return boolean|integer The ID of the newly inserted profile field group, or FALSE on failure
* @param int|NULL $mergeWith The group we are merging with, or NULL to not merge.
* @return bool|int The ID of the newly inserted profile field group, or FALSE on failure
*/
public function convertProfileFieldGroup( $info=array(), $mergeWith=NULL )
public function convertProfileFieldGroup( array $info=array(), ?int $mergeWith=NULL ) : bool|int
{
if ( !isset( $info['pf_group_id'] ) )
{
@@ -4467,11 +4456,11 @@ class Core extends Library
* Convert a Profile Field
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith THe ID of an existing profile field to merge this one with, or NULL to create new.
* @return boolean|integer The ID of the newly inserted profile field, or FALSE on failure.
* @param int|NULL $mergeWith THe ID of an existing profile field to merge this one with, or NULL to create new.
* @return bool|int The ID of the newly inserted profile field, or FALSE on failure.
* @note Profile Field Content for individual members needs to be done during the members step, not here.
*/
public function convertProfileField( $info=array(), $mergeWith=NULL )
public function convertProfileField( array $info=array(), ?int $mergeWith=NULL ) : bool|int
{
/* Get valid fields while taking hooks into account */
$validFields = array_merge( static::$fieldTypes, Field::$additionalFieldTypes );
@@ -4657,7 +4646,7 @@ class Core extends Library
/**
* @brief All local custom fields
*/
protected $cachedFields = NULL;
protected ?array $cachedFields = NULL;
/**
* Get profile fields using cache
@@ -4666,13 +4655,11 @@ class Core extends Library
* @return array
* @throws UnderflowException
*/
protected function _getField( $fieldId )
protected function _getField( int $fieldId ) : array
{
if( $this->cachedFields === NULL )
{
$fields = iterator_to_array( Db::i()->select( '*', 'core_pfields_data' )->setKeyField('pf_id') );
$this->cachedFields = ( is_array( $fields ) ) ? $fields : array();
$this->cachedFields = iterator_to_array( Db::i()->select( '*', 'core_pfields_data' )->setKeyField('pf_id') );
}
if( !isset( $this->cachedFields[ $fieldId ] ) )
@@ -4686,7 +4673,7 @@ class Core extends Library
/**
* @brief Store of field IDs to skip formatting
*/
protected $_skipFields = [];
protected array $_skipFields = [];
/**
* Format Member Profile Field Content
@@ -4695,7 +4682,7 @@ class Core extends Library
* @param array $fieldInfo The Profile Field Information to format. This SHOULD be in $foreign_id => $content format, however field_$foreign_id => $content is also accepted.
* @return array An array of data formatted for core_pfields_content
*/
protected function _formatMemberProfileFieldContent( $member_id, $fieldInfo )
protected function _formatMemberProfileFieldContent( int $member_id, array $fieldInfo ) : array
{
$return = array( 'member_id' => $member_id );
@@ -4774,10 +4761,10 @@ class Core extends Library
*
* @param array $info Data to insert
* @param array $votes Vote Data
* @return boolean|integer The ID of the newly inserted Poll, or false on failure.
* @return bool|int The ID of the newly inserted Poll, or false on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertPoll( $info=array(), $votes=array() )
public function convertPoll( array $info=array(), array $votes=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -4973,9 +4960,9 @@ class Core extends Library
* Convert a Profanity Filter
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted profanity filter, or FALSE on failure.
* @return bool|int The ID of the newly inserted profanity filter, or FALSE on failure.
*/
public function convertProfanityFilter( $info=array() )
public function convertProfanityFilter( array $info=array() ) : bool|int
{
if ( !isset( $info['wid'] ) )
{
@@ -5016,11 +5003,11 @@ class Core extends Library
/**
* Convert Question and Answer Spam Prevention
*
* @param string $info Data to insert
* @param array $info Data to insert
* @param array $answers The answers
* @return boolean|integer The ID of the newly insert Q&A, or FALSE on failure.
* @return bool|int The ID of the newly insert Q&A, or FALSE on failure.
*/
public function convertQuestionAndAnswer( $info, $answers=array() )
public function convertQuestionAndAnswer( array $info, array $answers=array() ) : bool|int
{
$haveId = TRUE;
if ( !isset( $info['qa_id'] ) )
@@ -5067,10 +5054,10 @@ class Core extends Library
* Convert a Rating
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted rating, or FALSE on failure.
* @return bool|int The ID of the newly inserted rating, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertRating( $info=array() )
public function convertRating( array $info=array() ) : bool|int
{
$haveId = TRUE;
if ( !isset( $info['id'] ) )
@@ -5158,10 +5145,10 @@ class Core extends Library
* Convert a Report Index
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted report index, or FALSE on failure.
* @return bool|int The ID of the newly inserted report index, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertReportIndex( $info=array() )
public function convertReportIndex( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5169,7 +5156,7 @@ class Core extends Library
return FALSE;
}
$contentClasses = \IPS\Content::routedClasses();
$contentClasses = Content::routedClasses();
if ( !isset( $info['class'] ) OR !in_array( $info['class'], $contentClasses ) )
{
$this->software->app->log( 'report_index_invalid_class', __METHOD__, App::LOG_WARNING, $info['id'] );
@@ -5276,10 +5263,10 @@ class Core extends Library
* @param array $info Data to insert
* @param NULL|string $filePath Path to files, or NULL if loading from the database.
* @param NULL|string $fileData If loading from the database, the content of the Binary column.
* @param integer|NULL $mergeWith The ID of the group to merge this one into, or NULL to create new.
* @param int|NULL $mergeWith The ID of the group to merge this one into, or NULL to create new.
* @return bool|int ID of new record on success, FALSE on failure
*/
public function convertReaction( $info=array(), $filePath=NULL, $fileData=NULL, int $mergeWith=NULL )
public function convertReaction( array $info=array(), ?string $filePath=NULL, ?string $fileData=NULL, ?int $mergeWith=NULL ) : bool|int
{
if ( !isset( $info['reaction_id'] ) )
{
@@ -5345,7 +5332,7 @@ class Core extends Library
try
{
$file = File::create( 'core_Reaction', $info['filename'], $fileData, 'reactions', FALSE, NULL );
$file = File::create( 'core_Reaction', $info['filename'], $fileData, 'reactions' );
unset( $info['filename'] );
$info['reaction_icon'] = (string) $file;
$file->getImageDimensions();
@@ -5380,10 +5367,10 @@ class Core extends Library
* Convert a Report
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted report, or FALSE on failure.
* @return bool|int The ID of the newly inserted report, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertReport( $info=array() )
public function convertReport( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5461,10 +5448,10 @@ class Core extends Library
* Convert a Report Comment
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted comment, or FALSE on failure.
* @return bool|int The ID of the newly inserted comment, or FALSE on failure.
* @note UNLIKE report indexes, this can be done separately.
*/
public function convertReportComment( $info=array() )
public function convertReportComment( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5559,10 +5546,10 @@ class Core extends Library
* Convert Reputation
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted reputation, or FALSE on failure.
* @return bool|int The ID of the newly inserted reputation, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached to is being converted.
*/
public function convertReputation( $info=array() )
public function convertReputation( array $info=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -5610,7 +5597,7 @@ class Core extends Library
{
try
{
/* Try to lookup a reaction ID link */
/* Try to lookup reaction ID link */
try
{
$info['reaction'] = $this->software->app->getLink( $info['reaction'], 'core_reactions' );
@@ -5777,9 +5764,9 @@ class Core extends Library
* @param array $info Data to insert
* @param string|NULL $badgepath Path to Reputation Badge file.
* @param string|NULL $badgedata Binary data for Reputation Badge file.
* @return boolean|integer The ID of the newly inserted reputation level, or FALSE on failure.
* @return bool|int The ID of the newly inserted reputation level, or FALSE on failure.
*/
public function convertReputationLevel( $info=array(), $badgepath=NULL, $badgedata=NULL )
public function convertReputationLevel( array $info=array(), ?string $badgepath=NULL, ?string $badgedata=NULL ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -5815,11 +5802,7 @@ class Core extends Library
$file = File::create( 'core_Theme', $info['level_image'], $badgedata );
$info['level_image'] = (string) $file;
}
catch( \Exception $e )
{
$info['level_image'] = '';
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['level_image'] = '';
}
@@ -5851,11 +5834,11 @@ class Core extends Library
* Convert an RSS Import Feed
*
* @param array $info Data to insert
* @param array $containerType Container Link Type
* @param string $containerType Container Link Type
* @param string $newLinkType Link type to use
* @return integer|boolean The ID of the newly inserted import feed, or FALSE on failure.
* @return int|bool The ID of the newly inserted import feed, or FALSE on failure.
*/
public function convertRssImport( $info, $containerType='forums_forums', $newLinkType='core_rss_import' )
public function convertRssImport( array $info, string $containerType='forums_forums', string $newLinkType='core_rss_import' ) : bool|int
{
if ( !isset( $info['rss_import_id'] ) )
{
@@ -5975,10 +5958,10 @@ class Core extends Library
*
* @param array $info Data to insert
* @param string $type Link type for RSS Feed
* @param mixed $contentType Content Link Type
* @return boolean TRUE on success, or FALSE on failure.
* @param string $contentType Content Link Type
* @return bool TRUE on success, or FALSE on failure.
*/
public function convertRssImported( $info=array(), $type='core_rss_import', $contentType='' )
public function convertRssImported( array $info=array(), string $type='core_rss_import', string $contentType='' ) : bool
{
/* Godspeed */
if ( isset( $info['rss_imported_import_id'] ) )
@@ -6031,9 +6014,9 @@ class Core extends Library
* Convert a Setting
*
* @param array $settings Settings to convert
* @return boolean|array An array of settings changed, or FALSE on failure.
* @return bool|array An array of settings changed, or FALSE on failure.
*/
public function convertSettings( $settings=array() )
public function convertSettings( array $settings=array() ) : bool|array
{
if ( !count( $settings ) )
{
@@ -6054,17 +6037,17 @@ class Core extends Library
/**
* @brief Store valid content class set by child converters, if contentrouter verification cannot be relied upon.
*/
protected $_ipsTagContentClass = NULL;
protected ?string $_ipsTagContentClass = NULL;
/**
* Convert a Tag
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted tag, or FALSE on failure.
* @return bool|int The ID of the newly inserted tag, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
* @note core_tags_cache and core_tags_perms need to be populated by the converter.
*/
public function convertTag( $info=array() )
public function convertTag( array $info=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -6229,9 +6212,9 @@ class Core extends Library
* @param string|NULL $icondata Binary data for the icon file
* @param string|NULL $coverfile Path to the club cover photo file
* @param string|NULL $coverdata Binary data for the icon file
* @return boolean|integer The ID of the newly inserted club, or FALSE on failure.
* @return bool|int The ID of the newly inserted club, or FALSE on failure.
*/
public function convertClub( $info=array(), $iconfile=NULL, $icondata=NULL, $coverfile=NULL, $coverdata=NULL )
public function convertClub( array $info=array(), ?string $iconfile=NULL, ?string $icondata=NULL, ?string $coverfile=NULL, ?string $coverdata=NULL ) : bool|int
{
if ( !isset( $info['club_id'] ) )
{
@@ -6352,7 +6335,7 @@ class Core extends Library
if ( isset( $info['last_activity'] ) )
{
if ( $info['last_activity'] instanceof Time )
if ( $info['last_activity'] instanceof DateTime )
{
$info['last_activity'] = $info['last_activity']->getTimestamp();
}
@@ -6383,9 +6366,9 @@ class Core extends Library
* Convert a Club Member
*
* @param array $info The data to insert
* @return boolean|string The unique ID of the newly inserted club member, or FALSE on failure.
* @return bool|int The unique ID of the newly inserted club member, or FALSE on failure.
*/
public function convertClubMember( $info=array() )
public function convertClubMember( array $info=array() ) : bool|int
{
if ( !isset( $info['club_id'] ) OR !isset( $info['member_id'] ) )
{
@@ -6475,9 +6458,9 @@ class Core extends Library
* Convert a Club Member
*
* @param array $info The data to insert
* @return boolean|string The unique ID of the newly inserted club member, or FALSE on failure.
* @return bool|int The unique ID of the newly inserted club member, or FALSE on failure.
*/
public function convertClubPage( array $info=array() )
public function convertClubPage( array $info=array() ) : bool|int
{
if ( !isset( $info['page_id'] ) OR !isset( $info['page_club'] ) )
{
@@ -6512,7 +6495,7 @@ class Core extends Library
if( is_array( $info['page_can_view'] ) )
{
$info['page_can_view'] = implode( ',', array_filter( $info['page_can_view'], function( $value ) {
return (bool) in_array( $value, array( 'nonmember', 'member', 'moderator' ) );
return in_array( $value, array( 'nonmember', 'member', 'moderator' ) );
} ) );
}
}
@@ -17,6 +17,7 @@ use ErrorException;
use Exception;
use IPS\Application;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\downloads\Category;
@@ -48,7 +49,7 @@ class Downloads extends Core
/**
* @brief Application
*/
public $app = 'downloads';
public string $app = 'downloads';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -56,7 +57,7 @@ class Downloads extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -244,11 +245,12 @@ class Downloads extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -299,15 +301,15 @@ class Downloads extends Core
break;
case 'convertClubDownloadsFiles':
$return['convertClubDownloadsFiles'] = array( 'downloads_files' => array( 'file_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_files' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubDownloadsFiles'] = array( 'downloads_files' => array( 'file_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_files' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubDownloadsComments':
$return['convertClubDownloadsComments'] = array( 'downloads_comments' => array( 'comment_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubDownloadsComments'] = array( 'downloads_comments' => array( 'comment_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubDownloadsReviews':
$return['convertClubDownloadsFiles'] = array( 'downloads_reviews' => array( 'review_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_reviews' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubDownloadsFiles'] = array( 'downloads_reviews' => array( 'review_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_reviews' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -323,9 +325,9 @@ class Downloads extends Core
/**
* A note on logging -
* If the data is missing and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing and it is required to convert the item, we should log a WARNING and return FALSE.
* If the data is missing, and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing, and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing, and it is required to convert the item, we should log a WARNING and return FALSE.
* If the conversion absolutely cannot proceed at all (filestorage locations not writable, for example), then we should log an ERROR and throw an \IPS\convert\Exception to completely halt the process and redirect to an error screen showing the last logged error.
*/
@@ -333,9 +335,9 @@ class Downloads extends Core
* Convert a Custom Field
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted field, or FALSE on failure.
* @return int|bool The ID of the newly inserted field, or FALSE on failure.
*/
public function convertDownloadsCfield( $info=array() )
public function convertDownloadsCfield( array $info=array() ) : bool|int
{
$validFields = array_merge( static::$fieldTypes, Field::$additionalFieldTypes );
@@ -406,8 +408,8 @@ class Downloads extends Core
}
$id = $info['cf_id'];
$fieldName = isset( $info['cf_name'] ) ? $info['cf_name'] : NULL;
$fieldDescription = isset( $info['cf_desc'] ) ? $info['cf_desc'] : NULL;
$fieldName = $info['cf_name'] ?? NULL;
$fieldDescription = $info['cf_desc'] ?? NULL;
unset( $info['cf_id'], $info['cf_name'], $info['cf_desc'] );
$inserted_id = Db::i()->insert( 'downloads_cfields', $info );
@@ -511,7 +513,7 @@ class Downloads extends Core
* @param array $fieldInfo The Custom Field Information to format. This SHOULD be in $foreign_id => $content format, however field_$foreign_id => $content is also accepted.
* @return array An array of data formatted for downloads_ccontent
*/
protected function _formatCustomFieldContent( $file_id, $fieldInfo )
protected function _formatCustomFieldContent( int $file_id, array $fieldInfo ) : array
{
$return = array( 'file_id' => $file_id );
@@ -549,9 +551,9 @@ class Downloads extends Core
* Convert a category
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted category, or FALSE on failure.
* @return int|bool The ID of the newly inserted category, or FALSE on failure.
*/
public function convertDownloadsCategory( $info=array() )
public function convertDownloadsCategory( array $info=array() ) : bool|int
{
if ( !isset( $info['cid'] ) )
{
@@ -799,9 +801,9 @@ class Downloads extends Core
* @param array $info Data to insert
* @param array $records Record Data to insert
* @param array $customFields Custom Field Data to insert
* @return integer|boolean The ID of the newly inserted file, or FALSE on failure.
* @return int|bool The ID of the newly inserted file, or FALSE on failure.
*/
public function convertDownloadsFile( $info=array(), $records=array(), $customFields=array() )
public function convertDownloadsFile( array $info=array(), array $records=array(), array $customFields=array() ) : bool|int
{
if ( !isset( $info['file_id'] ) )
{
@@ -1098,7 +1100,7 @@ class Downloads extends Core
if ( !isset( $record['record_realname'] ) )
{
if ( isset( $record['file_path'] ) AND !is_null( $record['file_path'] ) )
if ( isset( $record['file_path'] ) AND !empty( $record['file_path'] ) )
{
$fileName = explode( '/', $record['file_path'] );
$fileName = array_pop( $fileName );
@@ -1194,9 +1196,9 @@ class Downloads extends Core
/**
* Get Orphaned Files Category
*
* @return integer The Category ID.
* @return int The Category ID.
*/
protected function _orphanedFilesCategory()
protected function _orphanedFilesCategory() : int
{
try
{
@@ -1215,9 +1217,9 @@ class Downloads extends Core
* Convert a comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertDownloadsComment( $info=array() )
public function convertDownloadsComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -1331,9 +1333,9 @@ class Downloads extends Core
* Convert a review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted review, or FALSE on failure.
* @return int|bool The ID of the newly inserted review, or FALSE on failure.
*/
public function convertDownloadsReview( $info=array() )
public function convertDownloadsReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -1528,9 +1530,9 @@ class Downloads extends Core
* @param string|NULL $filepath Path to the file, or NULL.
* @param string|NULL $filedata Binary data for the file, or NULL.
* @param string|NULL $thumbnailpath Path to thumbnail, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
* @return int|bool The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath = NULL ) : bool|int
{
$map['location_key'] = 'downloads_Downloads';
$map['id1_type'] = 'downloads_files';
@@ -1558,9 +1560,9 @@ class Downloads extends Core
* Convert a Club Downloads Category
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted category, or FALSE on failure.
* @return int|bool The ID of the newly inserted category, or FALSE on failure.
*/
public function convertClubDownloadsCategory( $info=array() )
public function convertClubDownloadsCategory( array $info=array() ) : bool|int
{
$insertedId = $this->convertDownloadsCategory( $info );
if ( $insertedId )
@@ -1575,9 +1577,9 @@ class Downloads extends Core
*
* @param array $info Data to insert
* @param array $records File Records
* @return integer|boolean The ID of the newly inserted file, or FALSE on failure.
* @return int|bool The ID of the newly inserted file, or FALSE on failure.
*/
public function convertClubDownloadsFile( $info=array(), $records=array() )
public function convertClubDownloadsFile( array $info=array(), array $records=array() ) : bool|int
{
$insertedId = $this->convertDownloadsFile( $info, $records );
if ( $insertedId )
@@ -1591,9 +1593,9 @@ class Downloads extends Core
* Convert a Club Downloads Comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertClubDownloadsComment( $info=array() )
public function convertClubDownloadsComment( array $info=array() ) : bool|int
{
$insertedId = $this->convertDownloadsComment( $info );
if ( $insertedId )
@@ -1607,9 +1609,9 @@ class Downloads extends Core
* Convert a Club Downloads Review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertClubDownloadsReview( $info=array() )
public function convertClubDownloadsReview( array $info=array() ) : bool|int
{
$insertedId = $this->convertDownloadsReview( $info );
if ( $insertedId )
+44 -46
View File
@@ -16,6 +16,7 @@ namespace IPS\convert\Library;
use ErrorException;
use IPS\convert\App;
use IPS\convert\Exception;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -50,7 +51,7 @@ class Forums extends Core
/**
* @brief Application
*/
public $app = 'forums';
public string $app = 'forums';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -58,7 +59,7 @@ class Forums extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$classname = get_class( $this->software );
@@ -145,7 +146,7 @@ class Forums extends Core
$return[ $k ] = array(
'step_title' => 'convert_forums_rss_imported',
'step_method' => 'convertForumsRssImported',
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . (string) Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first(),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first(),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics', 'convertForumsRssImports' ),
@@ -205,7 +206,7 @@ class Forums extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_topics',
'step_method' => 'convertClubTopics',
'ips_rows' => Db::i()->select( 'COUNT(tid)', 'forums_topics', array( 'forum_id IN ( ' . (string) Db::i()->select( 'id', 'forums_forums', array( "club_id IS NOT NULL" ) ) . ')' ) ),
'ips_rows' => Db::i()->select( 'COUNT(tid)', 'forums_topics', array( 'forum_id IN ( ' . Db::i()->select( 'id', 'forums_forums', array( "club_id IS NOT NULL" ) ) . ')' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubForums' ),
@@ -254,7 +255,7 @@ class Forums extends Core
* @param bool $rowCount Count local rows
* @return array
*/
public function getMethodFromMenuRows( $method, $rowCount=FALSE )
public function getMethodFromMenuRows( string $method, bool $rowCount=FALSE ) : array
{
if( $method == 'convertForumsBoards' )
{
@@ -270,11 +271,12 @@ class Forums extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -327,11 +329,11 @@ class Forums extends Core
break;
case 'convertForumsRssImported':
$retun['convertForumsRssImported'] = array( 'forums_rss_imported' => NULL );
$return['convertForumsRssImported'] = array( 'forums_rss_imported' => NULL );
break;
case 'convertForumsQuestionRatings':
$retun['convertForumsQuestionRatings'] = array( 'forums_question_ratings' => NULL );
$return['convertForumsQuestionRatings'] = array( 'forums_question_ratings' => NULL );
break;
case 'convertForumsAnswerRatings':
@@ -352,11 +354,11 @@ class Forums extends Core
break;
case 'convertClubTopics':
$return['convertClubTopics'] = array( 'forums_topics' => array( 'tid IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_topics' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubTopics'] = array( 'forums_topics' => array( 'tid IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_topics' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubPosts':
$return['convertClubPosts'] = array( 'forums_posts' => array( 'pid IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_posts' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubPosts'] = array( 'forums_posts' => array( 'pid IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_posts' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -384,9 +386,9 @@ class Forums extends Core
* @param array|NULL $perms Permissions or NULL to insert no permissions.
* @param string|NULL $iconpath The path to the forums icon, or NULL.
* @param string|NULL $icondata The binary data for the forums icon, or NULL.
* @return integer|boolean The ID of the newly inserted forum, or FALSE on failure.
* @return int|bool The ID of the newly inserted forum, or FALSE on failure.
*/
public function convertForumsForum( $info=array(), $perms=NULL, $iconpath=NULL, $icondata=NULL )
public function convertForumsForum( array $info=array(), ?array $perms=NULL, ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -810,15 +812,11 @@ class Forums extends Core
$info['icon'] = NULL;
}
}
catch( \Exception $e )
catch( \Exception|ErrorException $e )
{
$info['icon'] = NULL;
}
catch( ErrorException $e )
{
$info['icon'] = NULL;
}
if ( isset( $info['club_id'] ) )
{
try
@@ -881,9 +879,9 @@ class Forums extends Core
/**
* Get Parent Forum ID for Orphaned Forums
*
* @return integer The ID of the forum created for forums that do not have a parent forum.
* @return int The ID of the forum created for forums that do not have a parent forum.
*/
protected function _getOrphanedForumCategory()
protected function _getOrphanedForumCategory() : int
{
try
{
@@ -905,9 +903,9 @@ class Forums extends Core
* Convert a topic
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted topic, or FALSE on failure
* @return int|bool The ID of the newly inserted topic, or FALSE on failure
*/
public function convertForumsTopic( $info=array() )
public function convertForumsTopic( array $info=array() ) : bool|int
{
if ( !isset( $info['tid'] ) )
{
@@ -1249,9 +1247,9 @@ class Forums extends Core
* Convert a Forum Post
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted post, or FALSE on failure.
* @return int|bool The ID of the newly inserted post, or FALSE on failure.
*/
public function convertForumsPost( $info=array() )
public function convertForumsPost( array $info=array() ) : bool|int
{
if ( !isset( $info['pid'] ) )
{
@@ -1441,7 +1439,7 @@ class Forums extends Core
$topicUpdate['topic_firstpost'] = $inserted_id;
}
if ( $isBestAnswer == TRUE )
if ( $isBestAnswer )
{
$topicUpdate['topic_answered_pid'] = $inserted_id;
}
@@ -1458,9 +1456,9 @@ class Forums extends Core
* Convert an Archived Post
*
* @param array $info Data to insert
* @param integer|boolean The ID of the newly inserted Archived Post, or FALSE on failure.
* @return int|bool The ID of the newly inserted Archived Post, or FALSE on failure.
*/
public function convertForumsArchivedPost( $info=array() )
public function convertForumsArchivedPost( array $info=array() ) : bool|int
{
/* This works a little differently... we actually need to insert it into the main posts table first, then move it. As such, the $info array should match that of the main posts method EXCEPT for a few keys which we'll extract out. */
if ( isset( $info['archive_added'] ) )
@@ -1478,7 +1476,7 @@ class Forums extends Core
/* If $return is FALSE, stop here. Something went wrong. */
if ( $return === FALSE )
{
return $return;
return false;
}
/* Re-extract the post. We need the topic too. */
@@ -1528,9 +1526,9 @@ class Forums extends Core
* Convert a forums topic multimod
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted Multi Mod, or FALSE on failure.
* @return int|bool The ID of the newly inserted Multi Mod, or FALSE on failure.
*/
public function convertForumsTopicMultimod( $info=array() )
public function convertForumsTopicMultimod( array $info=array() ) : bool|int
{
/* Another instance where we do not necessarily need this, but will store anyway if we have it */
$hasId = TRUE;
@@ -1687,9 +1685,9 @@ class Forums extends Core
* Convert an RSS Import Feed
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted import feed, or FALSE on failure.
* @return int|bool The ID of the newly inserted import feed, or FALSE on failure.
*/
public function convertForumsRssImport( $info=array() )
public function convertForumsRssImport( array $info=array() ) : bool|int
{
$info['rss_import_class'] = 'IPS\\forums\\Topic';
@@ -1713,9 +1711,9 @@ class Forums extends Core
* Convert an RSS Imported Topic... or try to, anyway.
*
* @param array $info Data to insert
* @return boolean TRUE on success, or FALSE on failure.
* @return bool|int TRUE on success, or FALSE on failure.
*/
public function convertForumsRssImported( $info=array() )
public function convertForumsRssImported( array $info=array() ) : bool|int
{
return parent::convertRssImported( $info, 'forums_rss_import', 'forums_topics' );
}
@@ -1724,9 +1722,9 @@ class Forums extends Core
* Convert a question rating
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted rating, or FALSE on failure.
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
*/
public function convertForumsQuestionRating( $info=array() )
public function convertForumsQuestionRating( array $info=array() ) : bool|int
{
/* We do not need to store an ID if one isn't present */
$hasId = TRUE;
@@ -1844,9 +1842,9 @@ class Forums extends Core
* Convert an Answer Rating
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted rating, or FALSE on failure.
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
*/
public function convertForumsAnswerRating( $info=array() )
public function convertForumsAnswerRating( array $info=array() ) : bool|int
{
/* We do not need to store an ID if one is not present */
$hasId = TRUE;
@@ -1968,9 +1966,9 @@ class Forums extends Core
* @param NULL|string $filepath The path to the attachment files or NULL if loading from the database.
* @param NULL|string $filedata If loading from the database, the content of the Binary column.
* @param NULL|string $thumbnailpath Path to thumbnail image
* @return boolean|integer The ID of the newly inserted attachment, or FALSE on failure.
* @return bool|int The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath=NULL ) : bool|int
{
/* The Core Library handles most of this. We just need to make sure forum specific data is set. */
$map['id1_type'] = 'forums_topics';
@@ -1986,9 +1984,9 @@ class Forums extends Core
* Convert a Club Forum
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted forum, or FALSE on failure.
* @return int|bool The ID of the newly inserted forum, or FALSE on failure.
*/
public function convertClubForum( $info=array() )
public function convertClubForum( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsForum( $info );
if ( $insertedId )
@@ -2002,9 +2000,9 @@ class Forums extends Core
* Convert a Club Topic
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted topic, or FALSE on failure.
* @return int|bool The ID of the newly inserted topic, or FALSE on failure.
*/
public function convertClubTopic( $info=array() )
public function convertClubTopic( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsTopic( $info );
if ( $insertedId )
@@ -2018,9 +2016,9 @@ class Forums extends Core
* Convert a Club Post
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted post, or FALSE on failure.
* @return int|bool The ID of the newly inserted post, or FALSE on failure.
*/
public function convertClubPost( $info=array() )
public function convertClubPost( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsPost( $info );
if ( $insertedId )
@@ -16,6 +16,7 @@ namespace IPS\convert\Library;
use ErrorException;
use Exception;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -52,7 +53,7 @@ class Gallery extends Core
/**
* @brief Application
*/
public $app = 'gallery';
public string $app = 'gallery';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -60,7 +61,7 @@ class Gallery extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -277,11 +278,12 @@ class Gallery extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -332,15 +334,15 @@ class Gallery extends Core
break;
case 'convertClubGalleryImages':
$return['convertClubGalleryImages'] = array( 'gallery_images' => array( 'image_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_images' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubGalleryImages'] = array( 'gallery_images' => array( 'image_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_images' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubGalleryComments':
$return['convertClubGalleryComments'] = array( 'gallery_comments' => array( 'comment_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubGalleryComments'] = array( 'gallery_comments' => array( 'comment_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubGalleryReviews':
$return['convertClubGalleryReviews'] = array( 'gallery_reviews' => array( 'review_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_reviews' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubGalleryReviews'] = array( 'gallery_reviews' => array( 'review_id IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_gallery_reviews' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -366,9 +368,9 @@ class Gallery extends Core
* Convert a category
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly converted category, or FALSE on error.
* @return int|bool The ID of the newly converted category, or FALSE on error.
*/
public function convertGalleryCategory( $info=array() )
public function convertGalleryCategory( array $info=array() ) : bool|int
{
if ( !isset( $info['category_id'] ) )
{
@@ -519,10 +521,10 @@ class Gallery extends Core
*
* @param array $info Data to insert
* @param array|NULL $socialgroup Array of social group data, or NULL.
* @param integer|NULL $category If the source software only has albums, and not categories, an existing category ID can be passed here to store converted albums. NULL to auto-create.
* @return integer|boolean The ID of the newly converted album, or FALSE on error.
* @param int|NULL $category If the source software only has albums, and not categories, an existing category ID can be passed here to store converted albums. NULL to auto-create.
* @return int|bool The ID of the newly converted album, or FALSE on error.
*/
public function convertGalleryAlbum( $info=array(), $socialgroup=NULL, $category=NULL )
public function convertGalleryAlbum( array $info=array(), ?array $socialgroup=NULL, ?int $category=NULL ) : bool|int
{
if ( !isset( $info['album_id'] ) )
{
@@ -640,7 +642,7 @@ class Gallery extends Core
}
$info['album_allowed_access'] = NULL;
if ( !is_null( $socialgroup ) AND is_array( $socialgroup ) )
if ( is_array( $socialgroup ) )
{
$socialGroupId = Db::i()->insert( 'core_sys_social_groups', array( 'owner_id' => $info['album_owner_id'] ) );
$members = array();
@@ -678,9 +680,9 @@ class Gallery extends Core
/**
* Orphaned Albums Category
*
* @return integer Orphaned Albums Category ID
* @return int Orphaned Albums Category ID
*/
protected function _orphanedAlbumsCategory()
protected function _orphanedAlbumsCategory() : int
{
try
{
@@ -714,10 +716,10 @@ class Gallery extends Core
*
* @param array $info Data to insert
* @param string|NULL $filepath The path to the image, or NULL.
* @param string|NULL $fileinfo The binary data for the image, or NULL
* @return integer|boolean The ID of the newly inserted image, or FALSE on failure.
* @param string|NULL $filedata The binary data for the image, or NULL
* @return int|bool The ID of the newly inserted image, or FALSE on failure.
*/
public function convertGalleryImage( $info=array(), $filepath=NULL, $filedata=NULL )
public function convertGalleryImage( array $info=array(), ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['image_id'] ) )
{
@@ -759,7 +761,7 @@ class Gallery extends Core
$info['image_album_id'] = 0;
}
if ( isset( $info['image_category_id'] ) AND $categoryFound == FALSE )
if ( isset( $info['image_category_id'] ) AND !$categoryFound )
{
try
{
@@ -772,7 +774,7 @@ class Gallery extends Core
}
else
{
if ( $categoryFound == FALSE )
if ( !$categoryFound )
{
$info['image_category_id'] = $this->_orphanedAlbumsCategory();
}
@@ -918,17 +920,12 @@ class Gallery extends Core
$info['image_file_size'] = $image->filesize();
}
}
catch( Exception $e )
catch( Exception|ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['image_id'] );
return FALSE;
}
catch( ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['image_id'] );
return FALSE;
}
if ( !isset( $info['image_approved'] ) )
{
$info['image_approved'] = 1;
@@ -1076,9 +1073,9 @@ class Gallery extends Core
* Convert an album comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertGalleryAlbumComment( $info=array() )
public function convertGalleryAlbumComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -1197,9 +1194,9 @@ class Gallery extends Core
* Convert an album review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted reiew, or FALSE on failure.
* @return int|bool The ID of the newly inserted reiew, or FALSE on failure.
*/
public function convertGalleryAlbumReview( $info=array() )
public function convertGalleryAlbumReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -1384,9 +1381,9 @@ class Gallery extends Core
* Convert a comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertGalleryComment( $info=array() )
public function convertGalleryComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -1505,9 +1502,9 @@ class Gallery extends Core
* Convert a review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted reiew, or FALSE on failure.
* @return int|bool The ID of the newly inserted reiew, or FALSE on failure.
*/
public function convertGalleryReview( $info=array() )
public function convertGalleryReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -1696,9 +1693,9 @@ class Gallery extends Core
* @param string|NULL $filepath The path to the attachment, or NULL.
* @param string|NULL $filedata The binary data of the attachment, or NULL.
* @param string|NULL $thumbnailpath Path to thumbnail, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
* @return int|bool The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath = NULL ) : bool|int
{
$map['location_key'] = 'gallery_Gallery';
$map['id1_type'] = 'gallery_images';
@@ -1726,9 +1723,9 @@ class Gallery extends Core
* Convert a Club Gallery Category
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted category, or FALSE on failure.
* @return int|bool The ID of the newly inserted category, or FALSE on failure.
*/
public function convertClubGalleryCategory( $info=array() )
public function convertClubGalleryCategory( array $info=array() ) : bool|int
{
$insertedId = $this->convertGalleryCategory( $info );
if ( $insertedId )
@@ -1744,9 +1741,9 @@ class Gallery extends Core
* @param array $info Data to insert
* @param string|NULL $filepath The path to the image, or NULL.
* @param string|NULL $filedata The binary data for the image, or NULL
* @return integer|boolean The ID of the newly inserted image, or FALSE on failure.
* @return int|bool The ID of the newly inserted image, or FALSE on failure.
*/
public function convertClubGalleryImage( $info=array(), $filepath=NULL, $filedata=NULL )
public function convertClubGalleryImage( array $info=array(), ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
$insertedId = $this->convertGalleryImage( $info, $filepath, $filedata );
if ( $insertedId )
@@ -1760,9 +1757,9 @@ class Gallery extends Core
* Convert a Club Gallery Comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertClubGalleryComment( $info=array() )
public function convertClubGalleryComment( array $info=array() ) : bool|int
{
$insertedId = $this->convertGalleryComment( $info );
if ( $insertedId )
@@ -1776,9 +1773,9 @@ class Gallery extends Core
* Convert a Club Gallery Review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted review, or FALSE on failure.
* @return int|bool The ID of the newly inserted review, or FALSE on failure.
*/
public function convertClubGalleryReview( $info=array() )
public function convertClubGalleryReview( array $info=array() ) : bool|int
{
$insertedId = $this->convertGalleryReview( $info );
if ( $insertedId )
+44 -44
View File
@@ -16,6 +16,7 @@ namespace IPS\convert\Library;
use Exception;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -52,7 +53,7 @@ class Nexus extends Library
/**
* @brief Application
*/
public $app = 'nexus';
public string $app = 'nexus';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -60,7 +61,7 @@ class Nexus extends Library
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -235,7 +236,7 @@ class Nexus extends Library
$return[ $k ] = [
'step_title' => 'convert_nexus_subscription_packages',
'step_method' => 'convertNexusSubscriptionPackages',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_member_subscription_packages' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'nexus_member_subscription_packages' ),
'source_rows' => [ 'table' => $v['table'], 'where' => $v['where'] ],
'per_cycle' => 200,
'dependencies' => [],
@@ -433,11 +434,12 @@ class Nexus extends Library
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -576,7 +578,7 @@ class Nexus extends Library
* @param array $fields Custom Field Data
* @return int|bool The ID of the inserted customer, or FALSE on failure
*/
public function convertNexusCustomer( $info, $fields=array() )
public function convertNexusCustomer( array $info, array $fields=array() ) : bool|int
{
if ( !isset( $info['member_id'] ) )
{
@@ -639,7 +641,7 @@ class Nexus extends Library
* @param array $fields The fields
* @return array Formatted Fields
*/
protected function _formatCustomerFields( $fields )
protected function _formatCustomerFields( array $fields ) : array
{
$return = array();
foreach( $fields as $key => $value )
@@ -667,7 +669,7 @@ class Nexus extends Library
/**
* @brief Allowed currencies
*/
protected $_allowedCurrencies = array( 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD',
protected array $_allowedCurrencies = array( 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD',
'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BYR', 'BZD', 'CAD', 'CDF', 'CHF',
'CLF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR',
'FJD', 'FKP', 'GBP', 'GEL', 'GGP', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR',
@@ -682,10 +684,10 @@ class Nexus extends Library
/**
* Convert a currency
*
* @param array Info
* @param array $info Info
* @return int|bool The newly inserted currency, or FALSE on failure
*/
public function convertNexusCurrency( $info )
public function convertNexusCurrency( array $info ) : bool|int
{
if ( !isset( $info['code'] ) )
{
@@ -725,7 +727,7 @@ class Nexus extends Library
* @param array $info Info
* @return int|bool The newly inserted note ID, or FALSE on failure
*/
public function convertNexusNote( $info )
public function convertNexusNote( array $info ) : bool|int
{
$hasId = TRUE;
if ( !isset( $info['note_id'] ) )
@@ -809,7 +811,7 @@ class Nexus extends Library
* @param string|NULL $filedata Raw filedata for the groups cover photo, or NULL
* @return int|bool THe ID of the newly inserted package group, or FALSE on failure
*/
public function convertNexusPackageGroup( $info, $filepath=NULL, $filedata=NULL )
public function convertNexusPackageGroup( array $info, ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['pg_id'] ) )
{
@@ -898,7 +900,7 @@ class Nexus extends Library
* @param array $info Info
* @return int|bool The ID of the newly inserted payment gateway, or FALSE on failure
*/
public function convertNexusPaymentMethod( $info )
public function convertNexusPaymentMethod( array $info ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['m_id'] ) )
@@ -962,7 +964,7 @@ class Nexus extends Library
* @param string|NULL $filePath Path to images
* @return int|bool The ID of the newly inserted package, or FALSE on failure
*/
public function convertNexusPackage( $info, $filePath=NULL )
public function convertNexusPackage( array $info, ?string $filePath=NULL ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['p_id'] ) )
@@ -1025,8 +1027,6 @@ class Nexus extends Library
}
catch( OutOfRangeException $ex ) { }
}, $newGroups );
$info['p_member_group'] = $info['p_member_group'];
}
/* Primary User Group */
@@ -1088,13 +1088,13 @@ class Nexus extends Library
$renewals = array();
if( isset( $info['p_renew_options'] ) AND count( $info['p_renew_options'] ) )
{
foreach ( $info['p_renew_options'] as $currency => $options )
foreach ( $info['p_renew_options'] as $k => $options )
{
$newOptions = array(
'cost' => [],
'term' => $options['term'],
'unit' => $options['unit'],
'add' => isset( $options['add'] ) ? $options['add'] : false
'add' => $options['add'] ?? false
);
foreach ( $options['cost'] as $currency => $cost )
@@ -1112,7 +1112,7 @@ class Nexus extends Library
/* Discounts */
//@TODO
$productImages = isset( $info['p_images'] ) ? $info['p_images'] : NULL;
$productImages = $info['p_images'] ?? NULL;
unset( $info['p_images'] );
$package = array(
@@ -1178,7 +1178,7 @@ class Nexus extends Library
$default = 0;
foreach( $productImages as $image )
{
if ( ( isset( $image['data'] ) AND is_null( $image['data'] ) ) AND !is_null( $filePath ) )
if ( ( isset( $image['data'] ) AND empty( $image['data'] ) ) AND !is_null( $filePath ) )
{
$filedata = @file_get_contents( rtrim( $filePath, '/' ) . '/' . $image['filename'] );
unset( $filepath );
@@ -1267,12 +1267,12 @@ class Nexus extends Library
* @param string|NULL $filePath Path to images
* @return int|bool The ID of the newly inserted package, or FALSE on failure
*/
public function convertNexusSubscriptionPackage( $info, $filePath=NULL )
public function convertNexusSubscriptionPackage( array $info, ?string $filePath=NULL ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['sp_id'] ) )
{
$this->software->app->log( 'nexus_package_missing_id', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'nexus_package_missing_id', __METHOD__, App::LOG_WARNING );
return FALSE;
}
@@ -1299,7 +1299,7 @@ class Nexus extends Library
/* !Required: Price */
if( !isset( $info['sp_price'] ) )
{
$this->software->app->log( 'nexus_subscription_missing_price', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['sp_id'] );
$this->software->app->log( 'nexus_subscription_missing_price', __METHOD__, App::LOG_WARNING, $info['sp_id'] );
return FALSE;
}
@@ -1321,7 +1321,7 @@ class Nexus extends Library
{
$newSecondaryGroups[] = $this->software->app->getLink( $group, 'core_groups', TRUE );
}
catch( \OutOfRangeException $ex ) { }
catch( OutOfRangeException $ex ) { }
}, $newSecondaryGroups );
}
@@ -1329,25 +1329,25 @@ class Nexus extends Library
{
try
{
$position = \IPS\Db::i()->select( 'MAX(p_position)', 'nexus_subscription_packages' )->first();
$position = Db::i()->select( 'MAX(p_position)', 'nexus_subscription_packages' )->first();
$info['sp_position'] = $position + 1;
}
catch( \UnderflowException $e ) { }
catch( UnderflowException $e ) { }
}
/* Base Price */
if( isset( $info['sp_price'] ) AND \count( $info['sp_price'] ) )
if( is_array( $info['sp_price'] ) AND count( $info['sp_price'] ) )
{
$newOptions = array(
'cost' => [],
'term' => $info['sp_price']['term'],
'unit' => $info['sp_price']['unit'],
'add' => isset( $info['sp_price']['add'] ) ? $info['sp_price']['add'] : false
'add' => $info['sp_price']['add'] ?? false
);
foreach ( $info['sp_price']['cost'] as $currency => $cost )
{
$price = new \IPS\nexus\Money( $cost, $currency );
$price = new Money( $cost, $currency );
$newOptions['cost'][ $currency ] = [ 'amount' => $price->amount, 'currency' => $currency ];
}
}
@@ -1356,25 +1356,25 @@ class Nexus extends Library
unset( $info['sp_price'] );
/* Renewal costs & terms */
if( isset( $info['sp_renew_options'] ) AND \count( $info['sp_renew_options'] ) )
if( isset( $info['sp_renew_options'] ) AND count( $info['sp_renew_options'] ) )
{
$newOptions = array(
'cost' => [],
'term' => $info['sp_renew_options']['term'],
'unit' => $info['sp_renew_options']['unit'],
'add' => isset( $info['sp_renew_options']['add'] ) ? $info['sp_renew_options']['add'] : false
'add' => $info['sp_renew_options']['add'] ?? false
);
foreach ( $info['sp_renew_options']['cost'] as $currency => $cost )
{
$price = new \IPS\nexus\Money( $cost, $currency );
$price = new Money( $cost, $currency );
$newOptions['cost'][ $currency ] = [ 'amount' => $price->amount, 'currency' => $currency ];
}
$info['sp_renew_options'] = json_encode( $newOptions );
}
$image = isset( $info['sp_image'] ) ? $info['sp_image'] : NULL;
$image = $info['sp_image'] ?? NULL;
unset( $info['sp_image'] );
$package = array(
@@ -1396,7 +1396,7 @@ class Nexus extends Library
/* Images */
if( $image )
{
if ( ( isset( $image['data'] ) AND \is_null( $image['data'] ) ) AND !\is_null( $filePath ) )
if ( ( isset( $image['data'] ) AND empty( $image['data'] ) ) AND !is_null( $filePath ) )
{
$filedata = @file_get_contents( rtrim( $filePath, '/' ) . '/' . $image['filename'] );
unset( $filepath );
@@ -1406,20 +1406,20 @@ class Nexus extends Library
{
try
{
$info['sp_image'] = (string) \IPS\File::create( 'nexus_Products', $image['filename'], $filedata );
$info['sp_image'] = (string) File::create( 'nexus_Products', $image['filename'], $filedata );
}
catch( \Exception $e ) {}
catch( Exception $e ) {}
}
}
/* Save Package Data */
$insertedId = \IPS\Db::i()->insert( 'nexus_member_subscription_packages', $this->_getValues( $package, $info ) );
$insertedId = Db::i()->insert( 'nexus_member_subscription_packages', $this->_getValues( $package, $info ) );
$originalId = $info['sp_id'];
unset( $info['sp_id'] );
/* Custom lang strings */
\IPS\Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}", $name );
\IPS\Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}_desc", $description );
Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}", $name );
Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}_desc", $description );
/* Add Link */
$this->software->app->addLink( $insertedId, $originalId, 'nexus_members_subs_pkg' );
@@ -1434,7 +1434,7 @@ class Nexus extends Library
* @param string $currency Invoice Currency
* @return int|bool The ID of the newly inserted invoice, or FALSE on failure
*/
public function convertNexusInvoice( $info, $currency )
public function convertNexusInvoice( array $info, string $currency ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['i_id'] ) )
@@ -1535,7 +1535,7 @@ class Nexus extends Library
* @param string $currency Transaction Currency
* @return int|bool The ID of the newly inserted transaction, or FALSE on failure
*/
public function convertNexusTransaction( $info, $currency )
public function convertNexusTransaction( array $info, string $currency ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['t_id'] ) )
@@ -1645,7 +1645,7 @@ class Nexus extends Library
* @param string $currency Transaction Currency
* @return int|bool The ID of the newly inserted purchase, or FALSE on failure
*/
public function convertNexusPurchase( $info, $currency )
public function convertNexusPurchase( array $info, string $currency ) : bool|int
{
/* !Required: ID */
if ( !isset( $info['ps_id'] ) )
@@ -1807,7 +1807,7 @@ class Nexus extends Library
* @param array $source User-supplied array
* @return array
*/
protected function _getValues( array $defaults, array $source )
protected function _getValues( array $defaults, array $source ) : array
{
array_walk( $defaults, function( &$value, $key, $source )
{
@@ -1823,10 +1823,10 @@ class Nexus extends Library
/**
* Check whether a given payment method is supported by Commerce
*
* @param $method
* @param string $method
* @return bool
*/
protected function _isPaymentMethodSupported( $method )
protected function _isPaymentMethodSupported( string $method ) : bool
{
$availableGateways = Gateway::gateways();
$methodKey = array_search( $method, array_keys( array_change_key_case( $availableGateways, CASE_LOWER ) ) );