Welcome to Geeklog, Anonymous Friday, March 01 2024 @ 12:05 am EST

Geeklog Forums

Auto Email events option?


Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
Is there a way -- can some one design -- the ability to email events to users when creating the event (or when approving to the master calender). It would be nice to create the event and email it to all or a group of users immediately -- rather than having the additional step of going to the mail users section and mailing the event.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
That shouldn\'t be too hard to do. There\'s even something similar already: The Admin can get a notification email when a user submits a new event. bye, Dirk
 Quote

Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
can you provide some instructions?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by me_dara: can you provide some instructions?
For what exactly? submit.php has a function sendNotification() that sends a notification email when someone submits a new story, link, or event. You can probably re-use some of that code to make your own notification function, which you should put in lib-custom.php. Then modify submit.php, admin/moderation.php and admin/event.php to call that function whenever a new event is submitted (and the submission queue is switched off), approved by an Admin, or entered by an Admin, respectively. bye, Dirk
 Quote

Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
What! -- I\'m not trying to write the code for all that. Maybe some out there can do it for me. The whole purpose of me using Geeklog is that it is a ready made solution. I want to just use it. I\'m way too busy working on other projects to try to get into this code. if no one wants to do it, fine, we\'ll just go through the extra step of sending an annoucement. but if you want to make a exhausted and overworked girl really happy...maybe you can do it for me.
 Quote

Status: offline

DTrumbower

Forum User
Moderator
Registered: 01/08/03
Posts: 507
Well, how much would you like to pay for this function? I\'m sure Dirk might be willing to do it for a fee.
 Quote

Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
I would pay heaps for it. However, as I just started my own business and had a baby, finances are tight. Maybe if other people were interested we can pool our money.
 Quote

Status: offline

DTrumbower

Forum User
Moderator
Registered: 01/08/03
Posts: 507
Maybe you should email him and get a price quote. Then you will know how much to pool.
 Quote

Status: offline

Mapp

Forum User
Newbie
Registered: 08/13/03
Posts: 8
I started on this earlier today and got a fair way. When admin approves event(s) email(s) get sent out all right. Now, I guess I\'ll make it work when admin submits an event but that will wait until tomorrow. I\'ll document what I wrote and post it. Still a few nagging little things to clear up but essentially works ok. Greg.
 Quote

Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
excited
Anxiously waiting... thanks, Greg!
 Quote

Status: offline

Mapp

Forum User
Newbie
Registered: 08/13/03
Posts: 8
As always, the actual writing of the code is the easy thing, figuring out what you want the behavior to be takes more work. So far, all I\'ve done is send emails with the subject line being the title of the event and the message body is the description. A couple of things occur to me, namely since I copied existing code there was a \"HTML\" option for the email which I got rid of for these purposes but maybe I should make it so that there is some html option? Maybe embed pictures, etc .... I really don\'t deal much with html mail so I don\'t even know what is possible to want in one\'s html mail. Embedded Flash movies? Another thought is to instead just include a \"mail_on_date\" field so that the emails don\'t necessarily get sent out when admin approves or submints but instead on some certain date? Sort of as a reminder type thing? Or as an \"as well as \" basis, so that immediately the event is added a mail goes out but admin could perhaps set another date to send out a reminder -- the thinking being that maybe you send the announcement that Dad\'s birthday party is happening at some place and time and then two days before you remind everyone again? So thats sort of what I\'m thinking about now. I\'m not proposing that I write the code for all that but it\'d be nice if the code I write now would accomodate that sort of thing so I\'m just giving a little thought to it. Greg.
 Quote

Status: offline

Mapp

Forum User
Newbie
Registered: 08/13/03
Posts: 8
OK, well I don't really need this myself right now so I can't spend too much time on it and I don't want to change too much so I left it so that the emails are only sent out if the story is explicitly approved. This means that if admin submits an event no mailer will be sent out, which suits me just fine as I really never want to submit as admin. It means you'd have to have a different name and/or submit anonymously and then log in and approve. I thought about doing it a different way, but then if I do that I may as well make it so users can have emails sent to groups that they are allowed to and such .... but that is quite a bit more coding and thinking. At any rate I hope what I've done helps. First of all I have two functions which go in the "/system/lib-custom.php" file (in addition to whatever else is in there).
Text Formatted Code
function compose_event_email ($event_array){
    if ($event_array['title'] != null){
        $event_message_layout = "Title: ".$event_array['title'];
                }
    if ($event_array['event_type'] != null){
        $event_message_layout .= "nEvent Type: ".$event_array['event_type'];
                }
    if ($event_array['datestart'] != null){
        $event_message_layout .= "nStart Date: ".$event_array['datestart'];
                }
    if ($event_array['timestart'] != null){
        $event_message_layout .= "nStart Time: ".$event_array['timestart'];
                }
    if ($event_array['dateend'] != null){
        $event_message_layout .= "nEnd Date: ".$event_array['dateend'];
                }
    if ($event_array['timeend'] != null){
        $event_message_layout .= "nEnd Time: ".$event_array['timeend'];
                }
    if ($event_array['allday'] != null){
        $event_message_layout .= "nAll Day: Yes";
        }
    if ($event_array['location'] != null){
        $event_message_layout .= "nLocation: ".$event_array['location'];
    }
    if ($event_array['address1'] != null){
        $event_message_layout .= "nAddress: ".$event_array['address1'];
    }
    if ($event_array['address2'] != null){
        $event_message_layout .= "n         ".$event_array['address2'];
    }
    if ($event_array['city'] != null){
        $event_message_layout .= "nCity: ".$event_array['city'];
    }
    if ($event_array['state'] != null){
        $event_message_layout .= "nState: ".$event_array['state'];
    }
    if ($event_array['zipcode'] != null){
        $event_message_layout .= "nZipcode: ".$event_array['zipcode'];
    }
    if ($event_array['description'] != null){
        $event_message_layout .= "nDescription: ".$event_array['description'];
    }

    return $event_message_layout;
}
function send_event_messages($event_id, $loopnum, $the_group_id)
{
    global $_CONF, $LANG31, $_TABLES, $LANG_CHARSET;
    $temp_vars = array("mail"=>"mail","to_group"=>"13","fra"=>"FlashSucks","fraepost"=>"flashsucks_blog@swfml.net", "subject"=>"mySubject", "message"=>"myMessage");

        if (empty($temp_vars['fra']) OR empty($temp_vars['fraepost']) OR empty($temp_vars['subject'])
        OR empty($temp_vars['message']) OR empty($temp_vars['to_group'])) {
                exit;
        }

        // Header information
        $headers = "From: {$temp_vars['fra']} rn";
        $headers .= "X-Sender: rn";
        $headers .= "X-Mailer: GeekLog " . VERSION . "rn"; // mailer
   
        $headers .= "Return-Path: rn";  // Return path for errors
    if (empty ($LANG_CHARSET)) {
        $charset = $_CONF['default_charset'];
        if (empty ($charset)) {
            $charset = "iso-8859-1";
        }
    } else {
        $charset = $LANG_CHARSET;
    }
        // and now mail it
            $sql = "SELECT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1";
            $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1";
            $sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id = {$temp_vars['to_group']}";

    $result = DB_query($sql);
    $nrows = DB_numRows($result);

    // Loop through and send the messages!
    for ($i = 1;$i
.... this next bit goes at about line 552 of "/public_html/admin/moderation.php" -- the only difference from the stock code is the if ($action2[$i] ... needs to be inserted before the existing "DB_copy" line .....
Text Formatted Code
            } else {
                // This is called in case this is a plugin. There may be some
                // plugin specific processing that needs to happen.
                 if ($action2[$i] == "auto_email"){
                     send_event_messages($mid,$i,$group_id);
                 }
                 DB_copy($table,$fields,$fields,$submissiontable,$id,$mid[$i]);
                $retval .= PLG_approveSubmission($type,$mid[$i]);
.... (if you use the "clean" style this is the path) in the "/public_html/layout/clean/admin/moderation/itemlist.thtml" file at about line goes the following -- right after before the closing ...
Text Formatted Code
                                        <b>{lang_auto_email}</b>
                                        <b>{lang_group_name}</b>
.... (if you use the "clean" style this is the path) the following goes in the "/public_html/layout/clean/admin/moderation/itemlistrows.thtml" file at about line 15 right before the closing tag ...
Text Formatted Code
                                           
                                           
                                       
                                       
                                            All Users
Block Admin
Event Admin
Group Admin
Link Admin
Logged-in Users
Mail Admin
Plugin Admin
Poll Admin
Root
Static Page Admin
Story Admin
Topic Admin
User Admin
 
... finally, in the /language/english.php file .... at line 881 or so, in the $Lang29 array .... add these ....
Text Formatted Code
    41 => "Auto Email",
    42 => "To Group"
.... and that should do it. Let me know if it doesn't work. I'll do more on it in the future. You (or anyone) might want to let me know any particular feature which might be desirable and I'll maybe add the functionality if I have time. greg
 Quote

Status: offline

me_dara

Forum User
Newbie
Registered: 07/20/03
Posts: 10
Wow... Thanks Greg. I\'ll let you know what how it works for us.
 Quote

All times are EST. The time is now 12:05 am.

  • 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