]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
sql optimisation cont.
[friendica.git] / include / enotify.php
index 6f0d65aedc52f43d281381023aa3d66d91d44448..f6f291e5d45be663ffa47523c997eb9652b681e3 100644 (file)
@@ -2,7 +2,7 @@
 
 function notification($params) {
 
-       logger('notification: entry');
+       logger('notification: entry', LOGGER_DEBUG);
 
        $a = get_app();
        $banner = t('Friendica Notification');
@@ -12,11 +12,16 @@ function notification($params) {
        $sitename = get_config('config','sitename');
        $site_admin = sprintf( t('%s Administrator'), $sitename);
 
-       $sender_name = t('Administrator');
+       $sender_name = $product;
        $sender_email = t('noreply') . '@' . $a->get_hostname();
 
-       $title = $params['item']['title'];
-       $body = $params['item']['body'];
+       if(array_key_exists('item',$params)) {
+               $title = $params['item']['title'];
+               $body = $params['item']['body'];
+       }
+       else {
+               $title = $body = '';
+       }
 
        if($params['type'] == NOTIFY_MAIL) {
 
@@ -32,8 +37,8 @@ function notification($params) {
 
        if($params['type'] == NOTIFY_COMMENT) {
 
-               $preamble = $subject = sprintf( t('%s commented on an item at %s'), $params['source_name'], $sitename);
-
+               $subject = sprintf( t('%s commented on an item at %s'), $params['source_name'], $sitename);
+               $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); 
                $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>');
@@ -49,13 +54,31 @@ function notification($params) {
                $itemlink =  $params['link'];
        }
 
+       if($params['type'] == NOTIFY_INTRO) {
+               $subject = sprintf( t('Introduction received at %s'), $sitename);
+               $preamble = sprintf( t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename); 
+               $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
+
+               $sitelink = t('Please visit %s to approve or reject the introduction.');
+               $tsitelink = sprintf( $sitelink, $siteurl );
+               $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+               $itemlink =  $params['link'];
+       }
+
+       if($params['type'] == NOTIFY_CONFIRM) {
+
+       }
+
+       // TODO - create notification entry in DB
+
+
 
        // send email notification if notification preferences permit
 
        require_once('bbcode.php');
        if(intval($params['notify_flags']) & intval($params['type'])) {
 
-               logger('notification: sending email');
+               logger('notification: sending notification email');
 
                push_lang($params['language']);
 
@@ -77,7 +100,7 @@ function notification($params) {
                        '$source_photo' => $params['source_photo'],
                        '$username'     => $params['to_name'],
                        '$hsitelink'    => $hsitelink,
-                       '$itemlink'     => $itemlink,
+                       '$itemlink'     => '<a href="' . $itemlink . '">' . $itemlink . '</a>',
                        '$thanks'       => $thanks,
                        '$site_admin'   => $site_admin,
                        '$title'                => stripslashes($title),
@@ -104,7 +127,7 @@ function notification($params) {
                        '$textversion'  => $textversion,        
                ));
 
-               logger('text: ' . $email_text_body);
+//             logger('text: ' . $email_text_body);
 
                // use the EmailNotification library to send the message
 
@@ -149,7 +172,7 @@ class enotify {
                // generate a multipart/alternative message header
                $messageHeader =
                        "From: {$params['fromName']} <{$params['fromEmail']}>\n" . 
-                       "Reply-To: {$params['replyTo']}\n" .
+                       "Reply-To: {$params['fromName']} <{$params['replyTo']}>\n" .
                        "MIME-Version: 1.0\n" .
                        "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
 
@@ -174,7 +197,7 @@ class enotify {
                        $multipartMessageBody,                                                  // message body
                        $messageHeader                                                                  // message headers
                );
-               logger("enotify::send returns " . $res, LOGGER_DEBUG);
+               logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
        }
 }
 ?>
\ No newline at end of file