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\Software\Core;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* PhpBB Core Converter
|
||||
*/
|
||||
class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -101,17 +104,20 @@ class _Phpbb extends \IPS\convert\Software
|
||||
/**
|
||||
* Allows software to add additional menu row options
|
||||
*
|
||||
* @param array $rows Existing rows
|
||||
* @return array
|
||||
*/
|
||||
public function extraMenuRows( $rows )
|
||||
public function extraMenuRows()
|
||||
{
|
||||
if( isset( $rows['convertBanfilters'] ) )
|
||||
{
|
||||
$rows['convertBanfilters2'] = $rows['convertBanfilters'];
|
||||
$rows['convertBanfilters2']['step_method'] = 'convertBanfilters2';
|
||||
$rows['convertBanfilters2']['source_rows'] = array( 'table' => static::canConvert()['convertBanfilters2']['table'], 'where' => static::canConvert()['convertBanfilters2']['where'] );
|
||||
}
|
||||
$rows = array();
|
||||
$rows['convertBanfilters2'] = array(
|
||||
'step_title' => 'convert_banfilters',
|
||||
'step_method' => 'convertBanfilters2',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_banfilters' ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertBanfilters2']['table'], 'where' => static::canConvert()['convertBanfilters2']['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBanfilters' ),
|
||||
'link_type' => 'core_banfilters'
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
@@ -131,9 +137,16 @@ class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
case 'banfilters':
|
||||
case 'disallow':
|
||||
$count = 0;
|
||||
$count += $this->db->select( 'COUNT(*)', 'banlist', array( "ban_userid=?", 0 ) )->first();
|
||||
$count += $this->db->select( 'COUNT(*)', 'disallow' )->first();
|
||||
try
|
||||
{
|
||||
$count = 0;
|
||||
$count += $this->db->select( 'COUNT(*)', 'banlist', array( "ban_userid=?", 0 ) )->first();
|
||||
$count += $this->db->select( 'COUNT(*)', 'disallow' )->first();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
return $count;
|
||||
break;
|
||||
|
||||
@@ -261,15 +274,28 @@ class _Phpbb extends \IPS\convert\Software
|
||||
|
||||
case 'convertMembers':
|
||||
$return['convertMembers'] = array();
|
||||
|
||||
/* We can only retain one type of photo */
|
||||
$return['convertMembers']['photo_hash'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_phpbb_randstring'),
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
/* Try to auto detect the salt */
|
||||
$salt = $this->db->select( 'config_value', 'config', array( 'config_name=?', 'avatar_salt' ) )->first();
|
||||
|
||||
if( empty( $salt ) )
|
||||
{
|
||||
throw new \UnderflowException();
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* We can only retain one type of photo */
|
||||
$return['convertMembers']['photo_hash'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_phpbb_randstring'),
|
||||
);
|
||||
}
|
||||
|
||||
/* Find out where the photos live */
|
||||
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
|
||||
@@ -353,8 +379,8 @@ class _Phpbb extends \IPS\convert\Software
|
||||
/**
|
||||
* Fix post data
|
||||
*
|
||||
* @param string raw post data
|
||||
* @return string parsed post data
|
||||
* @param string $post Raw post data
|
||||
* @return string Parsed post data
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
@@ -524,7 +550,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
'pf_type' => $type,
|
||||
'pf_content' => $default,
|
||||
'pf_not_null' => $row['field_required'],
|
||||
'pf_member_hide' => $row['field_hide'],
|
||||
'pf_member_hide' => $row['field_hide'] ? 'hide' : 'all',
|
||||
'pf_max_input' => ( $field_type == 'dropdown' ) ? NULL : $row['field_maxlen'], # ignore this for selects
|
||||
'pf_member_edit' => $row['field_active'],
|
||||
'pf_position' => $row['field_order'],
|
||||
@@ -579,7 +605,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -596,8 +622,22 @@ class _Phpbb extends \IPS\convert\Software
|
||||
public function convertMembers()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'user_id' );
|
||||
|
||||
try
|
||||
{
|
||||
/* Try to auto detect the salt */
|
||||
$avatarSalt = $this->db->select( 'config_value', 'config', array( 'config_name=?', 'avatar_salt' ) )->first();
|
||||
|
||||
if( empty( $avatarSalt ) )
|
||||
{
|
||||
throw new \UnderflowException();
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$avatarSalt = rtrim( $this->app->_session['more_info']['convertMembers']['photo_hash'], '_' );
|
||||
}
|
||||
|
||||
foreach( $this->fetch( 'users', 'user_id', array( "user_type<>?", 2 ) ) AS $row )
|
||||
{
|
||||
@@ -694,7 +734,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
if ( $row['user_avatar_type'] )
|
||||
{
|
||||
/* Is it numeric? Apparently phpBB doesn't clean up after itself. */
|
||||
if ( is_numeric( $row['user_avatar_type'] ) )
|
||||
if ( \is_numeric( $row['user_avatar_type'] ) )
|
||||
{
|
||||
switch( $row['user_avatar_type'] )
|
||||
{
|
||||
@@ -718,12 +758,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
$fileext = explode( '.', $row['user_avatar'] );
|
||||
$fileext = array_pop( $fileext );
|
||||
$filepath = $this->app->_session['more_info']['convertMembers']['photo_location'];
|
||||
$filename = $this->app->_session['more_info']['convertMembers']['photo_hash'] . '_' . $row['user_id'] . '.' . $fileext;
|
||||
break;
|
||||
|
||||
case 'avatar.driver.gravatar':
|
||||
$info['pp_photo_type'] = 'gravatar';
|
||||
$info['pp_gravatar'] = $row['user_avatar'];
|
||||
$filename = $avatarSalt . '_' . $row['user_id'] . '.' . $fileext;
|
||||
break;
|
||||
|
||||
case 'avatar.driver.remote':
|
||||
@@ -772,7 +807,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
|
||||
/* PM Folders */
|
||||
$pmFolders = iterator_to_array( $this->db->select( 'folder_name', 'privmsgs_folder', array( 'user_id=?', $row['user_id'] ) ) );
|
||||
$info['pconversation_filters'] = count( $pmFolders ) ? $pmFolders : NULL;
|
||||
$info['pconversation_filters'] = \count( $pmFolders ) ? $pmFolders : NULL;
|
||||
|
||||
/* Finally */
|
||||
$libraryClass->convertMember( $info, $pfields, $filename, $filepath );
|
||||
@@ -782,7 +817,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'core',
|
||||
'follow_area' => 'members',
|
||||
'follow_area' => 'member',
|
||||
'follow_rel_id' => $follower['zebra_id'],
|
||||
'follow_rel_id_type' => 'core_members',
|
||||
'follow_member_id' => $follower['user_id'],
|
||||
@@ -930,7 +965,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* If Type is null - skip */
|
||||
if ( is_null( $type ) )
|
||||
if ( \is_null( $type ) )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $row['ban_id'] );
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user