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 vBulletin 5.x Master 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
|
||||
*/
|
||||
@@ -70,6 +70,10 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'table' => 'user',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertMemberHistory' => array(
|
||||
'table' => 'userchangelog',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertIgnoredUsers' => array(
|
||||
'table' => 'userlist',
|
||||
'where' => array( "type=?", 'ignore' )
|
||||
@@ -85,6 +89,14 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'convertRanks' => array(
|
||||
'table' => 'usertitle',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertClubs' => array(
|
||||
'table' => 'node',
|
||||
'where' => 'clubs'
|
||||
),
|
||||
'convertClubMembers' => array(
|
||||
'table' => 'groupintopic',
|
||||
'where' => NULL
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -115,7 +127,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
case 'pm':
|
||||
try
|
||||
{
|
||||
$node = $this->db->select( 'nodeid', 'channel', array( "guid=?", 'vbulletin-4ecbdf567f3da8.31769341' ) )->first();
|
||||
$node = $this->db->select( 'nodeid', 'channel', array( "guid=?", static::$guids['private_messages'] ) )->first();
|
||||
|
||||
return $this->db->select( 'COUNT(*)', 'privatemessage', array( "privatemessage.msgtype=? AND node.parentid=?", 'message', $node ) )->join( 'node', 'privatemessage.nodeid = node.nodeid' )->first();
|
||||
}
|
||||
@@ -125,6 +137,28 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
}
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
if ( $where === 'clubs' )
|
||||
{
|
||||
return count( $this->fetchClubs() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'groupintopic':
|
||||
$clubs = array();
|
||||
foreach( $this->fetchClubs() AS $club )
|
||||
{
|
||||
$clubs[] = $club['nodeid'];
|
||||
}
|
||||
|
||||
$where = array( $this->db->in( 'nodeid', $clubs ) );
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
break;
|
||||
|
||||
default:
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
break;
|
||||
@@ -210,6 +244,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'convertProfileFields',
|
||||
'convertGroups',
|
||||
'convertMembers',
|
||||
'convertClubs'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -385,6 +420,24 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'convertClubs':
|
||||
$return['convertClubs'] = array();
|
||||
$return['convertClubs']['photo_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'database',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'file_system' ),
|
||||
),
|
||||
'userSuppliedInput' => 'file_system',
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
@@ -734,7 +787,6 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'g_bitoptions' => array(
|
||||
'gbw_promote_unit_type' => $gbw_promote_unit, // Type of group promotion to use. 1 is days since joining, 0 is content count. Corresponds to g_promotion
|
||||
'gbw_no_status_update' => !$checkpermission( 'visitormessagepermissions', 'canmessageownprofile' ), // Can NOT post status updates
|
||||
'gbw_soft_delete_own' => $checkpermission( 'forumpermissions', 'candeletepost' ), // Allow users of this group to hide their own submitted content
|
||||
'gbw_allow_upload_bgimage' => 1, // Can upload a cover photo?
|
||||
'gbw_view_reps' => $checkpermission( 'genericpermissions2', 'canprofilerep' ), // Can view who gave reputation?
|
||||
'gbw_no_status_import' => !$checkpermission( 'visitormessagepermissions', 'canmessageownprofile' ), // Can NOT import status updates from Facebook/Twitter
|
||||
@@ -743,6 +795,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'gbw_pm_override_inbox_full'=> $checkpermission( 'pmpermissions', 'canignorequota' ), // 1 means this group can send other members PMs even when that member's inbox is full
|
||||
'gbw_cannot_be_ignored' => ( ( $checkpermission( 'adminpermissions', 'ismoderator' ) OR $checkpermission( 'adminpermissions', 'cancontrolpanel' ) ) AND $this->_setting( 'ignoremods' ) ), // 1 means they cannot be ignored. 0 means they can
|
||||
),
|
||||
'g_hide_own_posts' => $checkpermission( 'forumpermissions', 'candeletepost' ),
|
||||
'g_pm_flood_mins' => $this->_setting( 'pmfloodtime' ) / 60,
|
||||
'g_post_polls' => $checkpermission( 'forumpermissions', 'canpostpoll' ) ? 1 : 0,
|
||||
'g_vote_polls' => $checkpermission( 'forumpermissions', 'canvote' ) ? 1 : 0,
|
||||
@@ -755,6 +808,82 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
|
||||
$libraryClass->setLastKeyValue( $group['usergroupid'] );
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
$libraryClass->convertGroupPromotion( $groupPromotion );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Member history type map
|
||||
*/
|
||||
protected $changeLogTypes = array( 'username' => 'display_name', 'email' => 'email_change', 'usergroupid' => 'member_group_id', 'membergroupids' => 'mgroup_others' );
|
||||
|
||||
/**
|
||||
* Convert member history
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertMemberHistory()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'changeid' );
|
||||
|
||||
$fixGroups = function( $string )
|
||||
{
|
||||
$groups = explode( ',', $string );
|
||||
$newGroups = array();
|
||||
|
||||
array_walk( $groups, function( &$item, $key ) use ( &$newGroups )
|
||||
{
|
||||
try
|
||||
{
|
||||
$item = $this->app->getLink( $item, 'core_groups' );
|
||||
$newGroups[] = $item;
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
});
|
||||
|
||||
return implode( ',', $newGroups );
|
||||
};
|
||||
|
||||
foreach( $this->fetch( 'userchangelog', 'changeid' ) AS $change )
|
||||
{
|
||||
if( !in_array( $change['fieldname'], array_keys( $this->changeLogTypes ) ) )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $change['changeid'] );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Any processing we need to do */
|
||||
switch( $this->changeLogTypes[ $change['fieldname'] ] )
|
||||
{
|
||||
case 'member_group_id':
|
||||
case 'mgroup_others':
|
||||
$change['oldvalue'] = $fixGroups( $change['oldvalue'] );
|
||||
$change['newvalue'] = $fixGroups( $change['newvalue'] );
|
||||
break;
|
||||
}
|
||||
|
||||
$libraryClass->convertMemberHistory( array(
|
||||
'log_id' => $change['changeid'],
|
||||
'log_member' => $change['userid'],
|
||||
'log_by' => $change['adminid'],
|
||||
'log_type' => $this->changeLogTypes[ $change['fieldname'] ],
|
||||
'log_data' => array( 'old' => $change['oldvalue'], 'new' => $change['newvalue'] ),
|
||||
'log_date' => $change['change_time'],
|
||||
'log_ip_address' => long2ip( $change['ipaddress'] )
|
||||
)
|
||||
);
|
||||
|
||||
$libraryClass->setLastKeyValue( $change['changeid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -894,6 +1023,8 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'allow_admin_mails' => $checkpermission( 'useroptions', 'adminemail' ),
|
||||
'members_disable_pm' => !$checkpermission( 'useroptions', 'receivepm' ),
|
||||
'member_posts' => $user['posts'],
|
||||
'fb_uid' => $user['fbuserid'],
|
||||
'fb_token' => $user['fbaccesstoken']
|
||||
);
|
||||
|
||||
/* Profile Fields */
|
||||
@@ -1076,7 +1207,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
continue;
|
||||
}
|
||||
|
||||
$libraryClass->convertWarnLog( array(
|
||||
$warnId = $libraryClass->convertWarnLog( array(
|
||||
'wl_id' => $warn['nodeid'],
|
||||
'wl_member' => $warn['infracteduserid'],
|
||||
'wl_moderator' => $node['userid'],
|
||||
@@ -1085,6 +1216,17 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'wl_note_member' => $node['description'],
|
||||
'wl_note_mods' => $warn['customreason'],
|
||||
) );
|
||||
|
||||
/* Add a member history record for this member */
|
||||
$libraryClass->convertMemberHistory( array(
|
||||
'log_id' => 'w' . $warn['nodeid'],
|
||||
'log_member' => $warn['infracteduserid'],
|
||||
'log_by' => $warn['userid'],
|
||||
'log_type' => 'warning',
|
||||
'log_data' => array( 'wid' => $warnId ),
|
||||
'log_date' => $warn['actiondateline']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $user['userid'] );
|
||||
@@ -1283,6 +1425,125 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert clubs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertClubs()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'nodeid' );
|
||||
|
||||
try
|
||||
{
|
||||
$mainNodeId = $this->db->select( 'nodeid', 'channel', array( "guid=?", static::$guids['clubs'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* shrug */
|
||||
throw new \IPS\convert\Software\Exception;
|
||||
}
|
||||
|
||||
$categories = array();
|
||||
foreach( $this->db->select( 'nodeid', 'node', array( "parentid=?", $mainNodeId ) ) AS $cat )
|
||||
{
|
||||
$categories[] = $cat;
|
||||
}
|
||||
|
||||
$checktype = function( $nodeoptions ) {
|
||||
if ( $nodeoptions & 8 )
|
||||
{
|
||||
return 'public';
|
||||
}
|
||||
else if ( $nodeoptions & 16 )
|
||||
{
|
||||
return 'private';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'closed';
|
||||
}
|
||||
};
|
||||
|
||||
foreach( $this->fetch( 'node', 'nodeid', array( $this->db->in( 'parentid', $categories ) ) ) AS $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
$channel = $this->db->select( '*', 'channel', array( "nodeid=?", $row['nodeid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$channel = array( 'filedataid' => 0 );
|
||||
}
|
||||
|
||||
$filedata = NULL;
|
||||
if ( $channel['filedataid'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$filedata = $this->db->select( '*', 'filedata', array( "filedataid=?", $channel['filedataid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'club_id' => $row['nodeid'],
|
||||
'name' => $row['title'],
|
||||
'type' => $checktype( $row['nodeoptions'] ),
|
||||
'created' => $row['publishdate'],
|
||||
'members' => $this->db->select( 'COUNT(*)', 'groupintopic', array( "nodeid=?", $row['nodeid'] ) )->first(),
|
||||
'owner' => $row['userid'],
|
||||
'profile_photo' => ( $filedata ) ? "club{$row['nodeid']}.{$filedata['extension']}" : NULL,
|
||||
'featured' => $row['sticky'], # I don't know if you can actually pin social groups, but the columns there so... may as well
|
||||
'about' => $row['description'],
|
||||
'last_activity' => $row['lastupdate'],
|
||||
);
|
||||
|
||||
$icondata = NULL;
|
||||
$iconpath = NULL;
|
||||
if ( $filedata )
|
||||
{
|
||||
if ( $this->app->_session['more_info']['convertClubs']['photo_location'] == 'database' )
|
||||
{
|
||||
$icondata = $filedata['filedata'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$folder = preg_split( '//', $filedata['userid'], NULL, PREG_SPLIT_NO_EMPTY );
|
||||
$folder = implode( '/', $folder );
|
||||
$iconpath = $this->app->_session['more_info']['convertClubs']['photo_location'] . '/' . $folder . '/' . $filedata['filedataid'] . '.attach';
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->convertClub( $info, $iconpath, $icondata );
|
||||
$libraryClass->setLastKeyValue( $row['nodeid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Club Members
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertClubMembers()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$clubs = array();
|
||||
foreach( $this->fetchClubs() AS $club )
|
||||
{
|
||||
$clubs[ $club['nodeid'] ] = $club['userid'];
|
||||
}
|
||||
foreach( $this->fetch( 'groupintopic', 'nodeid', array( $this->db->in( 'nodeid', array_keys( $clubs ) ) ) ) AS $row )
|
||||
{
|
||||
$libraryClass->convertClubMember( array(
|
||||
'club_id' => $row['nodeid'],
|
||||
'member_id' => $row['userid'],
|
||||
'status' => ( $row['userid'] == $clubs[ $row['nodeid'] ] ) ? 'leader' : 'member',
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* !vBulletin Specific Stuff */
|
||||
/**
|
||||
* @brief Silly Bit Options for Groups. Typically we would leave out app specific options (such as Forums here) however we need them for some general permissions, like uploading.
|
||||
@@ -1522,6 +1783,46 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
return $forums;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Channel GUID Mappins.
|
||||
* @note As far as I can tell, these are static and not unique per installation. Only the ones that are used are present.
|
||||
*/
|
||||
public static $guids = array(
|
||||
'clubs' => 'vbulletin-4ecbdf567f3a38.99555306',
|
||||
'private_messages' => 'vbulletin-4ecbdf567f3da8.31769341'
|
||||
);
|
||||
|
||||
/**
|
||||
* Fetch Clubs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchClubs()
|
||||
{
|
||||
$clubs = array();
|
||||
|
||||
try
|
||||
{
|
||||
/* Get the main social group node ID from the channel GUID. */
|
||||
$mainNodeId = $this->db->select( 'nodeid', 'channel', array( "guid=?", static::$guids['clubs'] ) )->first();
|
||||
|
||||
$categories = array();
|
||||
foreach( $this->db->select( 'nodeid', 'node', array( "parentid=?", $mainNodeId ) ) AS $cat )
|
||||
{
|
||||
$categories[] = $cat;
|
||||
}
|
||||
|
||||
/* The actual clubs are all two levels deep from the main channel node, so we need to sub-query the categories. */
|
||||
foreach( $this->db->select( '*', 'node', array( $this->db->in( 'parentid', $categories ) ) ) AS $row )
|
||||
{
|
||||
$clubs[ $row['nodeid'] ] = $row;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) { /* Just in case something goofy happened and there is no main channel */ }
|
||||
|
||||
return $clubs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Types Cache
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user