2 require_once('include/Emailer.php');
3 require_once('include/email.php');
4 require_once('include/bbcode.php');
5 require_once('include/html2bbcode.php');
7 function notification($params) {
9 #logger('notification()', LOGGER_DEBUG);
13 // from here on everything is in the recipients language
15 push_lang($params['language']);
18 $banner = t('Friendica Notification');
19 $product = FRIENDICA_PLATFORM;
20 $siteurl = $a->get_baseurl(true);
21 $thanks = t('Thank You,');
22 $sitename = $a->config['sitename'];
23 $site_admin = sprintf( t('%s Administrator'), $sitename);
26 $sender_name = $sitename;
27 $hostname = $a->get_hostname();
28 if(strpos($hostname,':'))
29 $hostname = substr($hostname,0,strpos($hostname,':'));
31 $sender_email = $a->config['sender_email'];
32 if (empty($sender_email)) {
33 $sender_email = t('noreply') . '@' . $hostname;
36 $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
38 $nickname = $user[0]["nickname"];
40 // with $params['show_in_notification_page'] == false, the notification isn't inserted into
41 // the database, and an email is sent if applicable.
42 // default, if not specified: true
43 $show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
45 $additional_mail_header = "";
46 $additional_mail_header .= "Precedence: list\n";
47 $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
48 $additional_mail_header .= "X-Friendica-Account: <".$nickname."@".$hostname.">\n";
49 $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
50 $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
51 $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
52 $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
55 if(array_key_exists('item',$params)) {
56 $title = $params['item']['title'];
57 $body = $params['item']['body'];
63 // e.g. "your post", "David's photo", etc.
64 $possess_desc = t('%s <!item_type!>');
66 if (isset($params['item']['id']))
67 $item_id = $params['item']['id'];
71 if (isset($params['parent']))
72 $parent_id = $params['parent'];
76 if($params['type'] == NOTIFY_MAIL) {
78 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
80 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
81 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
82 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
83 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
84 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
85 $itemlink = $siteurl . '/message/' . $params['item']['id'];
88 if($params['type'] == NOTIFY_COMMENT) {
89 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
91 //$parent_id = $params['parent'];
93 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
95 intval($params['uid'])
97 if ($p AND count($p) AND ($p[0]["ignored"])) {
98 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
102 // Check to see if there was already a tag notify or comment notify for this post.
103 // If so don't create a second notification
106 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
107 intval(NOTIFY_TAGSELF),
108 intval(NOTIFY_COMMENT),
109 intval(NOTIFY_SHARE),
110 dbesc($params['link']),
111 intval($params['uid'])
113 if($p and count($p)) {
119 // if it's a post figure out who's post it is.
123 if($params['otype'] === 'item' && $parent_id) {
124 $p = q("select * from item where id = %d and uid = %d limit 1",
126 intval($params['uid'])
130 $item_post_type = item_post_type($p[0]);
131 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
134 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
135 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
139 // "George Bull's post"
141 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
142 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
144 $p[0]['author-name'],
148 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
149 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
150 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
154 // Some mail softwares relies on subject field for threading.
155 // So, we cannot have different subjects for notifications of the same thread.
156 // Before this we have the name of the replier on the subject rendering
157 // differents subjects for messages on the same thread.
159 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
160 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
161 $epreamble = $dest_str;
163 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
164 $tsitelink = sprintf( $sitelink, $siteurl );
165 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
166 $itemlink = $params['link'];
169 if($params['type'] == NOTIFY_WALL) {
170 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
172 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
174 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
175 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
178 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
179 $tsitelink = sprintf( $sitelink, $siteurl );
180 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
181 $itemlink = $params['link'];
184 if($params['type'] == NOTIFY_TAGSELF) {
185 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
186 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
187 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
188 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
191 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
192 $tsitelink = sprintf( $sitelink, $siteurl );
193 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
194 $itemlink = $params['link'];
197 if($params['type'] == NOTIFY_SHARE) {
198 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
199 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
200 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
201 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
204 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
205 $tsitelink = sprintf( $sitelink, $siteurl );
206 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
207 $itemlink = $params['link'];
210 if($params['type'] == NOTIFY_POKE) {
212 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
213 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
214 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
215 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
218 $subject = str_replace('poked', t($params['activity']), $subject);
219 $preamble = str_replace('poked', t($params['activity']), $preamble);
220 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
222 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
223 $tsitelink = sprintf( $sitelink, $siteurl );
224 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
225 $itemlink = $params['link'];
228 if($params['type'] == NOTIFY_TAGSHARE) {
229 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
230 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
231 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
232 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
235 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
236 $tsitelink = sprintf( $sitelink, $siteurl );
237 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
238 $itemlink = $params['link'];
241 if($params['type'] == NOTIFY_INTRO) {
242 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
243 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
244 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
246 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
247 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
249 $sitelink = t('Please visit %s to approve or reject the introduction.');
250 $tsitelink = sprintf( $sitelink, $siteurl );
251 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
252 $itemlink = $params['link'];
254 switch ($params['verb']) {
255 case ACTIVITY_FRIEND:
256 // someone started to share with user (mostly OStatus)
257 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
258 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
259 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
260 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
263 case ACTIVITY_FOLLOW:
264 // someone started to follow the user (mostly OStatus)
265 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
266 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
267 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
268 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
272 // ACTIVITY_REQ_FRIEND is default activity for notifications
279 if($params['type'] == NOTIFY_SUGGEST) {
280 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
281 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
282 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
284 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
285 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
287 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
288 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
289 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
291 $sitelink = t('Please visit %s to approve or reject the suggestion.');
292 $tsitelink = sprintf( $sitelink, $siteurl );
293 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
294 $itemlink = $params['link'];
297 if($params['type'] == NOTIFY_CONFIRM) {
298 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
299 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
300 $preamble = sprintf( t('\'%1$s\' has accepted your connection request at %2$s'), $params['source_name'], $sitename);
301 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
303 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
304 $body = t('You are now mutual friends and may exchange status updates, photos, and email
305 without restriction.');
307 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
308 $tsitelink = sprintf( $sitelink, $siteurl );
309 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
310 $itemlink = $params['link'];
311 } else { // ACTIVITY_FOLLOW
312 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
313 $preamble = sprintf( t('\'%1$s\' has accepted your connection request at %2$s'), $params['source_name'], $sitename);
314 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
316 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
317 $body = sprintf(t('\'%1$s\' has chosen to accept you a "fan", which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.'), $params['source_name']);
319 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
321 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
322 $tsitelink = sprintf( $sitelink, $siteurl );
323 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
324 $itemlink = $params['link'];
329 if($params['type'] == NOTIFY_SYSTEM) {
330 switch($params['event']) {
331 case "SYSTEM_REGISTER_REQUEST":
332 $subject = sprintf( t('[Friendica System:Notify] registration request'));
333 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
334 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
336 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
337 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
338 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
340 $sitelink = t('Please visit %s to approve or reject the request.');
341 $tsitelink = sprintf( $sitelink, $params['link'] );
342 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
343 $itemlink = $params['link'];
345 case "SYSTEM_DB_UPDATE_FAIL":
350 if ($params['type'] == "SYSTEM_EMAIL"){
351 // not part of the notifications.
352 // it just send a mail to the user.
353 // It will be used by the system to send emails to users (like
354 // password reset, invitations and so) using one look (but without
355 // add a notification to the user, with could be inexistent)
356 $subject = $params['subject'];
357 $preamble = $params['preamble'];
358 $body = $params['body'];
363 $show_in_notification_page = false;
366 $subject .= " (".$nickname."@".$hostname.")";
370 'subject' => $subject,
371 'preamble' => $preamble,
372 'epreamble' => $epreamble,
374 'sitelink' => $sitelink,
375 'tsitelink' => $tsitelink,
376 'hsitelink' => $hsitelink,
377 'itemlink' => $itemlink
380 call_hooks('enotify',$h);
382 $subject = $h['subject'];
383 $preamble = $h['preamble'];
384 $epreamble = $h['epreamble'];
386 $sitelink = $h['sitelink'];
387 $tsitelink = $h['tsitelink'];
388 $hsitelink = $h['hsitelink'];
389 $itemlink = $h['itemlink'];
393 if ($show_in_notification_page) {
394 logger("adding notification entry", LOGGER_DEBUG);
397 $hash = random_string();
398 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
402 } while($dups == true);
406 $datarray['hash'] = $hash;
407 $datarray['name'] = $params['source_name'];
408 $datarray['url'] = $params['source_link'];
409 $datarray['photo'] = $params['source_photo'];
410 $datarray['date'] = datetime_convert();
411 $datarray['uid'] = $params['uid'];
412 $datarray['link'] = $itemlink;
413 $datarray['iid'] = $item_id;
414 $datarray['parent'] = $parent_id;
415 $datarray['type'] = $params['type'];
416 $datarray['verb'] = $params['verb'];
417 $datarray['otype'] = $params['otype'];
418 $datarray['abort'] = false;
420 call_hooks('enotify_store', $datarray);
422 if($datarray['abort']) {
427 // create notification entry in DB
429 $r = q("insert into notify (hash,name,url,photo,date,uid,link,iid,parent,type,verb,otype)
430 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,%d,'%s','%s')",
431 dbesc($datarray['hash']),
432 dbesc($datarray['name']),
433 dbesc($datarray['url']),
434 dbesc($datarray['photo']),
435 dbesc($datarray['date']),
436 intval($datarray['uid']),
437 dbesc($datarray['link']),
438 intval($datarray['iid']),
439 intval($datarray['parent']),
440 intval($datarray['type']),
441 dbesc($datarray['verb']),
442 dbesc($datarray['otype'])
445 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
447 intval($params['uid'])
450 $notify_id = $r[0]['id'];
456 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
457 // After we've stored everything, look again to see if there are any duplicates and if so remove them
460 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
461 intval(NOTIFY_TAGSELF),
462 intval(NOTIFY_COMMENT),
463 dbesc($params['link']),
464 intval($params['uid'])
466 if($p && (count($p) > 1)) {
467 for ($d = 1; $d < count($p); $d ++) {
468 q("delete from notify where id = %d",
473 // only continue on if we stored the first one
475 if($notify_id != $p[0]['id']) {
482 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
483 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
484 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
487 intval($params['uid'])
492 // send email notification if notification preferences permit
493 if((intval($params['notify_flags']) & intval($params['type']))
494 || $params['type'] == NOTIFY_SYSTEM
495 || $params['type'] == "SYSTEM_EMAIL") {
497 logger('sending notification email');
499 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
500 $id_for_parent = $params['parent']."@".$hostname;
502 // Is this the first email notification for this parent item and user?
504 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
505 intval($params['parent']),
506 intval($params['uid']) );
508 // If so, create the record of it and use a message-id smtp header.
511 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
512 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
513 values(%d,%d,%d,%d)",
515 intval($params['parent']),
516 intval($params['uid']),
519 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
520 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
521 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
522 logger($log_msg, LOGGER_DEBUG);
524 // If not, just "follow" the thread.
525 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
526 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
531 // textversion keeps linebreaks
532 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
533 $body))),ENT_QUOTES,'UTF-8')));
534 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
535 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
539 $datarray['banner'] = $banner;
540 $datarray['product'] = $product;
541 $datarray['preamble'] = $preamble;
542 $datarray['sitename'] = $sitename;
543 $datarray['siteurl'] = $siteurl;
544 $datarray['type'] = $params['type'];
545 $datarray['parent'] = $params['parent'];
546 $datarray['source_name'] = $params['source_name'];
547 $datarray['source_link'] = $params['source_link'];
548 $datarray['source_photo'] = $params['source_photo'];
549 $datarray['uid'] = $params['uid'];
550 $datarray['username'] = $params['to_name'];
551 $datarray['hsitelink'] = $hsitelink;
552 $datarray['tsitelink'] = $tsitelink;
553 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
554 $datarray['titemlink'] = $itemlink;
555 $datarray['thanks'] = $thanks;
556 $datarray['site_admin'] = $site_admin;
557 $datarray['title'] = stripslashes($title);
558 $datarray['htmlversion'] = $htmlversion;
559 $datarray['textversion'] = $textversion;
560 $datarray['subject'] = $subject;
561 $datarray['headers'] = $additional_mail_header;
563 call_hooks('enotify_mail', $datarray);
565 // check whether sending post content in email notifications is allowed
566 // always true for "SYSTEM_EMAIL"
567 $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
569 // load the template for private message notifications
570 $tpl = get_markup_template('email_notify_html.tpl');
571 $email_html_body = replace_macros($tpl,array(
572 '$banner' => $datarray['banner'],
573 '$product' => $datarray['product'],
574 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
575 '$sitename' => $datarray['sitename'],
576 '$siteurl' => $datarray['siteurl'],
577 '$source_name' => $datarray['source_name'],
578 '$source_link' => $datarray['source_link'],
579 '$source_photo' => $datarray['source_photo'],
580 '$username' => $datarray['to_name'],
581 '$hsitelink' => $datarray['hsitelink'],
582 '$hitemlink' => $datarray['hitemlink'],
583 '$thanks' => $datarray['thanks'],
584 '$site_admin' => $datarray['site_admin'],
585 '$title' => $datarray['title'],
586 '$htmlversion' => $datarray['htmlversion'],
587 '$content_allowed' => $content_allowed,
590 // load the template for private message notifications
591 $tpl = get_markup_template('email_notify_text.tpl');
592 $email_text_body = replace_macros($tpl,array(
593 '$banner' => $datarray['banner'],
594 '$product' => $datarray['product'],
595 '$preamble' => $datarray['preamble'],
596 '$sitename' => $datarray['sitename'],
597 '$siteurl' => $datarray['siteurl'],
598 '$source_name' => $datarray['source_name'],
599 '$source_link' => $datarray['source_link'],
600 '$source_photo' => $datarray['source_photo'],
601 '$username' => $datarray['to_name'],
602 '$tsitelink' => $datarray['tsitelink'],
603 '$titemlink' => $datarray['titemlink'],
604 '$thanks' => $datarray['thanks'],
605 '$site_admin' => $datarray['site_admin'],
606 '$title' => $datarray['title'],
607 '$textversion' => $datarray['textversion'],
608 '$content_allowed' => $content_allowed,
611 // logger('text: ' . $email_text_body);
613 // use the Emailer class to send the message
615 return Emailer::send(array(
616 'uid' => $params['uid'],
617 'fromName' => $sender_name,
618 'fromEmail' => $sender_email,
619 'replyTo' => $sender_email,
620 'toEmail' => $params['to_email'],
621 'messageSubject' => $datarray['subject'],
622 'htmlVersion' => $email_html_body,
623 'textVersion' => $email_text_body,
624 'additionalMailHeader' => $datarray['headers'],