• Welcome to Simple Machines Community Forum. Please login or sign up.
January 16, 2022, 08:45:20 PM

News:

SMF 2.0.19 has been released! Please update. Read more.


Group as Group Moderator (2.x)

Started by Vala, June 28, 2010, 02:55:50 PM

Previous topic - Next topic

Vala

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

ѕησω

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.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not dead yet, the time was soon to come to pass when mysql_query shall be gone and no more."

Norv

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.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

SugarD-x

June 30, 2011, 08:35:47 PM #3 Last Edit: March 03, 2013, 05:24:06 AM by SugarD-x
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.

Norv

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.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

SugarD-x

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.

Omega_K2

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.

SugarD-x

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.
* SugarD-x hopes it gets added.

SugarD-x

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.

Kindred

Since it is not in 2.1, to the he's of my knowledge, I would say it was not accepted
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

emanuele

I think someone was working on something, but not for 2.1.

This belongs to the batch of this topic.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

SugarD-x

Oh crap, my mistake guys. Sorry about that. Thanks for whoever moved this, and thanks to all who have replied! :)

moparisthebest

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.
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

Kindred

why didn't you just build this in php and trigger it using SMF's own scehduled tasks feature?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SugarD-x

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?

moparisthebest

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. :)
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

Kindred

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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

moparisthebest

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?
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

SugarD-x

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

moparisthebest

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)?
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

Kindred

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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Sure there is, but that's hardly convenient to run it every hour.
No good deed goes unpunished
All helpful urges should be circumvented

Kindred

but would you really need to run it every hour?   How often do you change a person's membergroup?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Fair point.

Why not go one better and hook it into the code when you change a membergroup or the members in it?
No good deed goes unpunished
All helpful urges should be circumvented

Kindred

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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SugarD-x

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.

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

moparisthebest

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. :)
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

Kindred

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...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

moparisthebest

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. :)
You can have my gun when you pry it from my cold, dead hands.
Linux users, we do it in the open.

SugarD-x

I would love you guys forever if you did it. :)

Dark Wizard

Hello, is any mod exists that can set group as group moderator yet?

Kindred

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Oldiesmann

No there isn't, and there are no plans to add it to my knowledge.
Michael Eshom
Cincy Space - now open!

Advertisement: