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['parent']))
67 $parent_id = $params['parent'];
71 if($params['type'] == NOTIFY_MAIL) {
73 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
75 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
76 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
77 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
78 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
79 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
80 $itemlink = $siteurl . '/message/' . $params['item']['id'];
83 if($params['type'] == NOTIFY_COMMENT) {
84 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
86 //$parent_id = $params['parent'];
88 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
90 intval($params['uid'])
92 if ($p AND count($p) AND ($p[0]["ignored"])) {
93 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
97 // Check to see if there was already a tag notify or comment notify for this post.
98 // If so don't create a second notification
101 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
102 intval(NOTIFY_TAGSELF),
103 intval(NOTIFY_COMMENT),
104 intval(NOTIFY_SHARE),
105 dbesc($params['link']),
106 intval($params['uid'])
108 if($p and count($p)) {
114 // if it's a post figure out who's post it is.
118 if($params['otype'] === 'item' && $parent_id) {
119 $p = q("select * from item where id = %d and uid = %d limit 1",
121 intval($params['uid'])
125 $item_post_type = item_post_type($p[0]);
126 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
129 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
130 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
134 // "George Bull's post"
136 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
137 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
139 $p[0]['author-name'],
143 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
144 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
145 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
149 // Some mail softwares relies on subject field for threading.
150 // So, we cannot have different subjects for notifications of the same thread.
151 // Before this we have the name of the replier on the subject rendering
152 // differents subjects for messages on the same thread.
154 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
155 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
156 $epreamble = $dest_str;
158 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
159 $tsitelink = sprintf( $sitelink, $siteurl );
160 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
161 $itemlink = $params['link'];
164 if($params['type'] == NOTIFY_WALL) {
165 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
167 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
169 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
170 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
173 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
174 $tsitelink = sprintf( $sitelink, $siteurl );
175 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
176 $itemlink = $params['link'];
179 if($params['type'] == NOTIFY_TAGSELF) {
180 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
181 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
182 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
183 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
186 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
187 $tsitelink = sprintf( $sitelink, $siteurl );
188 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
189 $itemlink = $params['link'];
192 if($params['type'] == NOTIFY_SHARE) {
193 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
194 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
195 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
196 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
199 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
200 $tsitelink = sprintf( $sitelink, $siteurl );
201 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
202 $itemlink = $params['link'];
205 if($params['type'] == NOTIFY_POKE) {
207 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
208 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
209 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
210 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
213 $subject = str_replace('poked', t($params['activity']), $subject);
214 $preamble = str_replace('poked', t($params['activity']), $preamble);
215 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
217 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
218 $tsitelink = sprintf( $sitelink, $siteurl );
219 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
220 $itemlink = $params['link'];
223 if($params['type'] == NOTIFY_TAGSHARE) {
224 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
225 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
226 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
227 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
230 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
231 $tsitelink = sprintf( $sitelink, $siteurl );
232 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
233 $itemlink = $params['link'];
236 if($params['type'] == NOTIFY_INTRO) {
237 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
238 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
239 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
241 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
242 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
244 $sitelink = t('Please visit %s to approve or reject the introduction.');
245 $tsitelink = sprintf( $sitelink, $siteurl );
246 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
247 $itemlink = $params['link'];
249 switch ($params['verb']) {
250 case ACTIVITY_FRIEND:
251 // someone started to share with user (mostly OStatus)
252 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
253 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
254 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
255 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
258 case ACTIVITY_FOLLOW:
259 // someone started to follow the user (mostly OStatus)
260 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
261 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
262 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
263 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
267 // ACTIVITY_REQ_FRIEND is default activity for notifications
274 if($params['type'] == NOTIFY_SUGGEST) {
275 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
276 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
277 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
279 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
280 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
282 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
283 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
284 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
286 $sitelink = t('Please visit %s to approve or reject the suggestion.');
287 $tsitelink = sprintf( $sitelink, $siteurl );
288 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
289 $itemlink = $params['link'];
292 if($params['type'] == NOTIFY_CONFIRM) {
293 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
294 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
295 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
296 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
298 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
299 $body = t('You are now mutual friends and may exchange status updates, photos, and email
300 without restriction.');
302 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
303 $tsitelink = sprintf( $sitelink, $siteurl );
304 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
305 $itemlink = $params['link'];
306 } else { // ACTIVITY_FOLLOW
307 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
308 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
309 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
311 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
312 $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']);
314 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
316 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
317 $tsitelink = sprintf( $sitelink, $siteurl );
318 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
319 $itemlink = $params['link'];
324 if($params['type'] == NOTIFY_SYSTEM) {
325 switch($params['event']) {
326 case "SYSTEM_REGISTER_REQUEST":
327 $subject = sprintf( t('[Friendica System:Notify] registration request'));
328 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
329 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
331 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
332 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
333 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
335 $sitelink = t('Please visit %s to approve or reject the request.');
336 $tsitelink = sprintf( $sitelink, $params['link'] );
337 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
338 $itemlink = $params['link'];
340 case "SYSTEM_DB_UPDATE_FAIL":
345 if ($params['type'] == "SYSTEM_EMAIL"){
346 // not part of the notifications.
347 // it just send a mail to the user.
348 // It will be used by the system to send emails to users (like
349 // password reset, invitations and so) using one look (but without
350 // add a notification to the user, with could be inexistent)
351 $subject = $params['subject'];
352 $preamble = $params['preamble'];
353 $body = $params['body'];
358 $show_in_notification_page = false;
361 $subject .= " (".$nickname."@".$hostname.")";
365 'subject' => $subject,
366 'preamble' => $preamble,
367 'epreamble' => $epreamble,
369 'sitelink' => $sitelink,
370 'tsitelink' => $tsitelink,
371 'hsitelink' => $hsitelink,
372 'itemlink' => $itemlink
375 call_hooks('enotify',$h);
377 $subject = $h['subject'];
378 $preamble = $h['preamble'];
379 $epreamble = $h['epreamble'];
381 $sitelink = $h['sitelink'];
382 $tsitelink = $h['tsitelink'];
383 $hsitelink = $h['hsitelink'];
384 $itemlink = $h['itemlink'];
388 if ($show_in_notification_page) {
389 logger("adding notification entry", LOGGER_DEBUG);
392 $hash = random_string();
393 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
397 } while($dups == true);
401 $datarray['hash'] = $hash;
402 $datarray['name'] = $params['source_name'];
403 $datarray['url'] = $params['source_link'];
404 $datarray['photo'] = $params['source_photo'];
405 $datarray['date'] = datetime_convert();
406 $datarray['uid'] = $params['uid'];
407 $datarray['link'] = $itemlink;
408 $datarray['parent'] = $parent_id;
409 $datarray['type'] = $params['type'];
410 $datarray['verb'] = $params['verb'];
411 $datarray['otype'] = $params['otype'];
412 $datarray['abort'] = false;
414 call_hooks('enotify_store', $datarray);
416 if($datarray['abort']) {
421 // create notification entry in DB
423 $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
424 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
425 dbesc($datarray['hash']),
426 dbesc($datarray['name']),
427 dbesc($datarray['url']),
428 dbesc($datarray['photo']),
429 dbesc($datarray['date']),
430 intval($datarray['uid']),
431 dbesc($datarray['link']),
432 intval($datarray['parent']),
433 intval($datarray['type']),
434 dbesc($datarray['verb']),
435 dbesc($datarray['otype'])
438 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
440 intval($params['uid'])
443 $notify_id = $r[0]['id'];
449 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
450 // After we've stored everything, look again to see if there are any duplicates and if so remove them
453 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
454 intval(NOTIFY_TAGSELF),
455 intval(NOTIFY_COMMENT),
456 dbesc($params['link']),
457 intval($params['uid'])
459 if($p && (count($p) > 1)) {
460 for ($d = 1; $d < count($p); $d ++) {
461 q("delete from notify where id = %d",
466 // only continue on if we stored the first one
468 if($notify_id != $p[0]['id']) {
475 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
476 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
477 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
480 intval($params['uid'])
485 // send email notification if notification preferences permit
486 if((intval($params['notify_flags']) & intval($params['type']))
487 || $params['type'] == NOTIFY_SYSTEM
488 || $params['type'] == "SYSTEM_EMAIL") {
490 logger('sending notification email');
492 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
493 $id_for_parent = $params['parent']."@".$hostname;
495 // Is this the first email notification for this parent item and user?
497 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
498 intval($params['parent']),
499 intval($params['uid']) );
501 // If so, create the record of it and use a message-id smtp header.
504 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
505 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
506 values(%d,%d,%d,%d)",
508 intval($params['parent']),
509 intval($params['uid']),
512 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
513 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
514 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
515 logger($log_msg, LOGGER_DEBUG);
517 // If not, just "follow" the thread.
518 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
519 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
524 // textversion keeps linebreaks
525 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
526 $body))),ENT_QUOTES,'UTF-8')));
527 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
528 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
532 $datarray['banner'] = $banner;
533 $datarray['product'] = $product;
534 $datarray['preamble'] = $preamble;
535 $datarray['sitename'] = $sitename;
536 $datarray['siteurl'] = $siteurl;
537 $datarray['type'] = $params['type'];
538 $datarray['parent'] = $params['parent'];
539 $datarray['source_name'] = $params['source_name'];
540 $datarray['source_link'] = $params['source_link'];
541 $datarray['source_photo'] = $params['source_photo'];
542 $datarray['uid'] = $params['uid'];
543 $datarray['username'] = $params['to_name'];
544 $datarray['hsitelink'] = $hsitelink;
545 $datarray['tsitelink'] = $tsitelink;
546 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
547 $datarray['titemlink'] = $itemlink;
548 $datarray['thanks'] = $thanks;
549 $datarray['site_admin'] = $site_admin;
550 $datarray['title'] = stripslashes($title);
551 $datarray['htmlversion'] = $htmlversion;
552 $datarray['textversion'] = $textversion;
553 $datarray['subject'] = $subject;
554 $datarray['headers'] = $additional_mail_header;
556 call_hooks('enotify_mail', $datarray);
558 // check whether sending post content in email notifications is allowed
559 // always true for "SYSTEM_EMAIL"
560 $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
562 // load the template for private message notifications
563 $tpl = get_markup_template('email_notify_html.tpl');
564 $email_html_body = replace_macros($tpl,array(
565 '$banner' => $datarray['banner'],
566 '$product' => $datarray['product'],
567 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
568 '$sitename' => $datarray['sitename'],
569 '$siteurl' => $datarray['siteurl'],
570 '$source_name' => $datarray['source_name'],
571 '$source_link' => $datarray['source_link'],
572 '$source_photo' => $datarray['source_photo'],
573 '$username' => $datarray['to_name'],
574 '$hsitelink' => $datarray['hsitelink'],
575 '$hitemlink' => $datarray['hitemlink'],
576 '$thanks' => $datarray['thanks'],
577 '$site_admin' => $datarray['site_admin'],
578 '$title' => $datarray['title'],
579 '$htmlversion' => $datarray['htmlversion'],
580 '$content_allowed' => $content_allowed,
583 // load the template for private message notifications
584 $tpl = get_markup_template('email_notify_text.tpl');
585 $email_text_body = replace_macros($tpl,array(
586 '$banner' => $datarray['banner'],
587 '$product' => $datarray['product'],
588 '$preamble' => $datarray['preamble'],
589 '$sitename' => $datarray['sitename'],
590 '$siteurl' => $datarray['siteurl'],
591 '$source_name' => $datarray['source_name'],
592 '$source_link' => $datarray['source_link'],
593 '$source_photo' => $datarray['source_photo'],
594 '$username' => $datarray['to_name'],
595 '$tsitelink' => $datarray['tsitelink'],
596 '$titemlink' => $datarray['titemlink'],
597 '$thanks' => $datarray['thanks'],
598 '$site_admin' => $datarray['site_admin'],
599 '$title' => $datarray['title'],
600 '$textversion' => $datarray['textversion'],
601 '$content_allowed' => $content_allowed,
604 // logger('text: ' . $email_text_body);
606 // use the Emailer class to send the message
608 return Emailer::send(array(
609 'uid' => $params['uid'],
610 'fromName' => $sender_name,
611 'fromEmail' => $sender_email,
612 'replyTo' => $sender_email,
613 'toEmail' => $params['to_email'],
614 'messageSubject' => $datarray['subject'],
615 'htmlVersion' => $email_html_body,
616 'textVersion' => $email_text_body,
617 'additionalMailHeader' => $datarray['headers'],