Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 06:08 pm EDT

Geeklog Forums

hmmmmm???

Page navigation


FreakWorld

Anonymous
Is there a way to make a user account email more thin 1 email?
The reason I am asking, is I have 5 Admin on my site.
So when someone has a problem. I want it to email all the admins so the first 1 on line can get to it.

 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
untested
if you have your admins all in the 'root' group then do this:

first, find this code in the function contactemail() in profiles.php (line 99ish of 1.3.11):
Text Formatted Code

                if (!empty ($A['fullname'])) {
                    $to = COM_formatEmailAddress ($A['fullname'], $A['email']);
                } else {
                    $to = COM_formatEmailAddress ($A['username'], $A['email']);
                }


 

second, replace it with this:
Text Formatted Code

            if($uid != 2){
                if (!empty ($A['fullname'])) {
                    $to = COM_formatEmailAddress ($A['fullname'], $A['email']);
                } else {
                    $to = COM_formatEmailAddress ($A['username'], $A['email']);
                }
            } elseif ($uid == 2){//if mail is being sent to admin/root
                $to = '';
                //get user ids of group 'root'
                $result = DB_query("SELECT ug_uid FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id='1'");
                if(DB_numRows($result) >= 1){
                    //for each of your admins add their email addy to $to
                    //i think mail.php can take an array or list of comma separated recipients...
                    while($A = DB_fetchArray($result)){
                        $Bresult = DB_query("SELECT username,fullname,email FROM {$_TABLES['users']} WHERE uid = {$A['ug_uid']}");
                        $B = DB_fetchArray($Bresult);
                        if (!empty ($B['fullname'])) {
                            $to .= ',' . COM_formatEmailAddress ($B['fullname'], $B['email']);
                        } else {
                            $to .= ',' . COM_formatEmailAddress ($B['username'], $B['email']);
                        }
                    }
                }
            }


 


that sends mail to all members of 'root' group whenever the site admin is being mailed. ...i think
Like i said, it is untested.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
btw, this neglects to check the user's personal prefs, e.g., perhaps one of your admins doesn't want to get mail--this will not check his preference.
 Quote

FreakWorld

Anonymous
cool thanks.
If they don't want to talk to members. Thin they need to stop being an admin. LOL
 Quote

FreakWorld

Anonymous
it works kinda.
1 problem.
It's sending 2 emails to everyone.
any ideas why?
 Quote

FreakWorld

Anonymous
after more test it's sending a number of emails to admins.
Say there is 3 admins.
Thin EACH admin well get 3 emails from 1 email.
Or say there is 2 admin.
Thin we well get 2 emails from 1.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Quote by FreakWorld:
any ideas why?

yes... but i'm just out the door so i'll catch you later tonight
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
find this line,
Text Formatted Code
    return $formatted_name . ' <' . $address . '>';


 
in function COM_formatEmailAddress() in lib-common.php and add a semicolon just after the address like this:
Text Formatted Code
    return $formatted_name . ' <' . $address . '>;';


 


dunno if that will solve the problem but its a place to start.
hope that helps

 Quote

FreakWorld

Anonymous
man I hate to tell you, but it stopped the email all together.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
lol...

k, try this: edit your while condition to this:
Text Formatted Code
while($A = DB_fetchArray($result,false)){
 
now it should not go over each admin twice--i'm assuming that it was adding an address for the index and then again for the assoc.

how can you tell i'm not testing any of this? Giving it a try
 Quote

FreakWorld

Anonymous
Want to check with you first.

1st code change keep?
2nd code change keep?
And all the while conditions in the lib-common.php?
There is a few.......
 Quote

FreakWorld

Anonymous
what I did try is, changing "while" in the first code you gave me.

with the ; in the lib-common.php it did not email anything.
with out it, it emails me mutable times like the first test.

lol if you don't mind working on this.
I don't mind testing your ideas. Mr. Green
 Quote

FreakWorld

Anonymous
so did you give up on me? Mr. Green
 Quote

Status: offline

Mikez

Forum User
Regular Poster
Registered: 06/17/05
Posts: 87
anyone ealse willing to take a shot at it?
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
try this slightly modified version of the above code...
Text Formatted Code

            if($uid != 2){
                if (!empty ($A['fullname'])) {
                    $to = COM_formatEmailAddress ($A['fullname'], $A['email']);
                } else {
                    $to = COM_formatEmailAddress ($A['username'], $A['email']);
                }
            } elseif ($uid == 2){//if mail is being sent to admin/root
                $to = array();
                //get user ids of group 'root'
                $resultA = DB_query("SELECT ug_uid FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id='1'");
                if(DB_numRows($resultA) >= 1){
                    //for each of your admins add their email addy to $to
                    //i think mail.php can take an array or list of comma separated recipients...
                    while($A = DB_fetchArray($resultA)){
                        $resultB = DB_query("SELECT username,fullname,email FROM {$_TABLES['users']} WHERE uid = {$A['ug_uid']}");
                        $B = DB_fetchArray($resultB);
                        if (!empty ($B['fullname'])) {
                            $to[] = COM_formatEmailAddress ($B['fullname'], $B['email']);
                        } else {
                            $to[] = COM_formatEmailAddress ($B['username'], $B['email']);
                        }
                    }
                }
            }


 
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
any word on success or not?
 Quote

Status: offline

Mikez

Forum User
Regular Poster
Registered: 06/17/05
Posts: 87
I am going to test it in the morning. With the move to the new sever, I still need to put a test site together.
 Quote

Status: offline

Mikez

Forum User
Regular Poster
Registered: 06/17/05
Posts: 87
IT WORKED!!!
Putting it on the main site.
Thanks!!!
 Quote

Status: offline

dewdoo

Forum User
Chatty
Registered: 01/03/04
Posts: 65
will this work for moderator too?

UPDATE: Big Celebration It does WORK! Big Celebration
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
yes, this will do the same for moderator(s). You just need the user id of the moderator(s) or the moderator's group id; and decide what uid triggers this mail (for example, the above code is triggered when someone sends mail to the site admin at uid #2).
. ...and be careful not to disable regular mail to all other members.
 Quote

Page navigation

All times are EDT. The time is now 06:08 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content