Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+138 -116
View File
@@ -12,16 +12,38 @@
namespace IPS\convert\Library;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use ErrorException;
use Exception;
use IPS\Application;
use IPS\convert\App;
use IPS\DateTime;
use IPS\Db;
use IPS\downloads\Category;
use IPS\downloads\Field;
use IPS\File;
use IPS\Http\url;
use IPS\Lang;
use IPS\Member;
use IPS\Member\Club;
use OutOfRangeException;
use function count;
use function defined;
use function get_class;
use function in_array;
use function is_array;
use function is_null;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Invision Downloads Converter
*/
class _Downloads extends Core
class Downloads extends Core
{
/**
* @brief Application
@@ -47,7 +69,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertDownloadsCfields',
'step_title' => 'convert_downloads_cfields',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_cfields' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_cfields' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array(),
@@ -66,7 +88,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertDownloadsCategories',
'step_title' => 'convert_downloads_categories',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_categories' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_categories' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => $dependencies,
@@ -89,7 +111,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertDownloadsFiles',
'step_title' => 'convert_downloads_files',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_files' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 10,
'dependencies' => $dependencies,
@@ -102,7 +124,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertDownloadsComments',
'step_title' => 'convert_downloads_comments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_comments' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_comments' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertDownloadsFiles' ),
@@ -115,7 +137,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertDownloadsReviews',
'step_title' => 'convert_downloads_reviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_reviews' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_reviews' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertDownloadsFiles' ),
@@ -128,7 +150,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_categories',
'step_method' => 'convertClubDownloadsCategories',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubs' ),
@@ -140,7 +162,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_files',
'step_method' => 'convertClubDownloadsFiles',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_files', array( Db::i()->in( 'file_cat', Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 10,
'dependencies' => array( 'convertClubDownloadsCategories' ),
@@ -152,7 +174,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_comments',
'step_method' => 'convertClubDownloadsComments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_comments', array( \IPS\Db::i()->in( 'comment_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_comments', array( Db::i()->in( 'comment_file_id', Db::i()->select( 'file_id', 'downloads_files', array( Db::i()->in( 'file_cat', Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubDownloadsFiles' ),
@@ -164,7 +186,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_reviews',
'step_method' => 'convertClubDownloadsReviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files_reviews', array( \IPS\Db::i()->in( 'review_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'downloads_files_reviews', array( Db::i()->in( 'review_file_id', Db::i()->select( 'file_id', 'downloads_files', array( Db::i()->in( 'file_cat', Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubDownloadsFiles' ),
@@ -188,7 +210,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_method' => 'convertAttachments',
'step_title' => 'convert_attachments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'downloads_Downloads' ) ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'downloads_Downloads' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 10,
'dependencies' => $dependencies,
@@ -225,7 +247,7 @@ class _Downloads extends Core
protected function truncate( $method )
{
$return = array();
$classname = \get_class( $this->software );
$classname = get_class( $this->software );
if( $classname::canConvert() === NULL )
{
@@ -243,9 +265,9 @@ class _Downloads extends Core
case 'convertDownloadsCfields':
if ( $method == $k )
{
foreach( \IPS\Db::i()->select( '*', 'downloads_cfields' ) AS $field )
foreach( Db::i()->select( '*', 'downloads_cfields' ) AS $field )
{
\IPS\Db::i()->dropColumn( 'downloads_ccontent', "field_{$field['cf_id']}" );
Db::i()->dropColumn( 'downloads_ccontent', "field_{$field['cf_id']}" );
}
}
$return['convertDownloadsCfields'] = array( 'downloads_cfields' => NULL );
@@ -269,7 +291,7 @@ class _Downloads extends Core
break;
case 'convertAttachments':
$return['convertAttachments'] = array( 'core_attachments' => \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'downloads_Downloads' ) ), 'core_attachments_map' => array( "location_key=?", 'downloads_Downloads' ) );
$return['convertAttachments'] = array( 'core_attachments' => Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'downloads_Downloads' ) ), 'core_attachments_map' => array( "location_key=?", 'downloads_Downloads' ) );
break;
case 'convertClubDownloadsCategories':
@@ -277,15 +299,15 @@ class _Downloads extends Core
break;
case 'convertClubDownloadsFiles':
$return['convertClubDownloadsFiles'] = array( 'downloads_files' => array( 'file_id IN ( ' . (string) \IPS\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 ( ' . (string) 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) \IPS\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 ( ' . (string) 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) \IPS\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 ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_downloads_reviews' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -315,23 +337,23 @@ class _Downloads extends Core
*/
public function convertDownloadsCfield( $info=array() )
{
$validFields = array_merge( static::$fieldTypes, \IPS\downloads\Field::$additionalFieldTypes );
$validFields = array_merge( static::$fieldTypes, Field::$additionalFieldTypes );
if ( !isset( $info['cf_id'] ) )
{
$this->software->app->log( 'downloads_cfield_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'downloads_cfield_missing_ids', __METHOD__, App::LOG_WARNING );
return FALSE;
}
if ( !isset( $info['cf_type'] ) OR !\in_array( $info['cf_type'], $validFields ) )
if ( !isset( $info['cf_type'] ) OR !in_array( $info['cf_type'], $validFields ) )
{
$this->software->app->log( 'downloads_cfield_invalid_type', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['cf_id'] );
$this->software->app->log( 'downloads_cfield_invalid_type', __METHOD__, App::LOG_WARNING, $info['cf_id'] );
return FALSE;
}
if ( isset( $info['cf_content'] ) )
{
if ( \is_array( $info['cf_content'] ) )
if ( is_array( $info['cf_content'] ) )
{
$info['cf_content'] = json_encode( $info['cf_content'] );
}
@@ -358,7 +380,7 @@ class _Downloads extends Core
if ( !isset( $info['cf_position'] ) )
{
$position = \IPS\Db::i()->select( 'MAX(cf_position)', 'downloads_cfields' )->first();
$position = Db::i()->select( 'MAX(cf_position)', 'downloads_cfields' )->first();
$info['cf_position'] = $position + 1;
}
@@ -388,12 +410,12 @@ class _Downloads extends Core
$fieldDescription = isset( $info['cf_desc'] ) ? $info['cf_desc'] : NULL;
unset( $info['cf_id'], $info['cf_name'], $info['cf_desc'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_cfields', $info );
$inserted_id = Db::i()->insert( 'downloads_cfields', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_cfields' );
/* Field Name */
\IPS\Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}", $fieldName ?: "Converted Field {$inserted_id}" );
\IPS\Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}_desc", $fieldDescription ?: '' );
Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}", $fieldName ?: "Converted Field {$inserted_id}" );
Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}_desc", $fieldDescription ?: '' );
/* Now... create our column */
$columnDefinition = array( 'name' => "field_{$inserted_id}" );
@@ -465,17 +487,17 @@ class _Downloads extends Core
}
}
\IPS\Db::i()->addColumn( 'downloads_ccontent', $columnDefinition );
Db::i()->addColumn( 'downloads_ccontent', $columnDefinition );
if ( $info['cf_type'] != 'Upload' )
{
if ( \in_array( $columnDefinition['type'], [ 'TEXT', 'MEDIUMTEXT' ] ) )
if ( in_array( $columnDefinition['type'], [ 'TEXT', 'MEDIUMTEXT' ] ) )
{
\IPS\Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'fulltext', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'fulltext', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
}
else
{
\IPS\Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'key', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'key', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
}
}
@@ -493,7 +515,7 @@ class _Downloads extends Core
{
$return = array( 'file_id' => $file_id );
if ( \count( $fieldInfo ) )
if ( count( $fieldInfo ) )
{
foreach( $fieldInfo as $key => $value )
{
@@ -510,7 +532,7 @@ class _Downloads extends Core
{
$link = $this->software->app->getLink( $id, 'downloads_cfields' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
/* Does not exist - skip */
continue;
@@ -533,7 +555,7 @@ class _Downloads extends Core
{
if ( !isset( $info['cid'] ) )
{
$this->software->app->log( 'downloads_category_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'downloads_category_missing_ids', __METHOD__, App::LOG_WARNING );
return FALSE;
}
@@ -543,7 +565,7 @@ class _Downloads extends Core
{
$info['cparent'] = $this->software->app->getLink( $info['cparent'], 'downloads_categories' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['cconv_parent'] = $info['cparent'];
}
@@ -581,20 +603,20 @@ class _Downloads extends Core
if ( !isset( $info['cposition'] ) )
{
$position = \IPS\Db::i()->select( 'MAX(cposition)', 'downloads_categories' )->first();
$position = Db::i()->select( 'MAX(cposition)', 'downloads_categories' )->first();
$info['cposition'] = $position + 1;
}
if ( isset( $info['ccfields'] ) )
{
if ( !\is_array( $info['ccfields'] ) )
if ( !is_array( $info['ccfields'] ) )
{
$info['ccfields'] = explode( ',', $info['ccfields'] );
}
$newCfields = array();
if ( \count( $info['ccfields'] ) )
if ( count( $info['ccfields'] ) )
{
foreach( $info['ccfields'] AS $field )
{
@@ -602,14 +624,14 @@ class _Downloads extends Core
{
$newCfields[] = $this->software->app->getLink( $field, 'downloads_cfields' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
continue;
}
}
}
if ( \count( $newCfields ) )
if ( count( $newCfields ) )
{
$info['ccfields'] = implode( ',', $newCfields );
}
@@ -623,7 +645,7 @@ class _Downloads extends Core
$info['ccfields'] = NULL;
}
$info['cname_furl'] = \IPS\Http\Url::seoTitle( $name );
$info['cname_furl'] = Url::seoTitle( $name );
if ( !isset( $info['ctags_disabled'] ) )
{
@@ -639,7 +661,7 @@ class _Downloads extends Core
$info['ctags_predefined'] = NULL;
$bitoptions = 0;
foreach( \IPS\downloads\Category::$bitOptions['bitoptions']['bitoptions'] AS $key => $value )
foreach( Category::$bitOptions['bitoptions']['bitoptions'] AS $key => $value )
{
if ( isset( $info['cbitoptions'][$key] ) AND $info['cbitoptions'][$key] )
{
@@ -650,7 +672,7 @@ class _Downloads extends Core
if ( isset( $info['ctypes'] ) )
{
if ( \is_array( $info['ctypes'] ) )
if ( is_array( $info['ctypes'] ) )
{
$info['ctypes'] = implode( ',', $info['ctypes'] );
}
@@ -660,7 +682,7 @@ class _Downloads extends Core
$info['ctypes'] = NULL;
}
if ( !isset( $info['csortorder'] ) OR !\in_array( $info['csortorder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
if ( !isset( $info['csortorder'] ) OR !in_array( $info['csortorder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
{
$info['csortorder'] = 'updated';
}
@@ -677,7 +699,7 @@ class _Downloads extends Core
if ( isset( $info['cmaxdims'] ) )
{
if ( \is_array( $info['cmaxdims'] ) )
if ( is_array( $info['cmaxdims'] ) )
{
$info['cmaxdims'] = implode( 'x', $info['cmaxdims'] );
}
@@ -703,7 +725,7 @@ class _Downloads extends Core
{
$info['cforum_id'] = $this->software->app->getSiblingLink( $info['cforum_id'], 'forums_forums', 'forums' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['cforum_id'] = 0;
}
@@ -730,7 +752,7 @@ class _Downloads extends Core
{
$info['cclub_id'] = $this->software->app->getLink( $info['cclub_id'], 'core_clubs', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['cclub_id'] = NULL;
}
@@ -747,25 +769,25 @@ class _Downloads extends Core
$id = $info['cid'];
unset( $info['cid'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_categories', $info );
$inserted_id = Db::i()->insert( 'downloads_categories', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_categories' );
\IPS\Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}", $name );
\IPS\Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}_desc", $desc );
Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}", $name );
Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}_desc", $desc );
\IPS\Db::i()->update( 'downloads_categories', array( "cparent" => $inserted_id ), array( "cconv_parent=?", $id ) );
\IPS\Db::i()->insert( 'core_permission_index', array( 'app' => 'downloads', 'perm_type' => 'category', 'perm_type_id' => $inserted_id, 'perm_view' => '' ) );
Db::i()->update( 'downloads_categories', array( "cparent" => $inserted_id ), array( "cconv_parent=?", $id ) );
Db::i()->insert( 'core_permission_index', array( 'app' => 'downloads', 'perm_type' => 'category', 'perm_type_id' => $inserted_id, 'perm_view' => '' ) );
if ( $info['cclub_id'] )
{
\IPS\Db::i()->insert( 'core_clubs_node_map', array(
Db::i()->insert( 'core_clubs_node_map', array(
'node_id' => $inserted_id,
'node_class' => "IPS\\downloads\\Category",
'club_id' => $info['cclub_id'],
'name' => $name
) );
\IPS\downloads\Category::load( $inserted_id )->setPermissionsToClub( \IPS\Member\Club::load( $info['cclub_id'] ) );
Category::load( $inserted_id )->setPermissionsToClub( Club::load( $info['cclub_id'] ) );
}
return $inserted_id;
@@ -783,26 +805,26 @@ class _Downloads extends Core
{
if ( !isset( $info['file_id'] ) )
{
$this->software->app->log( 'downloads_file_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'downloads_file_missing_ids', __METHOD__, App::LOG_WARNING );
return FALSE;
}
if ( !\count( $records ) )
if ( !count( $records ) )
{
$this->software->app->log( 'downloads_file_no_records', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['file_id'] );
$this->software->app->log( 'downloads_file_no_records', __METHOD__, App::LOG_WARNING, $info['file_id'] );
return FALSE;
}
if ( empty( $info['file_desc'] ) )
{
$this->software->app->log( 'downloads_file_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['file_id'] );
$this->software->app->log( 'downloads_file_missing_content', __METHOD__, App::LOG_WARNING, $info['file_id'] );
return FALSE;
}
if ( !isset( $info['file_name'] ) )
{
$info['file_name'] = "Untitled File {$info['file_id']}";
$this->software->app->log( 'downloads_file_no_title', __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['file_id'] );
$this->software->app->log( 'downloads_file_no_title', __METHOD__, App::LOG_NOTICE, $info['file_id'] );
}
if ( isset( $info['file_cat'] ) )
@@ -811,7 +833,7 @@ class _Downloads extends Core
{
$info['file_cat'] = $this->software->app->getLink( $info['file_cat'], 'downloads_categories' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['file_cat'] = $this->_orphanedFilesCategory();
}
@@ -851,7 +873,7 @@ class _Downloads extends Core
if ( isset( $info['file_submitted'] ) )
{
if ( $info['file_submitted'] instanceof \IPS\DateTime )
if ( $info['file_submitted'] instanceof DateTime )
{
$info['file_submitted'] = $info['file_submitted']->getTimestamp();
}
@@ -863,7 +885,7 @@ class _Downloads extends Core
if ( isset( $info['file_updated'] ) )
{
if ( $info['file_updated'] instanceof \IPS\DateTime )
if ( $info['file_updated'] instanceof DateTime )
{
$info['file_updated'] = $info['file_updated']->getTimestamp();
}
@@ -882,7 +904,7 @@ class _Downloads extends Core
{
$info['file_submitter'] = $this->software->app->getLink( $info['file_submitter'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['file_submitter'] = 0;
}
@@ -898,7 +920,7 @@ class _Downloads extends Core
{
$info['file_approver'] = $this->software->app->getLink( $info['file_approver'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['file_approver'] = 0;
}
@@ -910,7 +932,7 @@ class _Downloads extends Core
if ( isset( $info['file_approvedon'] ) )
{
if ( $info['file_approvedon'] instanceof \IPS\DateTime )
if ( $info['file_approvedon'] instanceof DateTime )
{
$info['file_approvedon'] = $info['file_approvedon']->getTimestamp();
}
@@ -926,7 +948,7 @@ class _Downloads extends Core
{
$info['file_topicid'] = $this->software->app->getSiblingLink( $info['file_topicid'], 'forums_topics', 'forums' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['file_topicid'] = 0;
}
@@ -941,9 +963,9 @@ class _Downloads extends Core
$info['file_ipaddress'] = '127.0.0.1';
}
$info['file_name_furl'] = \IPS\Http\Url::seoTitle( $info['file_name'] );
$info['file_name_furl'] = url::seoTitle( $info['file_name'] );
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
if ( Application::appIsEnabled( 'nexus' ) )
{
// @todo I need the Commerce Libraries for this
}
@@ -986,7 +1008,7 @@ class _Downloads extends Core
if ( isset( $info['file_last_comment'] ) )
{
if ( $info['file_last_comment'] instanceof \IPS\DateTime )
if ( $info['file_last_comment'] instanceof DateTime )
{
$info['file_last_comment'] = $info['file_last_comment']->getTimestamp();
}
@@ -998,7 +1020,7 @@ class _Downloads extends Core
if ( isset( $info['file_last_review'] ) )
{
if ( $info['file_last_review'] instanceof \IPS\DateTime )
if ( $info['file_last_review'] instanceof DateTime )
{
$info['file_last_review'] = $info['file_last_review']->getTimestamp();
}
@@ -1010,7 +1032,7 @@ class _Downloads extends Core
if ( isset( $info['file_edit_time'] ) )
{
if ( $info['file_edit_time'] instanceof \IPS\DateTime )
if ( $info['file_edit_time'] instanceof DateTime )
{
$info['file_edit_time'] = $info['file_edit_time']->getTimestamp();
}
@@ -1038,7 +1060,7 @@ class _Downloads extends Core
$id = $info['file_id'];
unset( $info['file_id'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_files', $info );
$inserted_id = Db::i()->insert( 'downloads_files', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_files' );
/* Now our records */
@@ -1059,7 +1081,7 @@ class _Downloads extends Core
$record['record_link_type'] = NULL;
$record['record_no_watermark'] = NULL;
if ( !isset( $record['record_type'] ) OR !\in_array( $record['record_type'], array( 'upload', 'ssupload', 'link' ) ) )
if ( !isset( $record['record_type'] ) OR !in_array( $record['record_type'], array( 'upload', 'ssupload', 'link' ) ) )
{
$record['record_type'] = 'upload';
}
@@ -1076,7 +1098,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 !is_null( $record['file_path'] ) )
{
$fileName = explode( '/', $record['file_path'] );
$fileName = array_pop( $fileName );
@@ -1086,7 +1108,7 @@ class _Downloads extends Core
if ( isset( $record['record_time'] ) )
{
if ( $record['record_time'] instanceof \IPS\DateTime )
if ( $record['record_time'] instanceof DateTime )
{
$record['record_time'] = $record['record_time']->getTimestamp();
}
@@ -1107,7 +1129,7 @@ class _Downloads extends Core
$container = 'monthly_' . date( 'Y', $record['record_time'] ) . '_' . date( 'm', $record['record_time'] );
/* We need the file storage to copy the file rather than move it */
\IPS\File::$copyFiles = TRUE;
File::$copyFiles = TRUE;
if ( $record['record_type'] == 'link' )
{
@@ -1116,7 +1138,7 @@ class _Downloads extends Core
}
else if ( $record['record_type'] == 'upload' )
{
$file = \IPS\File::create( 'downloads_Files', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$file = File::create( 'downloads_Files', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$record['record_location'] = (string) $file;
$record['record_size'] = $file->filesize();
@@ -1127,21 +1149,21 @@ class _Downloads extends Core
}
else
{
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$file = File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$file->thumbnailContainer = $container;
$record['record_location'] = (string) $file;
$record['record_thumb'] = (string) $file->thumbnail( 'downloads_Screenshots' );
$record['record_size'] = $file->filesize();
}
}
catch( \Exception | \ErrorException $e )
catch( Exception | ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, \IPS\convert\App::LOG_WARNING, ( $hasId ) ? $record['record_id'] : NULL );
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, ( $hasId ) ? $record['record_id'] : NULL );
continue;
}
/* Revert file system to default functionality */
\IPS\File::$copyFiles = FALSE;
File::$copyFiles = FALSE;
unset( $record['file_data'], $file, $record['file_path'] );
if ( $hasId )
@@ -1150,7 +1172,7 @@ class _Downloads extends Core
unset( $record['record_id'] );
}
$recordInsertedId = \IPS\Db::i()->insert( 'downloads_files_records', $record );
$recordInsertedId = Db::i()->insert( 'downloads_files_records', $record );
if ( $hasId )
{
@@ -1163,8 +1185,8 @@ class _Downloads extends Core
}
}
\IPS\Db::i()->update( 'downloads_files', array( 'file_primary_screenshot' => $primaryScreenshot ), array( "file_id=?", $inserted_id ) );
\IPS\Db::i()->replace( 'downloads_ccontent', $this->_formatCustomFieldContent( $inserted_id, $customFields ), TRUE );
Db::i()->update( 'downloads_files', array( 'file_primary_screenshot' => $primaryScreenshot ), array( "file_id=?", $inserted_id ) );
Db::i()->replace( 'downloads_ccontent', $this->_formatCustomFieldContent( $inserted_id, $customFields ), TRUE );
return $inserted_id;
}
@@ -1180,7 +1202,7 @@ class _Downloads extends Core
{
return $this->software->app->getLink( '__orphaned__', 'downloads_categories' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
return $this->convertDownloadsCategory( array(
'cid' => '__orphaned__',
@@ -1199,7 +1221,7 @@ class _Downloads extends Core
{
if ( !isset( $info['comment_id'] ) )
{
$this->software->app->log( 'downloads_comment_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'downloads_comment_missing_ids', __METHOD__, App::LOG_WARNING );
return FALSE;
}
@@ -1209,21 +1231,21 @@ class _Downloads extends Core
{
$info['comment_fid'] = $this->software->app->getLink( $info['comment_fid'], 'downloads_files' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$this->software->app->log( 'downloads_comment_missing_file', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
$this->software->app->log( 'downloads_comment_missing_file', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'downloads_comment_missing_file', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
$this->software->app->log( 'downloads_comment_missing_file', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
if ( empty( $info['comment_text'] ) )
{
$this->software->app->log( 'downloads_comment_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
$this->software->app->log( 'downloads_comment_missing_content', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
return FALSE;
}
@@ -1233,7 +1255,7 @@ class _Downloads extends Core
{
$info['comment_mid'] = $this->software->app->getLink( $info['comment_mid'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$info['comment_mid'] = 0;
}
@@ -1245,7 +1267,7 @@ class _Downloads extends Core
if ( isset( $info['comment_date'] ) )
{
if ( $info['comment_date'] instanceof \IPS\DateTime )
if ( $info['comment_date'] instanceof DateTime )
{
$info['comment_date'] = $info['comment_date']->getTimestamp();
}
@@ -1267,7 +1289,7 @@ class _Downloads extends Core
if ( isset( $info['comment_edit_time'] ) )
{
if ( $info['comment_edit_time'] instanceof \IPS\DateTime )
if ( $info['comment_edit_time'] instanceof DateTime )
{
$info['comment_edit_time'] = $info['comment_edit_time']->getTimestamp();
}
@@ -1284,7 +1306,7 @@ class _Downloads extends Core
if ( !isset( $info['comment_author'] ) )
{
$author = \IPS\Member::load( $info['comment_mid'] );
$author = Member::load( $info['comment_mid'] );
if ( $author->member_id )
{
@@ -1299,7 +1321,7 @@ class _Downloads extends Core
$id = $info['comment_id'];
unset( $info['comment_id'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_comments', $info );
$inserted_id = Db::i()->insert( 'downloads_comments', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_comments' );
return $inserted_id;
@@ -1315,7 +1337,7 @@ class _Downloads extends Core
{
if ( !isset( $info['review_id'] ) )
{
$this->software->app->log( 'download_review_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'download_review_missing_ids', __METHOD__, App::LOG_WARNING );
return FALSE;
}
@@ -1327,7 +1349,7 @@ class _Downloads extends Core
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
{
$this->software->app->log( 'download_review_missing_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
$this->software->app->log( 'download_review_missing_rating', __METHOD__, App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
@@ -1337,15 +1359,15 @@ class _Downloads extends Core
{
$info['review_mid'] = $this->software->app->getLink( $info['review_mid'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$this->software->app->log( 'download_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
$this->software->app->log( 'download_review_missing_author', __METHOD__, App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'download_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
$this->software->app->log( 'download_review_missing_author', __METHOD__, App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
@@ -1355,22 +1377,22 @@ class _Downloads extends Core
{
$info['review_fid'] = $this->software->app->getLink( $info['review_fid'], 'downloads_files' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$this->software->app->log( 'download_review_missing_file', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
$this->software->app->log( 'download_review_missing_file', __METHOD__, App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
}
if ( !isset( $info['review_author_name'] ) )
{
$author = \IPS\Member::load( $info['review_mid'] );
$author = Member::load( $info['review_mid'] );
$info['review_author_name'] = $author->name;
}
if ( isset( $info['review_date'] ) )
{
if ( $info['review_date'] instanceof \IPS\DateTime )
if ( $info['review_date'] instanceof DateTime )
{
$info['review_date'] = $info['review_date']->getTimestamp();
}
@@ -1387,7 +1409,7 @@ class _Downloads extends Core
if ( isset( $info['review_edit_time'] ) )
{
if ( $info['review_edit_time'] instanceof \IPS\DateTime )
if ( $info['review_edit_time'] instanceof DateTime )
{
$info['review_edit_time'] = $info['review_edit_time']->getTimestamp();
}
@@ -1409,13 +1431,13 @@ class _Downloads 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 )
{
@@ -1423,7 +1445,7 @@ class _Downloads extends Core
{
$memberId = $this->software->app->getLink( $member, 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
continue;
}
@@ -1432,7 +1454,7 @@ class _Downloads extends Core
}
}
if ( \count( $newVoters ) )
if ( count( $newVoters ) )
{
$info['review_votes_data'] = json_encode( $newVoters );
}
@@ -1448,19 +1470,19 @@ class _Downloads 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;
}
@@ -1492,7 +1514,7 @@ class _Downloads extends Core
$id = $info['review_id'];
unset( $info['review_id'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_reviews', $info );
$inserted_id = Db::i()->insert( 'downloads_reviews', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_reviews' );
return $inserted_id;
@@ -1520,7 +1542,7 @@ class _Downloads extends Core
$map['id3'] = NULL;
}
if ( \is_null( $map['id3'] ) OR $map['id3'] != 'review' )
if ( is_null( $map['id3'] ) OR $map['id3'] != 'review' )
{
$map['id2_type'] = 'downloads_comments';
}