Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+426 -46
View File
@@ -70,6 +70,32 @@ class _Gallery extends Core
'link_type' => 'gallery_albums',
);
break;
case 'convertGalleryAlbumComments':
$return[ $k ] = array(
'step_method' => 'convertGalleryAlbumComments',
'step_title' => 'convert_gallery_album_comments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_comments' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 1500,
'dependencies' => array( 'convertGalleryAlbums' ),
'link_type' => 'gallery_album_comments',
'requires_rebuild' => TRUE
);
break;
case 'convertGalleryAlbumReviews':
$return[ $k ] = array(
'step_method' => 'convertGalleryAlbumReviews',
'step_title' => 'convert_gallery_album_reviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_reviews' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 1500,
'dependencies' => array( 'convertGalleryAlbums' ),
'link_type' => 'gallery_album_reviews',
'requires_rebuild' => TRUE
);
break;
case 'convertGalleryImages':
$dependencies = array();
@@ -93,6 +119,7 @@ class _Gallery extends Core
'per_cycle' => 100,
'dependencies' => $dependencies,
'link_type' => 'gallery_images',
'requires_rebuild' => TRUE
);
break;
@@ -105,6 +132,7 @@ class _Gallery extends Core
'per_cycle' => 1500,
'dependencies' => array( 'convertGalleryImages' ),
'link_type' => 'gallery_comments',
'requires_rebuild' => TRUE
);
break;
@@ -117,6 +145,7 @@ class _Gallery extends Core
'per_cycle' => 1500,
'dependencies' => array( 'convertGalleryImages' ),
'link_type' => 'gallery_reviews',
'requires_rebuild' => TRUE
);
break;
@@ -193,6 +222,8 @@ class _Gallery extends Core
break;
}
}
$return = $this->software->extraMenuRows( $return );
return $return;
}
@@ -217,12 +248,24 @@ class _Gallery extends Core
switch( $k )
{
case 'convertGalleryCategories':
$return['convertGalleryCategories'] = array( 'gallery_categories' => NULL, 'core_clubs_node_map' => array( "node_class=?", "IPS\\gallery\\Category" ) );
$return['convertGalleryCategories'] = array(
'gallery_categories' => NULL,
'core_clubs_node_map' => array( "node_class=?", "IPS\\gallery\\Category" ),
'core_permission_index' => array( 'app=? AND perm_type=?', 'gallery', 'category' )
);
break;
case 'convertGalleryAlbums':
$return['convertGalleryAlbums'] = array( 'gallery_albums' => NULL );
break;
case 'convertGalleryAlbumComments':
$return['convertGalleryAlbumComments'] = array( 'gallery_album_comments' => NULL );
break;
case 'convertGalleryAlbumReviews':
$return['convertGalleryAlbumReviews'] = array( 'gallery_album_reviews' => NULL );
break;
case 'convertGalleryImages':
$return['convertGalleryImages'] = array( 'gallery_images' => NULL );
@@ -520,6 +563,11 @@ class _Gallery extends Core
{
$info['album_allow_rating'] = 1;
}
if ( !isset( $info['album_submit_type'] ) )
{
$info['album_submit_type'] = 0;
}
if ( !isset( $info['album_position'] ) )
{
@@ -573,7 +621,21 @@ class _Gallery extends Core
{
try
{
return $this->software->app->getLink( '__orphaned__', 'gallery_categories' );
$id = $this->software->app->getLink( '__orphaned__', 'gallery_categories' );
/* Check the category exists */
try
{
\IPS\gallery\Category::load( $id );
}
catch( \OutOfRangeException $e )
{
/* Delete the relation if it no longer exists */
$this->software->app->deleteLink( '__orphaned__', 'gallery_categories' );
throw new \OutOfRangeException;
}
return $id;
}
catch( \OutOfRangeException $e )
{
@@ -612,7 +674,7 @@ class _Gallery extends Core
if ( isset( $info['image_album_id'] ) )
{
/* We only want to do this if the Album ID is explicitly not 0, as that means it has no album, which is okay */
if ( $info['image_album_id'] > 0 )
if ( !empty( $info['image_album_id'] ) )
{
try
{
@@ -683,26 +745,6 @@ class _Gallery extends Core
}
}
if ( !isset( $info['image_caption'] ) )
{
if ( !is_null( $filepath ) )
{
$caption = explode( '/', $info['image_caption'] );
$caption = array_pop( $caption );
}
else
{
$caption = "Untitled Image {$info['image_id']}";
}
$info['image_caption'] = $caption;
}
if ( mb_strlen( $info['image_caption'] ) > 255 )
{
$info['image_caption'] = mb_substr( $info['image_caption'], 0, 200 );
}
if ( !isset( $info['image_description'] ) )
{
$info['image_description'] = NULL;
@@ -710,9 +752,7 @@ class _Gallery extends Core
/* We will build these later */
$info['image_masked_file_name'] = NULL;
$info['image_medium_file_name'] = NULL;
$info['image_small_file_name'] = NULL;
$info['image_thumb_file_name'] = NULL;
/* Figure this out before we bother creating the image */
if ( !isset( $info['image_file_type'] ) )
@@ -735,7 +775,7 @@ class _Gallery extends Core
{
$file_name = explode( '/', $filepath );
$file_name = array_pop( $file_name );
$info['image_file_name'] = $file_name;
$info['image_file_name'] = mb_substr( $file_name, 0, 255 );
}
else
{
@@ -744,6 +784,54 @@ class _Gallery extends Core
return FALSE;
}
}
else
{
$info['image_file_name'] = mb_substr( $info['image_file_name'], 0, 255 );
}
/* Image Caption */
if ( !isset( $info['image_caption'] ) )
{
if ( !is_null( $filepath ) )
{
$caption = explode( '/', $info['image_file_name'] );
$caption = array_pop( $caption );
}
else
{
$caption = "Untitled Image {$info['image_id']}";
}
$info['image_caption'] = $caption;
}
if ( mb_strlen( $info['image_caption'] ) > 255 )
{
$info['image_caption'] = mb_substr( $info['image_caption'], 0, 200 );
}
/* Dates */
foreach( array( 'image_date', 'image_last_comment', 'image_updated' ) AS $date )
{
if ( isset( $info[ $date ] ) )
{
if ( $info[ $date ] instanceof \IPS\DateTime )
{
$info[ $date ] = $info[ $date ]->getTimestamp();
}
}
else
{
$info[ $date ] = time();
}
}
/* Figure out the container */
$container = 'monthly_' . date( 'Y', $info['image_date'] ) . '_' . date( 'm', $info['image_date'] );
if( isset( $info['image_container'] ) )
{
$container = $info['image_container'];
}
/* Okay, let's create our image. We can use data returned from this later if it's missing. */
try
@@ -758,7 +846,7 @@ class _Gallery extends Core
$filedata = file_get_contents( $filepath );
}
$image = \IPS\File::create( 'gallery_Images', $info['image_file_name'], $filedata );
$image = \IPS\File::create( 'gallery_Images', $info['image_file_name'], $filedata, $container );
$info['image_original_file_name'] = (string) $image;
if ( !isset( $info['image_file_size'] ) )
@@ -790,23 +878,7 @@ class _Gallery extends Core
$info[ $count ] = 0;
}
}
/* Dates */
foreach( array( 'image_date', 'image_last_comment', 'image_updated' ) AS $date )
{
if ( isset( $info[ $date ] ) )
{
if ( $info[ $date ] instanceof \IPS\DateTime )
{
$info[ $date ] = $info[ $date ]->getTimestamp();
}
}
else
{
$info[ $date ] = time();
}
}
if ( !isset( $info['image_pinned'] ) )
{
$info['image_pinned'] = 0;
@@ -935,6 +1007,314 @@ class _Gallery extends Core
return $inserted_id;
}
/**
* Convert an album comment
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertGalleryAlbumComment( $info=array() )
{
if ( !isset( $info['comment_id'] ) )
{
$this->software->app->log( 'gallery_album_comment_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
if ( empty( $info['comment_text'] ) )
{
$this->software->app->log( 'gallery_album_comment_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
if ( isset( $info['comment_album_id'] ) )
{
try
{
$info['comment_album_id'] = $this->software->app->getLink( $info['comment_album_id'], 'gallery_albums' );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'gallery_album_comment_missing_image', __METHOD__, \IPS\convert\ApP::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'gallery_album_omment_missing_image', __METHOD__, \IPS\convert\ApP::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
if ( isset( $info['comment_edit_time'] ) )
{
if ( $info['comment_edit_time'] instanceof \IPS\DateTime )
{
$info['comment_edit_time'] = $info['comment_edit_time']->getTimestamp();
}
}
else
{
$info['comment_edit_time'] = 0;
}
if ( isset( $info['comment_author_id'] ) )
{
try
{
$info['comment_author_id'] = $this->software->app->getLink( $info['comment_author_id'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
{
$info['comment_author_id'] = 0;
}
}
else
{
$info['comment_author_id'] = 0;
}
if ( !isset( $info['comment_author_name'] ) )
{
$author = \IPS\Member::load( $info['comment_author_id'] );
if ( $author->member_id )
{
$info['comment_author_name'] = $author->name;
}
else
{
$info['comment_author_name'] = "Guest";
}
}
if ( !isset( $info['comment_ip_address'] ) OR filter_var( $info['comment_ip_address'], FILTER_VALIDATE_IP ) === FALSE )
{
$info['comment_ip_address'] = '127.0.0.1';
}
if ( isset( $info['comment_post_date'] ) )
{
if ( $info['comment_post_date'] instanceof \IPS\DateTime )
{
$info['comment_post_date'] = $info['comment_post_date']->getTimestamp();
}
}
else
{
$info['comment_post_date'] = time();
}
if ( !isset( $info['comment_approved'] ) )
{
$info['comment_approved'] = 1;
}
if ( !isset( $info['comment_append_edit'] ) )
{
$info['comment_append_edit'] = 0;
}
if ( !isset( $info['comment_edit_name'] ) )
{
$info['comment_edit_name'] = NULL;
}
$id = $info['comment_id'];
unset( $info['comment_id'] );
$inserted_id = \IPS\Db::i()->insert( 'gallery_album_comments', $info );
$this->software->app->addLink( $inserted_id, $id, 'gallery_album_comments' );
return $inserted_id;
}
/**
* Convert an album review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted reiew, or FALSE on failure.
*/
public function convertGalleryAlbumReview( $info=array() )
{
if ( !isset( $info['review_id'] ) )
{
$this->software->app->log( 'gallery_album_review_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
if ( empty( $info['review_content'] ) )
{
$this->software->app->log( 'gallery_album_review_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
{
$this->software->app->log( 'gallery_album_review_missing_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
if ( isset( $info['review_author'] ) )
{
try
{
$info['review_author'] = $this->software->app->getLink( $info['review_author'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'gallery_album_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'gallery_album_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
if ( isset( $info['review_album_id'] ) )
{
try
{
$info['review_album_id'] = $this->software->app->getLink( $info['review_album_id'], 'gallery_albums' );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'gallery_album_review_missing_album', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
}
if ( !isset( $info['review_author_name'] ) )
{
$info['review_author_name'] = \IPS\Member::load( $info['review_author'] )->name;
}
if ( isset( $info['review_date'] ) )
{
if ( $info['review_date'] instanceof \IPS\DateTime )
{
$info['review_date'] = $info['review_date']->getTimestamp();
}
}
else
{
$info['review_date'] = time();
}
if ( !isset( $info['review_ip_address'] ) OR filter_var( $info['review_ip_address'], FILTER_VALIDATE_IP ) === FALSE )
{
$info['review_ip_address'] = '127.0.0.1';
}
if ( isset( $info['review_edit_time'] ) )
{
if ( $info['review_edit_time'] instanceof \IPS\DateTime )
{
$info['review_edit_time'] = $info['review_edit_time']->getTimestamp();
}
}
else
{
$info['review_edit_time'] = 0;
}
if ( !isset( $info['review_edit_member_name'] ) )
{
$info['review_edit_member_name'] = '';
}
if ( !isset( $info['review_edit_show'] ) )
{
$info['review_edit_show'] = 0;
}
if ( isset( $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'] ) )
{
foreach( $info['review_votes_data'] AS $member => $vote )
{
try
{
$memberId = $this->software->app->getLink( $member, 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
{
continue;
}
$newVoters[ $memberId ] = $vote;
}
}
if ( count( $newVoters ) )
{
$info['review_votes_data'] = json_encode( $newVoters );
}
else
{
$info['review_votes_data'] = NULL;
}
}
else
{
$info['review_votes_data'] = NULL;
}
if ( !isset( $info['review_votes'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
{
$info['review_votes'] = 0;
}
else
{
$info['review_votes'] = count( json_decode( $info['review_votes_data'], TRUE ) );
}
}
if ( !isset( $info['review_votes_helpful'] ) )
{
if ( is_null( $info['review_votes_data'] ) )
{
$info['review_votes_helpful'] = 0;
}
else
{
$helpful = 0;
foreach( json_decode( $info['review_votes_data'], TRUE ) AS $member => $vote )
{
if ( $vote == 1 )
{
$helpful += 1;
}
}
$info['review_votes_helpful'] = $helpful;
}
}
if ( !isset( $info['review_approved'] ) )
{
$info['review_approved'] = 1;
}
$id = $info['review_id'];
unset( $info['review_id'] );
$inserted_id = \IPS\Db::i()->insert( 'gallery_album_reviews', $info );
$this->software->app->addLink( $inserted_id, $id, 'gallery_album_reviews' );
return $inserted_id;
}
/**
* Convert a comment
@@ -1253,7 +1633,7 @@ class _Gallery extends Core
* @param string|NULL $filedata The binary data of the attachment, 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 )
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
{
$map['location_key'] = 'gallery_Gallery';
$map['id1_type'] = 'gallery_images';
@@ -1274,7 +1654,7 @@ class _Gallery extends Core
$map['id2_type'] = 'gallery_reviews';
}
return parent::convertAttachment( $info, $map, $filepath, $filedata );
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
}
/**