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 = $product;
27 $hostname = $a->get_hostname();
28 if(strpos($hostname,':'))
29 $hostname = substr($hostname,0,strpos($hostname,':'));
31 // $sender_email = t('noreply') . '@' . $hostname;
32 $sender_email = $a->config['sender_email'];
33 if (empty($sender_email)) {
34 $sender_email = t('noreply') . '@' . $hostname;
37 $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
39 $nickname = $user[0]["nickname"];
41 // with $params['show_in_notification_page'] == false, the notification isn't inserted into
42 // the database, and an email is sent if applicable.
43 // default, if not specified: true
44 $show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
46 $additional_mail_header = "";
47 $additional_mail_header .= "Precedence: list\n";
48 $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
49 $additional_mail_header .= "X-Friendica-Account: <".$nickname."@".$hostname.">\n";
50 $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
51 $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
52 $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
53 $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
56 if(array_key_exists('item',$params)) {
57 $title = $params['item']['title'];
58 $body = $params['item']['body'];
64 // e.g. "your post", "David's photo", etc.
65 $possess_desc = t('%s <!item_type!>');
67 if($params['type'] == NOTIFY_MAIL) {
69 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
71 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
72 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
73 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
74 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
75 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
76 $itemlink = $siteurl . '/message/' . $params['item']['id'];
79 if($params['type'] == NOTIFY_COMMENT) {
80 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
82 $parent_id = $params['parent'];
84 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
86 intval($params['uid'])
88 if ($p AND count($p) AND ($p[0]["ignored"])) {
89 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
93 // Check to see if there was already a tag notify or comment notify for this post.
94 // If so don't create a second notification
97 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
98 intval(NOTIFY_TAGSELF),
99 intval(NOTIFY_COMMENT),
100 intval(NOTIFY_SHARE),
101 dbesc($params['link']),
102 intval($params['uid'])
104 if($p and count($p)) {
110 // if it's a post figure out who's post it is.
114 if($params['otype'] === 'item' && $parent_id) {
115 $p = q("select * from item where id = %d and uid = %d limit 1",
117 intval($params['uid'])
121 $item_post_type = item_post_type($p[0]);
122 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
125 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
126 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
130 // "George Bull's post"
132 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
133 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
135 $p[0]['author-name'],
139 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
140 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
141 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
145 // Some mail softwares relies on subject field for threading.
146 // So, we cannot have different subjects for notifications of the same thread.
147 // Before this we have the name of the replier on the subject rendering
148 // differents subjects for messages on the same thread.
150 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
151 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
152 $epreamble = $dest_str;
154 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
155 $tsitelink = sprintf( $sitelink, $siteurl );
156 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
157 $itemlink = $params['link'];
160 if($params['type'] == NOTIFY_WALL) {
161 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
163 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
165 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
166 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
169 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
170 $tsitelink = sprintf( $sitelink, $siteurl );
171 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
172 $itemlink = $params['link'];
175 if($params['type'] == NOTIFY_TAGSELF) {
176 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
177 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
178 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
179 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
182 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
183 $tsitelink = sprintf( $sitelink, $siteurl );
184 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
185 $itemlink = $params['link'];
188 if($params['type'] == NOTIFY_SHARE) {
189 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
190 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
191 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
192 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
195 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
196 $tsitelink = sprintf( $sitelink, $siteurl );
197 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
198 $itemlink = $params['link'];
201 if($params['type'] == NOTIFY_POKE) {
203 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
204 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
205 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
206 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
209 $subject = str_replace('poked', t($params['activity']), $subject);
210 $preamble = str_replace('poked', t($params['activity']), $preamble);
211 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
213 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
214 $tsitelink = sprintf( $sitelink, $siteurl );
215 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
216 $itemlink = $params['link'];
219 if($params['type'] == NOTIFY_TAGSHARE) {
220 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
221 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
222 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
223 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
226 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
227 $tsitelink = sprintf( $sitelink, $siteurl );
228 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
229 $itemlink = $params['link'];
232 if($params['type'] == NOTIFY_INTRO) {
233 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
234 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
235 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
237 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
238 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
240 $sitelink = t('Please visit %s to approve or reject the introduction.');
241 $tsitelink = sprintf( $sitelink, $siteurl );
242 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
243 $itemlink = $params['link'];
245 switch ($params['verb']) {
246 case ACTIVITY_FRIEND:
247 // someone started to share with user (mostly OStatus)
248 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
249 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
250 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
251 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
254 case ACTIVITY_FOLLOW:
255 // someone started to follow the user (mostly OStatus)
256 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
257 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
258 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
259 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
263 // ACTIVITY_REQ_FRIEND is default activity for notifications
270 if($params['type'] == NOTIFY_SUGGEST) {
271 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
272 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
273 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
275 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
276 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
278 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
279 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
280 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
282 $sitelink = t('Please visit %s to approve or reject the suggestion.');
283 $tsitelink = sprintf( $sitelink, $siteurl );
284 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
285 $itemlink = $params['link'];
288 if($params['type'] == NOTIFY_CONFIRM) {
289 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
290 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
291 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
292 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
294 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
295 $body = t('You are now mutual friends and may exchange status updates, photos, and email
296 without restriction.');
298 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
299 $tsitelink = sprintf( $sitelink, $siteurl );
300 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
301 $itemlink = $params['link'];
302 } else { // ACTIVITY_FOLLOW
303 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
304 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
305 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
307 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
308 $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']);
310 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
312 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
313 $tsitelink = sprintf( $sitelink, $siteurl );
314 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
315 $itemlink = $params['link'];
320 if($params['type'] == NOTIFY_SYSTEM) {
321 switch($params['event']) {
322 case "SYSTEM_REGISTER_REQUEST":
323 $subject = sprintf( t('[Friendica System:Notify] registration request'));
324 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
325 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
327 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
328 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
329 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
331 $sitelink = t('Please visit %s to approve or reject the request.');
332 $tsitelink = sprintf( $sitelink, $params['link'] );
333 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
334 $itemlink = $params['link'];
336 case "SYSTEM_DB_UPDATE_FAIL":
341 if ($params['type'] == "SYSTEM_EMAIL"){
342 // not part of the notifications.
343 // it just send a mail to the user.
344 // It will be used by the system to send emails to users (like
345 // password reset, invitations and so) using one look (but without
346 // add a notification to the user, with could be inexistent)
347 $subject = $params['subject'];
348 $preamble = $params['preamble'];
349 $body = $params['body'];
354 $show_in_notification_page = false;
357 $subject .= " (".$nickname."@".$hostname.")";
361 'subject' => $subject,
362 'preamble' => $preamble,
363 'epreamble' => $epreamble,
365 'sitelink' => $sitelink,
366 'tsitelink' => $tsitelink,
367 'hsitelink' => $hsitelink,
368 'itemlink' => $itemlink
371 call_hooks('enotify',$h);
373 $subject = $h['subject'];
374 $preamble = $h['preamble'];
375 $epreamble = $h['epreamble'];
377 $sitelink = $h['sitelink'];
378 $tsitelink = $h['tsitelink'];
379 $hsitelink = $h['hsitelink'];
380 $itemlink = $h['itemlink'];
384 if ($show_in_notification_page) {
385 logger("adding notification entry", LOGGER_DEBUG);
388 $hash = random_string();
389 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
393 } while($dups == true);
397 $datarray['hash'] = $hash;
398 $datarray['name'] = $params['source_name'];
399 $datarray['url'] = $params['source_link'];
400 $datarray['photo'] = $params['source_photo'];
401 $datarray['date'] = datetime_convert();
402 $datarray['uid'] = $params['uid'];
403 $datarray['link'] = $itemlink;
404 $datarray['parent'] = $parent_id;
405 $datarray['type'] = $params['type'];
406 $datarray['verb'] = $params['verb'];
407 $datarray['otype'] = $params['otype'];
408 $datarray['abort'] = false;
410 call_hooks('enotify_store', $datarray);
412 if($datarray['abort']) {
417 // create notification entry in DB
419 $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
420 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
421 dbesc($datarray['hash']),
422 dbesc($datarray['name']),
423 dbesc($datarray['url']),
424 dbesc($datarray['photo']),
425 dbesc($datarray['date']),
426 intval($datarray['uid']),
427 dbesc($datarray['link']),
428 intval($datarray['parent']),
429 intval($datarray['type']),
430 dbesc($datarray['verb']),
431 dbesc($datarray['otype'])
434 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
436 intval($params['uid'])
439 $notify_id = $r[0]['id'];
445 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
446 // After we've stored everything, look again to see if there are any duplicates and if so remove them
449 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
450 intval(NOTIFY_TAGSELF),
451 intval(NOTIFY_COMMENT),
452 dbesc($params['link']),
453 intval($params['uid'])
455 if($p && (count($p) > 1)) {
456 for ($d = 1; $d < count($p); $d ++) {
457 q("delete from notify where id = %d",
462 // only continue on if we stored the first one
464 if($notify_id != $p[0]['id']) {
471 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
472 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
473 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
476 intval($params['uid'])
481 // send email notification if notification preferences permit
482 if((intval($params['notify_flags']) & intval($params['type']))
483 || $params['type'] == NOTIFY_SYSTEM
484 || $params['type'] == "SYSTEM_EMAIL") {
486 logger('sending notification email');
488 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
489 $id_for_parent = $params['parent']."@".$hostname;
491 // Is this the first email notification for this parent item and user?
493 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
494 intval($params['parent']),
495 intval($params['uid']) );
497 // If so, create the record of it and use a message-id smtp header.
500 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
501 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
502 values(%d,%d,%d,%d)",
504 intval($params['parent']),
505 intval($params['uid']),
508 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
509 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
510 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
511 logger($log_msg, LOGGER_DEBUG);
513 // If not, just "follow" the thread.
514 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
515 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
520 // textversion keeps linebreaks
521 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
522 $body))),ENT_QUOTES,'UTF-8')));
523 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
524 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
528 $datarray['banner'] = $banner;
529 $datarray['product'] = $product;
530 $datarray['preamble'] = $preamble;
531 $datarray['sitename'] = $sitename;
532 $datarray['siteurl'] = $siteurl;
533 $datarray['type'] = $params['type'];
534 $datarray['parent'] = $params['parent'];
535 $datarray['source_name'] = $params['source_name'];
536 $datarray['source_link'] = $params['source_link'];
537 $datarray['source_photo'] = $params['source_photo'];
538 $datarray['uid'] = $params['uid'];
539 $datarray['username'] = $params['to_name'];
540 $datarray['hsitelink'] = $hsitelink;
541 $datarray['tsitelink'] = $tsitelink;
542 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
543 $datarray['titemlink'] = $itemlink;
544 $datarray['thanks'] = $thanks;
545 $datarray['site_admin'] = $site_admin;
546 $datarray['title'] = stripslashes($title);
547 $datarray['htmlversion'] = $htmlversion;
548 $datarray['textversion'] = $textversion;
549 $datarray['subject'] = $subject;
550 $datarray['headers'] = $additional_mail_header;
552 call_hooks('enotify_mail', $datarray);
554 // check whether sending post content in email notifications is allowed
555 // always true for "SYSTEM_EMAIL"
556 $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
558 // load the template for private message notifications
559 $tpl = get_markup_template('email_notify_html.tpl');
560 $email_html_body = replace_macros($tpl,array(
561 '$banner' => $datarray['banner'],
562 '$product' => $datarray['product'],
563 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
564 '$sitename' => $datarray['sitename'],
565 '$siteurl' => $datarray['siteurl'],
566 '$source_name' => $datarray['source_name'],
567 '$source_link' => $datarray['source_link'],
568 '$source_photo' => $datarray['source_photo'],
569 '$username' => $datarray['to_name'],
570 '$hsitelink' => $datarray['hsitelink'],
571 '$hitemlink' => $datarray['hitemlink'],
572 '$thanks' => $datarray['thanks'],
573 '$site_admin' => $datarray['site_admin'],
574 '$title' => $datarray['title'],
575 '$htmlversion' => $datarray['htmlversion'],
576 '$content_allowed' => $content_allowed,
579 // load the template for private message notifications
580 $tpl = get_markup_template('email_notify_text.tpl');
581 $email_text_body = replace_macros($tpl,array(
582 '$banner' => $datarray['banner'],
583 '$product' => $datarray['product'],
584 '$preamble' => $datarray['preamble'],
585 '$sitename' => $datarray['sitename'],
586 '$siteurl' => $datarray['siteurl'],
587 '$source_name' => $datarray['source_name'],
588 '$source_link' => $datarray['source_link'],
589 '$source_photo' => $datarray['source_photo'],
590 '$username' => $datarray['to_name'],
591 '$tsitelink' => $datarray['tsitelink'],
592 '$titemlink' => $datarray['titemlink'],
593 '$thanks' => $datarray['thanks'],
594 '$site_admin' => $datarray['site_admin'],
595 '$title' => $datarray['title'],
596 '$textversion' => $datarray['textversion'],
597 '$content_allowed' => $content_allowed,
600 // logger('text: ' . $email_text_body);
602 // use the Emailer class to send the message
604 return Emailer::send(array(
605 'uid' => $params['uid'],
606 'fromName' => $sender_name,
607 'fromEmail' => $sender_email,
608 'replyTo' => $sender_email,
609 'toEmail' => $params['to_email'],
610 'messageSubject' => $datarray['subject'],
611 'htmlVersion' => $email_html_body,
612 'textVersion' => $email_text_body,
613 'additionalMailHeader' => $datarray['headers'],