vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   forums problems please help (https://vborg.vbsupport.ru/showthread.php?t=74532)

miz 01-17-2005 04:52 PM

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...

Andreas 01-17-2005 05:09 PM

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.

miz 01-17-2005 09:46 PM

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 ?

Andreas 01-17-2005 10:15 PM

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.

miz 01-17-2005 10:20 PM

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 ?

Andreas 01-17-2005 10:23 PM

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?

miz 01-17-2005 10:30 PM

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...?

miz 01-17-2005 10:45 PM

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...

Andreas 01-17-2005 10:58 PM

*** 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.

miz 01-17-2005 11:04 PM

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


All times are GMT. The time now is 12:17 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.01411 seconds
  • Memory Usage 1,779KB
  • 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
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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