1 (edited by ephestione 2010-08-08 08:15)

Topic: [Release] New post email notification to admin address

I made, briefly tested and hence released a mini-extension that, whenever a user who's not the admin (uid!=2) posts a new reply/topic anywhere in the forum, sends a mail to the preconfigured admin mail with a link to said message.

It is only recommended to forum admins who manage very "silent" forums and want to be warned of new activity when it occurs instead of having to check regularly.

More information (english) can be found here: http://www.ephestione.it/punbb-e-mail-n … extension/
una descrizione più approfondita (in italiano) si trova qui: http://www.ephestione.it/it/punbb-e-mai … extension/

The extension's zip has been uploaded to the wiki 1.3 extensions list, http://punbb.informer.com/wiki/lib/exe/ … extensions (which only contains PNG files actually, this goes beyond my comprehension, anyway the uploader accepted my zip file, so you can find the pun_newpost_mail_notify.zip file in there.
Here's the direct link (thanks KeyDog wink) http://punbb.informer.com/wiki/_media/p … notify.zip

v 1.1 8/8/2010 later that morning, updated as per post #2 by Grez, thanks tongue
v 1.0 8/8/2010 1am very first release

2

Re: [Release] New post email notification to admin address

Hi, yea, I guess this can be useful for some people smile

I see just one flaw here...

ephestione wrote:

who's not the admin (uid!=2)

IMO better would be $forum_user['group_id'] != 1 - guess you wouldn't like to get emails when you would gave administration to someone another one day, and sometimes (for example when you migrate from another forum), you don't have to have id 2 at all  smile

Eraversum - scifi browser-based online webgame

Re: [Release] New post email notification to admin address

Thank you for putting this into code wink
I knew my approach was over-simplistic, as it basically assumes you installed punbb fresh, or something like it, and doesn't take into account other admin users.
It was between 1am and 2am while I was coding this and it was a straing enough, for a total newb of punbb, to find out the globals for admin mail and board name tongue
Will update it right away wink

Re: [Release] New post email notification to admin address

Just a little issue I have... the email addy it's coming from is not the usual forum email I have set...
It's using another one... I have two websites with different URL and different email admins etc... but your extension is somehow getting them from the root....

Any idea what I have to do to get default forum email sending?

Re: [Release] New post email notification to admin address

He's just using the mail() function itself, I believe, when he should be including the email handler from PunBB and using forum_mail();

Re: [Release] New post email notification to admin address

you're both right, but I have NO idea about your issues big_smile
The mail address as specified has been suggested by Grez, who indicated it would be better to use the mail address of whoever user is registered as "admin", instead of the user id 2, which is the default admin id but could not be the admin after all in an existing punbb installation.
So @keydog, the user whom the mail is arriving to, must be registered as "admin" in said forum (the "right" one, as I'm accessing just the DB tables that belong to the forum in which the extension is installed into), maybe there are two admin users in there and my extension is fetching the address of the first one it finds, which may not be the one you're looking for?

@nhodges
I'd be happy to update the extension to make it more punbb compliant, alas I have no idea how the forum_mail() function works, and what are its benefits over mail(), but if explaining that is a matter of a minute and you're willing to go over it, I may as well update the code.

Re: [Release] New post email notification to admin address

ephestione wrote:

user whom the mail is arriving to, must be registered as "admin" in said forum

Afraid not big_smile It's going to the owner of a CMS on another URL  ! And it's showing the URL of the CMS instead of anything to do with forum. Definitely need to revisit the mail being replaced by forum_mail

Re: [Release] New post email notification to admin address

...wait a second, I just reviewed the code of the extension, and the admin email address is not taken from the forum_user['group_id`] thing... that's just a check I make to avoid sending to the admin notifications of his own posts. I've forgotten my on code tongue
Anyway, apart from the mail() function being used instead of forum_mail() of which I know nothing, and do not have the mental energy to look into (;)), all the variables passed to it are legit punbb variables:
$forum_config['o_admin_email'] is the admin email address as specified in the config array of punbb
$forum_config['o_board_title'] same as previous for the forum title
$base_url and $new_pid are values that are defined prior of calling the extension's hook and refer to the "root" of the forum url and the "mysql_insert_id" of the last insert query of the last post...
so if you're getting the mail sent to that other user it is because $forum_config['o_admin_email'] points to that address instead of the admin's address.
I'd still like to be pointed to the documentation of forum_mail in order to decide if it has benefits, especially regarding this situation of yours wink

9

Re: [Release] New post email notification to admin address

So where do you go to setup/configure this extension once you've installed it? Sorry I'm new.

Re: [Release] New post email notification to admin address

you don't need to setup this extension, it's automatically active after installation, and sends out notifications as soon as someone who's not the admin writes a post; the behaviour cannot be changed unless you manually edit the source code.