]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
Merge branch 'master' of https://github.com/friendica/friendica into threaded_items
[friendica.git] / include / enotify.php
index 89ecc3703fff966929ffd84aab5603383e1d98d7..b4331f0926679a871249e83cdba43c4f5fdb5ed2 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+require_once('include/email.php');
+
 function notification($params) {
 
        logger('notification: entry', LOGGER_DEBUG);
@@ -54,6 +56,20 @@ function notification($params) {
 
                $parent_id = $params['parent'];
 
+               // Check to see if there was already a tag notify for this post.
+               // If so don't create a second notification
+               
+               $p = null;
+               $p = q("select id from notify where type = %d and link = '%s' and uid = %d limit 1",
+                       intval(NOTIFY_TAGSELF),
+                       dbesc($params['link']),
+                       intval($params['uid'])
+               );
+               if($p and count($p)) {
+                       pop_lang();
+                       return;
+               }
+       
 
                // if it's a post figure out who's post it is.
 
@@ -80,7 +96,7 @@ function notification($params) {
                        $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
                                                '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
                                                $itemlink,
-                                               $p[0]['author-name']
+                                               $p[0]['author-name'],
                                                $item_post_type);
                
                // "your post"
@@ -95,7 +111,7 @@ function notification($params) {
                // Before this we have the name of the replier on the subject rendering 
                // differents subjects for messages on the same thread.
 
-               $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %1$s'), $parent_id, $params['source_name']);
+               $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
                $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); 
                $epreamble = $dest_str; 
 
@@ -108,11 +124,11 @@ function notification($params) {
        if($params['type'] == NOTIFY_WALL) {
                $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
 
-               $preamble = sprintf( t('%1$s posted to your profile wall at %1$s') , $params['source_name'], $sitename);
+               $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
                
-               $epreamble = sprintf( t('%1$s posted to [url=%2s]your wall[/url]') , 
+               $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') , 
                                                                '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
-                                                               $itemlink); 
+                                                               $params['link']); 
                
                $sitelink = t('Please visit %s to view and/or reply to the conversation.');
                $tsitelink = sprintf( $sitelink, $siteurl );
@@ -123,7 +139,7 @@ function notification($params) {
        if($params['type'] == NOTIFY_TAGSELF) {
                $subject =      sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
                $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
-               $epreamble = sprintf( t('%1$s [url=%2s]tagged you[/url].') , 
+               $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') , 
                                                                '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
                                                                $params['link']); 
 
@@ -133,6 +149,24 @@ function notification($params) {
                $itemlink =  $params['link'];
        }
 
+       if($params['type'] == NOTIFY_POKE) {
+
+               $subject =      sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
+               $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
+               $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') , 
+                                                               '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
+                                                               $params['link']); 
+
+               $subject = str_replace('poked', t($params['activity']), $subject);
+               $preamble = str_replace('poked', t($params['activity']), $preamble);
+               $epreamble = str_replace('poked', t($params['activity']), $epreamble);
+
+               $sitelink = t('Please visit %s to view and/or reply to the conversation.');
+               $tsitelink = sprintf( $sitelink, $siteurl );
+               $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+               $itemlink =  $params['link'];
+       }
+
        if($params['type'] == NOTIFY_TAGSHARE) {
                $subject =      sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
                $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
@@ -292,7 +326,7 @@ function notification($params) {
                // If so, create the record of it and use a message-id smtp header.
 
                if(!$r) {
-                       logger("norify_id:" . intval($notify_id). ", parent: " . intval($params['parent']) . "uid: " . 
+                       logger("notify_id:" . intval($notify_id). ", parent: " . intval($params['parent']) . "uid: " . 
 intval($params['uid']), LOGGER_DEBUG);
                        $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
                                values(%d,%d,%d,%d)",
@@ -463,6 +497,7 @@ class enotify {
                        $multipartMessageBody,                                                  // message body
                        $messageHeader                                                                  // message headers
                );
+               logger("notification: enotify::send header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
                logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
        }
 }