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,21 +5,26 @@
|
||||
* @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\Software\Downloads;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Xenforo Downloads Converter
|
||||
*/
|
||||
class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
use \IPS\convert\Tools\Xenforo;
|
||||
|
||||
/**
|
||||
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
|
||||
*/
|
||||
@@ -30,11 +35,16 @@ class _Xenforo extends \IPS\convert\Software
|
||||
*/
|
||||
public static $tablePrefix = '';
|
||||
|
||||
/**
|
||||
* @brief XF2.1 changed serialized data to json decoded
|
||||
*/
|
||||
public static $useJson = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -49,7 +59,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Is this XF1 or XF2 */
|
||||
if ( static::$isLegacy === NULL )
|
||||
{
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( "addon_id=?", 'XF' ) )->first();
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( \IPS\Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
|
||||
|
||||
if ( $version < 2000010 )
|
||||
{
|
||||
@@ -59,6 +69,12 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
static::$tablePrefix = 'rm_';
|
||||
static::$isLegacy = FALSE;
|
||||
|
||||
/* Is this XF 2.1 */
|
||||
if ( $version > 2010010 )
|
||||
{
|
||||
static::$useJson = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +92,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "XenForo Resource Manager (1.5.x/2.0.x)";
|
||||
return "XenForo Resource Manager (1.5.x/2.0.x/2.1.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +257,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
$title = ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
$title = ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
@@ -275,12 +291,12 @@ class _Xenforo extends \IPS\convert\Software
|
||||
$info = array(
|
||||
'cf_id' => $row['field_id'],
|
||||
'cf_type' => $this->_mapFieldType( $row['field_type'], $row['match_type'] ),
|
||||
'cf_content' => static::$isLegacy ? \unserialize( $row['field_choices'] ) : json_decode( $row['field_choices'], TRUE ),
|
||||
'cf_content' => static::unpack( $row['field_choices'] ),
|
||||
'cf_not_null' => $row['required'],
|
||||
'cf_max_input' => $row['max_length'],
|
||||
'cf_input_format' => $inputFormat,
|
||||
'cf_position' => $row['display_order'],
|
||||
'cf_multiple' => ( in_array( $row['field_type'], array( 'checkbox', 'multiselect' ) ) ) ? 1 : 0
|
||||
'cf_multiple' => ( \in_array( $row['field_type'], array( 'checkbox', 'multiselect' ) ) ) ? 1 : 0
|
||||
);
|
||||
|
||||
$libraryClass->convertDownloadsCfield( $info );
|
||||
@@ -290,6 +306,8 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/**
|
||||
* Map the field types
|
||||
*
|
||||
* @param string $type Custom field type
|
||||
* @param string $match Match type
|
||||
* @return void
|
||||
*/
|
||||
protected function _mapFieldType( $type, $match )
|
||||
@@ -363,7 +381,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$prefix = $this->getPhrase( "thread_prefix_{$row['thread_prefix_id']}", "thread_prefix.{$row['thread_prefix_id']}" );
|
||||
|
||||
if ( is_null( $prefix ) )
|
||||
if ( \is_null( $prefix ) )
|
||||
{
|
||||
$prefix = '';
|
||||
}
|
||||
@@ -516,7 +534,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$field_type = $this->db->select( 'field_type', 'xf_' . static::$tablePrefix . 'resource_field', array( "field_id=?", $key ) )->first();
|
||||
|
||||
if ( in_array( $field_type, array( 'checkbox', 'multiselect' ) ) )
|
||||
if ( \in_array( $field_type, array( 'checkbox', 'multiselect' ) ) )
|
||||
{
|
||||
$cfields[$key] = static::$isLegacy ? json_encode( \unserialize( $value ) ) : $value;
|
||||
}
|
||||
@@ -526,7 +544,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->convertDownloadsFile( $info, $records, $cfields );
|
||||
$id = $libraryClass->convertDownloadsFile( $info, $records, $cfields );
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( '*', 'xf_' . static::$tablePrefix . 'resource_watch', array( "resource_id=?", $row['resource_id'] ) ) AS $follow )
|
||||
@@ -546,6 +564,23 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'follow_visible' => 1
|
||||
) );
|
||||
}
|
||||
|
||||
if( static::$useJson AND $id )
|
||||
{
|
||||
foreach( $this->db->select( '*', 'xf_reaction_content', array( "content_type=? AND content_id=?", 'resource_update', $row['resource_id'] ) ) as $reaction )
|
||||
{
|
||||
$libraryClass->convertReputation( array(
|
||||
'id' => $reaction['reaction_content_id'],
|
||||
'app' => 'downloads',
|
||||
'type' => 'file_id',
|
||||
'type_id' => $row['resource_id'],
|
||||
'member_id' => $reaction['reaction_user_id'],
|
||||
'member_received' => $row['user_id'],
|
||||
'reaction' => $reaction['reaction_id'],
|
||||
'rep_date' => $reaction['reaction_date']
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['resource_id'] );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user