Droplet or snippet request for notification when news is commented

Boudi

Hi folks :)

THnQ for your time and answers. They did the trick!  (Y)
...:: Bake the Unbakable ::...

Gast

correct place for your code lines are after the insert and before the line with the header-location
in the actual SP5 Package after line 160 and for line 161

DarkViper


Hi Boudi,

the wrong output of the Line <a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a> is an effect only.
The reason of is an empty variable $page['link'].
So you must explore, where this VAR has been set and why it's empty.

Manuela
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Boudi

I noticed that (in my case)

<a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a>

is not working properly any more and its output is: www.domain.com/pages.php instead of the specific url on where a comment was placed.

...:: Bake the Unbakable ::...

Boudi

Found this topic and this snippet code works well.

Any idea if a 'moderate' function is possible in the news mod?
...:: Bake the Unbakable ::...

CaptainRob

Thank you for the solution Marmot.
It's correct, with your code WB is now sending two separate emails, but that's no problem for me.  :-)

Thanks,
Rob

marmot

Hi,

Quote from: CaptainRob on November 09, 2012, 01:26:45 PM
So what must be changed to sent a notification mail to 2 email addresses?
in wb 283 phpmailer was upgraded to version 5.2 which brings a validation function for email addresses. That's the reason why your solution doesn't work anymore ("email1, email2" is not a valid address).
So you could send mail by mail:

   $mail_subject = 'A comment has been made';
   $mail_message = '<b> One item has been commented on this page: </b>
<a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a>

  <b> Title: </b>
'.$title.'

  <b> Comment: </b>
    '.$comment.'' ;
   
  $wb->mail(SERVER_EMAIL,'mail1@tosendmail.to',$mail_subject,$mail_message);
  $wb->mail(SERVER_EMAIL,'mail2@tosendmail.to',$mail_subject,$mail_message);
if you really need to send only one mail with 2 recipients, the only possibility I see is to change the wb core. For example in class.wb.php ~line 418 you find: $myMail->AddAddress($toaddress);
change this to $toaddresses = explode(', ',$toaddress);
foreach($toaddresses as $to)
$myMail->AddAddress($to);
none of these is tested so there is a good chance for errors in it  :wink:

regards

CaptainRob

Hello,

For some time I added this code in my modules/news/submit_comment.php


$mail_to = 'mail1@tosendmail.to' . ', ';
$mail_to .= 'mail2@tosendmail.to';

   $mail_subject = 'A comment has been made';
   $mail_message = '<b> One item has been commented on this page: </b>
<a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a>

  <b> Title: </b>
'.$title.'

  <b> Comment: </b>
    '.$comment.'' ;
   
   $wb->mail(SERVER_EMAIL,$mail_to,$mail_subject,$mail_message);


That was working fine in WB 2.8.2 now I have updated to 2.8.3 it is not working any more.
With 1 email address it is working fine, but with 2 addresses nothing is happening.

So what must be changed to sent a notification mail to 2 email addresses?

Thanks,
Rob


pcwacht

Please do.

Artcles is still an ongoing work in progress. The progress is being slowed down cause of the promised 2.9, ,  allso I was/am bizzy with some other modules needed for work. And work itself.
Allso had some operation on my hip last september, I needed a new one wich slowed me down as well.

Am coding articles when I have some spare time left wich is rarely the case ;)


John
[url="http://www.ictwacht.nl"]http://www.ictwacht.nl[/url] = Dutch ICT info
[url="http://www.pcwacht.nl"]http://www.pcwacht.nl[/url] = My first
both still work in progress, since years.....

snark

@pcwacht

Any progress on the articles module yet?

What i saw à while ago was very promising, i have made quite some additions to the news3,5 newsmodule, I will include the commentnotification and send you a version

nuke

Thanks for this Argos and John - this works great, just what I was looking for =)

-Mike

Quote from: Argos on November 10, 2010, 02:09:56 PM
Works right away John, thank you very much!  :-D

I'll post a reference in the other topic.

I have edited the snippet to contain a working link and the comment itself:

  $mail_to = 'address@tosendmail.to';
   $mail_subject = 'A comment has been made';
   $mail_message = 'One newsitem has been commented on this page: <a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a>
   
   Comment:
   '.$comment.'' ;
   
   $wb->mail(SERVER_EMAIL,$mail_to,$mail_subject,$mail_message);


pcwacht

will be in settings
adminsettings, use comments? use mail notification?
settings - comments, comment layout template and email template if the above is true

Will be a heap of settings ;)

John
[url="http://www.ictwacht.nl"]http://www.ictwacht.nl[/url] = Dutch ICT info
[url="http://www.pcwacht.nl"]http://www.pcwacht.nl[/url] = My first
both still work in progress, since years.....

Argos

Quote from: pcwacht on November 10, 2010, 03:09:40 PM
Cool to know I can still make working code without testing ;)
I'm jealous  :wink:
Quote
PS Will be incoörporated in articles.
Nice. Maybe you can use language variables instead of the hardcoded English text lines.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

pcwacht

Cool to know I can still make working code without testing ;)

PS Will be incoörporated in articles.
[url="http://www.ictwacht.nl"]http://www.ictwacht.nl[/url] = Dutch ICT info
[url="http://www.pcwacht.nl"]http://www.pcwacht.nl[/url] = My first
both still work in progress, since years.....

Argos

Works right away John, thank you very much!  :-D

I'll post a reference in the other topic.

I have edited the snippet to contain a working link and the comment itself:

  $mail_to = 'address@tosendmail.to';
   $mail_subject = 'A comment has been made';
   $mail_message = 'One newsitem has been commented on this page: <a href="'.$wb->page_link($page['link']).'">'.$wb->page_link($page['link']).'</a>
   
   Comment:
   '.$comment.'' ;
   
   $wb->mail(SERVER_EMAIL,$mail_to,$mail_subject,$mail_message);
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

pcwacht

Hoi Argos,

Can't be done with a droplet in settings.

You need extra code wich mail a warning when and only when a submission is made, therefore the best option is to add that code to submit_comment.php,
search for: around line 121,
   // Insert the comment into db
A few lines later, right before the header statement this code can be added.

   // Sending the email
               $mail_to = 'address@tosendmail.to';
               $mail_subject = 'A comment has been made';
               $mail_message = 'One newsitem has been commented on this page: '.$wb->page_link($page['link']).'?post_id='.$post_id.' !';
   $wb->mail(SERVER_EMAIL,$mail_to,$mail_subject,$mail_message);

Didn't test it!! but think it'll get you started ;)

Have fun,
John
[url="http://www.ictwacht.nl"]http://www.ictwacht.nl[/url] = Dutch ICT info
[url="http://www.pcwacht.nl"]http://www.pcwacht.nl[/url] = My first
both still work in progress, since years.....

Argos

I tried to implement a function that sends an email notification when a news item is commented. There is a topic that has code, but I can't get it to work. See https://forum.websitebaker.org/index.php/topic,4699.0.html

Ideal would be a droplet that I can just put in the settings of the news module, but code snippet to put in a php file would be okay as well. Can anyone help? Thanks in advance!
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!