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 01-17-2005, 04:52 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default forums problems please help

im tring to get other conditions to forums and i got little problem

i copied part of code from forum.php (admincp dir)

any way i have tried to do something like :

PHP Code:
$forumid "3"// just exsample
$forum fetch_foruminfo($forumid);
$DB_site->query(fetch_query_sql($forum'forum'"WHERE forumid=$forumid")); 
and i got this error :

PHP Code:
Invalid SQLUPDATE forum SET

### UPDATE QUERY GENERATED BY fetch_query_sql() ###
    
forumid '3',
    
styleid '0',
    
title 'warcraft privte forum',
    
description '',
    
options '3783',
    
displayorder '1',
    
daysprune '30',
    
newpostemail '',
    
newthreademail '',
    
parentid '-1',
    
parentlist '3,-1',
    
password '',
    
link '',
    
childlist '3,-1',
    
depth '0',
    
permissions 'Array',
    
active '1',
    
allowposting '1',
    
cancontainthreads '1',
    
moderatenewpost '0',
    
moderatenewthread '0',
    
moderateattach '0',
    
allowbbcode '1',
    
allowimages '1',
    
allowhtml '0',
    
allowsmilies '1',
    
allowicons '1',
    
allowratings '1',
    
countposts '0',
    
canhavepassword '0',
    
indexposts '0',
    
styleoverride '0',
    
showonforumjump '0',
    
warnall '0'
WHERE forumid=3
mysql error
Unknown column 'depth' in 'field list' 
now i cant find depth on forum table on db
on forum.php this query works fine so what might be the problem ?
please help...
Reply With Quote
  #2  
Old 01-17-2005, 05:09 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, $forum in forum.php is not initialized using fetch_foruminfo().

Better use
PHP Code:
$forum $DB_site->query_first("SELECT * FROM " TABLE_PREFIX "forum WHERE forumid = " intval($forumid)); 
as fetch_foruminfo() will generate extra-keys (like depth, allowbbcode, etc.) in the array.
Reply With Quote
  #3  
Old 01-17-2005, 09:46 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

line 86 :
PHP Code:
$forum fetch_foruminfo($forumid); 
and i need this values cuse i want to edit forum settings....
only from other script then f.php

so any other idea ?
Reply With Quote
  #4  
Old 01-17-2005, 10:15 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are right that forum.php does use fetch_foruminfo(), but array $forum in the handler for do=update consists only of certain keys of this array (defined by the forum constructed in the handler for do=add/edit).

And that's the point: If you use the array returned by fetch_foruminfo() directly it will contain keys that do not exist as columns in table forum, which causes problems in fetch_query_sql() as it will just use all keys in the given array to construct the query.
Reply With Quote
  #5  
Old 01-17-2005, 10:20 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
You are right that forum.php does use fetch_foruminfo(), but array $forum in the handler for do=update consists only of certain keys of this array (defined by the forum constructed in the handler for do=add/edit).

And that's the point: If you use the array returned by fetch_foruminfo() directly it will contain keys that do not exist as columns in table forum, which causes problems in fetch_query_sql() as it will just use all keys in the given array to construct the query.
well this is what i looking for the update and edit
i want to do=edit
its will give me alll forumid=3 options and i will change what i want
and $_Post['do'] = update

same forum.php is doing only from another script
thats why i used fetch_foruminfo() to get the info same as forum.php does
got my point ?
Reply With Quote
  #6  
Old 01-17-2005, 10:23 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I do understand what you want.
But you can't use the array returned by fetch_foruminfo() as input for fetch_query_sql() directly, as it does contain additional keys

What exactly do you want to change?
Reply With Quote
  #7  
Old 01-17-2005, 10:30 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so how would i get allowbbcode and allowhtml and other ++++ that forum info contains ?
i want to be able to edit this options and to update them
but not from forum.php...?
Reply With Quote
  #8  
Old 01-17-2005, 10:45 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm ok, ill try to explain some more
as part of my next version to my team hack
i want every team to have a privte forum
so i add teamid to forum table
deafult is 0
if teamid = 0 means that forum is regular forum
if teamid !=0 means its privte forum that belong to some team,
now i allredy did most of file edits
so on forum edit via forum.php you wont see forums that their teamid!=0
now im making a script that will make same options to all of forums
that their teamid !=0 so if ill do allow html
its will edit all forums that their teamid !=0
so i made a while loop for update
the only problem atm is to update the info.. same as forum.php does
i copied most of the code from their (the code that used in edit) also readed it few times
and i still cant find the problem. why its not get updated

so i decided to first make a static forum - with out the while loop (forumid : 3)
but on forum i cant update the info...

thats why im tring only to read the info and update it
to the rest i can take care...
Reply With Quote
  #9  
Old 01-17-2005, 10:58 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*** Untested ***

PHP Code:
if (!functions_exists('array_intersect_key') {
function 
array_intersect_key() {
   
$numArgs func_num_args();
   if (
<= $numArgs) {
       
$arrays =& func_get_args();
       for (
$idx 0$idx $numArgs$idx++) {
           if (! 
is_array($arrays[$idx])) {
               
trigger_error('Parameter ' . ($idx+1) . ' is not an array'E_USER_ERROR);
               return 
false;
           }
       }

       foreach (
$arrays[0] as $key => $val) {
           for (
$idx 1$idx $numArgs$idx++) {
               if (! 
array_key_exists($key$arrays[$idx])) {
                   unset(
$arrays[0][$key]);
               }
           }
       }

       return 
$arrays[0];
   }

   
trigger_error('Not enough parameters; two arrays expected'E_USER_ERROR);
   return 
false;
}
}

$forum fetch_foruminfo($forumid);

$forum['allowbbcode'] = false;

$forumoptions convert_array_to_bits(array_intersect_key($forum$_FORUMOPTIONS), $_FORUMOPTIONS);

$DB_site->query("UPDATE " TABLE_PREFIX "forum SET options=$forumoptions WHERE forumid=$forumid"); 
But I think it is by far easier to just execute a query which directly changes what you want to change:

Quote:
now im making a script that will make same options to all of forums
that their teamid !=0 so if ill do allow html
its will edit all forums that their teamid !=0
[sql]UPDATE forum SET options=options+256 WHERE teamid != 0 AND NOT (options&256)[/sql]

Don't forget to call build_forum_permissions() afterwards.
Reply With Quote
  #10  
Old 01-17-2005, 11:04 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm
few qustion :
1. what the function array_intersect_key() should do ?
2. why to use
PHP Code:
 $forumoptions convert_array_to_bits(array_intersect_key($forum$_FORUMOPTIONS), $_FORUMOPTIONS); 
if you got $options defined from the edit part ?

3. why did you added 256 to options on db ?

btw thank you very much for helping me out
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 07:20 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.04762 seconds
  • Memory Usage 2,288KB
  • 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
  • (6)bbcode_php
  • (2)bbcode_quote
  • (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