Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -5,19 +5,22 @@
|
||||
* @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 Downloads Converter
|
||||
*/
|
||||
class _Downloads extends Core
|
||||
{
|
||||
/**
|
||||
@@ -34,6 +37,7 @@ class _Downloads extends Core
|
||||
public function menuRows( $rowCounts=FALSE )
|
||||
{
|
||||
$return = array();
|
||||
$extraRows = $this->software->extraMenuRows();
|
||||
|
||||
foreach( $this->getConvertableItems() as $k => $v )
|
||||
{
|
||||
@@ -45,7 +49,7 @@ class _Downloads extends Core
|
||||
'step_title' => 'convert_downloads_cfields',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_cfields' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'downloads_cfields',
|
||||
);
|
||||
@@ -64,7 +68,7 @@ class _Downloads extends Core
|
||||
'step_title' => 'convert_downloads_categories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_categories' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'downloads_categories',
|
||||
);
|
||||
@@ -87,7 +91,7 @@ class _Downloads extends Core
|
||||
'step_title' => 'convert_downloads_files',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 250,
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'downloads_files',
|
||||
'requires_rebuild' => TRUE
|
||||
@@ -100,7 +104,7 @@ class _Downloads extends Core
|
||||
'step_title' => 'convert_downloads_comments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_comments' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertDownloadsFiles' ),
|
||||
'link_type' => 'downloads_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
@@ -113,7 +117,7 @@ class _Downloads extends Core
|
||||
'step_title' => 'convert_downloads_reviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_reviews' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertDownloadsFiles' ),
|
||||
'link_type' => 'downloads_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
@@ -126,7 +130,7 @@ class _Downloads extends Core
|
||||
'step_method' => 'convertClubDownloadsCategories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubs' ),
|
||||
'link_type' => 'core_club_downloads_categories',
|
||||
);
|
||||
@@ -138,7 +142,7 @@ class _Downloads extends Core
|
||||
'step_method' => 'convertClubDownloadsFiles',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files', array( \IPS\Db::i()->in( 'file_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertClubDownloadsCategories' ),
|
||||
'link_type' => 'core_club_downloads_files'
|
||||
);
|
||||
@@ -150,7 +154,7 @@ class _Downloads extends Core
|
||||
'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_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubDownloadsFiles' ),
|
||||
'link_type' => 'core_club_downloads_comments',
|
||||
);
|
||||
@@ -162,27 +166,46 @@ class _Downloads extends Core
|
||||
'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_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubDownloadsFiles' ),
|
||||
'link_type' => 'core_club_downloads_reviews',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$dependencies = array( 'convertDownloadsFiles' );
|
||||
|
||||
if ( array_key_exists( 'convertDownloadsComments', $this->getConvertableItems() ) )
|
||||
{
|
||||
$dependencies[] = 'convertDownloadsComments';
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'convertDownloadsReviews', $this->getConvertableItems() ) )
|
||||
{
|
||||
$dependencies[] = 'convertDownloadsReviews';
|
||||
}
|
||||
|
||||
$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' ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertDownloadsFiles', 'convertDownloadsComments', 'convertDownloadsReviews' ),
|
||||
'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 )
|
||||
@@ -196,12 +219,13 @@ class _Downloads 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 )
|
||||
{
|
||||
@@ -231,7 +255,8 @@ class _Downloads extends Core
|
||||
$return['convertDownloadsFiles'] = array(
|
||||
'downloads_files' => NULL,
|
||||
'downloads_files_records' => NULL,
|
||||
'core_tags' => array( 'tag_meta_app=? AND tag_meta_area=?', 'downloads', 'downloads' )
|
||||
'core_tags' => array( 'tag_meta_app=? AND tag_meta_area=?', 'downloads', 'downloads' ),
|
||||
'core_reputation_index' => array( 'app=? AND type=?', 'downloads', 'file_id' ),
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -298,7 +323,7 @@ class _Downloads extends Core
|
||||
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'] );
|
||||
return FALSE;
|
||||
@@ -306,7 +331,7 @@ class _Downloads extends Core
|
||||
|
||||
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'] );
|
||||
}
|
||||
@@ -430,7 +455,7 @@ class _Downloads extends Core
|
||||
|
||||
if ( $info['cf_type'] != 'Upload' )
|
||||
{
|
||||
if ( $columnDefinition['type'] == 'TEXT' )
|
||||
if ( \in_array( $columnDefinition['type'], [ 'TEXT', 'MEDIUMTEXT' ] ) )
|
||||
{
|
||||
\IPS\Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'fulltext', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
|
||||
}
|
||||
@@ -454,7 +479,7 @@ class _Downloads extends Core
|
||||
{
|
||||
$return = array( 'file_id' => $file_id );
|
||||
|
||||
if ( count( $fieldInfo ) )
|
||||
if ( \count( $fieldInfo ) )
|
||||
{
|
||||
foreach( $fieldInfo as $key => $value )
|
||||
{
|
||||
@@ -549,13 +574,13 @@ class _Downloads extends Core
|
||||
|
||||
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 )
|
||||
{
|
||||
@@ -570,7 +595,7 @@ class _Downloads extends Core
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $newCfields ) )
|
||||
if ( \count( $newCfields ) )
|
||||
{
|
||||
$info['ccfields'] = implode( ',', $newCfields );
|
||||
}
|
||||
@@ -611,7 +636,7 @@ class _Downloads extends Core
|
||||
|
||||
if ( isset( $info['ctypes'] ) )
|
||||
{
|
||||
if ( is_array( $info['ctypes'] ) )
|
||||
if ( \is_array( $info['ctypes'] ) )
|
||||
{
|
||||
$info['ctypes'] = implode( ',', $info['ctypes'] );
|
||||
}
|
||||
@@ -621,7 +646,7 @@ class _Downloads extends Core
|
||||
$info['ctypes'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['csortorder'] ) OR !in_array( $info['csortoder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
|
||||
if ( !isset( $info['csortorder'] ) OR !\in_array( $info['csortoder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
|
||||
{
|
||||
$info['csortorder'] = 'updated';
|
||||
}
|
||||
@@ -638,7 +663,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'] );
|
||||
}
|
||||
@@ -714,7 +739,7 @@ class _Downloads extends Core
|
||||
\IPS\Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}", $name );
|
||||
\IPS\Lang::saveCustom( 'downloads', "downloads_category_{$inserted_id}_desc", $desc );
|
||||
|
||||
\IPS\Db::i()->update( 'downloads_categories', array( "cparent" => $inserted_id ), array( "cconv_parent=? AND cconv_parent<>?", $id, 0 ) );
|
||||
\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' => '' ) );
|
||||
|
||||
if ( $info['cclub_id'] )
|
||||
@@ -748,7 +773,7 @@ class _Downloads extends Core
|
||||
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'] );
|
||||
return FALSE;
|
||||
@@ -968,6 +993,33 @@ class _Downloads extends Core
|
||||
{
|
||||
$info['file_last_review'] = $info['file_submitted'];
|
||||
}
|
||||
|
||||
if ( isset( $info['file_edit_time'] ) )
|
||||
{
|
||||
if ( $info['file_edit_time'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['file_edit_time'] = $info['file_edit_time']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['file_edit_time'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['file_edit_name'] ) )
|
||||
{
|
||||
$info['file_edit_name'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['file_edit_reason'] ) )
|
||||
{
|
||||
$info['file_edit_reason'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $info['file_append_edit'] ) )
|
||||
{
|
||||
$info['file_append_edit'] = 0;
|
||||
}
|
||||
|
||||
$id = $info['file_id'];
|
||||
unset( $info['file_id'] );
|
||||
@@ -992,7 +1044,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';
|
||||
}
|
||||
@@ -1009,7 +1061,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 );
|
||||
@@ -1343,13 +1395,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 )
|
||||
{
|
||||
@@ -1366,7 +1418,7 @@ class _Downloads extends Core
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $newVoters ) )
|
||||
if ( \count( $newVoters ) )
|
||||
{
|
||||
$info['review_votes_data'] = json_encode( $newVoters );
|
||||
}
|
||||
@@ -1382,19 +1434,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;
|
||||
}
|
||||
@@ -1439,6 +1491,7 @@ class _Downloads extends Core
|
||||
* @param array $map Map Data to insert
|
||||
* @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.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
|
||||
@@ -1453,7 +1506,7 @@ class _Downloads 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'] = 'downloads_comments';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user