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 10-05-2004, 02:23 PM
hkvic hkvic is offline
 
Join Date: Oct 2004
Location: Sussex UK
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom user fields

First off - sorry if cross posting is frowned on, but was advised to post this here after posting in the community forums...Anyway original post was:

I have just purchased VB after being with ikonboard for quite a while. I am going to be importing my old ikonboard 3.11 Mysql database which contains approx 2000 users and around 70,000 posts.

This database has been hacked over a period of time with custom additions. The main one that concerns me is that I have added 7 custom rows in the ib_member_profiles table which contain first and last member names, dates and other data.

My question is: is there any way to adapt the impex files so that I can import this additional data? If not, then I guess I'll have to enter all the details again by hand.

Any help or advice would be appreciated.

PS. wish I'd made this move years ago - I wouldn't be going through all this now.
Reply With Quote
  #2  
Old 10-05-2004, 04:00 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it shouldn't be such a problem to manipulate the impex to import those things as well.

As it is a very custom request, you might have to post a service request, but AFAICS it shouldn't be very hard, just a few more lines
Reply With Quote
  #3  
Old 10-05-2004, 05:11 PM
hkvic hkvic is offline
 
Join Date: Oct 2004
Location: Sussex UK
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Many thanks for that. Should I leave this here a while to see if there are any other responses or should I post a service request straight away?

I've only joined recently and am not really up to speed on the protocols here yet.
Reply With Quote
  #4  
Old 10-05-2004, 05:18 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're free to post a service request. Be aware though, that service requests are payed requests, so only post if you're willing to compensate the coder willing to help you. Also, have a look at the following thread before picking a coder: https://vborg.vbsupport.ru/showthread.php?t=69734

Unfortunatelly, I don't know impex well enough to help you.

Good luck though
Reply With Quote
  #5  
Old 10-05-2004, 05:50 PM
hkvic hkvic is offline
 
Join Date: Oct 2004
Location: Sussex UK
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cheers. I'll give it some serious consideration.
Reply With Quote
  #6  
Old 10-06-2004, 09:58 AM
Jerry's Avatar
Jerry Jerry is offline
 
Join Date: Jun 2003
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Two things we are going to be interested in here to get this done are :

The files ;

impex/systems/ikon_mysql/000.php The API module for the data source
impex/systems/ikon_mysql/004.php The import user module

The commands ;

add_custom_field()
add_custom_value()


Checking we are getting the data

First we need know that ImpEx is bring the data in when it imports users.

The extra fields are in the member_profiles table (ignoring the table prefix for this example).

Checking 000.php and finding get_ikon_mysql_user_details() we can see that we select * from the member_profiles (with a join on the calendar for some more info). So anything that is in the member_profiles table will be returned to module 004 when importing users.

If this wasn't the case and the fields were some where else, we'd have to alter this function to add the details to the array for that user id (have a look at EVE to see what I mean there).


Preparing vBulletin for the data

So now we know that the extra fields we are interested in are being passed to module 004, import user.

To prepare the target database so that it knows about the custom fields and what to do with them, we have to tell it about it, this is where we use :

$this->add_custom_field()

We place this inside the init() function of the class, this is the first function that is called once, the one that asks for paths, counts per page, does all the set up, cleans up from any previous import, etc. Lines 55 to 77 in ikon_mysql/004.php.

This takes 5 arguments and looks like this :

Code:
// Add all the custom fields we want to import
$tdt = $sessionobject->get_session_var('targetdatabasetype');
$ttp = $sessionobject->get_session_var('targettableprefix');

$this->add_custom_field($Db_target, $tdt, $ttp, 'age','user age');
$this->add_custom_field($Db_target, $tdt, $ttp, 'gender','user gender');
.....
As with an ImpEx function the first 3 arguments as the database object, the database type and the table prefix. I've used the short name variable $tdt and $ttp, so it fits on a line and is more readable.

Line 177 of ImpExDatabase.php for add_custom_field(). It adds the fields and coloums to profilefield and userfield.


Importing it

No now we know its coming in, and that we have set up the database to accept the data, we have to actually import it with each user by adding it to the user object just before its imported.

On lines 142-219 we are adding all the data, calling the parsing functions, building dates into unix timestamps etc. This is where we are filling up a user object with all its data before calling import_user() on it.

Lines 204-206 are doing some add_default_value() so well add our new lines after that :

$try->add_custom_value(varname, value);

So for us it is :

Code:
$try->add_custom_value('age', $user_details['AGE']);
$try->add_custom_value('gender', $user_details['GENDER']);
Note, we are using $try and not $this . $try is the user object and that is what we are adding the data to. You can see on line 123 and 142 that its a user object.

The first argument is the varname that we created up in the init section same as the 4th argument to the add_custom_field() function.

The second argument is the actual data for that user, as we have already checked the 000.php and the get_ikon_mysql_user_details() function we know the data is being returned, and for each pass in this loop the $user_details[] array will have all the data in there we need, we just have to put the correct column name in at the right place. Though we might have to trim or addslasshes depending on what the data might be, examples of that are all over the code in the import user module.

And that is it really.

Summary
000, make sure you are getting the data in get_ikon_mysql_user_details()

004->init(), add the correct filed to the database with add_custom_field()

004->resume(), actual import the data when importing the user add_custom_value()
Reply With Quote
  #7  
Old 10-06-2004, 09:42 PM
Jerry's Avatar
Jerry Jerry is offline
 
Join Date: Jun 2003
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So for instance if the extra fields where :

MEMBER_FNAME
MEMBER_LNAME
MEMBER_START
MEMBER_END
MEMBER_YEAR
MEMBER_STATE
MEMBER_HOUSE

The code would be :

Code:
// Add all the custom fields we want to import
$tdt = $sessionobject->get_session_var('targetdatabasetype');
$ttp = $sessionobject->get_session_var('targettableprefix');

$this->add_custom_field($Db_target, $tdt, $ttp, 'fname','First Name');
$this->add_custom_field($Db_target, $tdt, $ttp, 'lname','Last Name');
$this->add_custom_field($Db_target, $tdt, $ttp, 'start','Start');
$this->add_custom_field($Db_target, $tdt, $ttp, 'end','End');
$this->add_custom_field($Db_target, $tdt, $ttp, 'year','Year');
$this->add_custom_field($Db_target, $tdt, $ttp, 'state','State');
$this->add_custom_field($Db_target, $tdt, $ttp, 'house','House');
and

Code:
$try->add_custom_value('fname', $user_details['MEMBER_FNAME']);
$try->add_custom_value('lname', $user_details['MEMBER_LNAME']);
$try->add_custom_value('start', $user_details['MEMBER_START']);
$try->add_custom_value('end', $user_details['MEMBER_END']);
$try->add_custom_value('year', $user_details['MEMBER_YEAR']);
$try->add_custom_value('state', $user_details['MEMBER_STATE']);
$try->add_custom_value('house', $user_details['MEMBER_HOUSE']);

As shown in the attached file braced by :

Code:
// *******************
// The custom stuff
// *******************
Attached Files
File Type: php 004.php (12.5 KB, 13 views)
Reply With Quote
  #8  
Old 10-07-2004, 07:39 AM
hkvic hkvic is offline
 
Join Date: Oct 2004
Location: Sussex UK
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent, many thanks.

I've only been with VB for a couple of days and am amazed at the superb support offered.
Reply With Quote
  #9  
Old 03-14-2007, 11:38 PM
XXP XXP is offline
 
Join Date: Jan 2007
Location: Upstate NY
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jerry View Post
The commands ;

add_custom_field()
add_custom_value()

. . .

Summary
000, make sure you are getting the data in get_ikon_mysql_user_details()

004->init(), add the correct filed to the database with add_custom_field()

004->resume(), actual import the data when importing the user add_custom_value()
In the ImpExData.php module it says for function add_custom_value that the first argument, called "$key", is "the name of value being set".

What "name" is that? Is that any valid field name?

Also, if you don't mind, does the "set_value" function work for any valid existing (i.e., defined) vB field in the vbfields.php file?

Thanks.
Reply With Quote
  #10  
Old 03-15-2007, 06:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This thread is more then 2 years old. I suggest you post your question in the ImpEx forum on vb.com.
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 03:42 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02659 seconds
  • Memory Usage 2,295KB
  • Queries Executed 14 (?)
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
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete