1 (edited by noof 2005-01-12 23:17)

Topic: Multigroup mod for PunBB 1.2

What?
ok, this is the first punbb mod I ever release, so use it at your own risk wink anyways, this mod enables you to make a user member of more than one group, if you couldn't make that out from the topic smile the user still has a primary group that is "his/her group", the only time punbb uses the additional groups you have selected is for the read/post reply/post topic permission (i.e it's only used for forum permissions).. because of this you cannot select "Moderator" or "Administrator" as an additional group, they have to be the primary one..

How?
To install the mod you'll need:
* PunBB 1.2 (final, not the beta)
* punmod (tested with version 0.9.4)

I had to tweak punmod to make it work properly with PunBB 1.2 (if you're really wild n crazy you can try punmod 0.95beta). The things I needed to change was in _punmod/_punmod.php:
After (line 10-15)

$PUNMOD_MODE = -1;
$PUNMOD_ERROR = null;

$pun_root = './';

add

define('PUN_ROOT', $pun_root);

and after (line 20?)

define('PUN_TURN_OFF_MAINT', 1); // circumvent maintenance mode.

add

error_reporting(E_ALL ^ E_NOTICE);

which makes the first part of the file look like:

<?php

define('PUNMOD_FOLDER',   'punmods');
define('PUNMOD_REGISTRY', PUNMOD_FOLDER.'/_installed_mods.txt');
define('PUNMOD_APPLY',    0);
define('PUNMOD_VERIFY',   1);
define('PUNMOD_GETINFO',  2);
define('PUNMOD_ENGINE',   1);

$PUNMOD_MODE = -1;
$PUNMOD_ERROR = null;

$pun_root = './';

require $pun_root.'include/common.php';

if (!defined('PUN_DEBUG'))
    define('PUN_DEBUG', 1); // complete error message from PunBB on failure.

define('PUN_TURN_OFF_MAINT', 1); // circumvent maintenance mode.

error_reporting(E_ALL ^ E_NOTICE);

$mod_registry = array();

Then just follow the punmod instructions in the readme.txt:

1. Copy everything from the "upload" folder to your PunBB root folder.
2. Copy any mods you wish to apply into the "punmods" folder.
3. Ensure that PHP has write access permissions in PunBB folder and subfolders.
4. Open your browser to "punmod.php" and follow the on-screen instructions.

After the installation is finished you'll end up with a new listbox under the "Administration" page of the user profile. Hold down ctrl and select the group(s) the user should be member of, click "Save" and hopefully it works wink

Where?
Grab it here!

Disclaimer
This mod changes the PunBB source heavily and it might:
1) destroy your forum totally
2) crash your server
3) steal your girlfriend

although this didn't happen to me you never know wink


and btw, post here if you have any ideas or if it doesn't work...

Re: Multigroup mod for PunBB 1.2

this looks very interesting, i'm going to have a look when i get time, oh and nice work using Punmod smile

3

Re: Multigroup mod for PunBB 1.2

there is a bug. your mod will not work on PostgreSQL
you should change

ALTER TABLE `<prefix>users` ADD `membergroupids` VARCHAR(64) AFTER `group_id`

to

ALTER TABLE <prefix>users ADD membergroupids VARCHAR(64)

to let it work with postgres
PS Great MOD!

4 (edited by noof 2005-01-14 16:07)

Re: Multigroup mod for PunBB 1.2

ahh.. I've only tested it on mysql, not used to things that works on more than one DBMS smile thanks!
(fixed in version 0.11b)

5

Re: Multigroup mod for PunBB 1.2

well, probably it would be better to make so, to maintain original structure, or punmod does not support this kind of expressions ?
multigroup.pun...

##SQL PGSQL
        ALTER TABLE <prefix>users ADD membergroupids VARCHAR(64)
##SQL MYSQL
ALTER TABLE `<prefix>users` ADD `membergroupids` VARCHAR(64) AFTER `group_id`

Re: Multigroup mod for PunBB 1.2

neat smile

I'll integrate these changes into the next release of PunMod, thanks.

Please note that PunMod is still in beta phase, and some things will change - you will probably need to update the mod for the next version of PunMod ... as a minimum, you will be required to add ##UNSQL commands, you can read more about that in this thread, if you're not already following it:

http://punbb.org/forums/viewtopic.php?pid=30716#p30716

7 (edited by noof 2005-01-14 23:23)

Re: Multigroup mod for PunBB 1.2

XuMiX wrote:

well, probably it would be better to make so, to maintain original structure, or punmod does not support this kind of expressions ?
multigroup.pun...

##SQL PGSQL
        ALTER TABLE <prefix>users ADD membergroupids VARCHAR(64)
##SQL MYSQL
ALTER TABLE `<prefix>users` ADD `membergroupids` VARCHAR(64) AFTER `group_id`

whops, I didn't read that far in the readme roll

mindplay wrote:

neat smile

I'll integrate these changes into the next release of PunMod, thanks.

Please note that PunMod is still in beta phase, and some things will change - you will probably need to update the mod for the next version of PunMod ... as a minimum, you will be required to add ##UNSQL commands, you can read more about that in this thread, if you're not already following it:

http://punbb.org/forums/viewtopic.php?pid=30716#p30716

well, I kinda followed it, but I thought I'll let you guys decide what the format smile

added one sql for mysql and one for pg now..

8 (edited by XuMiX 2005-01-25 17:40)

Re: Multigroup mod for PunBB 1.2

bug:
add user to members and some your group
edit some forum permissions so members could not post topics and your new group could
now enter this forum by this user and you will not see any post new topic link
PS maybe you will not be able to post even through direct url - i have not checked this

Re: Multigroup mod for PunBB 1.2

SO this mod allows people to be in more then one group?
If so that would help out so much on my forum.

Re: Multigroup mod for PunBB 1.2

Hello,

this seems to be the solution to my problem. does it work?

thx SAM

11

Re: Multigroup mod for PunBB 1.2

not really good.. it still very incomplete
i've completed it for my site, but its too modded to make extract of this mod

12

Re: Multigroup mod for PunBB 1.2

Has anyone got this working with punBB 1.2.5?

Thx.

13 (edited by bradleyb 2005-09-26 19:22)

Re: Multigroup mod for PunBB 1.2

Here's a bug I found:
in profile.php, you should change

$new_add_group = (isset($_POST['add_group_id']) ? $_POST['add_group_id'] : null);

to

$new_add_group = (isset($_POST['add_group_id']) ? array_map('intval', $_POST['add_group_id']) : null);

to prevent the possibility of SQL injection.

Re: Multigroup mod for PunBB 1.2

also in profile.php, the line:

print_r($add_groups);

looks like debugging info that was left in by mistake.

15 (edited by bradleyb 2005-09-26 20:52)

Re: Multigroup mod for PunBB 1.2

in admin_user.php, the line:

$conditions[] = 'u.group_id='.$user_group.' OR membergroupids LIKE \'%,'.$user_group.',%\' OR membergroupids LIKE \''.$user_group.',%\' OR membergroupids LIKE \'%,'.$user_group.'\'';

should be:

$conditions[] = 'u.group_id='.$db->escape($user_group).' OR membergroupids=\''.$db->escape($user_group).'\' OR membergroupids LIKE \'%,'.$db->escape($user_group).',%\' OR membergroupids LIKE \''.$db->escape($user_group).',%\' OR membergroupids LIKE \'%,'.$db->escape($user_group).'\'';

I added an additional OR clause to it, so it will find users who are only in a single additional group (no commas in the membergroupids field).
The $db->escape() calls are added to bring it in line with the latest punbb version (SQL injection vulnerability).

16

Re: Multigroup mod for PunBB 1.2

First of... I'm not skilled with MySQL although I know enough to be able to guess from time to time. Perhaps I'm guessing wrong this time but we'll see.

I created a test user who is a regular member (primary group, gid 4) and let him join another user group (Spelledare, gid 8). When going to the forum Spelledare (only members with gid 8 has access to it) the following query is executed...

SELECT f.forum_name, f.redirect_url, f.moderators, f.num_topics, f.sort_by, fp.post_topics
FROM mb_forums AS f
LEFT JOIN mb_forum_perms AS fp ON ( fp.forum_id=f.id AND fp.group_id=4 )
LEFT JOIN mb_forum_perms AS fp1 ON ( fp1.forum_id=f.id AND fp1.group_id=8 )
WHERE (
    (
        fp.read_forum IS NULL OR fp.read_forum=1
    ) OR (
        fp1.read_forum IS NULL OR fp1.read_forum=1
    )
)
AND f.id=15

When used with phpmyadmin i get the following output...

forum_name    redirect_url    moderators    num_topics    sort_by    post_topics
Spelledare    NULL            NULL          14            0          0

No permissions to post topics! However, if I manually change fp.group_id to 8 and fp1.group_id to 4 I get post_topic=1. Does this mean that if fp matches the database it never checks fp1, fp2, fp3, etc? If so - how do you make it continue?

17

Re: Multigroup mod for PunBB 1.2

No one?

18

Re: Multigroup mod for PunBB 1.2

Is this Modification still up to date?

Re: Multigroup mod for PunBB 1.2

Chepra wrote:

Is this Modification still up to date?

I doubt it =/

20

Re: Multigroup mod for PunBB 1.2

Anyone who wanna update it? smile

Re: Multigroup mod for PunBB 1.2

I thought about trying, but decided to wait for multiple moderator group code from 1.3. (Then I'll realize I'm still in over my head, so don't get excited. tongue)