Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2008, 09:04 AM
FredrikSE FredrikSE is offline
 
Join Date: Jul 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Explanation of the touserarray in table PMTEXT

Hi!

I am currently working on several scripts that later on will migrate my current forum to vBulletin 3.7. So far I'm doing alright. Most of the information such as users, threads and posts are importing correctly into vBulletin which is good news. Now I'm trying to work out a script that will migrate all the PM's from my custom forum database.

The tables that the PM function is made up of is pm, pmtext, pmreceipt, in the vBulletin database. It's easy to understand what the information is doing in in most of tables. There is on field though, called touserarray, in table pmtext, that I need som help to parse, exactly what elements it's made up of!

touserarray:
Code:
a:1:{s:2:"cc";a:1:{i:10;s:5:"LeonL";}}
The user element is easy do decode from the string. But how about the rest?

Regards,

Fredrik
Reply With Quote
  #2  
Old 08-03-2008, 09:43 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use explode() on that string and it will return an array with all the values.

PS Why not use the DataManagers, would make things a lot easier and you do not need to know which tables store which information.

PPS To write an importer, you could use ImpEx as an example and write a new module based on existing ones.
Reply With Quote
  #3  
Old 08-03-2008, 10:53 AM
FredrikSE FredrikSE is offline
 
Join Date: Jul 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for you reply!

I assume the DataManager can be used when the forum from which you are importing is well known and supported by vBulletin, right?

In my case I'm importing from my very own custom forum and I feel ImpEx won't do the job for me. I gave it a try but I soon realized that it was not going to handle all my information the way I wanted.

This leaves me with the option to hard code scripts myself for the various categories I want to migrate. So far everything is working out very good.

One of the last thing is to get the PM's in place. You say I can use explode() on that string. It would be very helpful if you could give me a code example.
Reply With Quote
  #4  
Old 08-03-2008, 11:06 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DataManagers are used to manipulate the data in the vBulletin database. They have no connection with the system you are using to get the data. They are basically an API that will provide an interface to edit/insert/delete data without having to access the tables directly. You can find more information in our Articles section.

Sorry made a typo in my previous post, you should be using unserialize() on the string to get an array.

Example:
PHP Code:
<?php
$string 
'a:1:{s:2:"cc";a:1:{i:10;s:5:"LeonL";}}';
$array unserialize($string);
echo 
"<br />Var string: " $string;
echo 
"<br />Array array: <pre>";print_r($array);echo "</pre>";
?>
Would result in:
Code:
Var string: a:1:{s:2:"cc";a:1:{i:10;s:5:"LeonL";}}
Array array: 
Array(    [cc] => Array        (            [10] => LeonL        ))
Reply With Quote
  #5  
Old 08-03-2008, 05:21 PM
FredrikSE FredrikSE is offline
 
Join Date: Jul 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When you say DataManagers I assume you refer to functions and classes within the various php-files that vBulletin is made up of? First you have to be some what of a detective and look those up in a specific file I guess?

Thanks for your example. The only information of value really that comes out of the array when you run unserialize is the userID and username. Do you now what those other numbers are for in that string?

I sent three test PM from my admin account to the three users to see how/if the touserarray values other than userID/username changes.

This is the result taken from the database:

Code:
a:1:{s:2:"cc";a:1:{i:185;s:4:"Adam";}}
a:1:{s:2:"cc";a:1:{i:245;s:10:"cjsundberg";}}
a:1:{s:2:"cc";a:1:{i:309;s:6:"19-555";}}
The only value that changes is the value before the username. In the first string it's 4, then 10 and finally 6. Do you know what that value is for? When I run unserialize it doesn't show up!

I need to know this when I import so that I can anticipate the correct value.
Reply With Quote
  #6  
Old 08-03-2008, 05:31 PM
nexialys
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
You can use explode() on that string and it will return an array with all the values.
Hum, sorry to interveine, but it's a serialized entry... unserialize() is needed!
Reply With Quote
  #7  
Old 08-03-2008, 09:39 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nexialys View Post
Hum, sorry to interveine, but it's a serialized entry... unserialize() is needed!
2nd paragraph of post #4 my dear.
Reply With Quote
  #8  
Old 08-04-2008, 07:24 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by FredrikSE View Post
Thanks for your example. The only information of value really that comes out of the array when you run unserialize is the userID and username. Do you now what those other numbers are for in that string?

I sent three test PM from my admin account to the three users to see how/if the touserarray values other than userID/username changes.

This is the result taken from the database:

Code:
a:1:{s:2:"cc";a:1:{i:185;s:4:"Adam";}}
a:1:{s:2:"cc";a:1:{i:245;s:10:"cjsundberg";}}
a:1:{s:2:"cc";a:1:{i:309;s:6:"19-555";}}
The only value that changes is the value before the username. In the first string it's 4, then 10 and finally 6. Do you know what that value is for? When I run unserialize it doesn't show up!

I need to know this when I import so that I can anticipate the correct value.
There is no real need to know what the numbers in that string mean. You should just populate an array, and then use $string = serialize($array) to get this string.

But if you want to know:

a:1:{s:2:"cc";a:1:{i:185;s:4:"Adam";}}

a:1:{..} - Array with 1 entry
s:2:"cc"; - String, 2 positions, value "cc"
a:1:{....} - Array with 1 entry
i:185; - Integer, value 185 (probably userid on this example)
s:4:"Adam"; - String, 4 positions, value "Adam"
Reply With Quote
  #9  
Old 08-04-2008, 07:39 PM
FredrikSE FredrikSE is offline
 
Join Date: Jul 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So it wasn't more complicated than that after all?! The way you describe it, it seems like a straight forward process to populate the array and the store the whole PM-post into the database.

Thanks for your explanation. This means I will have a good night sleep not having to think about this array!
Reply With Quote
  #10  
Old 08-05-2008, 08:55 PM
FredrikSE FredrikSE is offline
 
Join Date: Jul 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would I populate this array?

Like this before I serialize it?!

PHP Code:
$touserarray = array("185""Adam"); 
Reply With Quote
Reply

Thread Tools
Display Modes

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 01:35 PM.


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.04451 seconds
  • Memory Usage 2,260KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_code
  • (2)bbcode_php
  • (3)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
  • (9)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete