[2.0.21] email posts or messages to combinations of groups

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
28
70%
Very Good
9
23%
Good
1
3%
Fair
2
5%
Poor
0
No votes
 
Total votes: 40

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

pclive72 wrote:Group Permissions Control
I select a group...
I get a list of forum categories, Simple permissions (Allow Access or Disallow Access), and Moderator status.
In group permiossions, when you select a group, click the 'Advanced Mode' link that gives you the detailed (not simple) permissions. If you do that, and if the mod really is installed, one of the columns will be called "Email Posts'.
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

Ok. I've installed the mod manually to find that there was a LOT of stuff missing that apparently did not get installed. I've got it working now, including the Topic Reply in Email. I see all of the options I wasn't seeing before. Now I'm having a different issue. When the email get's sent, every recipient is getting two copies of the email. I'm guessing that since some of the code already existed when I was going through manually, I may have inadvertently entered it a second time.

Can you advise me where to look for this code that might be causing the email to be sent twice?


Also, is this how the screen should look? I'm questioning it because it seems that the gray area should continue with white borders in between the fields.
Image

Thanks.
Paul
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

pclive72 wrote:Ok. I've installed the mod manually to find that there was a LOT of stuff missing that apparently did not get installed. I've got it working now, including the Topic Reply in Email. I see all of the options I wasn't seeing before. Now I'm having a different issue. When the email get's sent, every recipient is getting two copies of the email. I'm guessing that since some of the code already existed when I was going through manually, I may have inadvertently entered it a second time.

Can you advise me where to look for this code that might be causing the email to be sent twice?
I think you should look at each place where the mod tells you to make a change and see if you did it twice. That could be caused by duplicating the first long insert in posting.php or by dupliciating the first long insert in functions_post.php, but even if you find one place where you have doubled up you should still check it all.
Also, is this how the screen should look? I'm questioning it because it seems that the gray area should continue with white borders in between the fields.
Image
Yes, that's intentional. I was trying to distinguish between the part of the screen where you designate which groups should get the email and the rest of the screen.
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

Alan,

This really is a great mod. Thanks a bunch. I went back through and double check for duplication. It was your second suggestion causing the duplicate email. It was the long insert in functions_post.php.

Ok. Next issue. The only user I appears to be able to have this email option, is my original ADMIN account. I've created another account and gave it ADMIN rights and enabled the Email options in both a test group that I created as well as the individual test user permissions. I can't get the email checkbox to show up on another user. Only the original Admin.

What am I doing now?
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

It seems that only a group moderator is given the rights. I set the test user as the test group's moderator, and then the test user had the email option when posting. Any ideas?
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

pclive72 wrote:Ok. Next issue. The only user I appears to be able to have this email option, is my original ADMIN account. I've created another account and gave it ADMIN rights and enabled the Email options in both a test group that I created as well as the individual test user permissions. I can't get the email checkbox to show up on another user. Only the original Admin.

What am I doing now?
Don't know ;)

My guess is that you haven't really given that new user ADMIN rights. My guess is that you gave the user a 'rank' of site admin but that is not the same as making the user an "Administrator". Go to the ACP and click the 'permissions' link under "User Admin", then look up the new user and at the top of the page make sure the "User Level" is set to "Administrator" (and click submit once you do that so the setting will stick).

Alternatively, you can put the new user in a group that is granted permission to "email posts". You said you created a test group that you granted permission to email posts, but note that those permissions are forum by forum...are you sure you granted that email permission in all of your forums (or at least the ones you want the user to be able to email from)? And are you sure you actually put the new user in the test group?

If you still have problems, it means you made a mistake somewhere in installing the mod changes.
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

You were right about the ADMIN thing. Once I set the user as an Administrator from the user permissions page, then they had the email checkbox. But as it stands right now, only a true administrator or a Group moderator has this option available. I had already set every forum to "ON". But still only the moderator and true Administrators had the option.

So now I have to figure out why I can't successfully grant access based on the user belonging to a group that has appropriate permmissions.

I tried setting:
UPDATE phpbb_forums SET auth_emailposts = 0;

That should give everyone the option. But it doesn't for me. So I'm going to have to go back through and see what I did wrong.

If you have any ideas, they're certainly welcome. But in the meantime, I guess I'll retrace my steps.

Thanks for all of your help.
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

I just wanted to let you know that I found something that was causing my problem.

For the auth.php file, you are instructed to:

Code: Select all

#-----[ FIND ]------------------------------------------------
# this is a partial search : the full line is longer
			$a_sql = 'a.auth_view, a.auth_read, a.auth_post

#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			// start mod email posts and messages to combinations of groups (and end mod too)...
			// added references to 'auth_emailposts' in $a_sql and $auth_fields definitions below

#
#-----[ IN-LINE FIND ]----------------------------------------
#
, a.auth_delete

#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, a.auth_emailposts

#
#-----[ FIND ]------------------------------------------------
# this is a partial search : the full line is longer
			$auth_fields = array('auth_view', 'auth_read', 'auth_post'

#
#-----[ IN-LINE FIND ]----------------------------------------
#
, 'auth_delete'

#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, 'auth_emailposts'
The two find statements appear very similar. Additionally, the IN-LINE AFTER, ADD are equally similar which caused me to inadvertently skip over the second one thinking that I had just done that one. Omitting that one insertion of ", 'auth_emailposts'" didn't produce any errors. Instead, it only allowed Administrators and Moderators access to this feature.

Live and Learn.

Thanks for everything.
Paul
pclive72
Registered User
Posts: 68
Joined: Mon Jul 16, 2007 7:26 pm

Re: [2.0.21] email posts or messages to combinations of groups

Post by pclive72 »

There are at least 47 pages in this thread. I've read through a lot of them but I thought that maybe you'd know if what I'm looking for is there.

Has something been posted on how I might limit the ability for users to email certain groups? For example, the users that have rights to email posts, I don't necessarilly want them to be able to email "All Registered Users" or possibly even other groups. In fact, I may only have one or two groups that I'd like to be available with this option. Is this possible?

Thanks,
Paul
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

pclive72 wrote:Has something been posted on how I might limit the ability for users to email certain groups?
I think so ;)
pclive72 wrote:For example, the users that have rights to email posts, I don't necessarilly want them to be able to email "All Registered Users" or possibly even other groups. In fact, I may only have one or two groups that I'd like to be available with this option. Is this possible?
Yes, but your description so far is too vague. You need to figure out exactly what you want to do, and then you can tinker with the following code the mod adds to posting.php (especially the $sql query) in order to accomplish it:

Code: Select all

			// see if the user is a mod or admin or otherwise specifically authorized to email posts...
			// if so, give him an 'All Users' option, and if not, limit the groups to which he can email to
			// those groups (if any) that he moderates
			if( $is_auth['auth_mod'] || $is_auth['auth_emailposts'] )
			{
				// since this is a moderator or specifically authorized to email posts, do not limit the group lookup sql
				$sql_limit_groups = '';

				// now feed the template the information for the 'All users' row...
				$group_id = -1;
				$group_name = $lang['All_registered_users'];
				$group_notify = FALSE;
				// note that if you want 'all users' to be selected by default, change
				// the preceding line to $group_notify = TRUE;

				$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
				$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

				$template->assign_block_vars('listrow', array(
				'ROW_COLOR' => '#' . $row_color,
				'ROW_CLASS' => $row_class,

				'S_MARK_ID' => $group_id,
				'S_DEFAULT_DESIGNATED_GROUPS' => ( $group_notify ) ? 'checked="checked"' : '',

				'U_GROUP_NAME' => $group_name)
				);
			}
			else
			{
				// since this is not a moderator or speicfically authorized to email posts, limit the group lookup
				// sql to instances where the user is a moderator of a group
				$temp_user_id = $userdata['user_id'];
				$sql_limit_groups = "AND group_moderator = $temp_user_id";
			}
			// now figure out what groups to show in the list...
			$sql = "SELECT group_id, group_name, group_notify
			FROM " . GROUPS_TABLE . "
			WHERE group_single_user = 0
			$sql_limit_groups
			ORDER BY group_name";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Cannot find group info', '', __LINE__, __FILE__, $sql);
			}

			// now feed the template with info for the other groups (for the remaining rows)
			$group_id = '';
			while ( $row = $db->sql_fetchrow($result) )
			{
				$group_id = $row['group_id'];
				$group_name = $row['group_name'];
				$group_notify = FALSE;
				// note that this is set up so that by default no groups are checked and the
				// user needs to affirmatively check off any groups he wants the email to go to.
				// If you want the board to automatically 'remember' who the last emailed post or message went to
				// and check those groups off by default, change the preceding line to read:
				// $group_notify = ( $row['group_notify'] == 1 ) ? TRUE : FALSE;
				// but remember that this can be a bit dangerous since it is easy to inadvertently forget
				// to uncheck a group when you email a new post

				$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
				$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

				$template->assign_block_vars('listrow', array(
				'ROW_COLOR' => '#' . $row_color,
				'ROW_CLASS' => $row_class,

				'S_MARK_ID' => $group_id,
				'S_DEFAULT_DESIGNATED_GROUPS' => ( $group_notify ) ? 'checked="checked"' : '',

				'U_GROUP_NAME' => $group_name)
				);
			}
DenDix
Registered User
Posts: 4
Joined: Mon Feb 26, 2007 1:50 am

Re: [2.0.21] email posts or messages to combinations of groups

Post by DenDix »

pclive72 wrote:Has something been posted on how I might limit the ability for users to email certain groups?


I think so ;)

pclive72 wrote:For example, the users that have rights to email posts, I don't necessarilly want them to be able to email "All Registered Users" or possibly even other groups. In fact, I may only have one or two groups that I'd like to be available with this option. Is this possible?


Yes, but your description so far is too vague. You need to figure out exactly what you want to do, and then you can tinker with the following code the mod adds to posting.php (especially the $sql query) in order to accomplish it:
This is exactly what I want to do but I'm not familiar enough with php code to know exactly what to change in posting.php. When a member of a group tries to send an email of a post I want him to have ONLY the option to send the email to others in that group, NOT to "all users" or "other groups".

What exactly do I change in the code? Thanks for any help.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

DenDix wrote:When a member of a group tries to send an email of a post I want him to have ONLY the option to send the email to others in that group, NOT to "all users" or "other groups".
You can take a look at these posts for hints about where to take this:

http://www.phpbb.com/community/viewtopi ... 6#p3238146
http://www.phpbb.com/community/viewtopi ... 4#p1935014
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: [2.0.21] email posts or messages to combinations of groups

Post by asinshesq »

I think this should do the trick if you want it to work as follows:

- an admin or moderator is allowed to email to all registered users or to any group he or she feels like

- any other user is allowed to email email only to any group of which he or she is a member

Code: Select all

OPEN
posting.php

FIND
			if( $is_auth['auth_mod'] || $is_auth['auth_emailposts'] )

REPLACE WITH
			// restrict to admins and moderators the ability to email to all registered users and any group
			if( $is_auth['auth_mod'] )

FIND
			else
			{
				// since this is not a moderator or speicfically authorized to email posts, limit the group lookup
				// sql to instances where the user is a moderator of a group
				$temp_user_id = $userdata['user_id'];
				$sql_limit_groups = "AND group_moderator = $temp_user_id";
			}
			// now figure out what groups to show in the list...
			$sql = "SELECT group_id, group_name, group_notify
			FROM " . GROUPS_TABLE . "
			WHERE group_single_user = 0
			$sql_limit_groups
			ORDER BY group_name";


REPLACE WITH
			else
			{
				// since this is not an admin or moderator, limit the group lookup
				// sql to instances where the user is a member of the group
				$temp_user_id = $userdata['user_id'];
				$sql_limit_groups = "AND (g.group_id = ug.group_id AND ug.user_id = $temp_user_id AND ug.user_pending = 0)";
			}
			// now figure out what groups to show in the list...
			$sql = "SELECT DISTINCT g.group_id, g.group_name, g.group_notify
			FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug
			WHERE g.group_single_user = 0
			$sql_limit_groups
			ORDER BY g.group_name";
I haven't tested this so let me know if it works.
DenDix
Registered User
Posts: 4
Joined: Mon Feb 26, 2007 1:50 am

Re: [2.0.21] email posts or messages to combinations of groups

Post by DenDix »

Your code changes work great. Thanks a lot.
I don't think I ever could have figured that out on my own.
Post Reply

Return to “[2.0.x] MOD Database Releases”