View Single Post
  #256  
Old 02-02-2009, 09:41 AM
bananalive bananalive is offline
 
Join Date: Oct 2007
Location: UK
Posts: 2,802
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by brainfood View Post
Thanks for the great modification. I am just starting to use it and have two questions.

Question 1:
How do I get the form results to be saved to the database? When I creating a new form I see a drop down box with the following options:

PM Form to User
Post New Thread
Post in Thread
Email Form


I do not see anything that allows me to "save to database".

I checked the tables after creating a form and using the form and the formresults tables is empty.

Question 2:
Ideally I want a user to fill out a form and submit it. When it is submitted it is posted to a thread and saved to a database. Is this possible?

Thanks!
A1. I missed the option of new form, I'll correct this in next version. In the meanwhile just create the form and then when you edit it the option t save to database will appear.

A2. Yes. Use the following code in Form Hook: Before Submit:

PHP Code:
if ($complete)
    {
        
$db->query_write("INSERT INTO " TABLE_PREFIX "formresults
        (fid, userid, username, time, title, output)
        VALUES ('"
.$form[fid]."', '".$vbulletin->userinfo['userid']."', '".addslashes($vbulletin->userinfo['username'])."', ".TIMENOW.", '".addslashes($threadtitle)."', '".addslashes($formoutput)."')
        "
);
    } 
Quote:
Originally Posted by Pedrillo View Post
I discover that the form is submited or not depending of the order of the variable options that I indicate in the "Thread/ PM/ Email Title: " field:

Example: It's ok with "{q_1}: {q_2}" but not submit the form if I wrote "{q_2}: {q_1}"

In other form it's ok with "{q_6} {q_5}" but not with "{q_5} {q_6}"

What's wrong?

Thank you bananlive!
I'm not sure why this is happening, but I've found a fix for next release.
Quote:
Originally Posted by trickfly View Post
whats the point of this mod ?
You can collect data in the form you want from your users.
Quote:
Originally Posted by lazyseller View Post
Im able to access the form via misc.php?do=form&fid=10&threadid=(dynamic) but the script is unable to figure out which thread to post in.

I left "Threadid where Post is Created:*" blank since this would need to be dynamic. Unsure where to proceed from here.
What exactly do you mean by dynamic? Do you mean if misc.php?do=form&fid=10&threadid=12345 it gets posted in thread 12345.
Quote:
Originally Posted by alduren View Post
Thanks for this mod!!.

I have a question. In my form I have a field with this custom form output.

[IMG]{q_1}[/IMG]

When the answer is blank it shows [IMG] code because this field is not compulsory, like this

[IMG].[/IMG]

If the field is blank I don?t want to show BBcode, how could I correct this??
Form Hook: Before Submit:
PHP Code:
$formoutput str_replace(""""$formoutput); 
Quote:
Originally Posted by nascartr View Post
What about have an option to include a checkbox that if the member checks it then the form data is sent as a confirmation to the email address on file for them.

I am using this form system for a fantasy sports game and the results go into a private topic. Some of the members would like confirmation of their votes since they can't view the private topic.
Create yesno option

Form Hook: Before Submit:
PHP Code:
if ($qo_{54} == $vbphrase[yes] && $complete && $vbulletin->userinfo['email'])
{
$formoutput preg_replace('/(\[(.*?)\])/is'''$formoutput);
vbmail($vbulletin->userinfo['email'], $threadtitle$formoutput);

Quote:
Originally Posted by Vitaly View Post
Hi, Banana,

At last, got enougth time to study latest changes in your form constructor. Thanks a lot for your work. I have some proposals, may be, youll find those useful for your 3.0 version .

1. Processing can be switched from "form parameters" to "form actions". That will spin flexibility to the next level, and will simplify / improve coding & interface for each action.

Each action can have a custom parameter & action can be added to form in the same manner, as questions. The big advantage is, that you can have several action in one time (or just skip unnecessary one). Here is actions examples:

- posting
  • Create Thread
  • PM form
  • Email Form
  • ... (other types of data processing)
- customisations
  • Custom success message (? with JS redirect to URL)
  • Custom error message if no permissions to use form (? with JS redirect to URL)
Of cause, that can be done via hooks, but that method is much more complicated, than just push mouse buttons . And you are not limited to add new actions, when required. That's a kind of "advanced hooks conctructor"

(*) Don't know what is better: to keep title & template common, or make it individual for each posting action. Probably, second method is better and simplify main form editing page.

2. "Only for guest" questions.

Reason is simple: User should not care, which form to select for feedback. That's extremly significant for advertiser and payed visitors. If he is registered, then additional information is taken from profile. If not - he is asked to fill additional input fields.

Solution is trivial: add flag "only for guests" for all questions.

3. Full template language support in form templates.

AFAIK only macroses are supported now. But it would be useful to support <if> <else> and all internal forum variables in form templates. It seems, there are no serious barriers to do that. vBulletin have a powerful templates parser, that can be used. It's useful with proposal (2), when you can easily fix template output, depending on user permissions.

4. Please, check vulnerabilities issues

- What happens, if user enter macros name in text field? Are such patterns stripped (or converted to safe style) prior to process form?

5. It's better so send Emails in HTML. Вetter look, when use several actions (make post and send email)

(*) If you'll switch to "actions", it's possible to create new one "send email as HTML" . If each action has personal template, that's not a problem at all.

6. Don't know, if it's useful, but I'd enlarge default form description font to SIZE=2. And would remove "Form Description" from border.

7. It would be useful to have form active for user, but hidden from public list. No ideas, why you use 2 access settings in product options, but only sigle setting for each form. Parameter "who can view form in list" can solve it.

8. Date question format. Some prefer dd-mm-yy. May be, format type to this question?

9. Does "send email" support multiple addresses?

(*) Useful, but not critical if multiple actions are supported.

Regards,

Vitaly.
1&2. These would require alot of edits, but will probably be available in the future.
3. I've tried and failed to find easy way to allow <if> in form custom output
4. Shouldn't do, I'll check this
5. vbulletin mail system doesn't allow html or bbcode
6. You can use bbcode to do that
7. ? I don;t understand what you're saying
8. You can change that by editing form_formbit_date and:
PHP Code:
$qo_{$formbit[id]} = implode("/"$q_{$formbit[id]}); 
to
PHP Code:
$qo_{$formbit[id]} = implode(" "$q_{$formbit[id]}); 
9. Should do, haven't actually tested it
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02270 seconds
  • Memory Usage 1,829KB
  • 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
  • (5)bbcode_php
  • (7)bbcode_quote
  • (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