FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Adding users to a group using a script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Adding users to a group using a script [message #30308 is a reply to message #30191] Thu, 16 February 2006 16:45 Go to previous messageGo to previous message
djechelon is currently offline  djechelon   Italy
Messages: 46
Registered: July 2005
Karma:
Member
Sorry for answering so late but I've been a bit busy.

I have copied and rewritten the function you mentioned, making it rebuild the whole forum's group cache.
This is the result:

<?php
function grp_rebuild_cache($user_id=null) {
        global 
$conn;

        
$list = array();
        
$lmt '';

        
/* generate an array of permissions, in the end we end up with 1ist of permissions */
        
$r mysql_query("SELECT gm.user_id AS uid, gm.group_members_opt AS gco, gr.resource_id AS rid FROM Forum_group_members gm INNER JOIN Forum_group_resources gr ON gr.group_id=gm.group_id WHERE gm.group_members_opt>=65536 AND (gm.group_members_opt & 65536) > 0" . ($lmt ' AND '.$lmt ''),$conn) or die(mysql_error().__LINE__);
        while (
$o mysql_fetch_object($r)) {
                foreach (
$o as $k => $v) {
                        
$o->$k = (int) $v;
                }
                if (isset(
$list[$o->rid][$o->uid])) {
                        if (
$o->gco 131072) {
                                
$list[$o->rid][$o->uid] |= $o->gco;
                        } else {
                                
$list[$o->rid][$o->uid] &= $o->gco;
                        }
                } else {
                        
$list[$o->rid][$o->uid] = $o->gco;
                }
        }
        unset(
$r);

        
$tmp = array();
        foreach (
$list as $k => $v) {
                foreach (
$v as $u => $p) {
                        
$tmp[] = $k.",".$p.",".$u;
                }
        }

        if (!
$tmp) {
                
mysql_query("DELETE FROM Forum_group_cache" . ($lmt ' WHERE '.$lmt ''),$conn) or die(mysql_error().__LINE__);
                return;
        }

        
$sql "REPLACE INTO Forum_group_cache (resource_id, group_cache_opt, user_id) VALUES (".implode('), ('$tmp).")";
        
mysql_query($sql,$conn) or die(mysql_error().$sql);
        
mysql_query("DELETE FROM Forum_group_cache WHERE ".($lmt $lmt ' AND ' '')." id < LAST_INSERT_ID()",$conn) or die(mysql_error().__LINE__);

        
mysql_query("DELETE FROM Forum_group_cache" . ($lmt ' WHERE '.$lmt ''), $conn) or die(mysql_error().__LINE__);
        foreach (
$tmp as $ttmp) {
                
mysql_query("INSERT INTO Forum_group_cache (resource_id, group_cache_opt, user_id) VALUES (".$ttmp.")",$conn) or die(mysql_error().__LINE__);
        }

}
?>


I made it run without errors, but still users can't access the private Forums I mentioned before, even if they are listed in Groups Administration.

Running Consistency check is useless...
What should I do then?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Serious issue with mailing list - thread breaks when a message is modified
Next Topic: How to fix error when can't accesss admin control panel?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:23:20 GMT 2024

Total time taken to generate the page: 0.04303 seconds