]> git.mxchange.org Git - friendica.git/commitdiff
This merge brings back dbm::is_result() where I could find it.
authorRoland Haeder <roland@mxchange.org>
Sun, 18 Sep 2016 21:21:18 +0000 (23:21 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 18 Sep 2016 21:21:18 +0000 (23:21 +0200)
Merge branch 'develop' of github.com:friendica/friendica into rhaeder-develop

Signed-off-by: Roland Haeder <roland@mxchange.org>
97 files changed:
1  2 
include/Contact.php
include/Photo.php
include/acl_selectors.php
include/api.php
include/auth.php
include/cache.php
include/contact_selectors.php
include/contact_widgets.php
include/cron.php
include/datetime.php
include/delivery.php
include/dfrn.php
include/diaspora.php
include/enotify.php
include/event.php
include/expire.php
include/fcontact.php
include/feed.php
include/follow.php
include/gprobe.php
include/group.php
include/identity.php
include/items.php
include/like.php
include/lock.php
include/message.php
include/network.php
include/notifier.php
include/oauth.php
include/onepoll.php
include/plugin.php
include/queue_fn.php
include/security.php
include/session.php
include/socgraph.php
include/text.php
include/threads.php
include/user.php
mod/admin.php
mod/common.php
mod/community.php
mod/contactgroup.php
mod/contacts.php
mod/content.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/directory.php
mod/display.php
mod/editpost.php
mod/events.php
mod/friendica.php
mod/fsuggest.php
mod/group.php
mod/item.php
mod/lockview.php
mod/manage.php
mod/message.php
mod/mood.php
mod/msearch.php
mod/network.php
mod/nogroup.php
mod/noscrape.php
mod/notes.php
mod/notice.php
mod/notifications.php
mod/p.php
mod/photo.php
mod/photos.php
mod/poco.php
mod/poke.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/profperm.php
mod/proxy.php
mod/pubsubhubbub.php
mod/qsearch.php
mod/regmod.php
mod/salmon.php
mod/search.php
mod/settings.php
mod/subthread.php
mod/tagger.php
mod/uexport.php
mod/videos.php
mod/viewcontacts.php
mod/viewsrc.php
mod/wall_attach.php
mod/wall_upload.php
object/Item.php
update.php
view/templates/head.tpl
view/theme/diabook/theme.php
view/theme/vier/style.css
view/theme/vier/theme.php

index a5930e1cfc1ce5ad294d95f2d96c71de79b238ca,1dbf21c73755557b84a1dfcfa73c997380498886..6e8f93c9b156439ebf0eb9da4f0e0a07f6b7ac1e
@@@ -368,7 -393,7 +393,7 @@@ function random_profile() 
                        ORDER BY rand() LIMIT 1",
                dbesc(NETWORK_DFRN));
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return dirname($r[0]['url']);
        return '';
  }
index 23148f69cc9ed2cace671df92a9db9bdd5916673,d87bce478704fccb6489097269e2e83163a4fd5f..1bd1b3a26a01ece99b079fed65e5ee07ef09f1b9
@@@ -589,7 -589,7 +589,7 @@@ class Photo 
        $r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1",
            dbesc($rid)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
            $guid = $r[0]['guid'];
        else
            $guid = get_guid();
index 93dcdea7423e96472192d31c5342633186201a56,71a42478ba92c06b80c02f6f3d332af6382deba4..6b0a822cc25ebf54102489831f2dcf8c525ae9dc
@@@ -33,7 -33,7 +33,7 @@@ function group_select($selname,$selclas
  
        call_hooks($a->module . '_pre_' . $selname, $arr);
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
@@@ -144,7 -144,7 +144,7 @@@ function contact_selector($selname, $se
  
        call_hooks($a->module . '_pre_' . $selname, $arr);
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
@@@ -220,7 -220,7 +220,7 @@@ function contact_select($selname, $selc
  
        $receiverlist = array();
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
@@@ -314,7 -314,7 +314,7 @@@ function populate_acl($user = null, $sh
                        $r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                intval(local_user())
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $mail_enabled = true;
                                if(intval($r[0]['pubmail']))
                                        $pubmail_enabled = true;
@@@ -577,7 -577,7 +577,7 @@@ function acl_lookup(&$a, $out_type = 'j
                $r = array();
  
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $g){
                        $contacts[] = array(
                                "type"  => "c",
                                dbesc($search),
                                implode("','", $known_contacts)
                );
-               if (dba::is_result($r)){
 -              if (is_array($r) && count($r)){
++              if (dbm::is_result($r)){
                        foreach($r as $row) {
                                // nickname..
                                $up = parse_url($row['author-link']);
diff --cc include/api.php
index e25c15560e2cdb2c8a9cc731778c60ecf738de3a,a9c5e7a46820736fb22faf6adcca65efbccbc506..d6f6dec7d9b387fc86fd8cbc0c7aebd575b74dc8
                                dbesc(trim($user)),
                                dbesc($encrypted)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $record = $r[0];
                }
  
  
                if (isset($_GET["q"])) {
                        $r = q("SELECT id FROM `gcontact` WHERE `name`='%s'", dbesc($_GET["q"]));
--                      if (!count($r))
++                      if (!dbm::is_result($r))
                                $r = q("SELECT `id` FROM `gcontact` WHERE `nick`='%s'", dbesc($_GET["q"]));
  
-                       if (dba::is_result($r)) {
 -                      if (count($r)) {
++                      if (dbm::is_result($r)) {
+                               $k = 0;
                                foreach ($r AS $user) {
-                                       $user_info = api_get_user($a, $user["id"]);
-                                       //echo print_r($user_info, true)."\n";
-                                       $userdata = api_apply_template("user", $type, array('user' => $user_info));
-                                       $userlist[] = $userdata["user"];
+                                       $user_info = api_get_user($a, $user["id"], "json");
+                                       if ($type == "xml")
+                                               $userlist[$k++.":user"] = $user_info;
+                                       else
+                                               $userlist[] = $user_info;
                                }
                                $userlist = array("users" => $userlist);
                        } else {
                        intval(api_user())
                );
  
-               if(dba::is_result($r)) {
 -              if(!dbm::is_result($r))
 -                      return;
++              if(dbm::is_result($r)) {
  
-                       if($type === 'xml') {
-                               header("Content-type: application/xml");
-                               echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<ids>' . "\r\n";
-                               foreach($r as $rr)
-                                       echo '<id>' . $rr['id'] . '</id>' . "\r\n";
-                               echo '</ids>' . "\r\n";
-                               killme();
-                       }
-                       elseif($type === 'json') {
-                               $ret = array();
-                               header("Content-type: application/json");
-                               foreach($r as $rr)
-                                       if ($stringify_ids)
-                                               $ret[] = $rr['id'];
-                                       else
-                                               $ret[] = intval($rr['id']);
+               $ids = array();
+               foreach($r as $rr)
+                       if ($stringify_ids)
+                               $ids[] = $rr['id'];
+                       else
+                               $ids[] = intval($rr['id']);
  
-                               echo json_encode($ret);
-                               killme();
-                       }
-               }
+               return api_format_data("ids", $type, array('id' => $ids));
        }
  
-       function api_friends_ids(&$a,$type) {
-               api_ff_ids($a,$type,'friends');
+       function api_friends_ids($type) {
+               return api_ff_ids($type,'friends');
        }
-       function api_followers_ids(&$a,$type) {
-               api_ff_ids($a,$type,'followers');
+       function api_followers_ids($type) {
+               return api_ff_ids($type,'followers');
        }
        api_register_func('api/friends/ids','api_friends_ids',true);
        api_register_func('api/followers/ids','api_followers_ids',true);
index f3193ee9048ebf6d36000d1882d1552a78596467,d1917b8b30903138f18a8cd17203588c8c8f1361..5dc19d1dfc7eeb1ba0a1e5d7082701a54e6315aa
@@@ -50,7 -50,7 +50,7 @@@ if (isset($_SESSION) && x($_SESSION,'au
                $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($_SESSION['visitor_id'])
                );
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        $a->contact = $r[0];
                }
        }
                                dbesc(trim($_POST['username'])),
                                dbesc($encrypted)
                        );
-                       if (dba::is_result($r))
 -                      if (count($r))
++                      if (dbm::is_result($r))
                                $record = $r[0];
                }
  
index 7640f347b195b852f32a9c1f1aa037c54bc7ea12,d0b0dfafda9c4fc011102bf6a2fa0cd3cbc00d1b..032d231b2467f2eb455850c08505953ef72c63e0
@@@ -10,7 -10,7 +10,7 @@@
                                dbesc($key)
                        );
  
-                       if (dba::is_result($r))
 -                      if (count($r))
++                      if (dbm::is_result($r))
                                return $r[0]['v'];
  
                        return null;
@@@ -38,7 -38,7 +38,7 @@@
   *                    $r = q("SELECT * FROM `cache` WHERE `k`='%s' limit 1",
   *                            dbesc($key)
   *                    );
-  *                    if(dba::is_result($r)) {
 - *                    if(count($r)) {
++ *                    if(dbm::is_result($r)) {
   *                            q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s'",
   *                                    dbesc($value),
   *                                    dbesc(datetime_convert()),
index 77d38590b5e2a1b246a1c7442938e9f87736b2bc,35c9d983d72797f49ac49f46da496d93d1bfed48..8a7dd5606113202a4e0d66a0589adf0db2e18aa9
@@@ -7,12 -7,12 +7,12 @@@ function contact_profile_assign($curren
  
        $disabled = (($foreign_net) ? ' disabled="true" ' : '');
  
-       $o .= "<select id=\"contact-profile-selector\" $disabled name=\"profile-assign\" />\r\n";
+       $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" />\r\n";
  
        $r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
-                         intval($_SESSION['uid']));
+                       intval($_SESSION['uid']));
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
                        $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
index 8fabc6ff6959e956d5792b8a8c9bcb31a6152fe8,bbbd941b5609df3ae7321bc708599e17c6de4ccc..e0a33eee08728fc7dbf7608fd7c30a8f4dd4862f
@@@ -93,7 -93,7 +93,7 @@@ function networks_widget($baseurl,$sele
        );
  
        $nets = array();
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                require_once('include/contact_selectors.php');
                foreach($r as $rr) {
                                if($rr['network'])
@@@ -204,13 -204,13 +204,13 @@@ function common_friends_visitor_widget(
                                dbesc(normalise_link(get_my_url())),
                                intval($profile_uid)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $cid = $r[0]['id'];
                        else {
                                $r = q("select id from gcontact where nurl = '%s' limit 1",
                                        dbesc(normalise_link(get_my_url()))
                                );
-                               if(dba::is_result($r))
 -                              if(count($r))
++                              if(dbm::is_result($r))
                                        $zcid = $r[0]['id'];
                        }
                }
index 00dd500704a55a327dd9551f8ae9d71289a6e2c4,0669f24a1ea9bebf1420a20effaa5626a64409e7..a32f13ab61e589a3a7ccc898ccbc9086357dee60
@@@ -382,7 -410,7 +410,7 @@@ function cron_repair_diaspora(&$a) 
        $r = q("SELECT `id`, `url` FROM `contact`
                WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
                        ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA));
--      if ($r) {
++      if (dbm::is_result($r)) {
                foreach ($r AS $contact) {
                        if (poco_reachable($contact["url"])) {
                                $data = probe_url($contact["url"]);
@@@ -410,6 -438,12 +438,12 @@@ function cron_repair_database() 
        // There was an issue where the nick vanishes from the contact table
        q("UPDATE `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` SET `nick` = `nickname` WHERE `self` AND `nick`=''");
  
 -      if ($r)
+       // Update the global contacts for local users
+       $r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
++      if (dbm::is_result($r))
+               foreach ($r AS $user)
+                       update_gcontact_for_user($user["uid"]);
        /// @todo
        /// - remove thread entries without item
        /// - remove sign entries without item
index da9e84d90f2146d524e6c707d55a85e2d3821386,ea98f01fe0999e63bc45400470f76c6fdb2c9a25..3ac476b0081f9ea946d5c54f8b548f4c905455ac
@@@ -544,7 -558,7 +558,7 @@@ function update_contact_birthdays() 
        // In-network birthdays are handled within local_delivery
  
        $r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
  
                        logger('update_contact_birthday: ' . $rr['bd']);
index 7375beb232845de4d2e4ae67c6ab9d90a355898e,fe337743820dcb85940262fefdb4abe099c4d530..66f5e931ba1c095608fc018f9cdeb893e763c548
@@@ -254,7 -254,7 +254,7 @@@ function delivery_run(&$argv, &$argc)
                        intval($contact_id)
                );
  
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        $contact = $r[0];
  
                if ($contact['self'])
                                                        intval($argv[2]),
                                                        intval($uid)
                                                );
-                                               if (dba::is_result($r))
 -                                              if (count($r))
++                                              if (dbm::is_result($r))
                                                        $it = $r[0];
                                        }
                                        if (!$it)
index 4d116153bfc6a1f07e91696f32597599e13fcb8b,27fc644c6b21d2dbbf99d6b17f36c43cb1dfaa52..1615031ae0a186897782456d3a0411a309aab2f3
@@@ -1430,7 -1458,7 +1458,7 @@@ class dfrn 
                        dbesc(normalise_link($suggest["url"])),
                        intval($suggest["uid"])
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        return false;
  
                // Do we already have an fcontact record for this person?
                        dbesc($suggest["name"]),
                        dbesc($suggest["request"])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $fid = $r[0]["id"];
  
                        // OK, we do. Do we already have an introduction for this person ?
                                intval($suggest["uid"]),
                                intval($fid)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                return false;
                }
                if(!$fid)
                        dbesc($suggest["name"]),
                        dbesc($suggest["request"])
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $fid = $r[0]["id"];
                else
                        // database record did not get created. Quietly give up.
                                                dbesc($item["uri"]),
                                                intval($importer["uid"])
                                        );
-                                       if(dba::is_result($r))
 -                                      if(count($r))
++                                      if(dbm::is_result($r))
                                                $ev["id"] = $r[0]["id"];
  
                                        $event_id = event_store($ev);
                }
  
                // Update content if 'updated' changes
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        if (self::update_content($r[0], $item, $importer, $entrytype))
                                logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
                        else
                                        intval($posted_id),
                                        intval($importer["importer_uid"])
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $parent = $r[0]["parent"];
                                        $parent_uri = $r[0]["parent-uri"];
                                }
                                                        dbesc($item["parent-uri"]),
                                                        intval($importer["uid"])
                                        );
-                                       if(dba::is_result($r)) {
 -                                      if(count($r)) {
++                                      if(dbm::is_result($r)) {
                                                q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
                                                        intval($r[0]["id"])
                                                );
index 0556511857ea0f9eb8c1297e41d4b4ee5a330323,db6844f44d609476b984b673d3c591514d338571..ae8522d00365fdf67632230e3406090479e67192
@@@ -1188,7 -1274,7 +1274,7 @@@ class diaspora 
                $r = q("SELECT `id` FROM `mail` WHERE `uri` = '%s' LIMIT 1",
                        dbesc($message_uri)
                );
--              if($r) {
++              if(dbm::is_result($r)) {
                        logger("duplicate message already delivered.", LOGGER_DEBUG);
                        return false;
                }
  
                $p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
                        dbesc($item["thr-parent"]));
--              if(!$p)
++              if(!dbm::is_result($p))
                        return false;
  
                $parent = $p[0];
                        intval($item["parent"])
                );
  
--              if (!$p)
++              if (!dbm::is_result($p))
                        return false;
  
                $parent = $p[0];
                        intval($item["uid"])
                );
  
--              if (!$r) {
++              if (!dbm::is_result($r)) {
                        logger("conversation not found.");
                        return;
                }
index 55fec1f3187aa9189161925c8d33f1bb62a48123,bed00c5eaf95ac1969855d1ed8190a04dbf19c4c..3d72684498ab946095d867c161bd9f6214fa1540
@@@ -401,7 -411,7 +411,7 @@@ function notification($params) 
                        $hash = random_string();
                        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
                                dbesc($hash));
-                       if(dba::is_result($r))
 -                      if (count($r))
++                      if(dbm::is_result($r))
                                $dups = true;
                } while($dups == true);
  
@@@ -703,26 -723,26 +723,26 @@@ function check_item_notification($itemi
        $params["source_photo"] = $item[0]["author-avatar"];
  
        if ($item[0]["parent-uri"] === $item[0]["uri"]) {
-                 // Send a notification for every new post?
-                 $r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1",
-                         intval($item[0]['contact-id']),
-                         intval($uid)
-                 );
-                 $send_notification = count($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 (count($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 (dba::is_result($r))
-                                                 $send_notification = true;
-                                 }
-                         }
-                 }
+               // Send a notification for every new post?
+               $r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1",
+                       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",
+                               intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));
 -                      if (count($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 (count($r))
++                                      if (dbm::is_result($r))
+                                               $send_notification = true;
+                               }
+                       }
+               }
  
                if ($send_notification) {
                        $params["type"] = NOTIFY_SHARE;
index 4d5f3b8a1b2e77e9b77cc08683c0b3c9628e958b,a68e1c4626d37cf523711387fbd9539511317135..88166fc9e76c65acc2409f31856cedd6e0e0b556
@@@ -276,7 -279,7 +279,7 @@@ function event_store($arr) 
                                intval($arr['id']),
                                intval($arr['uid'])
                        );
-                       return((dba::is_result($r)) ? $r[0]['id'] : 0);
 -                      return((count($r)) ? $r[0]['id'] : 0);
++                      return((dbm::is_result($r)) ? $r[0]['id'] : 0);
                }
  
                // The event changed. Update it.
                        intval($arr['id']),
                        intval($arr['uid'])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
                        $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
                        $object .= '</object>' . "\n";
                        dbesc($arr['uri']),
                        intval($arr['uid'])
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $event = $r[0];
  
                $item_arr = array();
                $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($arr['uid'])
                );
-               //if(dba::is_result($r))
 -              //if(count($r))
++              //if(dbm::is_result($r))
                //      $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
  
  
index 5cc22d68304973d86b93d57aac7582dedff32639,873c594e8499ea93aeaa55727abeb09f34e81e28..5110713cdbef639c7ae2d449f28dc12efc9cc309
@@@ -39,7 -39,7 +39,7 @@@ function expire_run(&$argv, &$argc)
        logger('expire: start');
  
        $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
                        item_expire($rr['uid'],$rr['expire']);
index b268f2a03789183a1873673b7ac27cc74b52ea67,8821a985f2dc06e77619ce6bf7719c422358b031..45145ddf99fce7dc7a93ceee6dd0cf79ffa24eb8
@@@ -10,7 -10,7 +10,7 @@@ function fcontact_store($url,$name,$pho
                dbesc($nurl)
        );
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return $r[0]['id'];
  
        $r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
@@@ -23,7 -23,7 +23,7 @@@
                $r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
                        dbesc($nurl)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        return $r[0]['id'];
        }
  
Simple merge
index d5870e05de2612d39b52407d8f314be37b1e847f,08e74e02f3443d3b8a5849442ca4aee4710a20b6..1f188bf178aa7a797842633abf27cfaf33063fe0
@@@ -178,7 -178,7 +178,7 @@@ function new_contact($uid,$url,$interac
                        intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                // update contact
                if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
                        q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d",
                $r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0",
                        intval($uid)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $total_contacts = $r[0]['total'];
  
                if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
                        intval($uid),
                        dbesc($network)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $total_network = $r[0]['total'];
  
                if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
                        intval($uid)
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
                        require_once('include/salmon.php');
                        slapper($r[0],$contact['notify'],$slap);
index 70c45547eb39a149a2d969bc878702634577aae1,91b9b16e3306077ba2f0c574e6c46e0ce5fe066a..d6c1e912505c3f3c60a6564ddf62ceb88558d029
@@@ -65,7 -65,7 +65,7 @@@ function gprobe_run(&$argv, &$argc)
                        dbesc(normalise_link($url))
                );
        }
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                // Check for accessibility and do a poco discovery
                if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
                        poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
index 1c1fa631a13f59437573285706ed9a28fd86c8b2,53c0b78d841b5854f1eb08604a3c69aef0d2aad0..21f1943993640650e51ca0e9687d8fc4174bf681
@@@ -44,7 -44,7 +44,7 @@@ function group_rmv($uid,$name) 
                        intval($uid),
                        dbesc($name)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $group_id = $r[0]['id'];
                if(! $group_id)
                        return false;
@@@ -106,7 -106,7 +106,7 @@@ function group_byname($uid,$name) 
                intval($uid),
                dbesc($name)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return $r[0]['id'];
        return false;
  }
@@@ -139,7 -139,7 +139,7 @@@ function group_add_member($uid,$name,$m
                intval($gid),
                intval($member)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return true;    // You might question this, but
                                // we indicate success because the group member was in fact created
                                // -- It was just created at another time
@@@ -164,7 -164,7 +164,7 @@@ function group_get_members($gid) 
                        intval($gid),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $ret = $r;
        }
        return $ret;
@@@ -181,7 -181,7 +181,7 @@@ function group_public_members($gid) 
                        intval(local_user()),
                        dbesc(NETWORK_OSTATUS)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $ret = count($r);
        }
        return $ret;
@@@ -197,7 -197,7 +197,7 @@@ function mini_group_select($uid,$gid = 
                intval($uid)
        );
        $grps[] = array('name' => '', 'id' => '0', 'selected' => '');
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
                }
@@@ -255,7 -255,7 +255,7 @@@ function group_side($every="contacts",$
                $member_of = groups_containing(local_user(),$cid);
        }
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
  
@@@ -316,7 -316,7 +316,7 @@@ function expand_groups($a,$check_dead 
  
  
        $ret = array();
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                foreach($r as $rr)
                        $ret[] = $rr['contact-id'];
        if($check_dead AND !$use_gcontact) {
@@@ -345,7 -345,7 +345,7 @@@ function groups_containing($uid,$c) 
        );
  
        $ret = array();
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr)
                        $ret[] = $rr['gid'];
        }
index 18154a0fb89e650707f57e3a7df36d722a8950b1,91b31c078484b84563c83867a50507cb20afe561..c0c7936717fe3d0c3bef4e2c7960b41cf07a2523
@@@ -138,7 -138,7 +138,7 @@@ function get_profiledata_by_nick($nickn
                                        $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
                                                intval($visitor['cid'])
                                        );
-                                       if(dba::is_result($r))
 -                                      if(count($r))
++                                      if(dbm::is_result($r))
                                                $profile = $r[0]['profile-id'];
                                        break;
                                }
@@@ -230,7 -230,7 +230,7 @@@ function profile_sidebar($profile, $blo
  
                $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
                        local_user(), $profile_url);
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        $connect = false;
        }
  
                        'entries' => array(),
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        foreach($r as $rr) {
                                $profile['menu']['entries'][] = array(
                if(is_array($a->profile) AND !$a->profile['hide-friends']) {
                        $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
                                intval($a->profile['uid']));
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $updated =  date("c", strtotime($r[0]['updated']));
  
                        $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
                                dbesc(NETWORK_DIASPORA),
                                dbesc(NETWORK_OSTATUS)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $contacts = intval($r[0]['total']);
                }
        }
index cc416d8d982c06e3dfa1c94e5e87c197d4b5e94b,6d2c830f96ba8cf4a2c9ea63e59e1313371a7915..8f070996158f2a99efd20fb65ef602d355f9de0f
@@@ -413,7 -413,7 +413,7 @@@ function item_store($arr,$force_parent 
        /* check for create  date and expire time */
        $uid = intval($arr['uid']);
        $r = q("SELECT expire FROM user WHERE uid = %d", intval($uid));
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $expire_interval = $r[0]['expire'];
                if ($expire_interval>0) {
                        $expire_date =  new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC'));
                                intval($arr['uid'])
                        );
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $arr['network'] = $r[0]["network"];
  
                // Fallback to friendica (why is it empty in some cases?)
                $r = q("SELECT `guid` FROM `item` WHERE `guid` = '%s' AND `network` = '%s' AND `uid` = '%d' LIMIT 1",
                        dbesc($arr['guid']), dbesc($arr['network']), intval($arr['uid']));
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG);
                        return 0;
                }
                        intval($arr['uid'])
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        // is the new message multi-level threaded?
                        // even though we don't support it now, preserve the info
                        intval($r[0]["id"])
                );
                return 0;
-       } elseif(dba::is_result($r)) {
 -      } elseif(count($r)) {
++      } elseif(dbm::is_result($r)) {
  
                $current_post = $r[0]['id'];
                logger('item_store: created item ' . $current_post);
@@@ -979,7 -992,7 +992,7 @@@ function item_body_set_hashtags(&$item
  
  function get_item_guid($id) {
        $r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id));
-       if (dba::is_result($r))
 -      if (count($r))
++      if (dbm::is_result($r))
                return($r[0]["guid"]);
        else
                return("");
@@@ -998,7 -1011,7 +1011,7 @@@ function get_item_id($guid, $uid = 0) 
                $r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
                        WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid));
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        $id = $r[0]["id"];
                        $nick = $r[0]["nickname"];
                }
                                AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
                                AND `item`.`private` = 0 AND `item`.`wall` = 1
                                AND `item`.`guid` = '%s'", dbesc($guid));
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        $id = $r[0]["id"];
                        $nick = $r[0]["nickname"];
                }
@@@ -1313,7 -1326,7 +1326,7 @@@ function item_is_remote_self($contact, 
        if ($contact['remote_self'] == 2) {
                $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`",
                        intval($contact['uid']));
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        $datarray['contact-id'] = $r[0]["id"];
  
                        $datarray['owner-name'] = $r[0]["name"];
@@@ -1390,17 -1403,9 +1403,9 @@@ function new_follower($importer,$contac
                                intval($importer['uid']),
                                dbesc($url)
                );
-               if(dba::is_result($r)) {
-                               $contact_record = $r[0];
-                               $photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
-                               q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
-                                       dbesc($photos[0]),
-                                       dbesc($photos[1]),
-                                       dbesc($photos[2]),
-                                       intval($contact_record["id"])
-                               );
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
+                       $contact_record = $r[0];
+                       update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
                }
  
  
                        intval($importer['uid'])
                );
                $a = get_app();
--              if(count($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
++
++              if(dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
  
                        // create notification
                        $hash = random_string();
@@@ -1982,7 -1987,7 +1988,7 @@@ function drop_item($id,$interactive = t
                                dbesc($item['parent-uri']),
                                intval($item['uid'])
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
                                        intval($r[0]['id'])
                                );
@@@ -2019,7 -2024,7 +2025,7 @@@ function first_post_date($uid,$wall = f
                intval($uid),
                intval($wall ? 1 : 0)
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
  //            logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
                return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
        }
index 3ca005f28b72bafd6714b9bf4c9cea36be8eef46,118ec81ca1c35e47ca966c997c254a2a379234d1..36d7a922e72906cc17d51793ded0fdd5e3c60433
@@@ -90,7 -90,7 +90,7 @@@ function do_like($item_id, $verb) 
                WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
                intval($owner_uid)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $owner = $r[0];
  
        if(! $owner) {
                        intval($_SESSION['visitor_id']),
                        intval($owner_uid)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $contact = $r[0];
        }
        if(! $contact) {
                dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $like_item = $r[0];
  
                // Already voted, undo it
index 35d2b02aa88b09772a08ae48d54444b18484d5ff,70cf4b787b439dbf25c5c135965cd0b3b4bfad24..31b18191a9c7f7b3af8dadc5c80321dfc2fa8128
@@@ -16,7 -16,7 +16,7 @@@ function lock_function($fn_name, $bloc
                        dbesc($fn_name)
                );
  
-               if((dba::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
 -              if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
++              if((dbm::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
                        q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
                                dbesc(datetime_convert()),
                                dbesc($fn_name)
index fcbd53e4e76c749658cb1bf9861dae6691ce363a,51f3ad805a667fcbd45242625bb4f539d96d145c..041110440450df8fdf0729b23075a32cc386253d
@@@ -41,7 -41,7 +41,7 @@@ function send_message($recipient=0, $bo
                        dbesc($replyto),
                        dbesc($replyto)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $convid = $r[0]['convid'];
        }
  
@@@ -74,7 -74,7 +74,7 @@@
                        dbesc($conv_guid),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $convid = $r[0]['id'];
        }
  
                dbesc($uri),
                intval(local_user())
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $post_id = $r[0]['id'];
  
        /**
@@@ -210,7 -210,7 +210,7 @@@ function send_wallmessage($recipient=''
                dbesc($conv_guid),
                intval($recipient['uid'])
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $convid = $r[0]['id'];
  
        if(! $convid) {
index b238dbff657cd23d083d92dd5c4f80f765afeb5c,f20445d27e7493f73ea18ee2581efc2795bd48bd..09a6239193ca12c02a963f52d24c677755df9bcf
@@@ -338,7 -338,7 +338,6 @@@ function xml_status($st, $message = ''
        killme();
  }
  
--
  /**
   * @brief Send HTTP status header and exit.
   *
   *    'description' => optional message
   */
  
++/**
++ * @brief Send HTTP status header and exit.
++ *
++ * @param integer $val HTTP status result value
++ * @param array $description optional message
++ *    'title' => header title
++ *    'description' => optional message
++ */
  function http_status_exit($val, $description = array()) {
        $err = '';
        if($val >= 400) {
index 0e5f162843b85606217234f6c13734908ada0f3e,0610a4e398df5a9baba95ba58e4e9df7a6927b03..825e4aac15caafe382c75bbb1830c855ac2703d7
@@@ -314,7 -321,7 +321,7 @@@ function notifier_run(&$argv, &$argc)
                                                intval($uid),
                                                dbesc(NETWORK_DFRN)
                                        );
-                                       if(dba::is_result($r))
 -                                      if(count($r))
++                                      if(dbm::is_result($r))
                                                foreach($r as $rr)
                                                        $recipients_followup[] = $rr['id'];
                                }
                // We have not only to look at the parent, since it could be a Friendica thread.
                if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
  
-                       logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
+                       logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent[0]['author-link']." - Owner: ".$thr_parent[0]['owner-link'], LOGGER_DEBUG);
+                       // Send a salmon to the parent author
+                       $r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
+                               dbesc(normalise_link($thr_parent[0]['author-link'])),
+                               intval($uid));
+                       if ($r)
+                               $probed_contact = $r[0];
+                       else
+                               $probed_contact = probe_url($thr_parent[0]['author-link']);
+                       if ($probed_contact["notify"] != "") {
+                               logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
+                               $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
+                       }
+                       // Send a salmon to the parent owner
+                       $r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
+                               dbesc(normalise_link($thr_parent[0]['owner-link'])),
+                               intval($uid));
+                       if ($r)
+                               $probed_contact = $r[0];
+                       else
+                               $probed_contact = probe_url($thr_parent[0]['owner-link']);
+                       if ($probed_contact["notify"] != "") {
+                               logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
+                               $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
+                       }
  
 +                      // Send a salmon to the parent author
 +                      $probed_contact = probe_url($thr_parent[0]['author-link']);
 +                      if ($probed_contact["notify"] != "") {
 +                              logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
 +                              $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
 +                      }
 +
 +                      // Send a salmon to the parent owner
 +                      $probed_contact = probe_url($thr_parent[0]['owner-link']);
 +                      if ($probed_contact["notify"] != "") {
 +                              logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
 +                              $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
 +                      }
 +
                        // Send a salmon notification to every person we mentioned in the post
                        $arr = explode(',',$target_item['tag']);
                        foreach($arr as $x) {
  
                $r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra);
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $contacts = $r;
  
        } else
                                intval($uid),
                                dbesc(NETWORK_MAIL)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                foreach($r as $rr)
                                        $recipients[] = $rr['id'];
                        }
  
        // delivery loop
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
  
                foreach($r as $contact) {
                        if(!$contact['self']) {
  
                $r = array_merge($r2,$r1,$r0);
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
  
                        // throw everything into the queue in case we get killed
index bcfd79469b6439832b6d3c93b27fea2435705154,6a1d72d178f413fb68a94b8f7a64c7c35cb4d045..761a7a42c8e442a508db33166e544822653436a0
@@@ -23,7 -23,7 +23,7 @@@ class FKOAuthDataStore extends OAuthDat
                $r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id='%s'",
                        dbesc($consumer_key)
                );
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        return new OAuthConsumer($r[0]['client_id'],$r[0]['pw'],$r[0]['redirect_uri']);
                return null;
    }
@@@ -35,7 -35,7 +35,7 @@@
                        dbesc($token_type),
                        dbesc($token)
                );
-               if (dba::is_result($r)){
 -              if (count($r)){
++              if (dbm::is_result($r)){
                        $ot=new OAuthToken($r[0]['id'],$r[0]['secret']);
                        $ot->scope=$r[0]['scope'];
                        $ot->expires = $r[0]['expires'];
@@@ -52,7 -52,7 +52,7 @@@
                        dbesc($nonce),
                        intval($timestamp)
                );
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        return new OAuthToken($r[0]['id'],$r[0]['secret']);
                return null;
    }
@@@ -136,7 -136,7 +136,7 @@@ class FKOAuth1 extends OAuthServer 
                $r = q("SELECT * FROM `user` WHERE uid=%d AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
                        intval($uid)
                );
-               if(dba::is_result($r)){
 -              if(count($r)){
++              if(dbm::is_result($r)){
                        $record = $r[0];
                } else {
                   logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
  
                $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
                        intval($_SESSION['uid']));
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $a->contact = $r[0];
                        $a->cid = $r[0]['id'];
                        $_SESSION['cid'] = $a->cid;
@@@ -219,7 -219,7 +219,7 @@@ class FKOAuth2 extends OAuth2 
                $r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'",
                                dbesc($oauth_token));
        
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        return $r[0];
                return null;
        }
                $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
                                dbesc($code));
                
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        return $r[0];
                return null;
        }
index 19fa58ce023c29a8a0e6976b0e3863edff0fc8a1,e77937272088b31884b866471cb842957692e0eb..9ea1287ae1f53d41895a5732b768ab4cb57155a7
@@@ -94,7 -93,7 +93,7 @@@ function onepoll_run(&$argv, &$argc)
                        where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
                        intval($contact['id'])
                );
-               if (dba::is_result($r))
 -              if (count($r))
++              if (dbm::is_result($r))
                        if (!$r[0]['total'])
                                poco_load($contact['id'],$importer_uid,0,$contact['poco']);
        }
                                                        dbesc($datarray['uri'])
                                                );
  
-                                               if(dba::is_result($r)) {
 -                                              if(count($r)) {
++                                              if(dbm::is_result($r)) {
                                                        logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
  
                                                        // Only delete when mails aren't automatically moved or deleted
                                                        $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",
                                                                intval($importer_uid)
                                                        );
-                                                       if(dba::is_result($r))
 -                                                      if(count($r))
++                                                      if(dbm::is_result($r))
                                                                $datarray['parent-uri'] = $r[0]['parent-uri'];  // Set the parent as the top-level item
        //                                                      $datarray['parent-uri'] = $r[0]['uri'];
                                                }
                                                        $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
                                                                dbesc(protect_sprintf($datarray['title'])),
                                                                intval($importer_uid));
-                                                       if(dba::is_result($r))
 -                                                      if(count($r))
++                                                      if(dbm::is_result($r))
                                                                $datarray['parent-uri'] = $r[0]['parent-uri'];
                                                }
  
index 912591a5d01f561c9e5c5234a5b89d1f96c2dc67,f6e4a7a88223e651ad5c7ec1131891338571459d..28b02f9954caf551c0a5fec7185677e407adc47c
@@@ -79,7 -79,7 +79,7 @@@ function reload_plugins() 
        if(strlen($plugins)) {
  
                $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $installed = $r;
                else
                        $installed = array();
@@@ -150,7 -150,7 +150,7 @@@ function register_hook($hook,$file,$fun
                dbesc($file),
                dbesc($function)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return true;
  
        $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ",
@@@ -187,7 -187,7 +187,7 @@@ function load_hooks() 
        $a = get_app();
        $a->hooks = array();
        $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if(! array_key_exists($rr['hook'],$a->hooks))
                                $a->hooks[$rr['hook']] = array();
index 4c02417ea367861d1c8cbf28e98f8afd91d2e852,5214131b2bf0ed1e119b98379857838d6cf8ea20..a253aa2fb2282c4a0360f8e7fc58c9e128c84fde
@@@ -21,14 -21,16 +21,14 @@@ function was_recently_delayed($cid) 
                and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
                intval($cid)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return true;
  
        $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
                intval($cid)
        );
 -      if(count($r))
 -              return true;
  
-       return (dba::is_result($r));
 -      return false;
++      return (dbm::is_result($r));
  }
  
  
index 3d64ae66770a83f541ad4202ae97e6f918a76eb6,2d6db95f4f899cd6a877198217980c27b54b7d69..000451dbe51c076f142126a22e0f55f527d5d998
@@@ -42,7 -42,7 +42,7 @@@ function authenticate_success($user_rec
                $r = q("select * from user where uid = %d limit 1",
                        intval($_SESSION['submanage'])
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $master_record = $r[0];
        }
  
@@@ -70,7 -70,7 +70,7 @@@
  
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
                intval($_SESSION['uid']));
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $a->contact = $r[0];
                $a->cid = $r[0]['id'];
                $_SESSION['cid'] = $a->cid;
@@@ -158,7 -158,7 +158,7 @@@ function can_write_wall(&$a,$owner) 
                                intval(PAGE_COMMUNITY)
                        );
  
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $verified = 2;
                                return true;
                        }
@@@ -212,7 -212,7 +212,7 @@@ function permissions_sql($owner_id,$rem
                                intval($remote_user),
                                intval($owner_id)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $remote_verified = true;
                                $groups = init_groups_visitor($remote_user);
                        }
@@@ -294,7 -294,7 +294,7 @@@ function item_permissions_sql($owner_id
                                intval($remote_user),
                                intval($owner_id)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $remote_verified = true;
                                $groups = init_groups_visitor($remote_user);
                        }
@@@ -405,7 -405,7 +405,7 @@@ function init_groups_visitor($contact_i
                WHERE `contact-id` = %d ",
                intval($contact_id)
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr)
                        $groups[] = $rr['gid'];
        }
index 8c76eba41aa2b8534ff6fffd96b2950ae12339de,8f9d64606c00b3dda205e4e85badcca6316f8571..fe8e0848efb360e2f43068433c0420bcd77d864a
@@@ -17,7 -17,7 +17,7 @@@ function ref_session_read ($id) 
        if(x($id))
                $r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $session_exists = true;
                return $r[0]['data'];
        } else {
index 00f8fb11f3f8cfae43f993234fd2046928264e1d,89897aaa7ce5eceeeaa41a2b299b15cad5e5edfa..1e7362b8bde671e9b0d88e6e17cc96e4b3fcdf68
@@@ -39,7 -40,7 +40,7 @@@ function poco_load($cid,$uid = 0,$zcid 
                        $r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
                                intval($cid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $url = $r[0]['poco'];
                                $uid = $r[0]['uid'];
                        }
@@@ -205,14 -206,14 +206,14 @@@ function poco_check($profile_url, $name
        $r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
                dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $network = $r[0]["network"];
  
        if (($network == "") OR ($network == NETWORK_OSTATUS)) {
                $r = q("SELECT `network`, `url` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1",
                        dbesc($profile_url), dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $network = $r[0]["network"];
                        //$profile_url = $r[0]["url"];
                }
@@@ -948,7 -953,7 +953,7 @@@ function count_common_friends($uid,$cid
        );
  
  //    logger("count_common_friends: $uid $cid {$r[0]['total']}");
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return $r[0]['total'];
        return 0;
  
@@@ -994,7 -999,7 +999,7 @@@ function count_common_friends_zcid($uid
                intval($uid)
        );
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return $r[0]['total'];
        return 0;
  
@@@ -1033,7 -1038,7 +1038,7 @@@ function count_all_friends($uid,$cid) 
                intval($uid)
        );
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                return $r[0]['total'];
        return 0;
  
@@@ -1162,7 -1167,7 +1167,7 @@@ function update_suggestions() 
                dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA)
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
                        if(! in_array($base,$done))
index ed905d3fff9e133684399952dc420b7ec0c5566f,3aec42b3239b1fbee986d15b60183f53f05fc9fa..71b9a716c89944f415998c0ebc1eb937d7f7d65e
@@@ -491,7 -491,7 +491,7 @@@ function item_new_uri($hostname,$uid, $
  
                $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
                        dbesc($uri));
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $dups = true;
        } while($dups == true);
        return $uri;
@@@ -515,7 -515,7 +515,7 @@@ function photo_new_resource() 
                $r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
                        dbesc($resource)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $found = true;
        } while($found == true);
        return $resource;
@@@ -859,7 -864,7 +864,7 @@@ function contact_block() 
                        dbesc(NETWORK_OSTATUS),
                        dbesc(NETWORK_DIASPORA)
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $total = intval($r[0]['total']);
        }
        if(! $total) {
                                dbesc(NETWORK_DIASPORA),
                                intval($shown)
                );
-               if(dba::is_result($r)) {
-                       $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
-                       $micropro = Array();
-                       foreach($r as $rr) {
-                               $micropro[] = micropro($rr,true,'mpfriend');
 -              if ($r) {
++              if(dbm::is_result($r)) {
+                       $contacts = "";
+                       foreach ($r AS $contact)
+                               $contacts[] = $contact["id"];
+                       $r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
+                               dbesc(implode(",", $contacts)));
 -                      if(count($r)) {
++
++                      if(dbm::is_result($r)) {
+                               $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
+                               $micropro = Array();
+                               foreach($r as $rr) {
+                                       $micropro[] = micropro($rr,true,'mpfriend');
+                               }
                        }
                }
        }
@@@ -2050,7 -1917,7 +1918,7 @@@ function file_tag_update_pconfig($uid,$
                        //      intval($uid)
                        //);
  
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                unset($deleted_tags[$key]);
                        }
                        else {
@@@ -2080,7 -1947,7 +1948,7 @@@ function file_tag_save_file($uid,$item,
                intval($item),
                intval($uid)
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
                        q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
                                dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
index 33d6d3fc820fe81faef507f4b4b42553d70c6107,2e02e7ada3290ae0ecb690cad1d6ca912e307379..2b1b27679b3c3b17934b8985e5a7bfd50fe00b25
@@@ -83,12 -85,12 +85,12 @@@ function add_shadow_entry($item) 
  
        // Is there a shadow parent?
        $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri']));
--      if (!count($r))
++      if (!dbm::is_result($r))
                return;
  
        // Is there already a shadow entry?
        $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
-       if (dba::is_result($r))
 -      if (count($r))
++      if (dbm::is_result($r))
                return;
  
        // Preparing public shadow (removing user specific data)
  function update_thread_uri($itemuri, $uid) {
        $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
  
--      if(count($messages))
++      if(dbm::is_result($messages))
                foreach ($messages as $message)
                        update_thread($message["id"]);
  }
@@@ -115,7 -117,7 +117,7 @@@ function update_thread($itemid, $setmen
        $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
                        `deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
  
--      if (!$items)
++      if (!dbm::is_result($items))
                return;
  
        $item = $items[0];
index a61da7b3032abe5f1cebf22e5c74d8e98619eab6,3997a8a61f12584da6469808d767fb93c53c2db6..3a45837687b20eab8c7422baee9b498b86e8abe0
@@@ -130,7 -130,7 +130,7 @@@ function create_user($arr) 
                $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
                        dbesc($email)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $result['message'] .= t('Cannot use that email.') . EOL;
        }
  
                WHERE `nickname` = '%s' LIMIT 1",
                dbesc($nickname)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
  
        // Check deleted accounts that had this nickname. Doesn't matter to us,
                WHERE `username` = '%s' LIMIT 1",
                dbesc($nickname)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $result['message'] .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL;
  
        if(strlen($result['message'])) {
diff --cc mod/admin.php
index 3e19935cb528b5a38fdd539cbe315c423bc2d478,0749fd186137c3d26b755490a7d81ba321bac574..90fe059752961fd7e2b9339e0f24ae5adcd5122a
@@@ -1077,8 -1090,8 +1090,8 @@@ function admin_page_dbsync(&$a) 
        }
  
        $failed = array();
-       $r = q("select k, v from config where `cat` = 'database' ");
-       if(dba::is_result($r)) {
+       $r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $upd = intval(substr($rr['k'],7));
                        if($upd < 1139 || $rr['v'] === 'success')
diff --cc mod/common.php
index bc6533624993af0e08d88818c04d2a9d6e93330e,9b2c69f6d70c4955b12daaa6cca20ddf9e49f7de..b465612c3c5ddff776d4b9e82c8eb4def115d7aa
@@@ -57,13 -57,13 +57,13 @@@ function common_content(&$a) 
                                dbesc(normalise_link(get_my_url())),
                                intval($profile_uid)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $cid = $r[0]['id'];
                        else {
                                $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
                                        dbesc(normalise_link(get_my_url()))
                                );
-                               if(dba::is_result($r))
 -                              if(count($r))
++                              if(dbm::is_result($r))
                                        $zcid = $r[0]['id'];
                        }
                }
index fb50ad4bd219660d614310fc7cd36363a65d8fbe,06a96c7403f54ff933efa10c8cbaa1d3406a6830..dc270514a26c70d35bd2c5d79047da11ba452bc1
@@@ -59,7 -59,7 +59,7 @@@ function community_content(&$a, $updat
                        AND `item`.`private` = 0 AND `item`.`wall` = 1"
                );
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $a->set_pager_total($r[0]['total']);
  
                if(! $r[0]['total']) {
index be698325121600c6f35f96f39f8cb2c5505e8375,bf81afe079118767cd83e3917871e6cf34e510ff..d19e1b2ebf52ce07c8a27d3af7cec81df25f4f5c
@@@ -14,7 -14,7 +14,7 @@@ function contactgroup_content(&$a) 
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
  
index 19cbf4e6fb7db8f0a237ea82aacbe695fb7d2f81,ba8ad45c39926568deceb9fab40f1e945cefef86..3721937d4d77f0ecdb65f62739485d9787139723
@@@ -758,7 -763,7 +763,7 @@@ function contacts_content(&$a) 
        $r = q("SELECT COUNT(*) AS `total` FROM `contact`
                WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
                intval($_SESSION['uid']));
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
                $total = $r[0]['total'];
        }
                intval($a->pager['itemspage'])
        );
  
-       if(dba::is_result($r)) {
 -      $contacts = array();
 -
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $contacts[] = _contact_detail_for_template($rr);
                }
diff --cc mod/content.php
index 718dc77d29138e623defa14363fefb2e773c7cc4,c4b1f2f68f9a51a11d3f13b1e878544b970de9aa..76c59d19c061dcaa1e7dc1119d02b2b7bf4cc142
@@@ -93,7 -93,7 +93,7 @@@ function content_content(&$a, $update 
                );
  
                $str = '';
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr)
                                $str .= '<' . $rr['id'] . '>';
                if(strlen($str))
                                AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
                        intval($cid)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
  
                }
                $parents_arr = array();
                $parents_str = '';
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        foreach($r as $rr)
                                if(! in_array($rr['item_id'],$parents_arr))
                                        $parents_arr[] = $rr['item_id'];
index 55951cd51bb822b80da588816c8007f79f82a2ea,20d2e605e0a2d91c90e1d664567037d6baf1902d..6ffe785878b38ddc40653fb6b7492ddfa09f0298
@@@ -26,12 -26,12 +26,12 @@@ function delegate_content(&$a) 
                $r = q("select `nickname` from user where uid = %d limit 1",
                        intval($id)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
                                intval(local_user()),
                                dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname']))
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                q("insert into manage ( uid, mid ) values ( %d , %d ) ",
                                        intval($a->argv[2]),
                                        intval(local_user())
@@@ -64,7 -64,7 +64,7 @@@
                dbesc($a->user['email']),
                dbesc($a->user['password'])
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $full_managers = $r;
  
        $delegates = array();
@@@ -75,7 -75,7 +75,7 @@@
                intval(local_user())
        );
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $delegates = $r;
  
        $uids = array();
  
        $nicknames = array();
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
                }
  
        $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                foreach($r as $rr)
                        if(! in_array($rr['uid'],$uids))
                                $potentials[] = $rr;
index 29d3630aca5f5e2983fa01fb87618df8679b30c1,51cd59c62fe100b203e6caf8683571725491318c..1dab71306576d8294bf3a88719495c1b0e8183a7
@@@ -418,7 -419,7 +419,7 @@@ function dfrn_confirm_post(&$a,$handsfr
                $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($contact_id)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $contact = $r[0];
                else
                        $contact = null;
                                intval($uid)
                        );
  
-                       if((dba::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
 -                      if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
++                      if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
  
                                require_once('include/items.php');
  
                $r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
                        dbesc($decrypted_dfrn_id)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
                        xml_status(1,$message); // Birthday paradox - duplicate dfrn-id
                        // NOTREACHED
                $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($dfrn_record));
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $photo = $r[0]['photo'];
                else
                        $photo = $a->get_baseurl() . '/images/person-175.jpg';
                        intval($dfrn_record)
                );
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $combined = $r[0];
  
-               if((dba::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
 -              if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
++              if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
                        $mutual = ($new_relation == CONTACT_IS_FRIEND);
                        notification(array(
                                'type'         => NOTIFY_CONFIRM,
                                intval($local_uid)
                        );
  
-                       if((dba::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
 -                      if((count($r)) && ($r[0]['hide-friends'] == 0)) {
++                      if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
  
                                require_once('include/items.php');
  
index a75fbc40b8dad92a39516dab3c7ac85740e7c8c9,9613229dab04e3381f63a657448acb447f55e6ca..083e4d3488e463e963fa9e2f29d61f494ee49490
@@@ -76,7 -79,7 +79,7 @@@ function dfrn_poll_init(&$a) 
                        dbesc($a->argv[1])
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
  
                        q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
                        $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
                                dbesc($dfrn_id));
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                xml_status(1);
                                return; // NOTREACHED
                        }
@@@ -332,7 -335,7 +335,7 @@@ function dfrn_poll_post(&$a) 
                $reputation = 0;
                $text = '';
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $reputation = $r[0]['rating'];
                        $text = $r[0]['reason'];
  
@@@ -445,7 -448,7 +448,7 @@@ function dfrn_poll_content(&$a) 
                        dbesc($nickname)
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $challenge = '';
                        $encrypted_id = '';
                                ));
                        }
  
-                       $profile = ((dba::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
 -                      $profile = ((count($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
++                      $profile = ((dbm::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
  
                        switch($destination_url) {
                                case 'profile':
index dc9d32adf491b7e31dfa87fbb990103a200b3296,7fe2527f3d73c9401654243c4bcaa1b2cf29d757..0162ecf1938bd6c2e4221c492be83cd13437b92d
@@@ -89,7 -90,7 +90,7 @@@ function dfrn_request_post(&$a) 
                                        dbesc(normalise_link($dfrn_url))
                                );
  
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        if(strlen($r[0]['dfrn-id'])) {
  
                                                /**
                                        dbesc($dfrn_url),
                                        $parms['key'] // this was already escaped
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $def_gid = get_default_group(local_user(), $r[0]["network"]);
                                        if(intval($def_gid))
                                                group_add_member(local_user(), '', $r[0]['id'], $def_gid);
                        AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
                        dbesc(NETWORK_MAIL2)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if(! $rr['rel']) {
                                        q("DELETE FROM `contact` WHERE `id` = %d",
                        AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
                        dbesc(NETWORK_MAIL2)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if(! $rr['rel']) {
                                        q("DELETE FROM `contact` WHERE `id` = %d",
                                dbesc($poll),
                                intval($uid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $contact_id = $r[0]['id'];
  
                                $def_gid = get_default_group($uid, $r[0]["network"]);
                        $data = probe_url($url);
                        $network = $data["network"];
  
 +                      logger('dfrn_request: url=' . $url . ',network=' . $network . ',hcard=' . $hcard . ' - BEFORE!', LOGGER_DEBUG);
 +
                        // Canonicalise email-style profile locator
-                       $url = webfinger_dfrn($url,$hcard);
+                       $url = Probe::webfinger_dfrn($url,$hcard);
  
 +                      logger('dfrn_request: url=' . $url . ',network=' . $network . ',hcard=' . $hcard . ' - AFTER!', LOGGER_DEBUG);
 +
                        if (substr($url,0,5) === 'stat:') {
  
                                // Every time we detect the remote subscription we define this as OStatus.
                                                $parms['url'],
                                                $parms['issued-id']
                                        );
-                                       if(dba::is_result($r))
 -                                      if(count($r)) {
++                                      if(dbm::is_result($r))
                                                $contact_record = $r[0];
+                                               update_contact_avatar($photo, $uid, $contact_record["id"], true);
+                                       }
                                }
  
                        }
@@@ -715,16 -719,16 +723,16 @@@ function dfrn_request_content(&$a) 
                        dbesc($_GET['confirm_key'])
                );
  
-               if(dba::is_result($intro)) {
 -              if(count($intro)) {
++              if(dbm::is_result($intro)) {
 +
 +                      $auto_confirm = false;
  
                        $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
                                WHERE `contact`.`id` = %d LIMIT 1",
                                intval($intro[0]['contact-id'])
                        );
  
-                       if(dba::is_result($r)) {
 -                      $auto_confirm = false;
 -
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
                                        $auto_confirm = true;
  
index 531283936c61f567e8a5f9e172c5c5b042c436da,a6a9cb8ab24356f4ef017c7ed3e01b9e0414e75c..92a3f3d05bfe7b279c25225081e023548adea188
@@@ -78,7 -78,7 +78,7 @@@ function directory_content(&$a) 
        $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`
                        LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
                        WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $a->set_pager_total($r[0]['total']);
  
        $order = " ORDER BY `name` ASC ";
@@@ -90,7 -90,7 +90,7 @@@
                        LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
                        LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
                        WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
  
                if(in_array('small', $a->argv))
                        $photo = 'thumb';
diff --cc mod/display.php
index 849fef3f24ed18586b87600a23a822943434ef0b,f879a91aeca49ec4a135d7ed36e7d80520c148f1..cf7700a145a4e3cb209fbf3a9163dca0fb403e38
@@@ -16,10 -16,10 +16,10 @@@ function display_init(&$a) 
  
                // Does the local user have this item?
                if (local_user()) {
-                       $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
+                       $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
                                        AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
-                       if (dba::is_result($r)) {
 -                      if (count($r)) {
++                      if (dbm::is_result($r)) {
                                $nick = $a->user["nickname"];
                                $itemuid = local_user();
                        }
@@@ -36,7 -36,7 +36,7 @@@
                                        AND NOT `item`.`private` AND NOT `user`.`hidewall`
                                        AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                //      AND NOT `item`.`private` AND `item`.`wall`
-                       if (dba::is_result($r)) {
 -                      if (count($r)) {
++                      if (dbm::is_result($r)) {
                                $nick = $r[0]["nickname"];
                                $itemuid = $r[0]["uid"];
                        }
@@@ -53,9 -53,9 +53,9 @@@
                                        AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                //      AND NOT `item`.`private` AND `item`.`wall`
                }
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        if ($r[0]["id"] != $r[0]["parent"])
-                               $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
+                               $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
                                                AND `id` = %d", $r[0]["parent"]);
  
@@@ -70,7 -92,7 +92,7 @@@
                                                WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
                                                dbesc($nickname)
                                        );
-                                       if (dba::is_result($r))
 -                                      if (count($r))
++                                      if (dbm::is_result($r))
                                                $profiledata = $r[0];
  
                                        $profiledata["network"] = NETWORK_DFRN;
@@@ -259,7 -231,7 +231,7 @@@ function display_content(&$a, $update 
                                $r = q("SELECT `id` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
                                                AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
-                               if (dba::is_result($r)) {
 -                              if (count($r)) {
++                              if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                        $nick = $a->user["nickname"];
                                }
                                                AND NOT `item`.`private` AND NOT `user`.`hidewall`
                                                AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                        //      AND NOT `item`.`private` AND `item`.`wall`
-                               if (dba::is_result($r)) {
 -                              if (count($r)) {
++                              if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                        $nick = $r[0]["nickname"];
                                }
                                                AND NOT `item`.`private` AND `item`.`uid` = 0
                                                AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                        //      AND NOT `item`.`private` AND `item`.`wall`
-                               if (dba::is_result($r)) {
 -                              if (count($r)) {
++                              if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                }
                        }
                        intval($contact_id),
                        intval($a->profile['uid'])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $contact = $r[0];
                        $remote_contact = true;
                }
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                intval($a->profile['uid'])
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $a->page_contact = $r[0];
  
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
index bbd21a064dc9ac8f5572adaad7767824898d75a6,46a530dce09f49ec5da5058364aac0b88f4fe6df..5322a271c14863c322c401d787e44a06532c5ddd
@@@ -78,7 -78,7 +78,7 @@@ function editpost_content(&$a) 
                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                        intval(local_user())
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $mail_enabled = true;
                        if(intval($r[0]['pubmail']))
                                $pubmail_enabled = true;
diff --cc mod/events.php
index 1b2d8f9cefec3cf7d5fcdbdb152d5e4fa0fb94ae,1b5dfdf31c03618f2ed091dd72ac59be28473281..e579d3530dcf1fca230b4a16d9af61b29fc7f2d8
@@@ -361,7 -332,7 +332,7 @@@ function events_content(&$a) 
  
                $links = array();
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $r = sort_by_date($r);
                        foreach($r as $rr) {
                                $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
                        }
                }
  
                $events=array();
  
-               $last_date = '';
-               $fmt = t('l, F j');
-               if(dba::is_result($r)) {
+               // transform the event in a usable array
 -              if(count($r))
++              if(dbm::is_result($r)) {
                        $r = sort_by_date($r);
-                       foreach($r as $rr) {
-                               $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
-                               $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt));
-                               $d = day_translate($d);
-                               $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c'));
-                               if ($rr['nofinish']){
-                                       $end = null;
-                               } else {
-                                       $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c'));
-                               }
-                               $is_first = ($d !== $last_date);
-                               $last_date = $d;
-                               $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
-                               $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
-                               if(! $title) {
-                                       list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
-                                       $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
-                               }
-                               $html = format_event_html($rr);
-                               $rr['desc'] = bbcode($rr['desc']);
-                               $rr['location'] = bbcode($rr['location']);
-                               $events[] = array(
-                                       'id'=>$rr['id'],
-                                       'start'=> $start,
-                                       'end' => $end,
-                                       'allDay' => false,
-                                       'title' => $title,
-                                       'j' => $j,
-                                       'd' => $d,
-                                       'edit' => $edit,
-                                       'is_first'=>$is_first,
-                                       'item'=>$rr,
-                                       'html'=>$html,
-                                       'plink' => array($rr['plink'],t('link to source'),'',''),
-                               );
-                       }
-               }
+                       $events = process_events($r);
  
                if ($a->argv[1] === 'json'){
                        echo json_encode($events); killme();
                        intval($event_id),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $orig_event = $r[0];
        }
  
index 2ec8ab95a33cc4685a732fde5c599e4728d90b3f,aad5964baf6e5d1ddf737e88f46b636cb255d6d7..8c9e9d7ad414cce4e586b022e25b801469209b16
@@@ -24,7 -24,7 +24,7 @@@ function friendica_init(&$a) 
                $visible_plugins = array();
                if(is_array($a->plugins) && count($a->plugins)) {
                        $r = q("select * from addon where hidden = 0");
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                foreach($r as $rr)
                                        $visible_plugins[] = $rr['name'];
                }
@@@ -80,7 -80,7 +80,7 @@@ function friendica_content(&$a) 
        $visible_plugins = array();
        if(is_array($a->plugins) && count($a->plugins)) {
                $r = q("select * from addon where hidden = 0");
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr)
                                $visible_plugins[] = $rr['name'];
        }
index 986f92e34bca657aab64e1ee2c1c4935f465cc58,ad407d5f32a0ca80552fbe36a02e638296282d25..a905cb44af768c4d44fb3de73c324874d9d95d37
@@@ -33,7 -33,7 +33,7 @@@ function fsuggest_post(&$a) 
                        intval($new_contact),
                        intval(local_user())
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
                                VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
@@@ -50,7 -50,7 +50,7 @@@
                                dbesc($hash),
                                intval(local_user())
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $fsuggest_id = $r[0]['id'];
                                q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
                                        dbesc($note),
diff --cc mod/group.php
index 94947c1890bc475308d937fdd80b7070262d41bb,5b28784f5663cc1b7056125b26619416e9e76b6d..9f3551e1f5dd189557b4956e95a5869c7a6e240a
@@@ -107,7 -107,7 +107,7 @@@ function group_content(&$a) 
                                intval($a->argv[2]),
                                intval(local_user())
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $result = group_rmv(local_user(),$r[0]['name']);
                        if($result)
                                info( t('Group removed.') . EOL);
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
  
                intval(local_user())
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
                foreach($r as $member) {
                        if(! in_array($member['id'],$preselected)) {
diff --cc mod/item.php
index 935d66e6d8babc31e7e8abe21283db15bc974d5b,9a9b5895bdd719e0c8b04d8abec606c7bc5eafac..02fda2c2706a8533ee0034ec4caf66f5b5675bbf
@@@ -129,7 -130,7 +130,7 @@@ function item_post(&$a) 
                                intval($parent_item['contact-id']),
                                intval($uid)
                        );
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $parent_contact = $r[0];
  
                        // If the contact id doesn't fit with the contact, then set the contact to null
  
                                $r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
                                        dbesc(normalise_link($thrparent[0]["author-link"])));
-                               if (dba::is_result($r)) {
 -                              if (count($r)) {
++                              if (dbm::is_result($r)) {
                                        $parent_contact = $r[0];
                                        $parent_contact["thumb"] = $parent_contact["photo"];
                                        $parent_contact["micro"] = $parent_contact["photo"];
        $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($profile_uid)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $user = $r[0];
  
        if($orig_post) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                        intval(local_user())
                                );
-                               if(dba::is_result($r) && intval($r[0]['pubmail']))
 -                              if(count($r) && intval($r[0]['pubmail']))
++                              if(dbm::is_result($r) && intval($r[0]['pubmail']))
                                        $pubmail_enabled = true;
                        }
                }
                }
        }
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $author = $r[0];
                $contact_id = $author['id'];
        }
                $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
                        intval($profile_uid)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $contact_record = $r[0];
        }
  
                                        intval($profile_uid),
                                        intval($attach)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
                                                WHERE `uid` = %d AND `id` = %d",
                                                dbesc($str_contact_allow),
                                intval($profile_uid),
                                intval($mtch)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                if(strlen($attachments))
                                        $attachments .= ',';
                                $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
index df11a7f6fbcae1400bc1cbfd28da945f496519d2,0ae54c8c125f92d07616113a7b52865e3d61fed1..154350769525e120263b37e07d32587a01816512
@@@ -52,7 -52,7 +52,7 @@@ function lockview_content(&$a) 
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        dbesc(implode(', ', $allowed_groups))
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<b>' . $rr['name'] . '</b>';
        }
@@@ -60,7 -60,7 +60,7 @@@
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
                        dbesc(implode(', ',$allowed_users))
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = $rr['name'];
  
@@@ -70,7 -70,7 +70,7 @@@
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        dbesc(implode(', ', $deny_groups))
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
        }
@@@ -78,7 -78,7 +78,7 @@@
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
                        dbesc(implode(', ',$deny_users))
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<strike>' . $rr['name'] . '</strike>';
  
diff --cc mod/manage.php
index c56e4d8bc959a7bd30b20423232b2420bcb4f404,adcc3d787aac0d58563cbd5d38e82e50384498d2..f131e609c1bad914d31465ed049bb2bc365556f5
@@@ -15,7 -15,7 +15,7 @@@ function manage_post(&$a) 
                $r = q("select * from user where uid = %d limit 1",
                        intval($_SESSION['submanage'])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $uid = intval($r[0]['uid']);
                        $orig_record = $r[0];
                }
diff --cc mod/message.php
index 2a1152b8c0296e0fcf2493bc2d39c3637b877f76,4bd73d0cee9d36da73e625d467457843d4a4fe2a..4a65b744a647cf1e2339dfe11bdc5324dd94d6f7
@@@ -242,7 -242,7 +242,7 @@@ function message_content(&$a) 
                                intval($a->argv[2]),
                                intval(local_user())
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $parent = $r[0]['parent-uri'];
                                $convid = $r[0]['convid'];
  
                                intval(local_user()),
                                intval($a->argv[2])
                        );
-                       if(dba::is_result($r)) {
 -                      if(!$r) {
++                      if(!dbm::is_result($r)) {
+                               $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
+                                       intval(local_user()),
+                                       dbesc(normalise_link(base64_decode($a->argv[2])))
+                               );
+                       }
 -                      if(!$r) {
++
++                      if(!dbm::is_result($r)) {
+                               $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1",
+                                       intval(local_user()),
+                                       dbesc(base64_decode($a->argv[2]))
+                               );
+                       }
 -                      if(count($r)) {
++
++                      if(dbm::is_result($r)) {
                                $prename = $r[0]['name'];
                                $preurl = $r[0]['url'];
                                $preid = $r[0]['id'];
                        intval(local_user()),
                        intval($a->argv[1])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $contact_id = $r[0]['contact-id'];
                        $convid = $r[0]['convid'];
  
diff --cc mod/mood.php
index 9be60de1d852d3d278b8192798510f00f49960b4,f804af0c00819ec0d9ed93714867e44b49396502..4ddf16e34c23195191a9e64dca158e3b31f0ebb2
@@@ -36,7 -36,7 +36,7 @@@ function mood_init(&$a) 
                        intval($parent),
                        intval($uid)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $parent_uri = $r[0]['uri'];
                        $private    = $r[0]['private'];
                        $allow_cid  = $r[0]['allow_cid'];
diff --cc mod/msearch.php
index 8393a97ae8aec619a3022bae84c6705749b420a8,89de5b70576f354653ad4daf8645d5aa5b843876..fd46cc1e1bd5aaaa7ca24df3bdde357f1096cb59
@@@ -13,19 -13,17 +13,19 @@@ function msearch_post(&$a) 
        $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
                dbesc($search)
        );
 -      if(count($r))
 +
-       if(dba::is_result($r))
++      if(dbm::is_result($r))
                $total = $r[0]['total'];
  
 +      $results = array();
 +
        $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
                dbesc($search),
                intval($startrec),
                intval($perpage)
        );
  
-       if(dba::is_result($r)) {
 -      $results = array();
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr)
                        $results[] = array(
                                'name' => $rr['name'], 
diff --cc mod/network.php
index 28ce8fdbfe2f518925effd891f5d164df723673f,6ebedbcae8ff27f9ce63516080dacee98508cadf..0222e33401ac12c34a71c5195af1dd4d6cf9a75f
@@@ -182,7 -182,7 +182,7 @@@ function saved_searches($search) 
  
        $saved = array();
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $saved[] = array(
                                'id'            => $rr['id'],
@@@ -465,7 -381,7 +381,7 @@@ function network_content(&$a, $update 
                );
  
                $str = '';
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $rr)
                                $str .= '<' . $rr['id'] . '>';
                if(strlen($str))
                                AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
                        intval($cid)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
  
                        $entries[0] = array(
                                intval($_SESSION['uid'])
                        );
  
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $a->set_pager_total($r[0]['total']);
                        }
                }
diff --cc mod/nogroup.php
index a29cb9c86ee1985e1706edfcad6cc218142161a0,2f0985c9dbba0db74ae2be74bfc4d31a110c0f6d..c34120f0ff578ee43e14062252ccef3c5576d28b
@@@ -28,17 -28,17 +28,17 @@@ function nogroup_content(&$a) 
  
        require_once('include/Contact.php');
        $r = contacts_not_grouped(local_user());
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
        }
        $r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']);
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
  
-                       $contact_details = get_contact_details_by_url($rr['url'], local_user());
+                       $contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
  
                        $contacts[] = array(
-                               'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
+                               'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
                                'edit_hover' => t('Edit contact'),
                                'photo_menu' => contact_photo_menu($rr),
                                'id' => $rr['id'],
index 7b759d15d8bfbc3026bfbcc40ad1c45249f387b8,2a04605469b845745755b2bce39eb3a5f9472972..a2a71a8e2bab6ffa6c3ab9bdb2d52d70d6e2999e
@@@ -39,7 -43,7 +43,7 @@@ function noscrape_init(&$a) 
        if(is_array($a->profile) AND !$a->profile['hide-friends']) {
                $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
                        intval($a->profile['uid']));
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $json_info["updated"] =  date("c", strtotime($r[0]['updated']));
  
                $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
@@@ -49,7 -53,7 +53,7 @@@
                        dbesc(NETWORK_DIASPORA),
                        dbesc(NETWORK_OSTATUS)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $json_info["contacts"] = intval($r[0]['total']);
        }
  
diff --cc mod/notes.php
index ba5ef1b6d46accbca6db4fdc15ee7db1f993ec0e,a25d090ed701faad32ab49fb2dbc7012b13d8e2f..f1b49ebee42d0e6dbedc227d6b9694f6f2d621f4
@@@ -83,7 -82,7 +82,7 @@@ function notes_content(&$a,$update = fa
  
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
                $a->set_pager_itemspage(40);
        }
        $parents_arr = array();
        $parents_str = '';
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr)
                        $parents_arr[] = $rr['item_id'];
                $parents_str = implode(', ', $parents_arr);
                        dbesc($parents_str)
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $items = conv_sort($r,"`commented`");
  
                        $o .= conversation($a,$items,'notes',$update);
diff --cc mod/notice.php
index 161273b0acd489e2afe80732458f00d7cfc2a65c,19cf53189a1476dfb9795026ab9b23139ad0160f..7fdf4493a4f5cf30a801f4c0008df1c8970d2fa9
@@@ -6,7 -6,7 +6,7 @@@
                $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d",
                                intval($id)
                                );
-               if (dba::is_result($r)){
 -              if (count($r)){
++              if (dbm::is_result($r)){
                        $nick = $r[0]['nickname'];
                        $url = $a->get_baseurl()."/display/$nick/$id";
                        goaway($url);
index 6d8c68eb3505166d2c1b63d80f6dfd0430656966,af44097c1cb42a508c3267665d37b8fd2de8c52e..e6dbdf2640656a98b37a4765326953b8019d2b78
@@@ -21,7 -27,7 +27,7 @@@ function notifications_post(&$a) 
                        intval(local_user())
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $intro_id = $r[0]['id'];
                        $contact_id = $r[0]['contact-id'];
                }
@@@ -206,376 -207,113 +207,112 @@@ function notifications_content(&$a) 
                                                '$fan_selected' => $fan_selected,
                                                '$approve_as' => $helptext,
                                                '$as_friend' => t('Friend'),
-                                               '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer'))
+                                               '$as_fan' => (($it['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer'))
                                        ));
-                               }
-                               $header = $rr["name"];
-                               $ret = probe_url($rr["url"]);
-                               if ($rr['gnetwork'] == "")
-                                       $rr['gnetwork'] = $ret["network"];
-                               if ($ret["addr"] != "")
-                                       $header .= " <".$ret["addr"].">";
-                               $header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")";
-                               // Don't show these data until you are connected. Diaspora is doing the same.
-                               if($rr['gnetwork'] === NETWORK_DIASPORA) {
-                                       $rr['glocation'] = "";
-                                       $rr['gabout'] = "";
-                                       $rr['ggender'] = "";
-                               }
-                               $notif_content .= replace_macros($tpl, array(
-                                       '$header' => htmlentities($header),
-                                       '$str_notifytype' => t('Notification type: '),
-                                       '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
-                                       '$dfrn_text' => $dfrn_text,
-                                       '$dfrn_id' => $rr['issued-id'],
-                                       '$uid' => $_SESSION['uid'],
-                                       '$intro_id' => $rr['intro_id'],
-                                       '$contact_id' => $rr['contact-id'],
-                                       '$photo' => ((x($rr,'photo')) ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
-                                       '$fullname' => $rr['name'],
-                                       '$location' => bbcode($rr['glocation'], false, false),
-                                       '$location_label' => t('Location:'),
-                                       '$about' => bbcode($rr['gabout'], false, false),
-                                       '$about_label' => t('About:'),
-                                       '$keywords' => $rr['gkeywords'],
-                                       '$keywords_label' => t('Tags:'),
-                                       '$gender' => $rr['ggender'],
-                                       '$gender_label' => t('Gender:'),
-                                       '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''),
-                                       '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')),
-                                       '$url' => $rr['url'],
-                                       '$zrl' => zrl($rr['url']),
-                                       '$url_label' => t('Profile URL'),
-                                       '$knowyou' => $knowyou,
-                                       '$approve' => t('Approve'),
-                                       '$note' => $rr['note'],
-                                       '$ignore' => t('Ignore'),
-                                       '$discard' => t('Discard'),
-                               ));
-                       }
-               }
-               else
-                       info( t('No introductions.') . EOL);
-               $o .= replace_macros($notif_tpl, array(
-                       '$notif_header' => t('Notifications'),
-                       '$tabs' => $tabs,
-                       '$notif_content' => $notif_content,
-               ));
-               $o .= paginate($a);
-               return $o;
-       } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
-               $notif_tpl = get_markup_template('notifications.tpl');
-               $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
-                               `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
-                               `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
-                               FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
-                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND
-                                `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
-                       intval(local_user())
-               );
-               $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
-               $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
-               $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
-               $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
-               $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
-               $notif_content = '';
-               if ($r) {
-                       foreach ($r as $it) {
-                               switch($it['verb']){
-                                       case ACTIVITY_LIKE:
-                                               $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
-                                                       '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_DISLIKE:
-                                               $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
-                                                       '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_FRIEND:
-                                               $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-                                               $obj = parse_xml_string($xmlhead.$it['object']);
-                                               $it['fname'] = $obj->title;
-                                               $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
-                                                       '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       default:
-                                               $item_text = (($it['id'] == $it['parent'])
-                                                       ? sprintf( t("%s created a new post"), $it['author-name'])
-                                                       : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
-                                               $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
-                                               $notif_content .= replace_macros($tpl,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
-                                                       '$item_text' => $item_text,
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                               }
-                       }
-               } else {
-                       $notif_content = t('No more network notifications.');
-               }
-               $o .= replace_macros($notif_tpl, array(
-                       '$notif_header' => t('Network Notifications'),
-                       '$tabs' => $tabs,
-                       '$notif_content' => $notif_content,
-               ));
  
-       } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
+                                       $header = $it["name"];
  
-               $notif_tpl = get_markup_template('notifications.tpl');
+                                       if ($it["addr"] != "")
+                                               $header .= " <".$it["addr"].">";
  
-               $not_tpl = get_markup_template('notify.tpl');
-               require_once('include/bbcode.php');
+                                       $header .= " (".network_to_name($it['network'], $it['url']).")";
  
-               $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
-                       intval(local_user())
-               );
+                                       $notif_content[] = replace_macros($tpl, array(
+                                               '$header' => htmlentities($header),
+                                               '$str_notifytype' => t('Notification type: '),
+                                               '$notify_type' => $it['notify_type'],
+                                               '$dfrn_text' => $dfrn_text,
+                                               '$dfrn_id' => $it['dfrn_id'],
+                                               '$uid' => $it['uid'],
+                                               '$intro_id' => $it['intro_id'],
+                                               '$contact_id' => $it['contact_id'],
+                                               '$photo' => $it['photo'],
+                                               '$fullname' => $it['name'],
+                                               '$location' => $it['location'],
+                                               '$lbl_location' => t('Location:'),
+                                               '$about' => $it['about'],
+                                               '$lbl_about' => t('About:'),
+                                               '$keywords' => $it['keywords'],
+                                               '$lbl_keywords' => t('Tags:'),
+                                               '$gender' => $it['gender'],
+                                               '$lbl_gender' => t('Gender:'),
+                                               '$hidden' => array('hidden', t('Hide this contact from others'), ($it['hidden'] == 1), ''),
+                                               '$activity' => array('activity', t('Post a new friend activity'), $it['post_newfriend'], t('if applicable')),
+                                               '$url' => $it['url'],
+                                               '$zrl' => $it['zrl'],
+                                               '$lbl_url' => t('Profile URL'),
+                                               '$addr' => $it['addr'],
+                                               '$lbl_knowyou' => $lbl_knowyou,
+                                               '$lbl_network' => t('Network:'),
+                                               '$network' => network_to_name($it['network'], $it['url']),
+                                               '$knowyou' => $knowyou,
+                                               '$approve' => t('Approve'),
+                                               '$note' => $it['note'],
+                                               '$ignore' => t('Ignore'),
+                                               '$discard' => t('Discard'),
  
-               if (dba::is_result($r)) {
-                       foreach ($r as $it) {
-                               $notif_content .= replace_macros($not_tpl,array(
-                                       '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
-                                       '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO),
-                                       '$item_text' => strip_tags(bbcode($it['msg'])),
-                                       '$item_when' => relative_date($it['date'])
-                               ));
+                                       ));
+                                       break;
                        }
-               } else {
-                       $notif_content .= t('No more system notifications.');
                }
  
-               $o .= replace_macros($notif_tpl, array(
-                       '$notif_header' => t('System Notifications'),
-                       '$tabs' => $tabs,
-                       '$notif_content' => $notif_content,
-               ));
-       } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
-               $notif_tpl = get_markup_template('notifications.tpl');
-               $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname'];
-               $myurl = substr($myurl,strpos($myurl,'://')+3);
-               $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
-               $diasp_url = str_replace('/profile/','/u/',$myurl);
-               $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ",
-                       dbesc($myurl . '$'),
-                       dbesc($myurl . '\\]'),
-                       dbesc($diasp_url . '\\]')
-               );
-               $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
-                               `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
-                               `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
-                               FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
-                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1
-                               $sql_extra
-                               AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
-                       intval(local_user())
-               );
-               $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
-               $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
-               $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
-               $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
-               $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
-               $notif_content = '';
-               if (dba::is_result($r)) {
-                       foreach ($r as $it) {
-                               switch($it['verb']){
-                                       case ACTIVITY_LIKE:
-                                               $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_DISLIKE:
-                                               $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_FRIEND:
-                                               $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-                                               $obj = parse_xml_string($xmlhead.$it['object']);
-                                               $it['fname'] = $obj->title;
-                                               $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       default:
-                                               $item_text = (($it['id'] == $it['parent'])
-                                                       ? sprintf( t("%s created a new post"), $it['author-name'])
-                                                       : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
-                                               $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
-                                               $notif_content .= replace_macros($tpl,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => $item_text,
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                               }
-                       }
-               } else {
+               if($notifs['total'] == 0)
+                       info( t('No introductions.') . EOL);
  
-                       $notif_content = t('No more personal notifications.');
+       // Normal notifications (no introductions)
+       } else {
+               // The template files we need in different cases for formatting the content
+               $tpl_item_like = 'notifications_likes_item.tpl';
+               $tpl_item_dislike = 'notifications_dislikes_item.tpl';
+               $tpl_item_attend = 'notifications_attend_item.tpl';
+               $tpl_item_attendno = 'notifications_attend_item.tpl';
+               $tpl_item_attendmaybe = 'notifications_attend_item.tpl';
+               $tpl_item_friend = 'notifications_friends_item.tpl';
+               $tpl_item_comment = 'notifications_comments_item.tpl';
+               $tpl_item_post = 'notifications_posts_item.tpl';
+               $tpl_item_notify = 'notify.tpl';
+               // Loop trough ever notification This creates an array with the output html for each
+               // notification and apply the correct template according to the notificationtype (label).
+               foreach ($notifs['notifications'] as $it) {
+                       // We use the notification label to get the correct template file
+                       $tpl_var_name = 'tpl_item_'.$it['label'];
+                       $tpl_notif = get_markup_template($$tpl_var_name);
+                       $notif_content[] = replace_macros($tpl_notif,array(
+                               '$item_label' => $it['label'],
+                               '$item_link' => $it['link'],
+                               '$item_image' => $it['image'],
+                               '$item_text' => htmlentities($it['text']),
+                               '$item_when' => $it['when'],
+                               '$item_seen' => $it['seen'],
+                       ));
                }
  
-               $o .= replace_macros($notif_tpl, array(
-                       '$notif_header' => t('Personal Notifications'),
-                       '$tabs' => $tabs,
-                       '$notif_content' => $notif_content,
-               ));
-       } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
-               $notif_tpl = get_markup_template('notifications.tpl');
-               $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
-                               `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
-                               `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
-                               FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
-                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
-                                `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC",
-                       intval(local_user())
-               );
-               $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
-               $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
-               $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
-               $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
-               $notif_content = '';
-               if (dba::is_result($r)) {
-                       foreach ($r as $it) {
-                               switch($it['verb']){
-                                       case ACTIVITY_LIKE:
-                                               $notif_content .= replace_macros($tpl_item_likes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_DISLIKE:
-                                               $notif_content .= replace_macros($tpl_item_dislikes,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       case ACTIVITY_FRIEND:
-                                               $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-                                               $obj = parse_xml_string($xmlhead.$it['object']);
-                                               $it['fname'] = $obj->title;
-                                               $notif_content .= replace_macros($tpl_item_friends,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                                               break;
-                                       default:
-                                               $notif_content .= replace_macros($tpl_item_comments,array(
-                                                       //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
-                                                       '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
-                                                       '$item_image' => $it['author-avatar'],
-                                                       '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
-                                                       '$item_when' => relative_date($it['created'])
-                                               ));
-                               }
-                       }
-               } else {
-                       $notif_content = t('No more home notifications.');
+               // It doesn't make sense to show the Show unread / Show all link visible if the user is on the
+               // "Show all" page and there are no notifications. So we will hide it.
+               if($show == 0 || intval($show) && $notifs['total'] > 0) {
+                       $notif_show_lnk = array(
+                               'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
+                               'text' => ($show ? t('Show unread') : t('Show all')),
+                       );
                }
  
-               $o .= replace_macros($notif_tpl, array(
-                       '$notif_header' => t('Home Notifications'),
-                       '$tabs' => $tabs,
-                       '$notif_content' => $notif_content,
-               ));
+               // Output if there aren't any notifications available
+               if($notifs['total'] == 0)
+                       $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
        }
  
-       $o .= paginate($a);
 -
+       $o .= replace_macros($notif_tpl, array(
+               '$notif_header' => $notif_header,
+               '$tabs' => $tabs,
+               '$notif_content' => $notif_content,
+               '$notif_nocontent' => $notif_nocontent,
+               '$notif_show_lnk' => $notif_show_lnk,
+               '$notif_paginate' => paginate($a)
+       ));
        return $o;
  }
diff --cc mod/p.php
index 20d6cfdbafeb181ca263aec232a33d53722dab8a,8da044e9323916e742b2b1bb24404fefe854acdf..4db8f552962c9f8504c4a6ed1ea3c29971c6de42
+++ b/mod/p.php
@@@ -26,55 -44,20 +44,20 @@@ function p_init($a)
                killme();
        }
  
-       $post = array();
-       $reshared = diaspora::is_reshare($item[0]["body"]);
-       if ($reshared) {
-               $nodename = "reshare";
-               $post["root_diaspora_id"] = $reshared["root_handle"];
-               $post["root_guid"] = $reshared["root_guid"];
-               $post["guid"] = $item[0]["guid"];
-               $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
-               $post["public"] = (!$item[0]["private"] ? 'true':'false');
-               $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
-       } else {
-               $body = bb2diaspora($item[0]["body"]);
-               if(strlen($item[0]["title"]))
-                       $body = "## ".html_entity_decode($item[0]["title"])."\n\n".$body;
-               $nodename = "status_message";
-               $post["raw_message"] = str_replace("&", "&amp;", $body);
-               $post["guid"] = $item[0]["guid"];
-               $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
-               $post["public"] = (!$item[0]["private"] ? 'true':'false');
-               $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
-               $post["provider_display_name"] = $item[0]["app"];
+       // Fetch some data from the author (We could combine both queries - but I think this is more readable)
+       $r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user`
+               INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid`
+               WHERE `user`.`uid` = %d", intval($item[0]["uid"]));
 -      if (!$r) {
++      if (!dbm::is_result($r)) {
+               header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
+               killme();
        }
+       $user = $r[0];
  
-       $dom = new DOMDocument("1.0");
-       $root = $dom->createElement("XML");
-       $dom->appendChild($root);
-       $postelement = $dom->createElement("post");
-       $root->appendChild($postelement);
-       $statuselement = $dom->createElement($nodename);
-       $postelement->appendChild($statuselement);
-       foreach($post AS $index => $value) {
-               $postnode = $dom->createElement($index, $value);
-               $statuselement->appendChild($postnode);
-       }
+       $status = diaspora::build_status($item[0], $user);
+       $xml = diaspora::build_post_xml($status["type"], $status["message"]);
  
        header("Content-Type: application/xml; charset=utf-8");
-       $xml = $dom->saveXML();
-       // Diaspora doesn't send the XML header, so we remove them as well.
-       // So we avoid possible compatibility problems.
-       if (substr($xml, 0, 21) == '<?xml version="1.0"?>')
-               $xml = trim(substr($xml, 21));
        echo $xml;
  
        killme();
diff --cc mod/photo.php
index 33a0242352f27ab9604c544835059007a56259eb,4166b4d53949d4f9cb5b1f9467c045b224ef98e0..9141a98676aac92fd3d0edf7eb48584188fdc6fc
@@@ -76,7 -76,7 +76,7 @@@ function photo_init(&$a) 
                        intval($resolution),
                        intval($uid)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $data = $r[0]['data'];
                        $mimetype = $r[0]['type'];
                }
                        dbesc($photo),
                        intval($resolution)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $sql_extra = permissions_sql($r[0]['uid']);
  
                                intval($resolution)
                        );
  
-                       $public = (dba::is_result($r)) && ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid']  == '') AND ($r[0]['deny_gid']  == '');
 -                      $public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid']  == '') AND ($r[0]['deny_gid']  == '');
++                      $public = (dbm::is_result($r)) && ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid']  == '') AND ($r[0]['deny_gid']  == '');
  
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $resolution = $r[0]['scale'];
                                $data = $r[0]['data'];
                                $mimetype = $r[0]['type'];
diff --cc mod/photos.php
index b05bc12b1a029f34c193b18e70c61c122aa7e345,a191dcf0712562cd5222233024f8b20d9d2be7dc..328be50b27a00043f8c05c5b65e1c125f31654f6
@@@ -159,7 -160,7 +160,7 @@@ function photos_post(&$a) 
                                        intval($cid),
                                        intval($page_owner_uid)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $can_post = true;
                                        $visitor = $cid;
                                }
                                        dbesc($album)
                                );
                        }
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                foreach($r as $rr) {
                                        $res[] = "'" . dbesc($rr['rid']) . "'" ;
                                }
                        $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
                                intval($page_owner_uid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                foreach($r as $rr) {
                                        q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
                                                dbesc(datetime_convert()),
                                dbesc($a->argv[2])
                        );
                }
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
                                intval($page_owner_uid),
                                dbesc($r[0]['resource-id'])
                                dbesc($resource_id),
                                intval($page_owner_uid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $ph = new Photo($r[0]['data'], $r[0]['type']);
                                if($ph->is_valid()) {
                                        $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
                                intval($page_owner_uid)
                        );
                }
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $old_tag    = $r[0]['tag'];
                        $old_inform = $r[0]['inform'];
                }
                                                                        intval($page_owner_uid)
                                                                );
                                                        }*/
-                                                       if(dba::is_result($r)) {
 -                                                      if(count($r)) {
++                                                      if(dbm::is_result($r)) {
                                                                $newname = $r[0]['name'];
                                                                $profile = $r[0]['url'];
                                                                $notify = 'cid:' . $r[0]['id'];
@@@ -1028,7 -1029,7 +1029,7 @@@ function photos_content(&$a) 
                                        intval($contact_id),
                                        intval($owner_uid)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $can_post = true;
                                        $contact = $r[0];
                                        $remote_contact = true;
                                intval($contact_id),
                                intval($owner_uid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $contact = $r[0];
                                $remote_contact = true;
                        }
                        intval($owner_uid),
                        dbesc($album)
                );
-               if(dba::is_result($r)) {
-                       $a->set_pager_total(dba::is_result($r));
 -              if(count($r)) {
 -                      $a->set_pager_total(count($r));
++              if(dbm::is_result($r)) {
++                      $a->set_pager_total(dbm::is_result($r));
                        $a->set_pager_itemspage(20);
                }
  
  
                $photos = array();
  
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $twist = 'rotright';
                        foreach($r as $rr) {
                                if($twist == 'rotright')
  
                        );
  
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                $a->set_pager_total($r[0]['total']);
  
  
  
  
                        // display comments
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
  
                                foreach($r as $item) {
                                        builtin_activity_puller($item, $conv_responses);
                dbesc('Contact Photos'),
                dbesc( t('Contact Photos'))
        );
-       if(dba::is_result($r)) {
-               $a->set_pager_total(dba::is_result($r));
 -      if(count($r)) {
 -              $a->set_pager_total(count($r));
++      if(dbm::is_result($r)) {
++              $a->set_pager_total(dbm::is_result($r));
                $a->set_pager_itemspage(20);
        }
  
  
  
        $photos = array();
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $twist = 'rotright';
                foreach($r as $rr) {
                        //hide profile photos to others
diff --cc mod/poco.php
index 372f5b45b60ef40ddcd73c81b07249282ac5aa23,0a1b392169b22dbf3e5748bb4ebbbebc8aa65a25..d492d7e9336cb627a57a193182b575b500bca47c
@@@ -81,7 -81,7 +81,7 @@@ function poco_init(&$a) 
                        dbesc(NETWORK_STATUSNET)
                );
        }
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $totalResults = intval($r[0]['total']);
        else
                $totalResults = 0;
        }
  
        if(is_array($r)) {
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if (!isset($rr['generation'])) {
                                        if ($global)
diff --cc mod/poke.php
index f59ec186972f5cc666b04d4ef6f5edc9913f56d8,435da4dcd4facd27229767709633724529c690be..daa3c0a89c1c3876a4542c0fe289f0e77ba661eb
@@@ -66,7 -66,7 +66,7 @@@ function poke_init(&$a) 
                        intval($parent),
                        intval($uid)
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $parent_uri = $r[0]['uri'];
                        $private    = $r[0]['private'];
                        $allow_cid  = $r[0]['allow_cid'];
@@@ -159,7 -159,7 +159,7 @@@ function poke_content(&$a) 
                        intval($_GET['c']),
                        intval(local_user())
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $name = $r[0]['name'];
                        $id = $r[0]['id'];
                }
diff --cc mod/profile.php
index 66d7ce3999438c761532e847c859cc7183ae7b39,681b1dbd1cdd45974b9ee00b16ccf83dbcb9c544..04f6fa247f20828d90485b9666e5a23fc9d9614c
@@@ -13,7 -13,7 +13,7 @@@ function profile_init(&$a) 
                $which = $a->argv[1];
        else {
                $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
                }
                else {
@@@ -136,7 -136,7 +136,7 @@@ function profile_content(&$a, $update 
                        intval($contact_id),
                        intval($a->profile['profile_uid'])
                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $contact = $r[0];
                        $remote_contact = true;
                }
                            AND `thread`.`wall` = 1
                            $sql_extra $sql_extra2 ",
                            intval($a->profile['profile_uid'])
 -                  );
 +                      );
  
-                       if(dba::is_result($r)) {
 -              if(count($r)) {
 -                      $a->set_pager_total($r[0]['total']);
++                      if(dbm::is_result($r)) {
 +                              $a->set_pager_total($r[0]['total']);
                        }
                }
  
index 75b364d2b9dc310f68a00d3e2286d176a569a417,11e671afc58a2f58e5ef51655d55a473e78aa708..635fe7c55a34c73f759d54b996d08bc87f8abc9f
@@@ -32,7 -32,7 +32,7 @@@ function profile_photo_post(&$a) 
                                intval($_REQUEST['profile']),
                                intval(local_user())
                        );
-                       if(dba::is_result($r) && (! intval($r[0]['is-default'])))
 -                      if(count($r) && (! intval($r[0]['is-default'])))
++                      if(dbm::is_result($r) && (! intval($r[0]['is-default'])))
                                $is_default_profile = 0;
                }
  
@@@ -63,7 -63,7 +63,7 @@@
                        dbesc(local_user()),
                        intval($scale));
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $base_image = $r[0];
  
index dfab29894ed9f9833801fb7c0c4f6a6127ba9d96,d770e75c3af21f52549517f359f8aee257d08817..44cdaa70ff27ba55f9492045e5cd5af93d9ec9ec
@@@ -285,7 -286,7 +286,7 @@@ function profiles_post(&$a) 
                                                        intval(local_user())
                                                );
                                        }
-                                       if(dba::is_result($r)) {
 -                                      if(count($r)) {
++                                      if(dbm::is_result($r)) {
                                                $prf = $r[0]['url'];
                                                $newname = $r[0]['name'];
                                        }
@@@ -778,7 -759,7 +759,7 @@@ function profiles_content(&$a) 
                                "SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
                                local_user()
                        );
-                       if(dba::is_result($r)){
 -                      if(count($r)){
++                      if(dbm::is_result($r)){
                                //Go to the default profile.
                                goaway('profiles/'.$r[0]['id']);
                        }
  
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                        local_user());
-               if(dba::is_result($r)) {
-                       $tpl_header = get_markup_template('profile_listing_header.tpl');
-                       $o .= replace_macros($tpl_header,array(
-                               '$header' => t('Edit/Manage Profiles'),
-                               '$chg_photo' => t('Change profile photo'),
-                               '$cr_new' => t('Create New Profile'),
-                               '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")
-                       ));
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $tpl = get_markup_template('profile_entry.tpl');
                        foreach($r as $rr) {
-                               $o .= replace_macros($tpl, array(
+                               $profiles .= replace_macros($tpl, array(
                                        '$photo' => $a->remove_baseurl($rr['thumb']),
                                        '$id' => $rr['id'],
                                        '$alt' => t('Profile Image'),
index 91b84e2b9414a64c444b895ac335bc2b87ff8200,077f695bea14c15be10f592258847bcd6e3d1198..c3c189cd8a94da87347adc3fbdedac773c9ddfc5
@@@ -42,7 -42,7 +42,7 @@@ function profperm_content(&$a) 
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
  
@@@ -64,7 -64,7 +64,7 @@@
                );
  
                $ingroup = array();
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        foreach($r as $member)
                                $ingroup[] = $member['id'];
  
@@@ -94,7 -94,7 +94,7 @@@
                        $members = $r;
  
                        $ingroup = array();
-                       if(dba::is_result($r))
 -                      if(count($r))
++                      if(dbm::is_result($r))
                                foreach($r as $member)
                                        $ingroup[] = $member['id'];
                }
                        dbesc(NETWORK_DFRN)
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
                        foreach($r as $member) {
                                if(! in_array($member['id'],$ingroup)) {
diff --cc mod/proxy.php
index 02def84ca167e94788b70fe0c1c099beeacc1f51,abcaf4912798830546409ef6d16876bea9f3db96..75f485bc713d4ef912ff978660bb5ba44c054424
@@@ -136,7 -136,7 +136,7 @@@ function proxy_init() 
  
        if (!$direct_cache AND ($cachefile == "")) {
                $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
-               if (dba::is_result($r)) {
 -              if (count($r)) {
++              if (dbm::is_result($r)) {
                        $img_str = $r[0]['data'];
                        $mime = $r[0]["desc"];
                        if ($mime == "") $mime = "image/jpeg";
        } else
                $r = array();
  
--      if (!count($r)) {
++      if (!dbm::is_result($r)) {
                // It shouldn't happen but it does - spaces in URL
                $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
                $redirects = 0;
index a50efc9229c5bac7c78493322e829ca1f7da4194,5d7621cc745fdf648cd1dc79d83342d09ccbe694..5a66ccbc7cea1bc01a69ab751cb47765667269b0
@@@ -132,7 -132,7 +132,7 @@@ function pubsubhubbub_init(&$a) 
  
                        // if we are just updating an old subscription, keep the
                        // old values for push and last_update
-                       if (dba::is_result($r)) {
 -                      if (count($r)) {
++                      if (dbm::is_result($r)) {
                                $last_update = $r[0]['last_update'];
                                $push_flag = $r[0]['push'];
                        }
diff --cc mod/qsearch.php
index 0eabf6b7c6965caa89e473b71251950732a846a2,c35e253b670508c23771013c04187ca482f36a44..49868f4851a296cd651536f8beccf02bf8f2011d
@@@ -23,7 -23,7 +23,7 @@@ function qsearch_init(&$a) 
                intval($limit)
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
  
                foreach($r as $rr)
                        $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
@@@ -38,7 -38,7 +38,7 @@@
        );
  
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
  
                foreach($r as $rr)
                        $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
diff --cc mod/regmod.php
index 47258e0914493a8e1cde401f62fa66eed2a19d95,bbe733003a56dfe11ea9affceabd03f7be00fcb0..f37953ac50fc430e2b0703832f4a3827771276b2
@@@ -34,10 -34,10 +34,10 @@@ function user_allow($hash) 
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
                intval($user[0]['uid'])
        );
-       if(dba::is_result($r) && $r[0]['net-publish']) {
 -      if(count($r) && $r[0]['net-publish']) {
++      if(dbm::is_result($r) && $r[0]['net-publish']) {
                $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
                if($url && strlen(get_config('system','directory')))
-                       proc_run('php',"include/directory.php","$url");
+                       proc_run(PRIORITY_LOW, "include/directory.php", $url);
        }
  
        push_lang($register[0]['language']);
diff --cc mod/salmon.php
index ec0693b9412e7ac4be79c7d56a546346b7803bd4,37230a557351ad70e9b4faada55a17a89f6ef69e..e655da411bec4d39511703acecaf45daf6208cdb
@@@ -169,8 -169,8 +169,8 @@@ function salmon_post(&$a) 
        // Have we ignored the person?
        // If so we can not accept this post.
  
-       //if((dba::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
-       if(dba::is_result($r) && $r[0]['blocked']) {
 -      //if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
 -      if(count($r) && $r[0]['blocked']) {
++      //if((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
++      if(dbm::is_result($r) && $r[0]['blocked']) {
                logger('mod-salmon: Ignoring this author.');
                http_status_exit(202);
                // NOTREACHED
        // Placeholder for hub discovery.
        $hub = '';
  
-       $contact_rec = ((dba::is_result($r)) ? $r[0] : null);
 -      $contact_rec = ((count($r)) ? $r[0] : null);
++      $contact_rec = ((dbm::is_result($r)) ? $r[0] : null);
  
        ostatus::import($data,$importer,$contact_rec, $hub);
  
diff --cc mod/search.php
index 9ad1fe5077fe9b1d75491f68663351a042a9850d,a8372599916c4e574b0faca3e11fc1080184a651..587b89209d6875e4852a3d3df270ed864cffa58e
@@@ -15,7 -15,7 +15,7 @@@ function search_saved_searches() 
                intval(local_user())
        );
  
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $saved = array();
                foreach($r as $rr) {
                        $saved[] = array(
@@@ -210,20 -209,18 +209,17 @@@ function search_content(&$a) 
                        $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
                }
  
-               $r = q("SELECT STRAIGHT_JOIN `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
-                               `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
-                               `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
-                               `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-                       FROM `item`
-                               INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
-                       WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
-                               AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
 -
+               $r = q("SELECT %s
+                       FROM `item` %s
+                       WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
                                $sql_extra
-                       GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d ",
-                               intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
+                       GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d",
+                               item_fieldlists(), item_joins(), item_condition(),
+                               intval(local_user()),
+                               intval($a->pager['start']), intval($a->pager['itemspage']));
        }
  
--      if(! count($r)) {
++      if(! dbm::is_result($r)) {
                info( t('No results.') . EOL);
                return $o;
        }
index 841742363911e1ec27f473c1679ed445ac1a5046,e2d3f4d367bf94ebdea47c62c85d3df3fb5d8f22..932dfe26d995f6b55006a5965872c4631f24f70f
@@@ -254,7 -255,7 +255,7 @@@ function settings_post(&$a) 
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $eacct = $r[0];
                                        require_once('include/email.php');
                                        $mb = construct_mailbox_name($eacct);
@@@ -842,15 -844,15 +844,15 @@@ function settings_content(&$a) 
                        $r = null;
                }
  
-               $mail_server       = ((dba::is_result($r)) ? $r[0]['server'] : '');
-               $mail_port         = ((dba::is_result($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
-               $mail_ssl          = ((dba::is_result($r)) ? $r[0]['ssltype'] : '');
-               $mail_user         = ((dba::is_result($r)) ? $r[0]['user'] : '');
-               $mail_replyto      = ((dba::is_result($r)) ? $r[0]['reply_to'] : '');
-               $mail_pubmail      = ((dba::is_result($r)) ? $r[0]['pubmail'] : 0);
-               $mail_action       = ((dba::is_result($r)) ? $r[0]['action'] : 0);
-               $mail_movetofolder = ((dba::is_result($r)) ? $r[0]['movetofolder'] : '');
-               $mail_chk          = ((dba::is_result($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
 -              $mail_server       = ((count($r)) ? $r[0]['server'] : '');
 -              $mail_port         = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
 -              $mail_ssl          = ((count($r)) ? $r[0]['ssltype'] : '');
 -              $mail_user         = ((count($r)) ? $r[0]['user'] : '');
 -              $mail_replyto      = ((count($r)) ? $r[0]['reply_to'] : '');
 -              $mail_pubmail      = ((count($r)) ? $r[0]['pubmail'] : 0);
 -              $mail_action       = ((count($r)) ? $r[0]['action'] : 0);
 -              $mail_movetofolder = ((count($r)) ? $r[0]['movetofolder'] : '');
 -              $mail_chk          = ((count($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
++              $mail_server       = ((dbm::is_result($r)) ? $r[0]['server'] : '');
++              $mail_port         = ((dbm::is_result($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
++              $mail_ssl          = ((dbm::is_result($r)) ? $r[0]['ssltype'] : '');
++              $mail_user         = ((dbm::is_result($r)) ? $r[0]['user'] : '');
++              $mail_replyto      = ((dbm::is_result($r)) ? $r[0]['reply_to'] : '');
++              $mail_pubmail      = ((dbm::is_result($r)) ? $r[0]['pubmail'] : 0);
++              $mail_action       = ((dbm::is_result($r)) ? $r[0]['action'] : 0);
++              $mail_movetofolder = ((dbm::is_result($r)) ? $r[0]['movetofolder'] : '');
++              $mail_chk          = ((dbm::is_result($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
  
  
                $tpl = get_markup_template("settings_connectors.tpl");
index 4b417b75b92402762cb989b84be14f26f4d9ecf2,33cf7489c167764b716f3cee77ca7dae78011667..f86cf02d9d83b62a6980bf2a752452ce35401012
@@@ -53,7 -53,7 +53,7 @@@ function subthread_content(&$a) 
                WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
                intval($owner_uid)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $owner = $r[0];
  
        if(! $owner) {
@@@ -75,7 -75,7 +75,7 @@@
                        intval($_SESSION['visitor_id']),
                        intval($owner_uid)
                );
-               if(dba::is_result($r))
 -              if(count($r))
++              if(dbm::is_result($r))
                        $contact = $r[0];
        }
        if(! $contact) {
diff --cc mod/tagger.php
index 78bf11cc4c6e94fc27a8def13bfc48f808f2a309,e0ef1ceb02091496c4cf6d963daf02d903d4d88d..50415e709fe30d47f7be4822a6f327fb31807c8d
@@@ -39,7 -39,7 +39,7 @@@ function tagger_content(&$a) 
        $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
                intval($owner_uid)
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $owner_nick = $r[0]['nickname'];
                $blocktags = $r[0]['blocktags'];
        }
@@@ -50,7 -50,7 +50,7 @@@
        $r = q("select * from contact where self = 1 and uid = %d limit 1",
                intval(local_user())
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                        $contact = $r[0];
        else {
                logger('tagger: no contact_id');
@@@ -178,7 -178,7 +178,7 @@@ EOT
        $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1",
                dbesc($item['uri'])
        );
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
                        intval($r[0]['uid'])
                );
diff --cc mod/uexport.php
index dde5fe090d9919b501691ace6662aad869c71731,3114add7e4a56ae325ce024b379fd232a053f9fe..0aa9f68b26be48a202a5b35b0141b742ea703625
@@@ -44,7 -44,7 +44,7 @@@ function uexport_content(&$a)
  function _uexport_multirow($query) {
        $result = array();
        $r = q($query);
- //    if(dba::is_result($r)) {
 -//    if(count($r)) {
++//    if(dbm::is_result($r)) {
        if ($r){
                foreach($r as $rr){
              $p = array();
@@@ -130,7 -130,7 +130,7 @@@ function uexport_all(&$a) 
        $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ",
                intval(local_user())
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $total = $r[0]['total'];
  
        // chunk the output to avoid exhausting memory
                        intval($x),
                        intval(500)
                );
-               /*if(dba::is_result($r)) {
 -              /*if(count($r)) {
++              /*if(dbm::is_result($r)) {
                        foreach($r as $rr)
                                foreach($rr as $k => $v)
                                        $item[][$k] = $v;
diff --cc mod/videos.php
index 2cd013b008c1731ff993f459792185c6156517e1,e5a0887bb9f3a2e6e22c1ade3fe262977d94886f..75518472a3496a07be875d515107305227b4689a
@@@ -143,7 -143,7 +143,7 @@@ function videos_post(&$a) 
                        dbesc($video_id)
                );
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                        q("DELETE FROM `attach` WHERE `uid` = %d AND `id` = '%s'",
                                intval(local_user()),
                                dbesc($video_id)
@@@ -262,7 -262,7 +262,7 @@@ function videos_content(&$a) 
                                        intval($contact_id),
                                        intval($owner_uid)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $can_post = true;
                                        $contact = $r[0];
                                        $remote_contact = true;
                                intval($contact_id),
                                intval($owner_uid)
                        );
-                       if(dba::is_result($r)) {
 -                      if(count($r)) {
++                      if(dbm::is_result($r)) {
                                $contact = $r[0];
                                $remote_contact = true;
                        }
                $sql_extra GROUP BY hash",
                intval($a->data['user']['uid'])
        );
-       if(dba::is_result($r)) {
-               $a->set_pager_total(dba::is_result($r));
 -      if(count($r)) {
 -              $a->set_pager_total(count($r));
++      if(dbm::is_result($r)) {
++              $a->set_pager_total(dbm::is_result($r));
                $a->set_pager_itemspage(20);
        }
  
  
  
        $videos = array();
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if($a->theme['template_engine'] === 'internal') {
                                $alt_e = template_escape($rr['filename']);
index 43e31513085fdd7e058d9b12887ff36e8f6ac797,2eae8fec8e41813cdf3e21d19e80c584d6a71d40..3449643afdb3ef973000bcc35e57f9787b5fd49c
@@@ -54,7 -54,7 +54,7 @@@ function viewcontacts_content(&$a) 
                dbesc(NETWORK_DIASPORA),
                dbesc(NETWORK_OSTATUS)
        );
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                $a->set_pager_total($r[0]['total']);
  
        $r = q("SELECT * FROM `contact`
diff --cc mod/viewsrc.php
index 0c10cbf7c80dea057b6d35ba3f10e64126214ea1,3fa4eaed53bad2b53686a59aef0af30acf1f5645..1751b856f22e1928590116a4df3f75c17cb47daf
@@@ -24,7 -24,7 +24,7 @@@ function viewsrc_content(&$a) 
                dbesc($item_id)
        );
  
-       if(dba::is_result($r))
 -      if(count($r))
++      if(dbm::is_result($r))
                if(is_ajax()) {
                        echo str_replace("\n",'<br />',$r[0]['body']);
                        killme();
index 9a041d944873ff77ddf7278af7c3d9e3ebba8922,68752a0e1f659082e51ec6df90add56663d5ba1d..11ef81aca3125071b6f4b2b14745aa2afe090d6a
@@@ -55,7 -55,7 +55,7 @@@ function wall_attach_post(&$a) 
                                        intval($cid),
                                        intval($page_owner_uid)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $can_post = true;
                                        $visitor = $cid;
                                }
index ac7dd77649c563b962d55447acd7372cc4eda0ee,b815348c7010baddd103553dc653f83da416ce86..d2915d4de3075efcde64e77b6397832df0034819
@@@ -63,7 -63,7 +63,7 @@@ function wall_upload_post(&$a, $desktop
                                        intval($cid),
                                        intval($page_owner_uid)
                                );
-                               if(dba::is_result($r)) {
 -                              if(count($r)) {
++                              if(dbm::is_result($r)) {
                                        $can_post = true;
                                        $visitor = $cid;
                                }
diff --cc object/Item.php
index e1a46532a1468dcd5c2bf7a4efb14a16b0054499,9f01ac59b08af0b0c4bd86fbfff7d6da7b9f62f2..45d2dba3edb78c81c68823eecb1d08e312b4b8c0
@@@ -225,7 -235,7 +235,7 @@@ class Item extends BaseObject 
                                        intval($item['uid']),
                                        intval($item['id'])
                                );
-                               if (dba::is_result($r)) {
 -                              if (count($r)) {
++                              if (dbm::is_result($r)) {
                                        $ignore = array(
                                                'do' => t("ignore thread"),
                                                'undo' => t("unignore thread"),
diff --cc update.php
index 5ab3e69f3b794bd6727e9e697e110a58d070630e,f1981f730f28117d85bfbaeac66cb47610fd0059..0592c928c7d06336bc0649af58e1b8673be322a7
@@@ -85,7 -85,7 +85,7 @@@ function update_1006() 
        // create 's' keys for everybody that does not have one
  
        $r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $sres=openssl_pkey_new(array('encrypt_key' => false ));
                        $sprvkey = '';
@@@ -122,7 -122,7 +122,7 @@@ function update_1010() 
  function update_1011() {
        q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
        $r = q("SELECT * FROM `contact` WHERE 1");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                                q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
                                        dbesc(basename($rr['url'])),
@@@ -145,7 -145,7 +145,7 @@@ function update_1014() 
        require_once('include/Photo.php');
        q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
        $r = q("SELECT * FROM `photo` WHERE `scale` = 4");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $ph = new Photo($rr['data']);
                        if($ph->is_valid()) {
                }
        }
        $r = q("SELECT * FROM `contact` WHERE 1");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        if(stristr($rr['thumb'],'avatar'))
                                q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
@@@ -356,7 -356,7 +356,7 @@@ function update_1035() 
  function update_1036() {
  
        $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
                                dbesc(str_replace('include/photo','photo',$rr['photo'])),
@@@ -594,7 -594,7 +594,7 @@@ function update_1073() 
  function update_1074() {
        q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` ");
        $r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr)
                        q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
                                intval($rr['uid'])
  function update_1075() {
        q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
        $r = q("SELECT `uid` FROM `user` WHERE 1");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = true;
                        do {
@@@ -688,7 -688,7 +688,7 @@@ function update_1082() 
        if($r && count($r))
                return;
        $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $guid = get_guid();
                        q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
@@@ -731,7 -731,7 +731,7 @@@ function update_1087() 
        q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
  
        $r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
                                intval($rr['id'])
@@@ -854,7 -854,7 +854,7 @@@ function update_1100() 
        require_once('include/text.php');
  
        $r = q("select id, url from contact where url != '' and nurl = '' ");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        q("update contact set nurl = '%s' where id = %d",
                                dbesc(normalise_link($rr['url'])),
@@@ -1168,7 -1168,7 +1168,7 @@@ function update_1136() 
        // order in reverse so that we save the newest entry
  
        $r = q("select * from config where 1 order by id desc");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
  
        $arr = array();
        $r = q("select * from pconfig where 1 order by id desc");
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
@@@ -1692,7 -1692,7 +1692,7 @@@ function update_1190() 
        );
  
        // convert old forumlist addon entries in new config entries
-       if (dba::is_result($r)) {
 -      if (count($r)) {
++      if (dbm::is_result($r)) {
                foreach ($r as $rr) {
                        $uid = $rr['uid'];
                        $family = $rr['cat'];
index 733f8917a68dde4169dda260db12e314014ca958,70add44c2f72580bc5c5c618d8a58ef2d99f5035..8a5ff65cb6ab63bf8ac1fdd0fa5ffdad9acc6ce2
  <!--[if IE]>
  <script type="text/javascript" src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
 -<script type="text/javascript" src="js/modernizr.js" ></script>
 -<script type="text/javascript" src="js/jquery.js" ></script>
 -<!-- <script type="text/javascript" src="js/jquery-migrate.js" ></script>-->
 -<script type="text/javascript" src="js/jquery-migrate.js" ></script>
 -<script type="text/javascript" src="js/jquery.textinputs.js" ></script>
 -<script type="text/javascript" src="library/jquery-textcomplete/jquery.textcomplete.min.js" ></script>
 -<script type="text/javascript" src="js/autocomplete.js" ></script>
 -<script type="text/javascript" src="library/colorbox/jquery.colorbox-min.js"></script>
 -<script type="text/javascript" src="library/jgrowl/jquery.jgrowl_minimized.js"></script>
 -<script type="text/javascript" src="library/datetimepicker/jquery.datetimepicker.js"></script>
 -<script type="text/javascript" src="library/tinymce/jscripts/tiny_mce/tiny_mce_src.js" ></script>
 -<script type="text/javascript" src="library/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script>
 -<script type="text/javascript" src="js/acl.js" ></script>
 -<script type="text/javascript" src="js/webtoolkit.base64.js" ></script>
 -<script type="text/javascript" src="js/main.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/modernizr.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/jquery.js" ></script>
 +<!-- <script type="text/javascript" src="{{$baseurl}}/js/jquery-migrate.js" ></script>-->
 +<script type="text/javascript" src="{{$baseurl}}/js/jquery-migrate.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/jquery.textinputs.js" ></script>
- <script type="text/javascript" src="{{$baseurl}}/library/jquery-textcomplete/jquery.textcomplete.js" ></script>
++<script type="text/javascript" src="{{$baseurl}}/library/jquery-textcomplete/jquery.textcomplete.min.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/autocomplete.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/library/colorbox/jquery.colorbox-min.js"></script>
 +<script type="text/javascript" src="{{$baseurl}}/library/jgrowl/jquery.jgrowl_minimized.js"></script>
 +<script type="text/javascript" src="{{$baseurl}}/library/datetimepicker/jquery.datetimepicker.js"></script>
 +<script type="text/javascript" src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/library/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/acl.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/webtoolkit.base64.js" ></script>
 +<script type="text/javascript" src="{{$baseurl}}/js/main.js" ></script>
  <script>
  
        var updateInterval = {{$update_interval}};
index a13923ce4f07beb732c9b2577c2f1b5d014b18b8,972ad2e7cbf224b2ab5250d40bed52033c676bbc..9aa41fbe076669e1250db0d6d563bf036ab01a22
@@@ -393,7 -393,7 +393,7 @@@ if ($color=="dark") $color_path = "/dia
        $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id
                          where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
        $tpl = get_markup_template('ch_directory_item.tpl');
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $photo = 'photo';
                foreach($r as $rr) {
                        $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
                9
        );
        $tpl = get_markup_template('ch_directory_item.tpl');
-       if(dba::is_result($r)) {
 -      if(count($r)) {
++      if(dbm::is_result($r)) {
                $photo = 'thumb';
                foreach($r as $rr) {
                        $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
                                dbesc(t('Contact Photos')),
                                dbesc(t('Profile Photos'))
                                );
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
                $tpl = get_markup_template('ch_directory_item.tpl');
                foreach($r as $rr) {
                        $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
Simple merge
index 2d00f231cd3deea0ba736c7a7069cd0152bba36c,925ac76a1fe2284b4798a34268ceb95e7189b314..9cdd396fd1b69f6f80f773dd54360309754f08d8
@@@ -147,7 -147,7 +147,7 @@@ function vier_community_info() 
                $r = suggestion_query(local_user(), 0, 9);
  
                $tpl = get_markup_template('ch_directory_item.tpl');
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $aside['$comunity_profiles_title'] = t('Community Profiles');
                        $aside['$comunity_profiles_items'] = array();
                                WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
                                0, 9);
  
-               if(dba::is_result($r)) {
 -              $tpl = get_markup_template('ch_directory_item.tpl');
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $aside['$lastusers_title'] = t('Last users');
                        $aside['$lastusers_items'] = array();
  
                $tpl = get_markup_template('ch_connectors.tpl');
  
-               if(dba::is_result($r)) {
 -              if(count($r)) {
++              if(dbm::is_result($r)) {
  
                        $con_services = array();
                        $con_services['title'] = Array("", t('Connect Services'), "", "");