Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -2,9 +2,9 @@
|
||||
|
||||
/**
|
||||
* @brief Converter Library Downloads Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package Invision Community
|
||||
* @subpackage Converter
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
@@ -116,7 +116,55 @@ class _Downloads extends Core
|
||||
'link_type' => 'downloads_reviews',
|
||||
);
|
||||
break;
|
||||
|
||||
|
||||
case 'convertClubDownloadsCategories':
|
||||
$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" ) )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertClubs' ),
|
||||
'link_type' => 'core_club_downloads_categories',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertClubDownloadsFiles':
|
||||
$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_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertClubDownloadsCategories' ),
|
||||
'link_type' => 'core_club_downloads_files'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertClubDownloadsComments':
|
||||
$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_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertClubDownloadsFiles' ),
|
||||
'link_type' => 'core_club_downloads_comments',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertClubDownloadsReviews':
|
||||
$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_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertClubDownloadsFiles' ),
|
||||
'link_type' => 'core_club_downloads_reviews',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$return[ $k ] = array(
|
||||
'step_method' => 'convertAttachments',
|
||||
@@ -183,6 +231,22 @@ class _Downloads extends Core
|
||||
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' ) );
|
||||
break;
|
||||
|
||||
case 'convertClubDownloadsCategories':
|
||||
$return['convertClubDownloadsCategories'] = array( 'downloads_categories' => array( "cclub_id IS NOT NULL" ) );
|
||||
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}" ) ) . ')' ) );
|
||||
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}" ) ) . ')' ) );
|
||||
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}" ) ) . ')' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,6 +669,23 @@ class _Downloads extends Core
|
||||
$info['ctopic_suffix'] = '';
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $info['cclub_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['cclub_id'] = $this->software->app->getLink( $info['cclub_id'], 'core_clubs', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['cclub_id'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['cclub_id'] = NULL;
|
||||
}
|
||||
|
||||
/* Can't know this */
|
||||
$info['clast_file_id'] = 0;
|
||||
$info['clast_file_date'] = 0;
|
||||
@@ -621,6 +702,18 @@ class _Downloads extends Core
|
||||
|
||||
\IPS\Db::i()->update( 'downloads_categories', array( "cparent" => $inserted_id ), array( "cconv_parent=? AND cconv_parent<>?", $id, 0 ) );
|
||||
|
||||
if ( $info['cclub_id'] )
|
||||
{
|
||||
\IPS\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'] ) );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
@@ -911,15 +1004,13 @@ class _Downloads extends Core
|
||||
|
||||
try
|
||||
{
|
||||
if ( !isset( $record['file_data'] ) OR is_null( $record['file_data'] ) )
|
||||
if ( !isset( $record['file_data'] ) )
|
||||
{
|
||||
$record['file_data'] = file_get_contents( $record['file_path'] );
|
||||
}
|
||||
|
||||
if ( $record['record_type'] != 'link' )
|
||||
{
|
||||
unset( $record['file_path'] );
|
||||
$record['file_data'] = NULL;
|
||||
}
|
||||
|
||||
/* We need the file storage to copy the file rather than move it */
|
||||
\IPS\File\FileSystem::$converterCopy = TRUE;
|
||||
|
||||
if ( $record['record_type'] == 'link' )
|
||||
{
|
||||
@@ -930,7 +1021,7 @@ class _Downloads extends Core
|
||||
}
|
||||
else if ( $record['record_type'] == 'upload' )
|
||||
{
|
||||
$file = \IPS\File::create( 'downloads_Files', $record['record_realname'], $record['file_data'] );
|
||||
$file = \IPS\File::create( 'downloads_Files', $record['record_realname'], $record['file_data'], NULL, TRUE, $record['file_path'] );
|
||||
$record['record_location'] = (string) $file;
|
||||
$record['record_size'] = $file->filesize();
|
||||
|
||||
@@ -941,7 +1032,7 @@ class _Downloads extends Core
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'] );
|
||||
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], NULL, TRUE, $record['file_path'] );
|
||||
$record['record_location'] = (string) $file;
|
||||
$record['record_thumb'] = (string) $file->thumbnail( 'downloads_Files' );
|
||||
$record['record_size'] = $file->filesize();
|
||||
@@ -957,8 +1048,10 @@ class _Downloads extends Core
|
||||
$this->software->app->log( $e->getMessage(), __METHOD__, \IPS\convert\App::LOG_WARNING, ( $hasId ) ? $record['record_id'] : NULL );
|
||||
continue;
|
||||
}
|
||||
|
||||
unset( $record['file_data'] );
|
||||
|
||||
/* Revert file system to default functionality */
|
||||
\IPS\File\FileSystem::$converterCopy = FALSE;
|
||||
unset( $record['file_data'], $file );
|
||||
|
||||
if ( isset( $record['record_time'] ) )
|
||||
{
|
||||
@@ -1358,4 +1451,69 @@ class _Downloads extends Core
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function convertClubDownloadsCategory( $info=array() )
|
||||
{
|
||||
$insertedId = $this->convertDownloadsCategory( $info );
|
||||
if ( $insertedId )
|
||||
{
|
||||
$this->software->app->addLink( $insertedId, $info['cid'], 'core_clubs_downloads_categories' );
|
||||
}
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Club Downloads File
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function convertClubDownloadsFile( $info=array(), $records=array() )
|
||||
{
|
||||
$insertedId = $this->convertDownloadsFile( $info, $records );
|
||||
if ( $insertedId )
|
||||
{
|
||||
$this->software->app->addLink( $insertedId, $info['file_id'], 'core_clubs_downloads_files' );
|
||||
}
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function convertClubDownloadsComment( $info=array() )
|
||||
{
|
||||
$insertedId = $this->convertDownloadsComment( $info );
|
||||
if ( $insertedId )
|
||||
{
|
||||
$this->software->app->addLink( $insertedId, $info['comment_id'], 'core_clubs_downloads_comments' );
|
||||
}
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function convertClubDownloadsReview( $info=array() )
|
||||
{
|
||||
$insertedId = $this->convertDownloadsReview( $info );
|
||||
if ( $insertedId )
|
||||
{
|
||||
$this->software->app->addLink( $insertedId, $info['review_id'], 'core_clubs_downloads_reviews' );
|
||||
}
|
||||
return $insertedId;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user