The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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 |
#5
|
|||
|
|||
Cheers. I'll give it some serious consideration.
|
#6
|
||||
|
||||
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'); ..... 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']); 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() |
#7
|
||||
|
||||
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'); 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 // ******************* |
#8
|
|||
|
|||
Excellent, many thanks.
I've only been with VB for a couple of days and am amazed at the superb support offered. |
#9
|
|||
|
|||
Quote:
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. |
#10
|
|||
|
|||
This thread is more then 2 years old. I suggest you post your question in the ImpEx forum on vb.com.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|