Simple Machines Community Forum

SMF Development => Feature Requests => Topic started by: Vala on June 28, 2010, 02:55:50 PM

Title: Group as Group Moderator (2.x)
Post by: Vala on June 28, 2010, 02:55:50 PM
Hi,

What I'd like to be able to do in 2.0 RC3 (and beyond) is assign a group as the group moderator of another.  An example would be I have board "A" and membergroups "A Leaders", and "A Members."  "A leaders" has moderator roles over board "A."  I would like to be able to set the group "A Leaders" as the group moderator of "A Members" so that as the leadership/moderators of board A change they are granted/removed as group moderators of the members group via their addition/subtraction from the leadership group.

Thank you for your time and consideration.

Vala
Title: Re: Group as Group Moderator (2.x)
Post by: Acans on June 29, 2010, 04:09:16 AM
This can be done, however not buy group.

You must add members that you wish to be group leaders by (Admin > membergroups > Modify)

You'll see a field called group moderators, they can add, remove members from that group.
Title: Re: Group as Group Moderator (2.x)
Post by: Norv on November 20, 2010, 02:39:48 AM
I think I've seen this in IPB IIRC.
However, I haven't seen it requested any other time than this, thus I suspect that it's not a widespread usefulness...

Thank you for the suggestion, Vala. I doubt it will be in default SMF, but I'm sure a mod could be done to fit this need.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on June 30, 2011, 08:35:47 PM
Sorry for the bump, but to be honest this would actually be very useful and much more secure. PHPBB3 has it as well, and it doesn't make a whole lot of sense to me that users specifically can moderate groups but group ranks can't be set to do it. On many forums where one group is the lead of another, having it set by user could become a security issue because if the user loses their said leading rank, they would still be able to have control over who is in the member's group, which is a big problem. Same thing with not having another option for groups to moderate specific boards without changing the entire permissions system method being used. If the options for these two were added, forums that have such systems set up could easily just set a user with a specific rank that has these permissions already granted to the rank, and that would make life much easier for admins, not to mention reduce the chance of forgetting to remove multiple rights from many different places just for one user. When you moderate a large forum, it's hard to remember all of this at times...especially when you are only an admin on the forum and you don't actually participate in the forum's focus itself.
Title: Re: Group as Group Moderator (2.x)
Post by: Norv on July 03, 2011, 02:50:04 AM
Thank you for the feedback, SugarD. :)
TBH, this has come back lately a few more times as well... (in other topics).

More opinions are appreciated.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on July 03, 2011, 03:07:04 AM
Quote from: Norv on July 03, 2011, 02:50:04 AM
Thank you for the feedback, SugarD. :)
TBH, this has come back lately a few more times as well... (in other topics).

More opinions are appreciated.
No problem man. SMF and PHPBB have always been my favorite forum softwares, and I used to lean more towards PHPBB3, but ever since SMF 2 came out, I've been becoming more fond of it instead. ;)

Given that SMF is open source now, maybe it would be a good idea, (with the other softwares' permission), to maybe take a look at what the other softwares have that SMF doesn't, and maybe implement your own version of it if users like it enough. Overall most things are universal between them these days, but it's the little things, like this, that make those defining reasons behind which one a user chooses.
Title: Re: Group as Group Moderator (2.x)
Post by: Omega_K2 on December 01, 2011, 05:03:29 PM
I think the capability to appoint actual groups as moderators for other groups instead of invdividual users would be a great improvement. I support the idea aswell.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on December 01, 2011, 05:09:27 PM
Quote from: Omega_K2 on December 01, 2011, 05:03:29 PM
I think the capability to appoint actual groups as moderators for other groups instead of invdividual users would be a great improvement. I support the idea aswell.
/me hopes it gets added.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on September 15, 2012, 09:59:48 PM
I'm sorry to bump this, but I'm curious if this has this been accepted or denied. :)

The board it is in is not very clear on it's status, and it's been idle for almost a year without any official comments.
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on September 15, 2012, 11:12:42 PM
Since it is not in 2.1, to the he's of my knowledge, I would say it was not accepted
Title: Re: Group as Group Moderator (2.x)
Post by: emanuele on September 16, 2012, 03:57:31 AM
I think someone was working on something, but not for 2.1.

This belongs to the batch of this topic (http://www.simplemachines.org/community/index.php?topic=471300.0).
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on September 16, 2012, 08:01:59 PM
Oh crap, my mistake guys. Sorry about that. Thanks for whoever moved this, and thanks to all who have replied! :)
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 09:18:26 AM
I needed this functionality on my forum, and went ahead and implemented it as a simple shell script I run once an hour, you could have it run more often if you like, but it's good enough for me.

This script generates the SQL:

#!/bin/bash

# put groups to modify here, syntax is 'mod_group1,group1 mod_group2,group2' etc
groups='83,77'

# don't touch anything under here...

# ensure groups ends in a space, otherwise read below will skip the last one
last_character=${groups#${groups%?}}
[ "$last_character" == " " ] || groups="$groups "

# loop through them, printing the SQL
echo "$groups" | while IFS=',' read -d' ' mod_group group; do
    echo "-- group $mod_group moderating $group";
    echo "DELETE FROM smf_group_moderators WHERE id_group = $group;"
    echo "INSERT INTO smf_group_moderators SELECT $group AS id_group, id_member FROM smf_members WHERE id_group = $mod_group OR id_post_group = $mod_group OR FIND_IN_SET($mod_group, additional_groups);"
done


Which I actually execute with a script like this:

#!/bin/bash
/home/youruser/groupsModerateGroups.sh | mysql -umysql_user -pmysql_pass dbname >> /home/youruser/groupMods.log 2>&1
echo "ran $(date) successfully" >> /home/youruser/groupMods.log


The SQL generated of course looks like this:
-- group 83 moderating 77
DELETE FROM smf_group_moderators WHERE id_group = 77;
INSERT INTO smf_group_moderators SELECT 77 AS id_group, id_member FROM smf_members WHERE id_group = 83 OR id_post_group = 83 OR FIND_IN_SET(83, additional_groups);


If you have any questions, let me know.
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 09:33:12 AM
why didn't you just build this in php and trigger it using SMF's own scehduled tasks feature?
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on March 12, 2013, 09:35:49 AM
I'm a little confused as to why that code needs to have a timer running at all. Wouldn't it just be easier to make a PHP modification to the forum permissions?
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 09:59:01 AM
Quote from: Kindred on March 12, 2013, 09:33:12 AM
why didn't you just build this in php and trigger it using SMF's own scehduled tasks feature?

I've never used SMF's scheduled tasks feature, seems like it tries to re-invent cron, so I'd rather just use cron.  Someone can do this by using my queries above and writing 4 or 5 lines of PHP code pretty easily though, if they don't have cron.

Quote from: SugarD-x on March 12, 2013, 09:35:49 AM
I'm a little confused as to why that code needs to have a timer running at all. Wouldn't it just be easier to make a PHP modification to the forum permissions?

Easier? I don't think so.  Quicker? Certainly not, this took me maybe 5 minutes.  Better? Yes, built-in support would be much better, but you would also need to do the interface work for specifying which group gets to moderate which group, and then store/load that information into/from the database as well.  So this requires a PHP change, HTML change (maybe javascript too), and a database change.  I didn't feel like doing any of that, so I wrote 2 SQL queries and a shell script. :)
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 10:02:08 AM
Actually Sugar, what he appears to be doing is checking to see who is in what group and then assiging the USERS in that group to the correct permissions.

So, he's not modifying anything in the core of SMF's permissions to allow the group to be a gropup moderator.
What he is doing is checking (once an hour) to see who is in the group which he has made as a group moderator and then granting each user in that group to group moderator permission (or removing it, if they are no longer in the group)

it's a decent way to do it, without mucking with the smf permissions system actually...
He's just doing it inefficiently, by using an external script, when he could be using the smf scheduled tasks to do the same thing without any external junk at all.
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 10:03:18 AM
And it's even possible to get cron to call SMF's scheduled tasks... the reason it was set up is because not everyone can configure cron jobs properly.
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 10:23:10 AM
Quote from: Arantor on March 12, 2013, 10:03:18 AM
And it's even possible to get cron to call SMF's scheduled tasks... the reason it was set up is because not everyone can configure cron jobs properly.

In that case I think a mini-tutorial on cron would have been a better way to go, but I figured it was for people who *shudder* run this on windows without cron.

I might make a more robust version in the future in PHP, it would make this much cleaner in a language that had actual array support. :)  Is the only requirement for SMF's scheduled tasks that it be written in PHP?
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 10:28:03 AM
QuoteIn that case I think a mini-tutorial on cron would have been a better way to go, but I figured it was for people who *shudder* run this on windows without cron.

You mean like most of the developers who actually develop and test the software do it on their home computers?

And quite honestly, I can't imagine a quicker way to create support issues. Most of the users here, to be honest, are not up to the task of configuring cron jobs and are not willing to learn. And by giving them a large hurdle, you're actually discouraging them from using the software.

Quoteit would make this much cleaner in a language that had actual array support

PHP DOES have actual array support. In fact its array support is better than other languages.

QuoteIs the only requirement for SMF's scheduled tasks that it be written in PHP?

Pretty much, since you need to get the credentials from Settings.php to be able to use it automatically.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on March 12, 2013, 10:35:58 AM
Quote from: Kindred on March 12, 2013, 10:02:08 AM
Actually Sugar, what he appears to be doing is checking to see who is in what group and then assiging the USERS in that group to the correct permissions.

So, he's not modifying anything in the core of SMF's permissions to allow the group to be a gropup moderator.
What he is doing is checking (once an hour) to see who is in the group which he has made as a group moderator and then granting each user in that group to group moderator permission (or removing it, if they are no longer in the group)

it's a decent way to do it, without mucking with the smf permissions system actually...
He's just doing it inefficiently, by using an external script, when he could be using the smf scheduled tasks to do the same thing without any external junk at all.
Ah, thank you Kindred. I was a little confused as to why he was doing automated tasks instead of a direct database change upon actually setting something manually. Now I get why. :)
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 10:52:21 AM
Quote from: Arantor on March 12, 2013, 10:28:03 AM
Quoteit would make this much cleaner in a language that had actual array support

PHP DOES have actual array support. In fact its array support is better than other languages.

I know, I said it would be nice and more robust to write it in a language like PHP with actual array support, vs my hack in bash with IFS and friends... :)

I just stumbled across your thread here:
http://www.simplemachines.org/community/index.php?topic=329894.0
That explains it quite well, if I implement it that way though, is there a nice supported way to still run it from the command line (ie, cron)?
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 10:54:50 AM
There is not a "nice supported way" to run it from the command line. It requires a special bridge that has never, to my knowledge, been distributed.

But the point is, it'll still run... even without you using cron.
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 11:03:58 AM
actually, in SMF's scheduled tasks interface, there is a "run this now" option as well...

no command lin needed at all. add a scheduled task, it runs automatically. If you need to force it to run, trigger the run now option.
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 11:08:02 AM
Sure there is, but that's hardly convenient to run it every hour.
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 11:09:38 AM
but would you really need to run it every hour?   How often do you change a person's membergroup?
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 11:10:16 AM
Fair point.

Why not go one better and hook it into the code when you change a membergroup or the members in it?
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 11:12:14 AM
I was wondering how easy that would be to trigger........  it does seem tpo be the most logical place to trigger it, even more so than a scheduled task.
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on March 12, 2013, 11:15:41 AM
Quote from: Kindred on March 12, 2013, 11:12:14 AM
I was wondering how easy that would be to trigger........  it does seem tpo be the most logical place to trigger it, even more so than a scheduled task.
That's what I was getting at too, although I probably didn't do a good job at wording it. That was the reason why the automated system didn't make sense to me to begin with.
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 11:21:23 AM
Theory says you should be able to do it off the integrate_change_member_data hook, except changes to secondary groups probably won't trigger it. The code's pretty labyrinthine, between Profile-Modify and Profile, but as far as I can tell, id_group won't change unless you specifically change it, and changing additional_groups won't automatically trigger an id_group change. But... you could add additional_groups to the list in updateMemberData just before the hook is called, and then do something based on the hook call.
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 11:38:06 AM
Getting it to run is one thing, it's fairly straightforward any way you go about it.  The thing I didn't want to mess with, making this not a 'nice' mod, is the UI and database changes for storing which group moderates which other groups.  Right now it's a simple string in a bash script, even if I did port it to PHP, it would be a hard-coded array in PHP.

This is the difference between a quick hack (my code above), and a proper mod. :)
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 11:39:40 AM
No, a proper mod is one that modifies the code. There are plenty of mods that are only a step up from 'dirty nasty hack' by simple virtue of being packaged into a list of find/replace statements in an XML container.
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on March 12, 2013, 11:42:29 AM
it would be a pretty sunple UI.

Group to be moderated;group to be the moderators
store it in the mod settings array
do a foreach when you trigger the check and break apart the string at the semicolon
you could set as many as you want this way and have an array of 20 cross moderating groups.   lol



and lol Arantor....  yep...
Title: Re: Group as Group Moderator (2.x)
Post by: Arantor on March 12, 2013, 11:45:07 AM
Quoteand lol Arantor....  yep...

You do realise I made some of the nastiest :P

QuoteGroup to be moderated;group to be the moderators
store it in the mod settings array

Pretty much.
Title: Re: Group as Group Moderator (2.x)
Post by: moparisthebest on March 12, 2013, 11:49:32 AM
Quote from: Kindred on March 12, 2013, 11:42:29 AM
it would be a pretty sunple UI.

Group to be moderated;group to be the moderators
store it in the mod settings array
do a foreach when you trigger the check and break apart the string at the semicolon
you could set as many as you want this way and have an array of 20 cross moderating groups.   lol

I hate UI work, if you want to do that part, I'll write my stuff in PHP and we can package up a nice mod. :)
Title: Re: Group as Group Moderator (2.x)
Post by: SD-X on March 12, 2013, 01:47:10 PM
I would love you guys forever if you did it. :)
Title: Re: Group as Group Moderator (2.x)
Post by: Dark Wizard on November 05, 2015, 10:57:16 PM
Hello, is any mod exists that can set group as group moderator yet?
Title: Re: Group as Group Moderator (2.x)
Post by: Kindred on November 06, 2015, 06:41:09 AM
I do not believe so...
Title: Re: Group as Group Moderator (2.x)
Post by: Oldiesmann on November 24, 2015, 11:39:36 AM
No there isn't, and there are no plans to add it to my knowledge.