Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2012, 05:14 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL Query to bath upload paid subscribers

I am just wondering what would be the best way to mass upload a bunch of subscribed users to a forum. i dont want to chnage anything about the user since they are alreayd on the forum, but just upload paid subscription status.

I am moving away from the mod, a_w_c subscription system and want to use the default Vb subscription since that mod is no longer supported. Now I just want to move them over in mass via database instead of manually adding each users subscription. if should be pretty easy since the defualt vb subscription does not keep alot of the subscribers infor and I think there are only 2 tables i would need to populate: paymentinfo AND paymenttransaction

Is there another table I am missing? Also, i am not asking for an easy query that would do the migration in one click. I dont mind doing some manual work but can you help me make a query to create a subscription for: if I know USERNAME, DATE SUBSCRIBED, LENGTH? Would i need to add info like, what was previous usergroup or anything else?


Thanks!

--------------- Added [DATE]1328367056[/DATE] at [TIME]1328367056[/TIME] ---------------

i think i found the portion of the code that might have converted old vb data to the mod subsctioption data, maybe it can somehow be used:

Code:
$vbmodsubslog_sql = $vbulletin->db->query_read("
								SELECT sl.*, pi.subscriptionsubid 
								FROM `".TABLE_PREFIX."subscriptionlog` AS sl 
								LEFT JOIN `".TABLE_PREFIX."paymenttransaction` AS pt ON ( sl.regdate = pt.dateline AND pt.paymentinfoid <> 0 ) 
								LEFT JOIN `".TABLE_PREFIX."paymentinfo` AS pi ON ( pt.paymentinfoid = pi.paymentinfoid AND sl.userid = pi.userid )
							");
							
							if ( $vbulletin->db->num_rows( $vbmodsubslog_sql ) ){
								$time = time();
								while ( $vbmodsubslog = $vbulletin->db->fetch_array( $vbmodsubslog_sql ) ){
									
									if ( !empty( $vbulletin->options['ss_ns_sr_time'] ) && $vbmodsubslog['status'] ){
										$remindertime = strtotime( "-".$vbulletin->options['ss_ns_sr_time'], $vbmodsubslog['expirydate'] ); 
										
										if ( $remindertime < $time ){
											$remindertime = 0;
										}
									} else {
										$remindertime = 0;
									}
									
									if ( $termids[$vbmodsubslog['subscriptionid']][$vbmodsubslog['subscriptionsubid']] ){
										$termid = $termids[$vbmodsubslog['subscriptionid']][$vbmodsubslog['subscriptionsubid']];
									} else {
										$termid = 0;
									}
									$db_string = null; 
									$db_string = $BASE->compile_db_insert_string(
										array(
											'sid'			=> 'ss',
											'subid'			=> $vbmodsubslog['subscriptionid'],
											'termid'		=> $termid,
											'userid'		=> $vbmodsubslog['userid'],
											'active'		=> $vbmodsubslog['status'],
											'remindertime'	=> $remindertime,
											'stime'			=> $vbmodsubslog['regdate'],
											'etime'			=> $vbmodsubslog['expirydate']
										)
									); 
									
									$vbulletin->db->query_write("
										INSERT IGNORE INTO `".TABLE_PREFIX."awc_subscriptions_data` 
											(".$db_string['FIELD_NAMES'].") 
										VALUES 
											(".$db_string['FIELD_VALUES'].")
									");
								}
							}
							
							$vbmodtrans_sql = $vbulletin->db->query_read("
								SELECT pt.*, pi.*, pa.classname 
								FROM `".TABLE_PREFIX."paymenttransaction` AS pt 
								LEFT JOIN `".TABLE_PREFIX."paymentinfo` AS pi ON ( pt.paymentinfoid = pi.paymentinfoid ) 
								LEFT JOIN `".TABLE_PREFIX."paymentapi` AS pa ON ( pt.paymentapiid = pa.paymentapiid ) 
								WHERE pt.reversed <> 1 
								AND pt.paymentinfoid <> 0 
								AND pi.userid <> 0 
								AND pt.state = 1
							");
							
							if ( $vbulletin->db->num_rows( $vbmodtrans_sql ) ){
								while ( $vbmodtrans = $vbulletin->db->fetch_array( $vbmodtrans_sql ) ){
									$currency = strtoupper( $vbmodtrans['currency'] ); 
									
									if ( empty( $currency ) ){
										$currency = $vbulletin->options['awc_currency'];
									} 
									
									if ( empty( $vbmodtrans['classname'] ) ){
										$vbmodtrans['classname'] = 'imported';
									}
									
									if ( $termids[$vbmodtrans['subscriptionid']][$vbmodtrans['subscriptionsubid']] ){
										$termid = $termids[$vbmodtrans['subscriptionid']][$vbmodtrans['subscriptionsubid']];
									} else {
										$termid = 0;
									}
									$db_string = null; 
									$db_string = $BASE->compile_db_insert_string(
										array(
											'sid'				=> 'ss',
											'method'			=> $vbmodtrans['classname'],
											'anonymous'			=> 0,
											'disclose'			=> 1,
											'txn_id'			=> $vbmodtrans['transactionid'],
											'userid'			=> $vbmodtrans['userid'],
											'receiver_email'	=> $vbulletin->options['ss_paypal_email'],
											'item_number'		=> $termid,
											'payment_date'		=> $vbmodtrans['dateline'],
											'payment_status'	=> 'Completed',
											'mc_gross'			=> $vbmodtrans['amount'],
											'mc_fee'			=> 0,
											'mc_currency'		=> $currency
Attached Files
File Type: php ss.php (241.7 KB, 2 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:58 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07074 seconds
  • Memory Usage 2,188KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete