vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   New Posting Features - Easy Forms v4.x - Create a form or multiple forms without php or html knowledge (https://vborg.vbsupport.ru/showthread.php?t=234385)

XLCR GODFATHER 05-13-2010 02:24 PM

Quote:

Originally Posted by riskofficer (Post 2036339)
Thank you! One more thing about edit is something like "Usergroups Allowed to Edit Form Results". For example I'd like to leave this option (Edit Result) only for person whos answered (starter) and admins/moderators. BTW the option to delete results is in need of permissions too, I haven't found them.

I fully agree where leaving the delete option available makes it too easy for accidental click and should be a permission setting.

ThorstenA 05-13-2010 03:23 PM

Suggestion: Change phrase
Quote:

Error, you have exceeded limit for number of times this form can be submitted.
to
Quote:

Error, you have exceeded limit for number of times this form can be submitted.
Edit your submitted form.
Or better:
If a user has exceeded the limit for number of times he can submit the form, redirect him immediately to the edit form.

ThorstenA 05-13-2010 03:43 PM

Bugs:
  • I can not edit my own entry if the maximum number of entries is limited to one.
  • After I delete my entry (have no entries any more), I can not vote again because "I exceeded the limit"

ThorstenA 05-13-2010 05:16 PM

Quote:

Originally Posted by ThorstenA (Post 2036458)
Bugs:
  • I can not edit my own entry if the maximum number of entries is limited to one.

Solution for at least going to the edit form

1. Replace in plugin Easy Forms Part 1
Code:

    if ($form[submitlimitperuser] >= 1)
to
Code:

    if (!$formresult && $form[submitlimitperuser] >= 1)



2.
In same plugin in the area after
Code:

if ($_POST['do'] == 'postform')
replace
Code:

                if ($count >= $form[submitlimitperuser])
to
Code:

                if ($count > $form[submitlimitperuser])

ThorstenA 05-13-2010 05:38 PM

Bug: Poll displays free text entries

Solution: Replace in plugin Easy Forms Part 3 short after
Code:

if ($_REQUEST['do'] == 'formresults_poll')
{

the code
Code:

        $formbits = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "formbits WHERE fid = $fid AND type != 7 ORDER BY displayorder ASC");
to
Code:

        $formbits = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "formbits WHERE fid = $fid AND type NOT IN (1,6,7,8,9) ORDER BY displayorder ASC");

ThorstenA 05-13-2010 06:24 PM

Quote:

Originally Posted by ThorstenA (Post 2036458)
Bugs:
  • After I delete my entry (have no entries any more), I can not vote again because "I exceeded the limit"

Temporary, not really working solution
(This messes lots of things up in your database as userid 123 will have an effect on userid 12345). It is better to get the userids from a simple SELECT query of forumresults table.

Replace in plugin Easy Forms Part 2
Code:

if ($_REQUEST['do'] == 'deleteformresult')
{
        $caneditform = unserialize($vbulletin->options['caneditform']);
        if ($caneditform && !is_member_of($vbulletin->userinfo, $caneditform))
        {
                print_no_permission();
        }
        $id = $vbulletin->input->clean_gpc('g', 'id', TYPE_UINT);
        $fid = $vbulletin->input->clean_gpc('g', 'fid', TYPE_UINT);
        $db->query_write("DELETE FROM " . TABLE_PREFIX . "formresults WHERE id=$id");
        $db->query_write("UPDATE " . TABLE_PREFIX . "forms SET userids = REPLACE(userids,\"," . $vbulletin->userinfo[userid] . "\",\"\")  WHERE fid=$fid");
        $vbulletin->url = "misc.php?do=forms";       
        eval(print_standard_redirect('redirect_deleteq'));
}

to
Code:

if ($_REQUEST['do'] == 'deleteformresult')
{
        $caneditform = unserialize($vbulletin->options['caneditform']);
        if ($caneditform && !is_member_of($vbulletin->userinfo, $caneditform))
        {
                print_no_permission();
        }
        $id = $vbulletin->input->clean_gpc('g', 'id', TYPE_UINT);
        $fid = $vbulletin->input->clean_gpc('g', 'fid', TYPE_UINT);
        $db->query_write("DELETE FROM " . TABLE_PREFIX . "formresults WHERE id=$id");
        $db->query_write("UPDATE " . TABLE_PREFIX . "forms SET userids = REPLACE(userids,\"," . $vbulletin->userinfo[userid] . "\",\"\")  WHERE fid=$fid");
        $vbulletin->url = "misc.php?do=forms";       
        eval(print_standard_redirect('redirect_deleteq'));
}


ThorstenA 05-13-2010 06:35 PM

To have my users automatically redirect to the form results page where they can edit their entries if they exceeded their maximum entries, I use this code in plugin Easy Forums Part 1
Code:

    if (!$formresult && $form[submitlimitperuser] >= 1)
    {
        $userids = $form[userids];
        $userid = $vbulletin->userinfo[userid];
        $count = substr_count(",$userids,", ",$userid,");
        if ($count >= $form[submitlimitperuser])
        {
        $vbulletin->url = "misc.php?do=formresults&fid=" . $fid;
        eval(print_standard_redirect('redirect_deleteq'));

            //$errormessage = "Error, you have exceeded limit for number of times this form can be submitted.";
            //eval(standard_error($errormessage));

        }
    }

I use this product as a review type. For each form a user can only have one entry. As I only have one entry to be displayed on this page anyway, I am redirecting my user to the edit page directly. For doing that I need the id of the formresults table:
Code:

    $id = $db->query_first("SELECT id FROM " . TABLE_PREFIX . "formresults WHERE fid = '$fid' AND userid = " . $vbulletin->userinfo[userid] . "");
        $vbulletin->url = "misc.php?do=editformresult&id=" . $id[id] . "&fid=" . $fid;
        eval(print_standard_redirect('redirect_deleteq'));


ThorstenA 05-13-2010 06:42 PM

This is about the database "review" model where users are allowed to give an entry once (limit: 1).

Users are allowed to see the poll results from all users. However, for Privacy Reasons users can only see their own entries on form results table:

In plugin Easy Forms Part 3 replace
Code:

        $formresults = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "formresults WHERE fid = '$fid' $search AND userid=" . $vbulletin->userinfo[userid] . " ORDER BY time DESC");
to
Code:

        $formresults = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "formresults WHERE fid = '$fid' $search AND userid=" . $vbulletin->userinfo[userid] . " ORDER BY time DESC");

ThorstenA 05-13-2010 08:36 PM

After user has completed the entry successfully, he is redirected to the statistic page:

Replace in plugin Easy Forms Part 1
Code:

    if ($complete && $show['editing'])
    {
        $sdata = serialize($qo);
        $db->query_write("
            UPDATE " . TABLE_PREFIX . "formresults
            SET
                title = '".$db->escape_string($threadtitle)."',
                output = '".$db->escape_string($formoutput)."',
                sdata = '".$db->escape_string($sdata)."'
            WHERE
                fid = '".$fid."' AND
                id = '".$show['edit_id']."'
        ");
        $errormessage = "Form Result was successfully updated.";
        $vbulletin->url = $vbulletin->options['bburl'] . "/misc.php?do=formresults&fid=$fid";
        eval(print_standard_redirect($errormessage, false, true));
    }

to
Code:

            if ($complete && $show['editing'])
    {
        $sdata = serialize($qo);
        $db->query_write("
            UPDATE " . TABLE_PREFIX . "formresults
            SET
                title = '".$db->escape_string($threadtitle)."',
                output = '".$db->escape_string($formoutput)."',
                sdata = '".$db->escape_string($sdata)."'
            WHERE
                fid = '".$fid."' AND
                id = '".$show['edit_id']."'
        ");
        $errormessage = "Form Result was successfully updated.";
        $vbulletin->url = $vbulletin->options['bburl'] . "/misc.php?do=formresults_poll&fid=$fid";
        eval(print_standard_redirect($errormessage, false, true));
    }


ThorstenA 05-13-2010 09:23 PM

I love this product! Therefore I took some time to look into it and I have some suggestions for its database structure
  • Rename row time to dateline (as they do in the other vbulletin tables)
  • Remove username from table formresults and fetch username by querying user table.
    ("... FROM formresults, user WHERE formresults.userid=user.userid ...")
  • Remove userids from table forms and get this information from table forumresults. This is needed for limit users entries for a question. It is very hard to maintain duplicate (redundant) information. You have all these infos when querying forumresults table
    ("SELECT count(userid) AS usercount FROM forumresults WHERE fid=$fid AND userid=" . $vbulletin->userinfo[userid] ."")
  • Remove redirect from table forms. It is redundant to redirecturl.


All times are GMT. The time now is 05:38 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.06649 seconds
  • Memory Usage 1,776KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (16)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (4)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete