Topic: User Groups Read Board Default Management Tweak needed

Hi All,
I need some help with this....
Bottomline: when I set a "User Group" to default to "Read Board" = "No", when I then go into "Admin:Forums" I want the Read Forum checkbox to default to unchecked and not be greyed out, so I can check it if I want to.

Background:
I have a forum setup where we make only 2 forums available to guests for read-only access.  Kind of like an entrance zone with good public info.
Then everything else is "in house" (its a school).
This, of course, requires setting the Group Option:Read Board" value for Guests to "Yes".  There are other groups we do this with as well.
*But then every time you add a new forum you have to go through the User Group list and check those boxes off.
This makes for a great deal of constant administrative tedium.

I want to be able to set guest, or any, user group to default to not read forum (set in "User Groups") , but then be
able to allow them to read only a couple of forums, and post or not as we set it.

-----------------------------------------------
In order to change this behavior I thought it would be a simple matter to go into file:admin_forums.php and around line357 where the form display is set, change the behaviors for read_forum_new input option query statement of checked="checked" and disabled="disabled"; however, after playing with it for some time I am finding it is not so straightforward as I expected it might be.

I am continuing to search for the answer on the "other" forums but thought I'd ask for some help here.

---
BTW... we are very happy to announce not only the arrival of a new human being in the family (!!!grandchild:wow!!) but also I have just completed migrating one of our heavily modded forums to FluxBB 1.2.20 !  Finally made the time to do this... took less than two days, a little tedious but I must say it went more smoothly (and straightforward) than I anticipated.

Cheers,
TwoHawks

===================================
Oh, PS (off topic, I know): I read with a bit of disdain all of the complaining that goes on.  Don't really care to engage in debate about it - seems petty and useless afaiac.  I just want to say that I know and appreciate how tough it is dedicating time to work, family, and volunteer projects (especially ones you want to dream 'perfect') and things don't always go the way you may want or dream them to.
   The spirit of the developers here encourages me, its a large part of why I'm here. 
   @Paul, thank you for your hard work and dedication.  Don't let bs get you down (not to say that it is or would). 
   This is a great project, with great people.  My hat is off to all you developers - ...thank you is all I really mean, or care, to say.

Last edited by twohawks (2008-11-16 20:44:08)

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

That's not how the read board group setting is meant to work. It disables the ability of the group to access any part of the site at all.

Re: User Groups Read Board Default Management Tweak needed

Thanks for the response, Smartys.

So I guess this means that I'd have to go and change  the permissions methods being used in the forums/topics/posts pages, right?

If that's all I had to do, I am thinking then it may be worth it (as long as I limited this to dealing with read permissions in those zones).

Last edited by twohawks (2008-11-16 22:47:19)

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

Thank you Smartys for that super-simple direction, it set me on the right path.  I know it was kind of stupid almost, but you know how it can get with your face right in something... you can forget to step back and consider the bigger picture sometimes.

Well I figured it out.... but I do not know if its really kosher, or wont know without deeper testing and feedback, but here is the (obvious) idea....

(EDITED 11-22-2008: Don't do it this way, it will not fully address the problem, and will be too much work. See posts ahead. HTH)

1) In "admin_forums.php" --> 2 edits:
      a) reconstruct the "$read_forum_new" variable assignment under "now lets deal with permissions" section (around line 190) to resemble the same construction as the following two variables, $post_replies_new and     $post_topics_new,
      b) and then similarly (starting at around ln 340)
         -- Edit the variable assignment for each $read_forum_xxxx variable to resemble the $post_xxx variables method of assignment, and
         -- Edit the form input tag table cell for "Read Forum" permisions checkbox to resemble the one(s) constructed for post.

2) In the necessary file, say for instance "index.php", I can...
   a) turn off read board permissions check at the beginning of the file, and then
   b) in the query that sets up printing categories and forums (in this case), JOIN the groups table in there so you can include testing for read permissions in tandem with forum table read permissions (that's already there).

That's the general idea.  Of course, then the post.php file, and possibly search or what have you, needs to be done as well.
Allows setting a group permissions, like say for guests, globally to OFF, and then I can check it to ON only for a specific Forum.  As well, then the admin does not have to always go and check it off, etc etc per problems described in my initial post.
=========================================
When I got it set up it seems to work just fine, but I have to test it more thoroughly.

*****I would really be interested in any feedback from the pro's here as to any concerns you might caution that I be careful to look at, and what you generally think about it - good idea/practice?, bad idea/practice?, doesn't much matter?, etc.*****

Thanks.

Last edited by twohawks (2008-11-22 08:39:56)

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

What I meant was that disabling a group's ability to read the board SHOULD keep them from reading any forum. The easiest way to do what you need to do is to modify admin_forums.php so all new forums insert a forum permissions row disabling reading for the specified groups. Whether that involves adding a new group permission or just hardcoding the groups into admin_forums.php is up to you.

Re: User Groups Read Board Default Management Tweak needed

I got a little sidetracked, but this isn't dead.
I realized after some work on 'the other method' pretty much what you just indicated... that its not so much about changing anything about how permissions are working for groups so much as affecting a permission change for a new forum -
Thank you for posting that.
When I've had time to get back to it and sort it out I will post.

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

Okay. got if sussed.  Here is the edit for making....

New Forum Group Permissions Default To OFF  (for Fluxbb 1.2.x)

#
#-------------[ 1. Open File   admin_forums.php   ]----------------
#
#
#-------------[ 2a. Find (line: ~52)]-----------------
#
    $db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());

#
#-------------[ 2b. Add After ]-----------------------
#
        //###### SET NEWLY ADDED FORUM GROUP PERMISSIONS OFF BY DEFAULT #########
        //       turn on to activate, comment out to return to normal settings   //
        $result = $db->query('SELECT MAX(id) AS last_f FROM '.$db->prefix.'forums') or error('Unable to fetch forum ident', __FILE__, __LINE__, $db->error());
        $cur_forum = $db->fetch_assoc($result);
        $result = $db->query('SELECT g_id FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
        while ($cur_group = $db->fetch_assoc($result))
        $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].','.$cur_forum['last_f'].',0,0,0)') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
        //###### END OF SET NEWLY ADDED FORUM GROUP PERMISSIONS OFF BY DEFAULT #########

That's it.
========================

Additionally, if upon making a new forum you prefer to be redirected to the new forum's edit page instead of back to the forums list, you can do this....

###---------ADDITIONAL FOR REDIRECT (if you like)------------------------
#
#-------------[ 3a. Find (line: ~68)]-----------------
#
    redirect("admin_forums.php?edit_forum=".$cur_forum['last_f']."",'Forum added. Redirecting …');

#
#-------------[ 3b. Replace With ]--------------
#
    // ###### Change Redirect to Edit the New Forum instead of back to the forum list #######
    //ORG redirect('admin_forums.php','Forum added. Redirecting …');
    redirect("admin_forums.php?edit_forum=".$cur_forum['last_f']."",'Forum added. Redirecting …');

THANK YOU FOR YOUR HELP, SMARTYS!

Last edited by twohawks (2008-11-22 22:43:24)

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

One note: selecting MAX(id) is wrong. Use $db->insert_id() instead

Re: User Groups Read Board Default Management Tweak needed

Thats great! I looked all over (for how to obtain/read the last row or column in a table) but the best (and most compact) method I could find was using SELECT MAX().  Didn't even think to search on 'determine last inserted' item.

I looked up $db->insert_id() and get that (direct and way less code), however, I do not understand your comment that using MAX(id) "is wrong"...
why is that "wrong as opposed to, say, "not the best method"?

Last edited by twohawks (2008-11-23 08:54:01)

TwoHawks
Love is the Function.
No Form is the Tool.

Re: User Groups Read Board Default Management Tweak needed

Because it introduces a race condition into your code. $db->insert_id is safe because it gets data just from your connection. MAX(id) can be affected by other people doing things at the same time smile

Re: User Groups Read Board Default Management Tweak needed

Thanks for the clarification.

TwoHawks
Love is the Function.
No Form is the Tool.