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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2005, 08:42 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default function problem with globalising query

the call to the function is

PHP Code:
    $pieceexists $DB_site->query_first("
        SELECT pieceid, userid, styleid ,catid, title, pagetext, dateline
        FROM prs_pieces
        WHERE pieceid = 
$p
    "
);
    
    
$modificationperms prs_can_moderate();
    if (!
$modificationperms)
    {
        echo 
$modificationperms;
        die(
'you dont have permission');
    }
    unset(
$modificationperms); 
and the function is
PHP Code:
function prs_can_moderate()
{
    global 
$DB_site$vboptions$vbphrase$bbuserinfo$postownership$pieceexists$post;

    if (
$bbuserinfo['userid'] == $postownership['userid'])
    {
        
$canmodit TRUE;
    }

    if (
$bbuserinfo['userid'] == $pieceexists['userid'])
    {
        
$canmodit TRUE;
    }

    if (
$bbuserinfo['userid'] == $post['userid'])
    {
        
$canmodit TRUE;
    }

    if (
$bbuserinfo['usergroupid'] == 6)
    {
        
$canmodit TRUE;
    }

    return 
$canmodit;

so why won't it recognise the $pieceexists query?
Reply With Quote
  #2  
Old 08-26-2005, 08:52 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Should work.
Are you sure it dies have a valid record?

Btw:
I would implement it as
PHP Code:
function prs_can_moderate()
{
    global 
$DB_site$vboptions$vbphrase$bbuserinfo$postownership$pieceexists$post;

    return (
        (
$bbuserinfo['userid'] == $postownership['userid'])
        OR
        (
$bbuserinfo['userid'] == $pieceexists['userid'])
        OR
        (
$bbuserinfo['userid'] == $post['userid'])
        OR
        (
$bbuserinfo['usergroupid'] == 6)
    ); 
Theoretically this should be faster then ifs.
But maybe PHP is smart enough to optimize this itself?
Reply With Quote
  #3  
Old 08-26-2005, 09:20 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

switched to yours and still won't let them edit based on the $pieceexists['userid' matching the bbuserinfo[userid]

i've even tried adding debug stuff to the funtion like

if (!$pieceexists)
{
echo "i'm gonna die";
die('i am dead');
}

and still nope, but i don't get that error being in usergroupd 6?
Reply With Quote
  #4  
Old 08-26-2005, 09:25 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DEVDEBUG("pieceuid = $pieceexists[userid], bbuserid = $bbuserinfo[userid]");

What does output (you can also echo or die, doesn't matter) does that generate?
Reply With Quote
  #5  
Old 08-26-2005, 09:29 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

from within the function "pieceuid = , bbuserid = 10"

just tried assigning it to it's own $puid variable and it still refuses to pass into this function :S
Reply With Quote
  #6  
Old 08-26-2005, 09:45 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And before the function call?
print_r($pieceexists) before and within the function?

Btw: are you calling it form within another function?
Reply With Quote
  #7  
Old 08-26-2005, 09:52 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

before the function call it gives me the correct array
before the functions defined in the relevant function.php it's blank
and in the function it's also blank

and nope it's not within any function bar the conditional (if)
Reply With Quote
  #8  
Old 08-26-2005, 09:57 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

> before the functions defined in the relevant function.php it's blank

I don't understand that.
But I think you got a Problem with Variable Scope.

Where exactly is the calling Code located, where is the function located?
Reply With Quote
  #9  
Old 08-26-2005, 10:04 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what i mean is
PHP Code:
    print_r($pieceexists);
    die();

function 
prs_can_moderate()
{
    global 
$DB_site$vboptions$vbphrase$bbuserinfo$postownership$pieceexists$post$puid;


    return (
        (
$bbuserinfo['userid'] == $postownership['userid'])
        OR
        (
$bbuserinfo['userid'] == $puid)
        OR
        (
$bbuserinfo['userid'] == $post['userid'])
        OR
        (
$bbuserinfo['usergroupid'] == 6
    );

and any idea on how to fix it?

the function is near the bottom of functions_prs.php located in the includes directory.

and the call is located in modify.php outside of the forums directory in www.home.com/creative
Reply With Quote
  #10  
Old 08-26-2005, 10:08 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, this print_r() will most likely always be blank, as you are requiring functions_prs.php before querying $pieceexists.

IMHO, all the code pieces you've shown so far seem to be OK.
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 08:13 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.04438 seconds
  • Memory Usage 2,275KB
  • Queries Executed 11 (?)
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_php
  • (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
  • (10)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_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