Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -5,19 +5,23 @@
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @subpackage convert
* @since 21 Jan 2015
*/
namespace IPS\convert\Library;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Invision Gallery Converter
* @note We must extend the Core Library here so we can access methods like convertAttachment, convertFollow, etc
*/
class _Gallery extends Core
{
/**
@@ -34,7 +38,7 @@ class _Gallery extends Core
public function menuRows( $rowCounts=FALSE )
{
$return = array();
$classname = get_class( $this->software );
$extraRows = $this->software->extraMenuRows();
foreach( $this->getConvertableItems() as $k => $v )
{
@@ -46,7 +50,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_categories',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_categories' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 200,
'dependencies' => array(),
'link_type' => 'gallery_categories',
);
@@ -66,7 +70,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_albums',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_albums' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 200,
'dependencies' => $dependencies,
'link_type' => 'gallery_albums',
);
@@ -78,7 +82,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_album_comments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_comments' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1500,
'per_cycle' => 200,
'dependencies' => array( 'convertGalleryAlbums' ),
'link_type' => 'gallery_album_comments',
'requires_rebuild' => TRUE
@@ -91,7 +95,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_album_reviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_reviews' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1500,
'per_cycle' => 200,
'dependencies' => array( 'convertGalleryAlbums' ),
'link_type' => 'gallery_album_reviews',
'requires_rebuild' => TRUE
@@ -117,7 +121,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_images',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 10,
'dependencies' => $dependencies,
'link_type' => 'gallery_images',
'requires_rebuild' => TRUE
@@ -130,7 +134,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_comments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_comments' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1500,
'per_cycle' => 200,
'dependencies' => array( 'convertGalleryImages' ),
'link_type' => 'gallery_comments',
'requires_rebuild' => TRUE
@@ -143,7 +147,7 @@ class _Gallery extends Core
'step_title' => 'convert_gallery_reviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_reviews' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1500,
'per_cycle' => 200,
'dependencies' => array( 'convertGalleryImages' ),
'link_type' => 'gallery_reviews',
'requires_rebuild' => TRUE
@@ -156,7 +160,7 @@ class _Gallery extends Core
'step_method' => 'convertClubGalleryCategories',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_categories', array( "category_club_id IS NOT NULL" ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertGalleryImages' ),
'link_type' => 'core_club_gallery_categories'
);
@@ -168,7 +172,7 @@ class _Gallery extends Core
'step_method' => 'convertClubGalleryImages',
'ips_rows' => \IPS\Db::i()->select( 'SUM(category_count_imgs)', 'gallery_categories', array( "category_club_id IS NOT NULL" ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 10,
'dependencies' => array( 'convertClubGalleryCategories' ),
'link_type' => 'core_club_gallery_images'
);
@@ -180,7 +184,7 @@ class _Gallery extends Core
'step_method' => 'convertClubGalleryComments',
'ips_rows' => \IPS\Db::i()->select( 'SUM(category_count_comments)', 'gallery_categories', array( "category_club_id IS NOT NULL" ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertClubGalleryImages' ),
'link_type' => 'core_club_gallery_comments'
);
@@ -192,7 +196,7 @@ class _Gallery extends Core
'step_method' => 'convertClubGalleryReviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_reviews', array( \IPS\Db::i()->in( 'review_image_id', \IPS\Db::i()->select( 'image_id', 'gallery_images', array( \IPS\Db::i()->in( 'image_category_id', \IPS\Db::i()->select( 'category_id', 'gallery_categories', array( "category_club_id IS NOT NULL" ) ) ) ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertClubGalleryImages' ),
'link_type' => 'core_club_gallery_reviews'
);
@@ -216,15 +220,22 @@ class _Gallery extends Core
'step_title' => 'convert_attachments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'gallery_Images' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 10,
'dependencies' => $dependencies,
'link_type' => 'core_attachments',
);
break;
}
}
$return = $this->software->extraMenuRows( $return );
/* Append any extra steps immediately to retain ordering */
if( isset( $v['extra_steps'] ) )
{
foreach( $v['extra_steps'] as $extra )
{
$return[ $extra ] = $extraRows[ $extra ];
}
}
}
/* Run the queries if we want row counts */
if( $rowCounts )
@@ -238,12 +249,13 @@ class _Gallery extends Core
/**
* Returns an array of tables that need to be truncated when Empty Local Data is used
*
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
{
$return = array();
$classname = get_class( $this->software );
$classname = \get_class( $this->software );
if( $classname::canConvert() === NULL )
{
@@ -459,7 +471,7 @@ class _Gallery extends Core
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$inserted_id}", $name );
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$inserted_id}_desc", $desc );
\IPS\Db::i()->update( 'gallery_categories', array( "category_parent_id" => $inserted_id ), array( "category_conv_parent=? AND category_conv_parent<>?", $id, 0 ) );
\IPS\Db::i()->update( 'gallery_categories', array( "category_parent_id" => $inserted_id ), array( "category_conv_parent=?", $id ) );
\IPS\Db::i()->insert( 'core_permission_index', array( 'app' => 'gallery', 'perm_type' => 'category', 'perm_type_id' => $inserted_id, 'perm_view' => '' ) );
if ( $info['category_club_id'] )
@@ -493,7 +505,7 @@ class _Gallery extends Core
return FALSE;
}
if ( is_null( $category ) )
if ( \is_null( $category ) )
{
if ( isset( $info['album_category_id'] ) )
{
@@ -514,6 +526,16 @@ class _Gallery extends Core
else
{
$info['album_category_id'] = $category;
/* Check the category exists */
try
{
\IPS\gallery\Category::load( $info['album_category_id'] );
}
catch( \OutOfRangeException $e )
{
$info['album_category_id'] = $this->_orphanedAlbumsCategory();
}
}
if ( isset( $info['album_owner_id'] ) )
@@ -545,7 +567,7 @@ class _Gallery extends Core
$info['album_description'] = '';
}
if ( !isset( $info['album_type'] ) OR !in_array( $info['album_type'], array( 1, 2, 3 ) ) )
if ( !isset( $info['album_type'] ) OR !\in_array( $info['album_type'], array( 1, 2, 3 ) ) )
{
$info['album_type'] = 1;
}
@@ -565,7 +587,7 @@ class _Gallery extends Core
$info['album_last_img_date'] = 0;
$info['album_last_x_images'] = NULL;
if ( !isset( $info['album_sort_options'] ) OR !in_array( $info['album_sort_options'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
if ( !isset( $info['album_sort_options'] ) OR !\in_array( $info['album_sort_options'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
{
$info['album_sort_options'] = 'updated';
}
@@ -593,7 +615,7 @@ class _Gallery extends Core
}
$info['album_allowed_access'] = NULL;
if ( !is_null( $socialgroup ) AND is_array( $socialgroup ) )
if ( !\is_null( $socialgroup ) AND \is_array( $socialgroup ) )
{
$socialGroupId = \IPS\Db::i()->insert( 'core_sys_social_groups', array( 'owner_id' => $info['album_owner_id'] ) );
$members = array();
@@ -679,7 +701,7 @@ class _Gallery extends Core
}
/* If we don't have any image to process, just stop here */
if ( is_null( $filedata ) AND ( is_null( $filepath ) OR !file_exists( $filepath ) ) )
if ( \is_null( $filedata ) AND ( \is_null( $filepath ) OR !file_exists( $filepath ) ) )
{
$this->software->app->log( 'gallery_image_missing_image', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['image_id'] );
return FALSE;
@@ -748,7 +770,7 @@ class _Gallery extends Core
$info['image_member_id'] = NULL;
}
if ( is_null( $info['image_member_id'] ) )
if ( \is_null( $info['image_member_id'] ) )
{
try
{
@@ -777,7 +799,7 @@ class _Gallery extends Core
if ( $mime_type === 'application/x-unknown' OR ( \strstr( $mime_type, 'image' ) === FALSE AND \strstr( $mime_type, 'video' ) === FALSE ) )
{
$this->software->app->log( 'gallery_image_invalid_mime_type', __METHOD__, \IPS\convert\App::LOG_WARNING, $image['image_id'] );
$this->software->app->log( 'gallery_image_invalid_mime_type', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['image_id'] );
return FALSE;
}
@@ -787,7 +809,7 @@ class _Gallery extends Core
if ( !isset( $info['image_file_name'] ) )
{
/* If we were passed a path, try and figure it out */
if ( !is_null( $filepath ) )
if ( !\is_null( $filepath ) )
{
$file_name = explode( '/', $filepath );
$file_name = array_pop( $file_name );
@@ -808,7 +830,7 @@ class _Gallery extends Core
/* Image Caption */
if ( !isset( $info['image_caption'] ) )
{
if ( !is_null( $filepath ) )
if ( !\is_null( $filepath ) )
{
$caption = explode( '/', $info['image_file_name'] );
$caption = array_pop( $caption );
@@ -852,7 +874,7 @@ class _Gallery extends Core
/* Okay, let's create our image. We can use data returned from this later if it's missing. */
try
{
if ( is_null( $filedata ) AND !is_null( $filepath ) )
if ( \is_null( $filedata ) AND !\is_null( $filepath ) )
{
if( !file_exists( $filepath ) )
{
@@ -1248,13 +1270,13 @@ class _Gallery extends Core
if ( isset( $info['review_votes_data'] ) )
{
if ( !is_array( $info['review_votes_data'] ) )
if ( !\is_array( $info['review_votes_data'] ) )
{
$info['review_votes_data'] = json_decode( $info['review_votes_data'], TRUE );
}
$newVoters = array();
if ( !is_null( $info['review_votes_data'] ) AND count( $info['review_votes_data'] ) )
if ( !\is_null( $info['review_votes_data'] ) AND \count( $info['review_votes_data'] ) )
{
foreach( $info['review_votes_data'] AS $member => $vote )
{
@@ -1271,7 +1293,7 @@ class _Gallery extends Core
}
}
if ( count( $newVoters ) )
if ( \count( $newVoters ) )
{
$info['review_votes_data'] = json_encode( $newVoters );
}
@@ -1287,19 +1309,19 @@ class _Gallery extends Core
if ( !isset( $info['review_votes'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
if ( \is_null( $info['review_votes_data'] ) )
{
$info['review_votes'] = 0;
}
else
{
$info['review_votes'] = count( json_decode( $info['review_votes_data'], TRUE ) );
$info['review_votes'] = \count( json_decode( $info['review_votes_data'], TRUE ) );
}
}
if ( !isset( $info['review_votes_helpful'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
if ( \is_null( $info['review_votes_data'] ) )
{
$info['review_votes_helpful'] = 0;
}
@@ -1556,13 +1578,13 @@ class _Gallery extends Core
if ( isset( $info['review_votes_data'] ) )
{
if ( !is_array( $info['review_votes_data'] ) )
if ( !\is_array( $info['review_votes_data'] ) )
{
$info['review_votes_data'] = json_decode( $info['review_votes_data'], TRUE );
}
$newVoters = array();
if ( !is_null( $info['review_votes_data'] ) AND count( $info['review_votes_data'] ) )
if ( !\is_null( $info['review_votes_data'] ) AND \count( $info['review_votes_data'] ) )
{
foreach( $info['review_votes_data'] AS $member => $vote )
{
@@ -1579,7 +1601,7 @@ class _Gallery extends Core
}
}
if ( count( $newVoters ) )
if ( \count( $newVoters ) )
{
$info['review_votes_data'] = json_encode( $newVoters );
}
@@ -1595,19 +1617,19 @@ class _Gallery extends Core
if ( !isset( $info['review_votes'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
if ( \is_null( $info['review_votes_data'] ) )
{
$info['review_votes'] = 0;
}
else
{
$info['review_votes'] = count( json_decode( $info['review_votes_data'], TRUE ) );
$info['review_votes'] = \count( json_decode( $info['review_votes_data'], TRUE ) );
}
}
if ( !isset( $info['review_votes_helpful'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
if ( \is_null( $info['review_votes_data'] ) )
{
$info['review_votes_helpful'] = 0;
}
@@ -1647,6 +1669,7 @@ class _Gallery extends Core
* @param array $map Attachment Map Data
* @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.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
@@ -1661,7 +1684,7 @@ class _Gallery extends Core
$info['id3'] = NULL;
}
if ( is_null( $info['id3'] ) OR $info['id3'] != 'review' )
if ( \is_null( $info['id3'] ) OR $info['id3'] != 'review' )
{
$map['id2_type'] = 'gallery_comments';
}
@@ -1694,7 +1717,7 @@ 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
* @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.
*/
public function convertClubGalleryImage( $info=array(), $filepath=NULL, $filedata=NULL )