Hack: Improving the New Item email notification

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
User avatar
chadness
Joomla! Guru
Joomla! Guru
Posts: 768
Joined: Mon Aug 22, 2005 5:43 pm
Location: Minneapolis, MN
Contact:

Hack: Improving the New Item email notification

Post by chadness » Thu Oct 06, 2005 5:42 pm

Have you ever wanted to know more than just that a new private message has arrived when your users submit items?  How about, what they submitted and a quick link back to your administration panel?

OK, here's what to do.

In your language file (for example, if using english, your /language/english.php file), change your _ON_NEW_CONTENT line to this (customize it how you like):

Code: Select all

DEFINE('_ON_NEW_CONTENT', "Hello,\nA new content item has been submitted by [ %s ] titled [ %s ] for the section [ %s ] and category [ %s ].\nPlease go to $mosConfig_live_site/administrator/ to view and approve this article.\nPlease do not respond to this message as it is automatically generated and is for information purposes only." );
Then go in to /components/com_messages/messages.class.php, and delete these two lines (should be 84 and 85):

Code: Select all

$subject = _NEW_MESSAGE;
$msg = _NEW_MESSAGE;
Then, in the next line (formerly 87), change $msg to $message, like so:

Code: Select all

mosMail($mosConfig_mailfrom, $mosConfig_fromname, $recipient, $subject, $message);
This will make it email using the same subject and message line that is in the private message.

[edit - included reference to the language file]
Last edited by chadness on Wed Jul 12, 2006 7:19 pm, edited 1 time in total.

User avatar
jackbremer
Joomla! Explorer
Joomla! Explorer
Posts: 265
Joined: Wed Jul 12, 2006 5:37 pm
Location: London, UK

Re: Hack: Improving the New Item email notification

Post by jackbremer » Wed Jul 12, 2006 5:41 pm

OK, here's what to do. Try changing your _ON_NEW_CONTENT line to this (customize it how you like):
in which file though? I've tried changing things in the following files:

/components/com_content/content.php
/components/com_messages/messages.class.php

neither seem to work, wherever I add in that code or wherever I modify something. I have now got the emails more useful, and showing the contents of the actual private message, but nothing works to include your polite message. I think you have simply ommitted to inform us which file we should add that code to!

Thanks in advance for your assistance...

User avatar
chadness
Joomla! Guru
Joomla! Guru
Posts: 768
Joined: Mon Aug 22, 2005 5:43 pm
Location: Minneapolis, MN
Contact:

Re: Hack: Improving the New Item email notification

Post by chadness » Wed Jul 12, 2006 5:53 pm

Good point - I didn't make that very clear.  _ON_NEW_CONTENT is one of the variables in your language file.  So, if you are using english, you would change it in /language/english.php .

User avatar
jackbremer
Joomla! Explorer
Joomla! Explorer
Posts: 265
Joined: Wed Jul 12, 2006 5:37 pm
Location: London, UK

Re: Hack: Improving the New Item email notification

Post by jackbremer » Wed Jul 12, 2006 7:03 pm

AWESOME! thanks for the speedy response too... once I managed to undo all the changes I'd done it worked a treat!

Cheers, and keep up the great work.

Mods/Admins feel free to clean up this thread now to include reference to the language file in the original post...

User avatar
chadness
Joomla! Guru
Joomla! Guru
Posts: 768
Joined: Mon Aug 22, 2005 5:43 pm
Location: Minneapolis, MN
Contact:

Re: Hack: Improving the New Item email notification

Post by chadness » Wed Jul 12, 2006 7:19 pm

jackbremer wrote: AWESOME! thanks for the speedy response too... once I managed to undo all the changes I'd done it worked a treat!

Cheers, and keep up the great work.

Mods/Admins feel free to clean up this thread now to include reference to the language file in the original post...
Done.  I'll leave the comments in case anyone else was wondering where that was.

Lionel
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Tue Oct 04, 2005 2:12 am

Re: Hack: Improving the New Item email notification

Post by Lionel » Fri Jul 14, 2006 7:53 am

Very cool. Actually the first part in language file was already in there. Changing the class made it work.
Now, can that email be linked to the content?

User avatar
jackbremer
Joomla! Explorer
Joomla! Explorer
Posts: 265
Joined: Wed Jul 12, 2006 5:37 pm
Location: London, UK

Re: Hack: Improving the New Item email notification

Post by jackbremer » Fri Jul 14, 2006 8:51 am

Indeed Lionel, it was in there originally, and this simply makes it more polite and provides a link direct to the administration panel.

I suppose if we knew what the content's variable name was we could include that too? I don't quite understand how it knows which bit refers to which when they are listed simply as $s for each variable in the language file... any ideas?

Ottobufonto
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 118
Joined: Tue Sep 06, 2005 10:53 pm

Re: Hack: Improving the New Item email notification

Post by Ottobufonto » Mon Jul 24, 2006 3:32 pm

Doea anyone know whether this will make it into J! 1.5 or whether there is a module/component about to handle this???

Such basic functionality - its astounding...

If not - I'll try the hack for now.

User avatar
cozimek
Joomla! Guru
Joomla! Guru
Posts: 570
Joined: Thu Aug 18, 2005 1:27 pm
Location: Washington, DC & San Francisco, CA
Contact:

Re: Hack: Improving the New Item email notification

Post by cozimek » Mon Jul 24, 2006 3:35 pm

Ottobufonto,

I don't believe this will be included in 1.5, but if you can come up with a good modeled hack, I'm sure we can persuade the core to include the functionality into 1.6, etc.

Best,
Ryan
Soapbox Engage - "Empowering the missions of non-profits through technology"
www.soapboxengage.com
Twittering at www.twitter.com/cozimek (@cozimek)

Ottobufonto
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 118
Joined: Tue Sep 06, 2005 10:53 pm

Re: Hack: Improving the New Item email notification

Post by Ottobufonto » Mon Jul 24, 2006 3:45 pm

I didn't mean I would write a hack... well I can try - but J! 2.0 might be out before that... :-)

I have seen the "email me on new message", but I think this should be a configurable system where you can select receipients from publisher list against differnt sections of the page... instead of admin..

When I said basic - I didn't mean simple. just something that a cms should do.... user a) submits content to b) or c) or d) and based on set of rules differnt publishers get notified to approve content.... implementation is probably for from trivial.

Otto

loophole
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Nov 14, 2006 1:32 am
Location: USA
Contact:

Re: Hack: Improving the New Item email notification

Post by loophole » Mon Jul 07, 2008 12:10 am

This didn't quite work for me. Here's what I had to do to make it work (using 1.0.15):

Changed the language file (/language/english.php) as you instructed:

Code: Select all

DEFINE('_ON_NEW_CONTENT', "Hello,\nA new content item has been submitted by [ %s ] titled [ %s ] for the section [ %s ] and category [ %s ].\nPlease go to $mosConfig_live_site/administrator/ to view and approve this article.\nPlease do not respond to this message as it is automatically generated and is for information purposes only." );
Editing /components/com_messages/messages.class.php didn't seem to work for me, so I left it alone. Instead I added the following to /component/com_content/content.php around line 2400 right after:

foreach ($users as $user_id) {
$msg = new mosMessage( $database );
$msg->send( $my->id, $user_id, "New Item", sprintf( _ON_NEW_CONTENT, $my->username, $row->title, $section, $category ) );
}

Add:

Code: Select all

mosMail( "[email protected]", "Admin", "[email protected]", "New Item", sprintf( _ON_NEW_CONTENT, $my->username, $row->title, $section, $category ) );


Works like a charm - curious for you opinion on this! Personally I hate hacks, they make life difficult. However, my client needed a better way of controlling workflow. They have rules set on the email client that receives this email. It checks the section and category then forwards it to the correct publisher for that section. I have my fingers crossed that the next version of Joomla will have this capability built in!


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”