View Single Post
  #58  
Old 01-19-2009, 11:03 PM
Bradley_Wint Bradley_Wint is offline
 
Join Date: Jul 2007
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, with that note, I guess I'll post it here.

So after taking a look at both mods, I think that sharing the db information is the way to link the two. However, each mod writes entries into separate tables in the vB database. This mod adds information to the user table and the gXboxLive uses the userfield table.

Since this is a much smaller mod, I think it would be best to mod this since it's only one file of code, rather than over 10 different files for gXboxLive. With the gXboxLive, they ask you to make a new field (lets say your field id is 5). In the MySQL backend, the userfield will have a record called field5, where the gXboxLive usernames will be stored for each individual user.

My theory is, set up your gXboxLive mod first, get the code (once again we use 5). Now in this mod, there is a bit of MySQL you need to change.

Code:
		<code>
			<installcode><![CDATA[
			if (!field_exists('user', 'gf_xbox', 'gf_wii', 'gf_playstation'))
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user ADD gf_xbox VARCHAR( 15 ) AFTER msn");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user ADD gf_wii VARCHAR( 19 ) AFTER msn");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user ADD gf_playstation VARCHAR( 16 ) AFTER msn");
			function field_exists($table, $field)
			{
				global $db;
				return ($db->num_rows($db->query_read("SHOW COLUMNS FROM `" . TABLE_PREFIX .$table."` LIKE '".$field."'"))> 0);
			}
			]]></installcode>

			<uninstallcode><![CDATA[$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP gf_xbox");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP gf_wii");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP gf_playstation");]]></uninstallcode>
		</code>
Now you will want to change it to something like this
Code:
		<code>
			<installcode><![CDATA[
			if (!field_exists('userfield', 'field5', 'field6', 'field7'))
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield ADD field5 VARCHAR( 15 ) AFTER field4");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield ADD field6 VARCHAR( 19 ) AFTER field4");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield ADD field7 VARCHAR( 16 ) AFTER field4");
			function field_exists($table, $field)
			{
				global $db;
				return ($db->num_rows($db->query_read("SHOW COLUMNS FROM `" . TABLE_PREFIX .$table."` LIKE '".$field."'"))> 0);
			}
			]]></installcode>

			<uninstallcode><![CDATA[$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield DROP gf_xbox");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield DROP field6");
			$db->query_write("ALTER TABLE " . TABLE_PREFIX . "userfield DROP field7");]]></uninstallcode>
		</code>
Basically I am replacing the variables.

user > userfield
gf_xbox > field5
gf_wii > field6
gf_playstation > field7

Please not these field numbers may vary depending on the number of fields you already have. So say you assigned field20 to gXboxLive, gf_xbox would be field21, gf_wii would be field22 and gf_playstation would be field23.

The excerpt above deals with only the initial set up of the tables and what not. I just highlighted that portion since it sets the stage for the entire code to function properly. Continue reading.

Now the confusing bit starts, because I didn't have time to sit down and figure what exactly was a MySQL function or a template function, even though I could pretty much tell by looking (just lazy to go through all honestly). So if you want to take the chance, remember what you assigned the initial MySQL entries as.

e.g.
user > userfield
gf_xbox > field5
gf_wii > field6
gf_playstation > field7

Now, basically it's about going into an editor and replacing all the variables in the XML document. Basically your MySQL entries will be renamed and aligned with the userfield data, so new data will be recorded there instead. However, your templates will also be renamed (e.g. field5_live_gamertag). So if you are prepared to remember how you assigned them, then in theory this should work. I haven't tested it out yet since I didn't get the time, but I think this is basic math here since the author wrote his code pretty straightforward, and replacing the vars shouldn't be a big issue, once it's done it unison.

However, please BACK UP YOUR DATABASE first before trying anything.

Then, install gXboxLive and then install this code. Im guessing if you had gXboxLive already installed, no biggie either.

I would pray that they both work simultaneously.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02015 seconds
  • Memory Usage 1,792KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete