All comments to central e-mail address

Discussion corner for Developers of Serendipity.
Post Reply
Mickel
Regular
Posts: 5
Joined: Wed Feb 14, 2007 8:01 am

All comments to central e-mail address

Post by Mickel »

Hello,

First of all I'd like to thank the developers of Serendipity for their job well done. I love the software and the way it has been created. I do have a question, though. Before posting here, I have tried to get an answer on my question with the search function, but I couldn't find a solution.

I would like my serendipity to send copies of ALL comments (not entries!) to a central e-mail address (the "admin" address?). Naturally I already receive the comments on entries that I create, but I'd like to keep track of ALL comments and comments to comments that ALL authors receive. In other words, each time someone sends a comment to an entry, I would like serendipity to send a copy of the e-mail that the original author receives to a central (admin?) address.

Would someone be able to and prepared to post the solution for making this happen here?

Thanks for your time and help...

- Mickel
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: All comments to central e-mail address

Post by garvinhicking »

Hi!

Actually, s9y does not support this "out of the box", so you need to install a plugin to do that for you.

Luckily, such a plugin is VERY easy to do.

Just copy and paste the code below and save it inside /plugins/serendipity_event_mailcc/serendipity_event_mailcc.php. Then you go to your s9y admin panel, go to 'configure plugins', click on "click here to install an event plugin" and select the plugin "Adds CC to all sent emails" from the list. This will have a config screen where you can enter an email adress which will get each and every single email that s9y spews out.

This plugin has a simple caveat: E-Mails will only be sent, if the owner of an entry has "Send notification for comments" enabled. Else, an email will not be send, and thus you can't get a CC. To alter this functionality, changes in the core of s9y would need to be made, which I currently think should not really be necessary.

Of course, one other possibility for you is to just subscribe to the RSS comment feed of your blog, as this will contain all comments made to the blog :-)

But now for the simple plugin:

Code: Select all

<?php # $Id: serendipity_event_emoticate.php 1600 2007-01-26 10:01:30Z garvinhicking $

if (IN_serendipity !== true) {
    die ("Don't hack!");
}

class serendipity_event_mailcc extends serendipity_event
{
    var $title = 'Adds CC to all sent emails';

    function introspect(&$propbag) {
        global $serendipity;

        $propbag->add('name',          'Adds CC to all sent emails');
        $propbag->add('description',   '(Notice: Make sure that the all of your authors have the option to receiv comment notification emails activated, or else no mails will be created that can be CCed');
        $propbag->add('stackable',     false);
        $propbag->add('author',        'Garvin Hicking');
        $propbag->add('version',       '1.0');
        $propbag->add('requirements',  array('serendipity' => '0.8','smarty'      => '2.6.7','php'         => '4.1.0'
        ));
        $propbag->add('groups', array('BACKEND_FEATURES'));
        $propbag->add('event_hooks',   array('backend_sendmail' => true));
        $propbag->add('configuration', array('cc'));
    }

    function generate_content(&$title) {
        $title = $this->title;
    }

    function introspect_config_item($name, &$propbag) {
        switch($name) {
            case 'cc':
            $propbag->add('type',        'string');
            $propbag->add('name',        'E-Mail address to CC');
            $propbag->add('description', '');
            $propbag->add('default',     'nobody@example.com');
            break;
        }
        return true;
    }

    function event_hook($event, &$bag, &$eventData) {
        global $serendipity;
        $hooks = &$bag->get('event_hooks');

        if (isset($hooks[$event])) {
            switch($event) {
                case 'backend_sendmail':
                    $eventData['headers'][] = 'CC: ' . $this->get_config('cc');
                    return true;
                    break;

              default:
                return false;
            }
        } else {
            return false;
        }
    }

}
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Mickel
Regular
Posts: 5
Joined: Wed Feb 14, 2007 8:01 am

Thank you!!

Post by Mickel »

I just installed the plugin and it works WONDERS!! You're good!!

Thank you so much for taking the time to do this for me. I really appreciate it :D. I have to try and get into the details of Smarty. It looks easy, but I am not as PHP literate.

Anyways, thanks again :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Thank you!!

Post by garvinhicking »

Hi!

Great to hear that it works, you'Re welcome. :-)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Re: All comments to central e-mail address

Post by stm999999999 »

garvinhicking wrote: Just copy and paste the code below and save it inside /plugins/serendipity_event_mailcc/serendipity_event_mailcc.php.
Will it be put to spartacus?
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: All comments to central e-mail address

Post by garvinhicking »

Hi!
Will it be put to spartacus?
Nah, this is IMHO too small for too little benefit to let it clod up spartacus.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

hm, 1st I think nothing is too little, our plugin-pool must grown up!

2nd: I believe that this plugin can be interesting for every non-single-user-blog because - as I wrote many time before - even emails with "please approve a comment" go to the article-author wo has not the privileges to approve. So, with this plugin, these emails can go to one admin-user, too.
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
stm999999999 wrote:hm, 1st I think nothing is too little, our plugin-pool must grown up!
But not with the current Spartacus infrastructure. The large package.xml is already too large and fails on servers with only 8MB memory.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

Uih, that's bad :-(
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Lars Strojny offered to do some work on improving spartacus and changing the API. Let's see what he/we can come up with. :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
cleanforum
Regular
Posts: 6
Joined: Sun Mar 04, 2007 2:04 pm

Post by cleanforum »

Many thanks for the question and the answer - the former was broadly what I was seeking to do and Gavin's plugin-ette did it!

Thanks to you all.

Phil
tchirou
Regular
Posts: 29
Joined: Thu Feb 01, 2007 11:16 pm

Post by tchirou »

Hi,

I have installed Garvin's Plugin and it gives this in the header of the administration panel and in the box indicating "your entry has been saved".

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /mnt/136/free.fr/e/c/akeow/serendipity/plugins/serendipity_event_mailcc/serendipity_event_mailcc.php:2) in /mnt/136/free.fr/e/c/akeow/serendipity/include/functions_config.inc.php on line 567

Warning: Cannot modify header information - headers already sent by (output started at /mnt/136/free.fr/e/c/akeow/serendipity/plugins/serendipity_event_mailcc/serendipity_event_mailcc.php:2) in /mnt/136/free.fr/e/c/akeow/serendipity/plugins/serendipity_event_httpauth/serendipity_event_httpauth.php on line 185

Warning: Cannot modify header information - headers already sent by (output started at /mnt/136/free.fr/e/c/akeow/serendipity/plugins/serendipity_event_mailcc/serendipity_event_mailcc.php:2) in /mnt/136/free.fr/e/c/akeow/serendipity/serendipity_admin.php on line 11
Any idea ? It could scare my authors :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

You might have saved the file with a whitspace/newline before the first <?php or after the last ?>, remove that and the error will go away.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
tchirou
Regular
Posts: 29
Joined: Thu Feb 01, 2007 11:16 pm

Post by tchirou »

Exact. Well done Mister :wink:
Post Reply