]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
Close DB connection in api_saved_searches_list
[friendica.git] / include / enotify.php
index 10723fb418af41432d91f80d3a8da7f7f8320d03..99d5ea0ab3939504f7458cac9a919efe46e613a3 100644 (file)
@@ -1,12 +1,15 @@
 <?php
-
+/**
+ * @file include/enotify.php
+ */
 use Friendica\App;
+use Friendica\Core\Config;
 use Friendica\Core\System;
+use Friendica\Database\DBM;
+use Friendica\Util\Emailer;
 
-require_once('include/Emailer.php');
-require_once('include/email.php');
-require_once('include/bbcode.php');
-require_once('include/html2bbcode.php');
+require_once 'include/bbcode.php';
+require_once 'include/html2bbcode.php';
 
 /**
  * @brief Creates a notification entry and possibly sends a mail
@@ -51,7 +54,7 @@ function notification($params) {
                        array('uid' => $params['uid']), array('limit' => 1));
 
                // There is no need to create notifications for forum accounts
-               if (!dbm::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {
+               if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {
                        return;
                }
        }
@@ -422,7 +425,7 @@ function notification($params) {
                        $hash = random_string();
                        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
                                dbesc($hash));
-                       if (dbm::is_result($r)) {
+                       if (DBM::is_result($r)) {
                                $dups = true;
                        }
                } while ($dups == true);
@@ -589,7 +592,7 @@ function notification($params) {
 
                // check whether sending post content in email notifications is allowed
                // always true for SYSTEM_EMAIL
-               $content_allowed = ((!get_config('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL));
+               $content_allowed = ((!Config::get('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL));
 
                // load the template for private message notifications
                $tpl = get_markup_template('email_notify_html.tpl');
@@ -635,7 +638,8 @@ function notification($params) {
 
                // use the Emailer class to send the message
 
-               return Emailer::send(array(
+               return Emailer::send(
+                       array(
                        'uid' => $params['uid'],
                        'fromName' => $sender_name,
                        'fromEmail' => $sender_email,
@@ -644,11 +648,11 @@ function notification($params) {
                        'messageSubject' => $datarray['subject'],
                        'htmlVersion' => $email_html_body,
                        'textVersion' => $email_text_body,
-                       'additionalMailHeader' => $datarray['headers'],
-               ));
+                       'additionalMailHeader' => $datarray['headers'])
+               );
        }
 
-    return False;
+       return false;
 }
 
 /**
@@ -742,17 +746,17 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
                        intval($item[0]['contact-id']),
                        intval($uid)
                );
-               $send_notification = dbm::is_result($r);
+               $send_notification = DBM::is_result($r);
 
                if (!$send_notification) {
                        $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
                                intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));
 
-                       if (dbm::is_result($tags)) {
+                       if (DBM::is_result($tags)) {
                                foreach ($tags AS $tag) {
                                        $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
                                                normalise_link($tag["url"]), intval($uid));
-                                       if (dbm::is_result($r))
+                                       if (DBM::is_result($r))
                                                $send_notification = true;
                                }
                        }