From 5910fbf42023f36e69068c4ec09c772d997bbb72 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 21 Feb 2012 00:02:42 -0800 Subject: fill in notify msg with redirect link after we get the id --- include/enotify.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index c19cc3a9c..7fa83cfa4 100755 --- a/include/enotify.php +++ b/include/enotify.php @@ -28,7 +28,7 @@ function notification($params) { $subject = sprintf( t('New mail received at %s'),$sitename); $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename); - $epreamble = sprintf( t('%s sent you %s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $siteurl . '/message]' . t('a private message') . '[/url]'); + $epreamble = sprintf( t('%s sent you %s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to your private messages.'); $tsitelink = sprintf( $sitelink, $siteurl . '/message' ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); @@ -39,7 +39,7 @@ function notification($params) { $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']); - $epreamble = sprintf( t('%s commented on %s you have been following.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('an item/conversation') . '[/url]'); + $epreamble = sprintf( t('%s commented on %s you have been following.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('an item/conversation') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -49,7 +49,7 @@ function notification($params) { if($params['type'] == NOTIFY_WALL) { $preamble = $subject = sprintf( t('%s posted to your profile wall at %s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%s posted to %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('your profile wall.') . '[/url]'); + $epreamble = sprintf( t('%s posted to %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your profile wall.') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -69,7 +69,7 @@ function notification($params) { if($params['type'] == NOTIFY_TAGSHARE) { $preamble = $subject = sprintf( t('%s tagged your post at %s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%s tagged %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('your post') . '[/url]' ); + $epreamble = sprintf( t('%s tagged %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your post') . '[/url]' ); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -80,7 +80,7 @@ function notification($params) { 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); - $epreamble = sprintf( t('You\'ve received %s from %s.'), '[url=' . $params['link'] . ']' . t('an introduction') . '[/url]' , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + $epreamble = sprintf( t('You\'ve received %s from %s.'), '[url=$itemlink]' . t('an introduction') . '[/url]' , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = sprintf( t('You may visit their profile at %s'),$params['source_link']); $sitelink = t('Please visit %s to approve or reject the introduction.'); @@ -93,7 +93,7 @@ function notification($params) { $subject = sprintf( t('Friend suggestion received at %s'), $sitename); $preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename); $epreamble = sprintf( t('You\'ve received %s for %s from %s.'), - '[url=' . $params['link'] . ']' . t('a friend suggestion') . '[/url]', + '[url=$itemlink]' . t('a friend suggestion') . '[/url]', '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]', '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = t('Name:') . ' ' . $params['item']['name'] . "\n"; @@ -130,14 +130,13 @@ function notification($params) { // create notification entry in DB - $r = q("insert into notify (hash,name,url,photo,date,msg,uid,link,type,verb,otype) - values('%s','%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')", + $r = q("insert into notify (hash,name,url,photo,date,uid,link,type,verb,otype) + values('%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')", dbesc($hash), dbesc($params['source_name']), dbesc($params['source_link']), dbesc($params['source_photo']), dbesc(datetime_convert()), - dbesc($epreamble), intval($params['uid']), dbesc($itemlink), intval($params['type']), @@ -155,6 +154,14 @@ function notification($params) { return; $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id; + $msg = replace_macros($epreamble,array('$itemlink' => $itemlink)); + $r = q("update notify set msg = '%s' where id = %d and uid = %d limit 1", + dbesc($msg), + intval($notify_id), + intval($params['uid']) + ); + + // send email notification if notification preferences permit -- cgit v1.2.3