]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
More usage of dbm::is_result($r) instead of count($r):
[friendica.git] / include / enotify.php
index bcb2ebe7ca35fe5d1e8a841083aee3e55f59f7bc..d548ec1ac72bfda6df3d3d85776ca6c639dc3c22 100644 (file)
@@ -411,7 +411,7 @@ function notification($params) {
                        $hash = random_string();
                        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
                                dbesc($hash));
-                       if (count($r))
+                       if (dbm::is_result($r))
                                $dups = true;
                } while($dups == true);
 
@@ -441,7 +441,7 @@ function notification($params) {
                // create notification entry in DB
 
                $r = q("INSERT INTO `notify` (`hash`, `name`, `url`, `photo`, `date`, `uid`, `link`, `iid`, `parent`, `type`, `verb`, `otype`, `name_cache`)
-                       values('%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s')",
+                       values('%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s')",
                        dbesc($datarray['hash']),
                        dbesc($datarray['name']),
                        dbesc($datarray['url']),
@@ -648,6 +648,7 @@ function notification($params) {
  * @param str $defaulttype (Optional) Forces a notification with this type.
  */
 function check_item_notification($itemid, $uid, $defaulttype = "") {
+       $a = get_app();
 
        $notification_data = array("uid" => $uid, "profiles" => array());
        call_hooks('check_item_notification', $notification_data);
@@ -666,7 +667,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
        $profiles[] = $owner[0]["url"];
 
        // Notifications from Diaspora are often with an URL in the Diaspora format
-       $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
+       $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
 
        $profiles2 = array();
 
@@ -720,7 +721,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
        $params["to_email"] = $user[0]["email"];
        $params["item"] = $item[0];
        $params["parent"] = $item[0]["parent"];
-       $params["link"] = App::get_baseurl().'/display/'.urlencode($item[0]["guid"]);
+       $params["link"] = $a->get_baseurl().'/display/'.urlencode($item[0]["guid"]);
        $params["otype"] = 'item';
        $params["source_name"] = $item[0]["author-name"];
        $params["source_link"] = $item[0]["author-link"];
@@ -732,7 +733,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
                        intval($item[0]['contact-id']),
                        intval($uid)
                );
-               $send_notification = count($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",
@@ -742,7 +743,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
                                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 (count($r))
+                                       if (dbm::is_result($r))
                                                $send_notification = true;
                                }
                        }
@@ -805,4 +806,4 @@ function format_notification_message($name, $message) {
        }
 
        return $message;
-}
\ No newline at end of file
+}