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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2005, 04:11 AM
endquote endquote is offline
 
Join Date: Jan 2002
Location: Seattle, WA
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding fields with Datamanager?

In the vB announcements forum, it says: "Naturally, plugins can attach themselves to the data managers, allowing you to add code that runs before or after saving, or even to add new fields."

Has anyone figured out the add new fields bit yet?
Reply With Quote
  #2  
Old 06-22-2005, 04:28 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope, as far as I can see you have to hack the DM class(s) to add new fields, if this is not the case then someone please tell me how to do it, because I have had to do it this way.
Reply With Quote
  #3  
Old 06-22-2005, 10:41 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For every Datamanager there is a name_start Hook where you can add custom fields.

Example for the User Datamanager :
Hook: userdata_start
Code:
PHP Code:
$this->validfields['myfield'] = array(TYPE_STRREQ_NO'if ($data != 'notallowed') { return true; } else {return false; }')); 
This adds a new field myfield which is not required and will accept strings other then 'notallowed'.
Reply With Quote
  #4  
Old 06-22-2005, 10:43 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

endquote,

You are currently showing up as unlicensed. To be able to download hacks and/or receive support here at vBulletin.org, we ask you to please click here (vB-germany users click here) and enter your email address, to show us that you are licensed.

You will need to use your customer number and password (which will be in the email you got when you paid for your license) to access that page. Please note that your email is case sensitive. The update of your account may take up to one hour.

Thank you.
Reply With Quote
  #5  
Old 06-23-2005, 01:54 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
For every Datamanager there is a name_start Hook where you can add custom fields.

Example for the User Datamanager :
Hook: userdata_start
Code:
PHP Code:
$this->validfields[] = array('myfield'TYPE_STRREQ_NO'if ($data != 'notallowed') { return true; } else {return false; }')); 
This adds a new field myfield which is not required and will accept strings other then 'notallowed'.
Awsome. Now the question is, do many areas of vBulletin use data managers?
Reply With Quote
  #6  
Old 06-25-2005, 12:33 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
For every Datamanager there is a name_start Hook where you can add custom fields.

Example for the User Datamanager :
Hook: userdata_start
Code:
PHP Code:
$this->validfields[] = array('myfield'TYPE_STRREQ_NO'if ($data != 'notallowed') { return true; } else {return false; }')); 
This adds a new field myfield which is not required and will accept strings other then 'notallowed'.
Actually, this doesn't work. I had to change it to this ;

Code:
$this->validfields['myfield'] = array(TYPE_STR, REQ_NO[high], 'if ($data != 'notallowed') { return true; } else {return false; }')[/high]);
With the highlighted bit being optional (and not used by me).
Reply With Quote
  #7  
Old 06-25-2005, 12:37 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Right. Slight mistake on my end.
But at least I was willing to post the correct code

Of course the fieldname must be the key.
Reply With Quote
  #8  
Old 06-27-2005, 02:18 AM
enqu0te enqu0te is offline
 
Join Date: Jun 2005
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Finally got some license issues sorted out so now I can view the code. I basically got it once you pointed out that hook in the constructor though.

Another question would be... I don't suppose there's any way to automatically add fields to the actual db tables with a plugin? At least not without checking if the field was there every time your DM ran, which would be dumb. Can that be done with the "plugin definitions xml file"? I haven't really looked into that yet.
Reply With Quote
  #9  
Old 06-27-2005, 02:24 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sounds like you'll have to get the user to manually run an install script or query unfortunatly.

Its a good idea to be able to add "run once" queries though.
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 09:59 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.03998 seconds
  • Memory Usage 2,247KB
  • 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
  • (1)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete