]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
Generate preview pictures from enclosed data from feeds.
[friendica.git] / include / enotify.php
index 631cb8aed028975391518fe39d461818fb2051fa..51263871b6aad1d4d5d8716ed65a3c1d34f0d304 100644 (file)
@@ -308,7 +308,24 @@ function notification($params) {
        }
 
        if($params['type'] == NOTIFY_SYSTEM) {
-               //I have yet to find what system notificatons are...
+               switch($params['event']) {
+                       case "SYSTEM_REGISTER_REQUEST":
+                               $subject = sprintf( t('[Friendica System:Notify] registration request'));
+                               $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
+                               $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
+                                                                               $itemlink,
+                                                                               '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
+                               $body = sprintf( t('Full Name:  %1$s\nSite Location:    %2$s\nLogin Name:       %3$s (%4$s)'),
+                                                                       $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
+
+                               $sitelink = t('Please visit %s to approve or reject the request.');
+                               $tsitelink = sprintf( $sitelink, $params['link'] );
+                               $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
+                               $itemlink =  $params['link'];
+                               break;
+                       case "SYSTEM_DB_UPDATE_FAIL":
+                               break;
+               }
        }
 
        if ($params['type'] == "SYSTEM_EMAIL"){
@@ -319,11 +336,6 @@ function notification($params) {
                // add a notification to the user, with could be inexistent)
                        $subject = $params['subject'];
                        $preamble = $params['preamble'];
-                       if (x($params,'epreamble')){
-                               $epreamble = $params['epreamble'];
-                       } else {
-                               $epreamble = str_replace("\n","<br>\n",$preamble);
-                       }
                        $body =  $params['body'];
                        $sitelink = "";
                        $tsitelink = "";
@@ -360,6 +372,7 @@ function notification($params) {
 
 
        if ($show_in_notification_page) {
+               logger("adding notification entry", LOGGER_DEBUG);
                do {
                        $dups = false;
                        $hash = random_string();
@@ -529,14 +542,15 @@ function notification($params) {
                call_hooks('enotify_mail', $datarray);
 
                // check whether sending post content in email notifications is allowed
-               $content_allowed = !get_config('system','enotify_no_content');
+               // always true for "SYSTEM_EMAIL"
+               $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
 
                // load the template for private message notifications
                $tpl = get_markup_template('email_notify_html.tpl');
                $email_html_body = replace_macros($tpl,array(
                        '$banner'       => $datarray['banner'],
                        '$product'      => $datarray['product'],
-                       '$preamble'     => $datarray['preamble'],
+                       '$preamble'     => str_replace("\n","<br>\n",$datarray['preamble']),
                        '$sitename'     => $datarray['sitename'],
                        '$siteurl'      => $datarray['siteurl'],
                        '$source_name'  => $datarray['source_name'],
@@ -577,7 +591,7 @@ function notification($params) {
 
                // use the Emailer class to send the message
 
-               Emailer::send(array(
+               return Emailer::send(array(
                        'fromName' => $sender_name,
                        'fromEmail' => $sender_email,
                        'replyTo' => $sender_email,
@@ -587,7 +601,6 @@ function notification($params) {
                        'textVersion' => $email_text_body,
                        'additionalMailHeader' => $datarray['headers'],
                ));
-        return True;
        }
 
     return False;