Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 06-05-2011, 03:59 PM
av8or1 av8or1 is offline
 
Join Date: Mar 2011
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Issues with $_POST within a product/plugin

Hi-

I am attempting to add an element to the inline moderation options (vB 4.1.3). The approach is to use a product that is imported/added via the customary procedure in the admincp. I've read Lynne's recommended link regarding how to do this in vB4 (as opposed to vB3) and seem to have that worked out.

However I am not seeing the expected values in the $_POST['tlist'] and $_POST['plist'] array members when the action is taken. This code is roughly modeled after (and uses some of the exact code from) the inlinemod.php script. A good example is the Move Threads option in the inline moderation list. And when examining that, I noticed a difference between "movethread" and "domovethreads" WRT how the thread IDs are accessed. Thus from ~line 170:

PHP Code:
        case 'movethread':
        case 
'mergethread':
        case 
'viewthread':
        case 
'spamthread':
        {
                if (empty(
$tlist))
                {
                        eval(
standard_error(fetch_error('you_did_not_select_any_valid_threads')));
                }

                if (
count($tlist) > $threadlimit)
                {
                        eval(
standard_error(fetch_error('you_are_limited_to_working_with_x_threads'$threadlimit)));
                }

                
$threadids implode(','$tlist);

                break;
        }
        case 
'dodeletethreads':
        case 
'domovethreads':
        case 
'domergethreads':
        {
                
$vbulletin->input->clean_array_gpc('p', array(
                        
'threadids' => TYPE_STR,
                ));
                
$threadids explode(','$vbulletin->GPC['threadids']);
                foreach (
$threadids AS $index => $threadid)
                {
 ... 
And yes, I caught and understand the code around line 105 where a file-scoped local named $tlist is created from a possible merge. I don't do that in this product, but it shouldn't be relevant to being able to extract the thread IDs from the $_POST array.

As I mentioned, the code in this product follows that same type of model, including the differentiation between movethread and domovethreads. (which I don't understand completely but followed it anyway)

So here are the (seemingly) pertinent snippets from this product that I am attempting to add:

HTML Code:
	<templates>
		<template name="forumdisplay_changetest" templatetype="template" date="1567832678" username="user" version="1.0"><![CDATA[
<form action="inlinemod.php" method="post" name="vbform">
<input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />

<vb:if condition="$_POST['do']=='changetest'">
<input type="hidden" name="threadids" value="{vb:raw threadids}" />
<input type="hidden" name="do" value="dochangetest" />
</vb:if>
...
Note the attempt to alter the $_POST data from "changetest" to "dochangetest" in this template definition. I saw this elsewhere and tried to mimic it, but it doesn't change the result. Heck, I'm not even sure it's the right approach, but I decided to give it a try.

After the template definition is finished, then the plugin defintions follow. I adopted standard practice here, doing the the caching, etc. as described in the HOW-TO article. Also, I am using the vB_Template stuff to actually create the option in the inlinemod list of radio buttons. This works: I can select my option, press proceed and I am taken to inlinemod.php just as I should be. So that seems to be ok, it's what happens when I'm there that isn't. I'll save including those plugin snippets for the sake of brevity.

The plugin code that seems necessary to include however is the one that is attached to the inlinemod_start hook, thus:

Code:
		<plugin active="1" executionorder="5">
			<title>Change Test</title>
			<hookname>inlinemod_start</hookname>
			<phpcode><![CDATA[
if ($_POST['do']=="changetest" || $_POST['do']=="dochangetest")
{
echo "inlinemod_start (TOC): post=<br />"; var_dump($_POST); echo "<br />";
var_dump($vbulletin->GPC); echo "<br />";
And that little diagnostic printout tells the story. The $_POST['tlist'] is empty and so naturally so is the GPC['tlist'] entry. Therefore a few lines later when I perform a basic sanity check thus:

PHP Code:
if ($_POST['do']=="changetest") {
    if (empty(
$vbulletin->GPC['tlist'])) {
        eval(
standard_error(fetch_error('you_did_not_select_any_valid_threads')));
    } 
The error is thrown and execution halts.

So ok. I must be missing something obvious here, as this concept isn't all that difficult. I've done a search on vb.org and I've dug through the code in an attempt to find where the list of selected threads (via forumdisplay.php) is captured and stored in $_POST plus entered some additional diagnostic code in inlinemod.php (no modifications, only printing) but I haven't figured out where I am going wrong yet.

The plan is to keep banging away, but I thought I'd check here and see if anyone can see where I went left when I should have went right. Apologies in advance if this is a noob error, this is my first stab at adding a product.

Thanks,

Jerry

ps-I just had a feeling that someone looking at this might want to see the template for the radio button, so I decided to go back and include it anyway, despite what I said above about brevity. Anyway, here it is:

HTML Code:
		<template name="forumdisplay_changetest_link" templatetype="template" date="1567832678" username="user" version="1.0"><![CDATA[
		<li><label><input type="radio" name="do" value="changetest" /> {vb:raw vbphrase.changetest_link}</label></li>
--------------- Added [DATE]1307295681[/DATE] at [TIME]1307295681[/TIME] ---------------

UPDATE

Ok I think I know the difference between movethread and domovethreads now...

--------------- Added [DATE]1307333104[/DATE] at [TIME]1307333104[/TIME] ---------------

UPDATE

Ok I got past the thread IDs issue and am now getting the correct ID that was selected on the forumdisplay page. However my template doesn't render, even though I am using vB_Template. So now to work on that. I'll post the answer when I get everything working.

Thanks.

--------------- Added [DATE]1307366465[/DATE] at [TIME]1307366465[/TIME] ---------------

Got the template to render last night. However it needs work, HTML-wise that is. Once I finish that off, then I'll have only to flush out a few details and my first plugin will be complete.
Reply With Quote
  #2  
Old 06-07-2011, 12:39 AM
av8or1 av8or1 is offline
 
Join Date: Mar 2011
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok got this working properly and installed. The issue ended up being associated with how the inlinemod option selections are passed to the inlinemod.php script. Line 105 was the key (vB 4.1.3).

Thanks
Reply With Quote
  #3  
Old 06-07-2011, 01:30 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got this figured out.
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 08:29 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03874 seconds
  • Memory Usage 2,201KB
  • 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
  • (2)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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