]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #3010 from Quix0r/rewrites/mixed-static-object-reference-calls
authorMichael Vogel <icarus@dabo.de>
Mon, 19 Dec 2016 13:12:50 +0000 (14:12 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Dec 2016 13:12:50 +0000 (14:12 +0100)
Rewrites: mixed static object reference calls (and very sadly more ...)

142 files changed:
boot.php
include/Contact.php
include/Core/Config.php
include/Core/PConfig.php
include/ForumManager.php
include/NotificationsManager.php
include/Probe.php
include/acl_selectors.php
include/api.php
include/auth.php
include/auth_ejabberd.php
include/contact_selectors.php
include/contact_widgets.php
include/conversation.php
include/cron.php
include/cronhooks.php
include/datetime.php
include/dba.php
include/dba_pdo.php
include/dbstructure.php
include/delivery.php
include/dfrn.php
include/diaspora.php
include/discover_poco.php
include/enotify.php
include/event.php
include/expire.php
include/fcontact.php
include/files.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/nav.php
include/network.php
include/notifier.php
include/oauth.php
include/oembed.php
include/onepoll.php
include/pgettext.php
include/plugin.php
include/poller.php
include/queue_fn.php
include/redir.php
include/security.php
include/socgraph.php
include/tags.php
include/text.php
include/threads.php
include/uimport.php
include/user.php
library/langdet/Text/LanguageDetect.php
mod/admin.php
mod/allfriends.php
mod/api.php
mod/attach.php
mod/cal.php
mod/common.php
mod/community.php
mod/contactgroup.php
mod/contacts.php
mod/content.php
mod/crepair.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/directory.php
mod/editpost.php
mod/events.php
mod/fbrowser.php
mod/fetch.php
mod/friendica.php
mod/fsuggest.php
mod/group.php
mod/ignored.php
mod/install.php
mod/item.php
mod/lockview.php
mod/lostpass.php
mod/manage.php
mod/match.php
mod/message.php
mod/modexp.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/notify.php
mod/openid.php
mod/p.php
mod/photo.php
mod/photos.php
mod/ping.php
mod/poco.php
mod/poke.php
mod/post.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/profperm.php
mod/proxy.php
mod/pubsub.php
mod/pubsubhubbub.php
mod/qsearch.php
mod/receive.php
mod/redir.php
mod/regmod.php
mod/salmon.php
mod/search.php
mod/settings.php
mod/share.php
mod/starred.php
mod/subthread.php
mod/suggest.php
mod/tagger.php
mod/tagrm.php
mod/uexport.php
mod/videos.php
mod/viewcontacts.php
mod/viewsrc.php
mod/wall_attach.php
mod/wall_upload.php
mod/wallmessage.php
mod/xrd.php
object/BaseObject.php
object/Conversation.php
object/Item.php
tests/get_tags_test.php
update.php
view/theme/frio/theme.php
view/theme/vier/style.css
view/theme/vier/theme.php

index 49745122481b4c51e0dfb7e124bf7a479d4719ce..b282f8d48e0b64577860cfcad7da20c4d943a75d 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -767,7 +767,7 @@ class App {
 
        }
 
-       function get_basepath() {
+       public static function get_basepath() {
 
                $basepath = get_config("system", "basepath");
 
@@ -1191,7 +1191,7 @@ class App {
                q("START TRANSACTION");
 
                $r = q("SELECT `pid` FROM `process` WHERE `pid` = %d", intval(getmypid()));
-               if(!dbm::is_result($r)) {
+               if (!dbm::is_result($r)) {
                        q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')",
                                intval(getmypid()),
                                dbesc($command),
@@ -1207,7 +1207,7 @@ class App {
                q("START TRANSACTION");
 
                $r = q("SELECT `pid` FROM `process`");
-               if(dbm::is_result($r)) {
+               if (dbm::is_result($r)) {
                        foreach ($r AS $process) {
                                if (!posix_kill($process["pid"], 0)) {
                                        q("DELETE FROM `process` WHERE `pid` = %d", intval($process["pid"]));
@@ -1294,10 +1294,6 @@ class App {
         */
        function max_processes_reached() {
 
-               // Is the function called statically?
-               if (!is_object($this))
-                       return(self::$a->max_processes_reached());
-
                if ($this->is_backend()) {
                        $process = "backend";
                        $max_processes = get_config('system', 'max_processes_backend');
@@ -1329,10 +1325,6 @@ class App {
         */
        function maxload_reached() {
 
-               // Is the function called statically?
-               if (!is_object($this))
-                       return(self::$a->maxload_reached());
-
                if ($this->is_backend()) {
                        $process = "backend";
                        $maxsysload = intval(get_config('system', 'maxloadavg'));
@@ -1479,17 +1471,18 @@ function system_unavailable() {
 
 
 function clean_urls() {
-       global $a;
+       $a = get_app();
        //      if($a->config['system']['clean_urls'])
        return true;
        //      return false;
 }
 
 function z_path() {
-       global $a;
-       $base = $a->get_baseurl();
+       $base = App::get_baseurl();
+
        if(! clean_urls())
                $base .= '/?q=';
+
        return $base;
 }
 
@@ -1499,10 +1492,10 @@ function z_path() {
  * @see App::get_baseurl()
  *
  * @return string
+ * @TODO Maybe super-flous and deprecated? Seems to only wrap App::get_baseurl()
  */
 function z_root() {
-       global $a;
-       return $a->get_baseurl();
+       return App::get_baseurl();
 }
 
 /**
@@ -1685,7 +1678,7 @@ function run_update_function($x) {
 function check_plugins(&$a) {
 
        $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
-       if(dbm::is_result($r))
+       if (dbm::is_result($r))
                $installed = $r;
        else
                $installed = array();
@@ -1903,7 +1896,7 @@ function info($s) {
  * @return int
  */
 function get_max_import_size() {
-       global $a;
+       $a = get_app();
        return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 );
 }
 
@@ -2029,7 +2022,7 @@ function current_theme(){
                $r = q("select theme from user where uid = %d limit 1",
                        intval($a->profile_uid)
                );
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $page_theme = $r[0]['theme'];
        }
 
@@ -2100,7 +2093,7 @@ function current_theme(){
  * @return string
  */
 function current_theme_url() {
-       global $a;
+       $a = get_app();
 
        $t = current_theme();
 
@@ -2142,7 +2135,7 @@ function feed_birthday($uid,$tz) {
                        intval($uid)
        );
 
-       if(dbm::is_result($p)) {
+       if (dbm::is_result($p)) {
                $tmp_dob = substr($p[0]['dob'],5);
                if(intval($tmp_dob)) {
                        $y = datetime_convert($tz,$tz,'now','Y');
index 58748e289a70717b3cdbe35f0a2aad65cb2e8c1b..7ca45a21bd01e32baee60d3e235faa49afc76cb1 100644 (file)
@@ -64,7 +64,7 @@ function contact_remove($id) {
        $r = q("select uid from contact where id = %d limit 1",
                intval($id)
        );
-       if((! count($r)) || (! intval($r[0]['uid'])))
+       if((! dbm::is_result($r)) || (! intval($r[0]['uid'])))
                return;
 
        $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
@@ -242,7 +242,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
                        FROM `gcontact` WHERE `nurl` = '%s'",
                                dbesc(normalise_link($url)));
 
-       if ($r) {
+       if (dbm::is_result($r)) {
                // If there is more than one entry we filter out the connector networks
                if (count($r) > 1) {
                        foreach ($r AS $id => $result) {
@@ -428,7 +428,7 @@ function random_profile() {
                        ORDER BY rand() LIMIT 1",
                dbesc(NETWORK_DFRN));
 
-       if(count($r))
+       if (dbm::is_result($r))
                return dirname($r[0]['url']);
        return '';
 }
index a5eca0570a56efc86f1ecf26ed4dae91f71e07df..7b7045a9ee3ed2f3fe00989d97db6cba13e9959f 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 namespace Friendica\Core;
+
+use dbm;
+
 /**
  * @file include/Core/Config.php
  *
@@ -30,10 +33,10 @@ class Config {
         * @return void
         */
        public static function load($family) {
-               global $a;
+               $a = get_app();
 
                $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        foreach ($r as $rr) {
                                $k = $rr['k'];
                                if ($family === 'config') {
@@ -72,7 +75,7 @@ class Config {
         */
        public static function get($family, $key, $default_value = null, $refresh = false) {
 
-               global $a;
+               $a = get_app();
 
                if (!$refresh) {
                        // Looking if the whole family isn't set
@@ -123,7 +126,7 @@ class Config {
         * @return mixed Stored $value or false if the database update failed
         */
        public static function set($family, $key, $value) {
-               global $a;
+               $a = get_app();
 
                $stored = self::get($family, $key);
 
@@ -171,7 +174,7 @@ class Config {
         */
        public static function delete($family, $key) {
 
-               global $a;
+               $a = get_app();
                if (x($a->config[$family],$key)) {
                        unset($a->config[$family][$key]);
                }
index 63d204b3a2cd01ff63c1b88842ed65d83c1866bf..43735018e4ce143b2826ed61d61987d21cd9303e 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 namespace Friendica\Core;
+
+use dbm;
+
 /**
  * @file include/Core/PConfig.php
  * @brief contains the class with methods for the management
@@ -28,12 +31,12 @@ class PConfig {
         * @return void
         */
        public static function load($uid, $family) {
-               global $a;
+               $a = get_app();
                $r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
                        dbesc($family),
                        intval($uid)
                );
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        foreach ($r as $rr) {
                                $k = $rr['k'];
                                $a->config[$uid][$family][$k] = $rr['v'];
@@ -65,7 +68,7 @@ class PConfig {
         */
        public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
 
-               global $a;
+               $a = get_app();
 
                if (!$refresh) {
                        // Looking if the whole family isn't set
@@ -120,7 +123,7 @@ class PConfig {
         */
        public static function set($uid, $family, $key, $value) {
 
-               global $a;
+               $a = get_app();
 
                $stored = self::get($uid, $family, $key);
 
@@ -171,7 +174,7 @@ class PConfig {
         */
        public static function delete($uid,$family,$key) {
 
-               global $a;
+               $a = get_app();
 
                if (x($a->config[$uid][$family], $key)) {
                        unset($a->config[$uid][$family][$key]);
index d01ece4d95377fb2f3643484d095fda8ebeb74ee..c2a20df29faf069bd0b3fc987b33e3d12b918e7f 100644 (file)
@@ -88,7 +88,7 @@ class ForumManager {
                $total = count($contacts);
                $visible_forums = 10;
 
-               if(dbm::is_result($contacts)) {
+               if (dbm::is_result($contacts)) {
 
                        $id = 0;
 
index 13a2534e1e42b6e36e5072fd40b1f75719a0d871..2adab59721e4cd48d88c482eea03f9ad3681997d 100644 (file)
@@ -88,7 +88,7 @@ class NotificationsManager {
                                intval(local_user())
                        );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $this->_set_extra($r);
 
                return false;
@@ -105,7 +105,7 @@ class NotificationsManager {
                        intval($id),
                        intval(local_user())
                );
-               if(dbm::is_result($r)) {
+               if (dbm::is_result($r)) {
                        return $this->_set_extra($r)[0];
                }
                return null;
@@ -358,7 +358,7 @@ class NotificationsManager {
                        intval(local_user())
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $r[0]['total'];
 
                return 0;
@@ -401,7 +401,7 @@ class NotificationsManager {
                                intval($limit)
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $notifs = $this->formatNotifs($r, $ident);
 
                $arr = array (
@@ -430,7 +430,7 @@ class NotificationsManager {
                        intval(local_user())
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $r[0]['total'];
 
                return 0;
@@ -466,7 +466,7 @@ class NotificationsManager {
                        intval($limit)
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $notifs = $this->formatNotifs($r, $ident);
 
                $arr = array (
@@ -520,7 +520,7 @@ class NotificationsManager {
                        intval(local_user())
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $r[0]['total'];
 
                return 0;
@@ -564,7 +564,7 @@ class NotificationsManager {
                                intval($limit)
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $notifs = $this->formatNotifs($r, $ident);
                
                $arr = array (
@@ -596,7 +596,7 @@ class NotificationsManager {
                        intval(local_user())
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $r[0]['total'];
 
                return 0;
@@ -638,7 +638,7 @@ class NotificationsManager {
                                intval($limit)
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $notifs = $this->formatNotifs($r, $ident);
 
                $arr = array (
@@ -668,7 +668,7 @@ class NotificationsManager {
                                intval($_SESSION['uid'])
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        return $r[0]['total'];
 
                return 0;
@@ -713,7 +713,7 @@ class NotificationsManager {
                                intval($limit)
                );
 
-               if(dbm::is_result($r))
+               if (dbm::is_result($r))
                        $notifs = $this->formatIntros($r);
 
                $arr = array (
index 14e8d5bcad8ab2593547a100bb12c3fa09a365bf..5c2ba86ccde08e0ec1a56926bc97f139859d9c99 100644 (file)
@@ -1084,7 +1084,7 @@ class Probe {
 
                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
 
-               if(count($x) && count($r)) {
+               if (dbm::is_result($x) && dbm::is_result($r)) {
                        $mailbox = construct_mailbox_name($r[0]);
                        $password = '';
                        openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);
index 71a42478ba92c06b80c02f6f3d332af6382deba4..ed9c634c23a8073950eb6ae40e146444e8554737 100644 (file)
@@ -33,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
 
        call_hooks($a->module . '_pre_' . $selname, $arr);
 
-       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 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
 
        call_hooks($a->module . '_pre_' . $selname, $arr);
 
-       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 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
 
        $receiverlist = array();
 
-       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 @@ function populate_acl($user = null, $show_jotnets = false) {
                        $r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                intval(local_user())
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $mail_enabled = true;
                                if(intval($r[0]['pubmail']))
                                        $pubmail_enabled = true;
@@ -577,7 +577,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                $r = array();
 
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $g){
                        $contacts[] = array(
                                "type"  => "c",
@@ -612,7 +612,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                                dbesc($search),
                                implode("','", $known_contacts)
                );
-               if (is_array($r) && count($r)){
+               if (dbm::is_result($r)){
                        foreach($r as $row) {
                                // nickname..
                                $up = parse_url($row['author-link']);
index 1f3c762989f3f2c5850fdfd4327768307b545060..2ae1aeaa026e25e9f8c7fbca5b7d0bb61ec4aa79 100644 (file)
                                dbesc(trim($user)),
                                dbesc($encrypted)
                        );
-                       if(count($r))
+                       if (dbm::is_result($r))
                                $record = $r[0];
                }
 
                if (is_null($user_info)) $user_info = api_get_user($a);
                $arr['$user'] = $user_info;
                $arr['$rss'] = array(
-                       'alternate' => $user_info['url'],
-                       'self' => App::get_baseurl(). "/". $a->query_string,
-                       'base' => App::get_baseurl(),
-                       'updated' => api_date(null),
+                       'alternate'    => $user_info['url'],
+                       'self'         => App::get_baseurl(). "/". $a->query_string,
+                       'base'         => App::get_baseurl(),
+                       'updated'      => api_date(null),
                        'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
-                       'language' => $user_info['language'],
-                       'logo'  => App::get_baseurl()."/images/friendica-32.png",
+                       'language'     => $user_info['language'],
+                       'logo'         => App::get_baseurl()."/images/friendica-32.png",
                );
 
                return $arr;
 
                if (isset($_GET["q"])) {
                        $r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
-                       if (!count($r))
+                       if (!dbm::is_result($r))
                                $r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
 
-                       if (count($r)) {
+                       if (dbm::is_result($r)) {
                                $k = 0;
                                foreach ($r AS $user) {
                                        $user_info = api_get_user($a, $user["id"], "json");
                        intval(api_user())
                );
 
-               if(!dbm::is_result($r))
+               if (!dbm::is_result($r))
                        return;
 
                $ids = array();
                        intval(api_user())
                );
 
-               if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+               if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
                        throw new BadRequestException("Unknown contact");
 
                $cid = $r[0]['id'];
                                intval($uid),
                                intval($gid));
                        // error message if specified gid is not in database
-                       if (count($r) == 0)
+                       if (!dbm::is_result($r))
                                throw new BadRequestException("gid not available");
                }
                else
                        intval($uid),
                        intval($gid));
                // error message if specified gid is not in database
-               if (count($r) == 0)
+               if (!dbm::is_result($r))
                        throw new BadRequestException('gid not available');
 
                // get data of the specified group id and group name
 
                $profile_url = $user_info["url"];
                // message if nothing was found
-               if (count($r) == 0) 
+               if (!dbm::is_result($r))
+                       $success = array('success' => false, 'search_results' => 'problem with query');
+               else if (count($r) == 0) 
                        $success = array('success' => false, 'search_results' => 'nothing found');
                else {
                        $ret = Array();
        }
        api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
 
-
        /**
         * @brief return data of all the profiles a user has to the client
         *
                                intval(api_user()),
                                intval($profileid));
                        // error message if specified gid is not in database
-                       if (count($r) == 0)
+                       if (!dbm::is_result($r))
                                throw new BadRequestException("profile_id not available");
                }
                else
index d1917b8b30903138f18a8cd17203588c8c8f1361..2ca9c3efb29e7937b326b40ee8e5d2665693cd57 100644 (file)
@@ -50,7 +50,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
                $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($_SESSION['visitor_id'])
                );
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $a->contact = $r[0];
                }
        }
@@ -73,7 +73,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
                        intval($_SESSION['uid'])
                );
 
-               if (!count($r)) {
+               if (!dbm::is_result($r)) {
                        nuke_session();
                        goaway(z_root());
                }
@@ -169,7 +169,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
                                dbesc(trim($_POST['username'])),
                                dbesc($encrypted)
                        );
-                       if (count($r))
+                       if (dbm::is_result($r))
                                $record = $r[0];
                }
 
index e1900dc7304df8501794b5f9537fc050d59f3e85..e12da35ef1755057b37e78e26e2069ba50fa7035 100755 (executable)
@@ -146,7 +146,7 @@ class exAuth {
         * @param array $aCommand The command array
         */
        private function isuser($aCommand) {
-               global $a;
+               $a = get_app();
 
                // Check if there is a username
                if (!isset($aCommand[1])) {
@@ -214,7 +214,7 @@ class exAuth {
         * @param array $aCommand The command array
         */
        private function auth($aCommand) {
-               global $a;
+               $a = get_app();
 
                // check user authentication
                if (sizeof($aCommand) != 4) {
index 35c9d983d72797f49ac49f46da496d93d1bfed48..0790e503ea3d24cef132442f8e949dac98e5333d 100644 (file)
@@ -12,7 +12,7 @@ function contact_profile_assign($current,$foreign_net) {
        $r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
                        intval($_SESSION['uid']));
 
-       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 bbbd941b5609df3ae7321bc708599e17c6de4ccc..f66d23c518e5b16125d91c7d3381f92b17404ea2 100644 (file)
@@ -93,7 +93,7 @@ function networks_widget($baseurl,$selected = '') {
        );
 
        $nets = array();
-       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 @@ function common_friends_visitor_widget($profile_uid) {
                                dbesc(normalise_link(get_my_url())),
                                intval($profile_uid)
                        );
-                       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(count($r))
+                               if (dbm::is_result($r))
                                        $zcid = $r[0]['id'];
                        }
                }
index 63db42d93ad91439b552d7213dfdd1f5fe7b5ffe..567bf83e1bfdb2e7b0d2d0a38af11fc2b37f298e 100644 (file)
@@ -109,7 +109,7 @@ function localize_item(&$item){
                $r = q("SELECT * from `item`,`contact` WHERE
                                `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
                                 dbesc($item['parent-uri']));
-               if(count($r)==0) return;
+               if (!dbm::is_result($r)) return;
                $obj=$r[0];
 
                $author  = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
@@ -245,7 +245,7 @@ function localize_item(&$item){
                $r = q("SELECT * from `item`,`contact` WHERE
                `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
                 dbesc($item['parent-uri']));
-               if(count($r)==0) return;
+               if (!dbm::is_result($r)) return;
                $obj=$r[0];
 
                $author  = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
@@ -294,7 +294,7 @@ function localize_item(&$item){
                                        dbesc($obj->id),
                                        intval($item['uid'])
                        );
-                       if(count($r) && $r[0]['plink']) {
+                       if (dbm::is_result($r) && $r[0]['plink']) {
                                $target = $r[0];
                                $Bname = $target['author-name'];
                                $Blink = $target['author-link'];
index 730325ba8c0ccb95cc2ab786a4e6f0741178c193..77332dcec6c2daa300b2222b496dfd2fee0cdbc8 100644 (file)
@@ -43,7 +43,7 @@ function cron_run(&$argv, &$argc){
 
        // Don't check this stuff if the function is called by the poller
        if (App::callstack() != "poller_run") {
-               if (App::maxload_reached())
+               if ($a->maxload_reached())
                        return;
                if (App::is_already_running('cron', 'include/cron.php', 540))
                        return;
@@ -434,7 +434,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"]);
@@ -474,7 +474,7 @@ function cron_repair_database() {
 
        // 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 ($r)
+       if (dbm::is_result($r))
                foreach ($r AS $user)
                        update_gcontact_for_user($user["uid"]);
 
index 4bb1e5f65960b3b3c1bbad1077d34628388040b0..7524a0c3a8883c80b4a914e54093d7cfa9351508 100644 (file)
@@ -25,7 +25,7 @@ function cronhooks_run(&$argv, &$argc){
 
        // Don't check this stuff if the function is called by the poller
        if (App::callstack() != "poller_run") {
-               if (App::maxload_reached())
+               if ($a->maxload_reached())
                        return;
                if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
                        return;
index 16b134e90b13d8525fdfd3535f3694bb451ade2e..e88c274ab967449649311a592171af1f7be4a9a8 100644 (file)
@@ -552,7 +552,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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
 
                        logger('update_contact_birthday: ' . $rr['bd']);
index 16d2dc54d9cc1a362028699c974f41a8299174fb..920027cbcfaeef721a02f2ec3214efed0fcf459b 100644 (file)
@@ -35,7 +35,7 @@ class dba {
        public  $error = false;
 
        function __construct($server, $user, $pass, $db, $install = false) {
-               global $a;
+               $a = get_app();
 
                $stamp1 = microtime(true);
 
@@ -139,7 +139,7 @@ class dba {
        }
 
        public function q($sql, $onlyquery = false) {
-               global $a;
+               $a = get_app();
 
                if (!$this->db || !$this->connected) {
                        return false;
index 7b720fb6c1217e31be5ae0368ea9facbdfcf229e..a44c447af20fa568d8ed15bb6e6082fc5330b182 100644 (file)
@@ -44,7 +44,7 @@ class dba {
        public  $error = false;
 
        function __construct($server,$user,$pass,$db,$install = false) {
-               global $a;
+               $a = get_app();
     
     # work around, to store the database - configuration in DDDBL
     $objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
@@ -99,7 +99,7 @@ class dba {
        }
 
        public function q($sql, $onlyquery = false) {
-               global $a;
+               $a = get_app();
 
     $strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
     
index 94e8da4a44fbda632652204ecc4afe53f1acf1bf..c694014f68fae8b11b7d952bc538b1efac9b8f56 100644 (file)
@@ -17,6 +17,14 @@ function update_fail($update_id, $error_message){
                $admin_mail_list
        );
 
+       // No valid result?
+       if (!dbm::is_result($adminlist)) {
+               logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
+
+               // Don't continue
+               return;
+       }
+
        // every admin could had different language
 
        foreach ($adminlist as $admin) {
@@ -73,7 +81,7 @@ function table_structure($table) {
        $fielddata = array();
        $indexdata = array();
 
-       if (is_array($indexes))
+       if (dbm::is_result($indexes))
                foreach ($indexes AS $index) {
                        if ($index["Index_type"] == "FULLTEXT")
                                continue;
@@ -93,7 +101,7 @@ function table_structure($table) {
                        $indexdata[$index["Key_name"]][] = $column;
                }
 
-       if (is_array($structures)) {
+       if (dbm::is_result($structures)) {
                foreach($structures AS $field) {
                        $fielddata[$field["Field"]]["type"] = $field["Type"];
                        if ($field["Null"] == "NO")
@@ -151,6 +159,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
        foreach ($tables AS $table) {
                $table = current($table);
 
+               logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
                $database[$table] = table_structure($table);
        }
 
@@ -179,7 +188,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                $sql3="";
                if (!isset($database[$name])) {
                        $r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
-                       if(false === $r) {
+                       if (!dbm::is_result($r)) {
                                $errors .=  t('Errors encountered creating database tables.').$name.EOL;
                        }
                        $is_new_table = True;
@@ -256,7 +265,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
 
                        if ($action) {
                                $r = @$db->q($sql3);
-                               if(false === $r)
+                               if (dbm::is_result($r))
                                        $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
                        }
                }
index 8fce98774250cdaeeaccda7bd841671cbda1a7ed..a7aebe709a29b726a504cd300a201b8832429320 100644 (file)
@@ -53,11 +53,11 @@ function delivery_run(&$argv, &$argc){
                        dbesc($item_id),
                        dbesc($contact_id)
                );
-               if (!count($r)) {
+               if (!dbm::is_result($r)) {
                        continue;
                }
 
-               if (App::maxload_reached())
+               if ($a->maxload_reached())
                        return;
 
                // It's ours to deliver. Remove it from the queue.
@@ -131,7 +131,7 @@ function delivery_run(&$argv, &$argc){
                                intval($item_id)
                        );
 
-                       if ((!count($r)) || (!intval($r[0]['parent']))) {
+                       if ((!dbm::is_result($r)) || (!intval($r[0]['parent']))) {
                                continue;
                        }
 
@@ -184,7 +184,7 @@ function delivery_run(&$argv, &$argc){
                        intval($uid)
                );
 
-               if (!count($r))
+               if (!dbm::is_result($r))
                        continue;
 
                $owner = $r[0];
@@ -254,7 +254,7 @@ function delivery_run(&$argv, &$argc){
                        intval($contact_id)
                );
 
-               if (count($r))
+               if (dbm::is_result($r))
                        $contact = $r[0];
 
                if ($contact['self'])
@@ -423,7 +423,7 @@ function delivery_run(&$argv, &$argc){
                                                        intval($argv[2]),
                                                        intval($uid)
                                                );
-                                               if (count($r))
+                                               if (dbm::is_result($r))
                                                        $it = $r[0];
                                        }
                                        if (!$it)
@@ -478,14 +478,14 @@ function delivery_run(&$argv, &$argc){
                                                                dbesc($it['parent-uri']),
                                                                intval($uid));
 
-                                                       if (count($r) AND ($r[0]['title'] != ''))
+                                                       if (dbm::is_result($r) AND ($r[0]['title'] != ''))
                                                                $subject = $r[0]['title'];
                                                        else {
                                                                $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
                                                                        dbesc($it['parent-uri']),
                                                                        intval($uid));
 
-                                                               if (count($r) AND ($r[0]['title'] != ''))
+                                                               if (dbm::is_result($r) AND ($r[0]['title'] != ''))
                                                                        $subject = $r[0]['title'];
                                                        }
                                                }
index 272105128fe07a2ea4c9711a54cdf4d52deb6c67..6451b8521bf326bac30fccdf00e3b19d8c8e28aa 100644 (file)
@@ -105,7 +105,7 @@ class dfrn {
                        dbesc($owner_nick)
                );
 
-               if(! count($r))
+               if(! dbm::is_result($r))
                        killme();
 
                $owner = $r[0];
@@ -139,7 +139,7 @@ class dfrn {
                                intval($owner_id)
                        );
 
-                       if(! count($r))
+                       if(! dbm::is_result($r))
                                killme();
 
                        $contact = $r[0];
@@ -1443,6 +1443,7 @@ class dfrn {
         * @param array $importer Record of the importer user mixed with contact of the content
         */
        private function process_suggestion($xpath, $suggestion, $importer) {
+               $a = get_app();
 
                logger("Processing suggestions");
 
@@ -1462,7 +1463,7 @@ class dfrn {
                        dbesc(normalise_link($suggest["url"])),
                        intval($suggest["uid"])
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        return false;
 
                // Do we already have an fcontact record for this person?
@@ -1473,7 +1474,7 @@ class dfrn {
                        dbesc($suggest["name"]),
                        dbesc($suggest["request"])
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $fid = $r[0]["id"];
 
                        // OK, we do. Do we already have an introduction for this person ?
@@ -1481,7 +1482,7 @@ class dfrn {
                                intval($suggest["uid"]),
                                intval($fid)
                        );
-                       if(count($r))
+                       if (dbm::is_result($r))
                                return false;
                }
                if(!$fid)
@@ -1496,7 +1497,7 @@ class dfrn {
                        dbesc($suggest["name"]),
                        dbesc($suggest["request"])
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $fid = $r[0]["id"];
                else
                        // database record did not get created. Quietly give up.
@@ -1745,7 +1746,7 @@ class dfrn {
                                LIMIT 1",
                                dbesc($item["parent-uri"])
                        );
-                       if($r && count($r)) {
+                       if (dbm::is_result($r)) {
                                $r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
                                        INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                                        WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
@@ -1757,7 +1758,7 @@ class dfrn {
                                        dbesc($r[0]["parent-uri"]),
                                        intval($importer["importer_uid"])
                                );
-                               if($r && count($r))
+                               if (dbm::is_result($r))
                                        $is_a_remote_action = true;
                        }
 
@@ -1895,7 +1896,7 @@ class dfrn {
                                        dbesc($item["verb"]),
                                        dbesc($item["parent-uri"])
                                );
-                               if($r && count($r))
+                               if (dbm::is_result($r))
                                        return false;
 
                                $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
@@ -1904,7 +1905,7 @@ class dfrn {
                                        dbesc($item["verb"]),
                                        dbesc($item["parent-uri"])
                                );
-                               if($r && count($r))
+                               if (dbm::is_result($r))
                                        return false;
                        } else
                                $is_like = false;
@@ -1920,7 +1921,7 @@ class dfrn {
                                                intval($importer["importer_uid"])
                                        );
 
-                                       if(!count($r))
+                                       if (!dbm::is_result($r))
                                                return false;
 
                                        // extract tag, if not duplicate, add to parent item
@@ -2192,7 +2193,7 @@ class dfrn {
                                                dbesc($item["uri"]),
                                                intval($importer["uid"])
                                        );
-                                       if(count($r))
+                                       if (dbm::is_result($r))
                                                $ev["id"] = $r[0]["id"];
 
                                        $event_id = event_store($ev);
@@ -2213,7 +2214,7 @@ class dfrn {
                }
 
                // Update content if 'updated' changes
-               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
@@ -2235,7 +2236,7 @@ class dfrn {
                                        intval($posted_id),
                                        intval($importer["importer_uid"])
                                );
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        $parent = $r[0]["parent"];
                                        $parent_uri = $r[0]["parent-uri"];
                                }
@@ -2323,7 +2324,7 @@ class dfrn {
                                intval($importer["uid"]),
                                intval($importer["id"])
                        );
-               if(!count($r)) {
+               if (!dbm::is_result($r)) {
                        logger("Item with uri ".$uri." from contact ".$importer["id"]." for user ".$importer["uid"]." wasn't found.", LOGGER_DEBUG);
                        return;
                } else {
@@ -2417,7 +2418,7 @@ class dfrn {
                                                        dbesc($item["parent-uri"]),
                                                        intval($importer["uid"])
                                        );
-                                       if(count($r)) {
+                                       if (dbm::is_result($r)) {
                                                q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
                                                        intval($r[0]["id"])
                                                );
index f2d48486788bf68145cd3dcbb22b07395b4d91f5..94c6ccfb8d201dfa55b7e1e766ca72dece17af88 100644 (file)
@@ -1278,7 +1278,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;
                }
@@ -2925,7 +2925,7 @@ class diaspora {
 
                $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];
@@ -2956,7 +2956,7 @@ class diaspora {
                        intval($item["parent"])
                );
 
-               if (!$p)
+               if (!dbm::is_result($p))
                        return false;
 
                $parent = $p[0];
@@ -3170,7 +3170,7 @@ class diaspora {
                        intval($item["uid"])
                );
 
-               if (!$r) {
+               if (!dbm::is_result($r)) {
                        logger("conversation not found.");
                        return;
                }
index 0b468faea189e522505ed5c686facd22be905406..bf3e47edd9a514acde02b4dcb5cdcb8d00a676be 100644 (file)
@@ -26,7 +26,7 @@ function discover_poco_run(&$argv, &$argc){
 
        // Don't check this stuff if the function is called by the poller
        if (App::callstack() != "poller_run")
-               if (App::maxload_reached())
+               if ($a->maxload_reached())
                        return;
 
        if(($argc > 2) && ($argv[1] == "dirsearch")) {
index 5b2bea2977b070fdb908eeb720ca1a699ba15173..c6e0506e96ef2e34191e6d3fd250f4192e068a8a 100644 (file)
@@ -411,7 +411,7 @@ function notification($params) {
                        $hash = random_string();
                        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
                                dbesc($hash));
-                       if (count($r))
+                       if (dbm::is_result($r))
                                $dups = true;
                } while($dups == true);
 
@@ -648,6 +648,7 @@ function notification($params) {
  * @param str $defaulttype (Optional) Forces a notification with this type.
  */
 function check_item_notification($itemid, $uid, $defaulttype = "") {
+       $a = get_app();
 
        $notification_data = array("uid" => $uid, "profiles" => array());
        call_hooks('check_item_notification', $notification_data);
@@ -666,7 +667,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
        $profiles[] = $owner[0]["url"];
 
        // Notifications from Diaspora are often with an URL in the Diaspora format
-       $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
+       $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
 
        $profiles2 = array();
 
@@ -732,17 +733,17 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
                        intval($item[0]['contact-id']),
                        intval($uid)
                );
-               $send_notification = count($r);
+               $send_notification = dbm::is_result($r);
 
                if (!$send_notification) {
                        $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
                                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;
                                }
                        }
index 6c0e2bdec6e68608a5d8267200cb75ea6289f8e6..3a41dad4e70dd5b66b3f51cc964f62b8271b3e5e 100644 (file)
@@ -271,7 +271,7 @@ function event_store($arr) {
                        intval($arr['id']),
                        intval($arr['uid'])
                );
-               if((! count($r)) || ($r[0]['edited'] === $arr['edited'])) {
+               if((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
 
                        // Nothing has changed. Grab the item id to return.
 
@@ -279,7 +279,7 @@ function event_store($arr) {
                                intval($arr['id']),
                                intval($arr['uid'])
                        );
-                       return((count($r)) ? $r[0]['id'] : 0);
+                       return((dbm::is_result($r)) ? $r[0]['id'] : 0);
                }
 
                // The event changed. Update it.
@@ -312,7 +312,7 @@ function event_store($arr) {
                        intval($arr['id']),
                        intval($arr['uid'])
                );
-               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";
@@ -365,7 +365,7 @@ function event_store($arr) {
                        dbesc($arr['uri']),
                        intval($arr['uid'])
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $event = $r[0];
 
                $item_arr = array();
@@ -407,7 +407,7 @@ function event_store($arr) {
                $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($arr['uid'])
                );
-               //if(count($r))
+               //if (dbm::is_result($r))
                //      $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
 
 
@@ -515,7 +515,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
                intval($event_params["event_id"])
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r;
 
 }
@@ -557,7 +557,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
                        dbesc($event_params["adjust_finish"])
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r;
 }
 
@@ -750,7 +750,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
                );
        }
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r;
 }
 
@@ -773,7 +773,7 @@ function event_export($uid, $format = 'ical') {
        // we are allowed to show events
        // get the timezone the user is in
        $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
-       if (count($r))
+       if (dbm::is_result($r))
                $timezone = $r[0]['timezone'];
 
        // get all events which are owned by a uid (respects permissions);
index 873c594e8499ea93aeaa55727abeb09f34e81e28..eca2b1c42ad9a7ee3962c047e8c67e7faeb22051 100644 (file)
@@ -39,7 +39,7 @@ function expire_run(&$argv, &$argc){
        logger('expire: start');
 
        $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
-       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 8821a985f2dc06e77619ce6bf7719c422358b031..b2706e51a0226e3cc13bfd6cafb4179a8c249fd6 100644 (file)
@@ -10,7 +10,7 @@ function fcontact_store($url,$name,$photo) {
                dbesc($nurl)
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r[0]['id'];
 
        $r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
@@ -19,11 +19,11 @@ function fcontact_store($url,$name,$photo) {
                dbesc($photo)
        );
 
-       if($r) {
+       if (dbm::is_result($r)) {
                $r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
                        dbesc($nurl)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        return $r[0]['id'];
        }
 
index b3bd7690fe7194a9403fc4b386343f17e1210e56..7bff0e3468bd7d0331e0549ce2dd9c3616aa574a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 function create_files_from_item($itemid) {
-       global $a;
+       $a = get_app();
 
        $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
 
index 77f0bbe2f102f246e8abab9cf68dc311207d8684..7a3514b3a73aa4942ca00f009cc6128361782461 100644 (file)
@@ -177,12 +177,12 @@ function new_contact($uid,$url,$interactive = false) {
                dbesc($ret['network'])
        );
 
-       if(!count($r))
+       if (!dbm::is_result($r))
                $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
                        intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
        );
 
-       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",
@@ -200,7 +200,7 @@ function new_contact($uid,$url,$interactive = false) {
                $r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0",
                        intval($uid)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $total_contacts = $r[0]['total'];
 
                if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
@@ -212,7 +212,7 @@ function new_contact($uid,$url,$interactive = false) {
                        intval($uid),
                        dbesc($network)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $total_network = $r[0]['total'];
 
                if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
@@ -254,7 +254,7 @@ function new_contact($uid,$url,$interactive = false) {
                intval($uid)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                $result['message'] .=  t('Unable to retrieve contact information.') . EOL;
                return $result;
        }
index 42a8ef71355d1fc8a044c254de0e82ef6c42a762..7169aada3f7e38435d194f770c62f8186794b9da 100644 (file)
@@ -64,7 +64,7 @@ function gprobe_run(&$argv, &$argc){
                        dbesc(normalise_link($url))
                );
        }
-       if(dbm::is_result($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 53c0b78d841b5854f1eb08604a3c69aef0d2aad0..2c903306864da2caa1ef4368212faffb6c016c43 100644 (file)
@@ -44,7 +44,7 @@ function group_rmv($uid,$name) {
                        intval($uid),
                        dbesc($name)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $group_id = $r[0]['id'];
                if(! $group_id)
                        return false;
@@ -106,7 +106,7 @@ function group_byname($uid,$name) {
                intval($uid),
                dbesc($name)
        );
-       if(count($r))
+       if (dbm::is_result($r))
                return $r[0]['id'];
        return false;
 }
@@ -139,11 +139,11 @@ function group_add_member($uid,$name,$member,$gid = 0) {
                intval($gid),
                intval($member)
        );
-       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
-       if(! count($r))
+       if(! dbm::is_result($r))
                $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
                        VALUES( %d, %d, %d ) ",
                        intval($uid),
@@ -164,7 +164,7 @@ function group_get_members($gid) {
                        intval($gid),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $ret = $r;
        }
        return $ret;
@@ -181,7 +181,7 @@ function group_public_members($gid) {
                        intval(local_user()),
                        dbesc(NETWORK_OSTATUS)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $ret = count($r);
        }
        return $ret;
@@ -197,7 +197,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
                intval($uid)
        );
        $grps[] = array('name' => '', 'id' => '0', 'selected' => '');
-       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 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
                $member_of = groups_containing(local_user(),$cid);
        }
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
 
@@ -316,7 +316,7 @@ function expand_groups($a,$check_dead = false, $use_gcontact = false) {
 
 
        $ret = array();
-       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 @@ function groups_containing($uid,$c) {
        );
 
        $ret = array();
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        $ret[] = $rr['gid'];
        }
index a792c4714426a9a1334442a90f07620177f9ca85..bf05a005160eb81d83e7a1012bf21052f98bba82 100644 (file)
@@ -138,7 +138,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
                                        $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
                                                intval($visitor['cid'])
                                        );
-                                       if(count($r))
+                                       if (dbm::is_result($r))
                                                $profile = $r[0]['profile-id'];
                                        break;
                                }
@@ -159,7 +159,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
                                intval($profile_int)
                );
        }
-       if((!$r) && (!count($r))) {
+       if (!dbm::is_result($r)) {
                $r = q("SELECT `contact`.`id` AS `contact_id`, `profile`.`uid` AS `profile_uid`, `profile`.*,
                                `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
                        FROM `profile`
@@ -236,7 +236,7 @@ function profile_sidebar($profile, $block = 0) {
 
                $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
                        local_user(), $profile_url);
-               if (count($r))
+               if (dbm::is_result($r))
                        $connect = false;
        }
 
@@ -289,7 +289,7 @@ function profile_sidebar($profile, $block = 0) {
                        'entries' => array(),
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        foreach($r as $rr) {
                                $profile['menu']['entries'][] = array(
@@ -368,7 +368,7 @@ function profile_sidebar($profile, $block = 0) {
                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(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 NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
@@ -378,7 +378,7 @@ function profile_sidebar($profile, $block = 0) {
                                dbesc(NETWORK_DIASPORA),
                                dbesc(NETWORK_OSTATUS)
                        );
-                       if(count($r))
+                       if (dbm::is_result($r))
                                $contacts = intval($r[0]['total']);
                }
        }
@@ -460,7 +460,7 @@ function get_birthdays() {
                        dbesc(datetime_convert('UTC','UTC','now'))
        );
 
-       if($r && count($r)) {
+       if (dbm::is_result($r)) {
                $total = 0;
                $now = strtotime('now');
                $cids = array();
@@ -543,7 +543,7 @@ function get_events() {
                        dbesc(datetime_convert('UTC','UTC','now - 1 days'))
        );
 
-       if($r && count($r)) {
+       if (dbm::is_result($r)) {
                $now = strtotime('now');
                $istoday = false;
                foreach($r as $rr) {
index c2c4c10293edc3a8d2cdeeca304df1819fe74469..da9147faddddd4da00cc2d7050b74cfe6c2d7dd2 100644 (file)
@@ -451,7 +451,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        /* check for create  date and expire time */
        $uid = intval($arr['uid']);
        $r = q("SELECT expire FROM user WHERE uid = %d", intval($uid));
-       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'));
@@ -568,19 +568,19 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                        intval($arr['uid'])
                );
 
-               if (!count($r))
+               if (!dbm::is_result($r))
                        $r = q("SELECT `network` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND `nurl` = '%s' LIMIT 1",
                                dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS),
                                dbesc(normalise_link($arr['author-link']))
                        );
 
-               if (!count($r))
+               if (!dbm::is_result($r))
                        $r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                                intval($arr['contact-id']),
                                intval($arr['uid'])
                        );
 
-               if (count($r))
+               if (dbm::is_result($r))
                        $arr['network'] = $r[0]["network"];
 
                // Fallback to friendica (why is it empty in some cases?)
@@ -634,7 +634,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                $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 (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;
                }
@@ -662,7 +662,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                        intval($arr['uid'])
                );
 
-               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
@@ -1120,7 +1120,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 (count($r))
+       if (dbm::is_result($r))
                return($r[0]["guid"]);
        else
                return("");
@@ -1139,7 +1139,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 (count($r)) {
+               if (dbm::is_result($r)) {
                        $id = $r[0]["id"];
                        $nick = $r[0]["nickname"];
                }
@@ -1153,7 +1153,7 @@ function get_item_id($guid, $uid = 0) {
                                AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
                                AND `item`.`private` = 0 AND `item`.`wall` = 1
                                AND `item`.`guid` = '%s'", dbesc($guid));
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $id = $r[0]["id"];
                        $nick = $r[0]["nickname"];
                }
@@ -1454,7 +1454,7 @@ function item_is_remote_self($contact, &$datarray) {
        if ($contact['remote_self'] == 2) {
                $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`",
                        intval($contact['uid']));
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $datarray['contact-id'] = $r[0]["id"];
 
                        $datarray['owner-name'] = $r[0]["name"];
@@ -1531,7 +1531,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                                intval($importer['uid']),
                                dbesc($url)
                );
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $contact_record = $r[0];
                        update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
                }
@@ -1541,7 +1541,8 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                        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();
@@ -1580,7 +1581,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                                ));
 
                        }
-               } elseif (count($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
+               } elseif (dbm::is_result($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
                        $r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
                                        intval($importer['uid']),
                                        dbesc($url)
@@ -1628,7 +1629,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
        // through the direct Diaspora protocol. If we try and use
        // the feed, we'll get duplicates. So don't.
 
-       if ((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
+       if ((! dbm::is_result($r)) || $contact['network'] === NETWORK_DIASPORA)
                return;
 
        $push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
@@ -1846,7 +1847,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
                intval($days)
        );
 
-       if (! count($r))
+       if (! dbm::is_result($r))
                return;
 
        $expire_items = get_pconfig($uid, 'expire','items');
@@ -1924,7 +1925,7 @@ function drop_item($id,$interactive = true) {
                intval($id)
        );
 
-       if (! count($r)) {
+       if (! dbm::is_result($r)) {
                if (! $interactive)
                        return 0;
                notice( t('Item not found.') . EOL);
@@ -2111,7 +2112,7 @@ function drop_item($id,$interactive = true) {
                                dbesc($item['parent-uri']),
                                intval($item['uid'])
                        );
-                       if (count($r)) {
+                       if (dbm::is_result($r)) {
                                q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
                                        intval($r[0]['id'])
                                );
@@ -2147,7 +2148,7 @@ function first_post_date($uid,$wall = false) {
                intval($uid),
                intval($wall ? 1 : 0)
        );
-       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 118ec81ca1c35e47ca966c997c254a2a379234d1..5b6d1b9e6e7fbf642b768396fee1fe305dea4232 100644 (file)
@@ -57,7 +57,7 @@ function do_like($item_id, $verb) {
                dbesc($item_id)
        );
 
-       if(! $item_id || (! count($r))) {
+       if(! $item_id || (! dbm::is_result($r))) {
                logger('like: no item ' . $item_id);
                return false;
        }
@@ -78,7 +78,7 @@ function do_like($item_id, $verb) {
                        intval($item['contact-id']),
                        intval($item['uid'])
                );
-               if(! count($r))
+               if(! dbm::is_result($r))
                        return false;
                if(! $r[0]['self'])
                        $remote_owner = $r[0];
@@ -90,7 +90,7 @@ function do_like($item_id, $verb) {
                WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
                intval($owner_uid)
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $owner = $r[0];
 
        if(! $owner) {
@@ -112,7 +112,7 @@ function do_like($item_id, $verb) {
                        intval($_SESSION['visitor_id']),
                        intval($owner_uid)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $contact = $r[0];
        }
        if(! $contact) {
@@ -135,7 +135,7 @@ function do_like($item_id, $verb) {
                dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
        );
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $like_item = $r[0];
 
                // Already voted, undo it
index 70cf4b787b439dbf25c5c135965cd0b3b4bfad24..0c7b6acaa4afbaa45c440fccb194399ea60539d2 100644 (file)
@@ -16,14 +16,14 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
                        dbesc($fn_name)
                );
 
-               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)
                        );
                        $got_lock = true;
                }
-               elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
+               elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
                        q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
                                dbesc($fn_name),
                                dbesc(datetime_convert())
@@ -56,10 +56,10 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
                                dbesc($fn_name)
                     );
 
-               if(count($r) && $r[0]['locked'])
+               if (dbm::is_result($r) && $r[0]['locked'])
                        sleep($wait_sec);
 
-       } while(count($r) && $r[0]['locked'] && ((time() - $start) < $timeout));
+       } while(dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));
 
        return;
 }}
index 51f3ad805a667fcbd45242625bb4f539d96d145c..ea2fcef3bcb213e24ed280b844f05c90507d3f91 100644 (file)
@@ -41,7 +41,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                        dbesc($replyto),
                        dbesc($replyto)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $convid = $r[0]['convid'];
        }
 
@@ -74,7 +74,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                        dbesc($conv_guid),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $convid = $r[0]['id'];
        }
 
@@ -113,7 +113,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                dbesc($uri),
                intval(local_user())
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $post_id = $r[0]['id'];
 
        /**
@@ -210,7 +210,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
                dbesc($conv_guid),
                intval($recipient['uid'])
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $convid = $r[0]['id'];
 
        if(! $convid) {
index 7a8230cc15da8f4bc6b9f6a6c7d0cb9479b82c0b..2a9f24ca9f5644e351e4ac29fd7ee2a676a4074e 100644 (file)
@@ -88,7 +88,7 @@ function nav_info(App $a)
                // user info
                $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
                $userinfo = array(
-                       'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
+                       'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
                        'name' => $a->user['username'],
                );
        } else {
index 351951846c6f38ef1f006b662f4335c5514ccd54..df46d35932fcb694b506a3bc361516e118d609fa 100644 (file)
@@ -338,7 +338,6 @@ function xml_status($st, $message = '') {
        killme();
 }
 
-
 /**
  * @brief Send HTTP status header and exit.
  *
@@ -348,6 +347,14 @@ function xml_status($st, $message = '') {
  *    '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) {
@@ -381,19 +388,23 @@ function http_status_exit($val, $description = array()) {
  * @return boolean True if it's a valid URL, fals if something wrong with it
  */
 function validate_url(&$url) {
-
        if(get_config('system','disable_url_validation'))
                return true;
+
        // no naked subdomains (allow localhost for tests)
        if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
                return false;
+
        if(substr($url,0,4) != 'http')
                $url = 'http://' . $url;
+
+       /// @TODO Really supress function outcomes? Why not find them + debug them?
        $h = @parse_url($url);
 
-       if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
+       if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
                return true;
        }
+
        return false;
 }
 
index 812752a55c2ac2975834be4154de455d3c052cc7..2f9599d07255934c9c9792182b7a043c5ef62eb5 100644 (file)
@@ -170,7 +170,7 @@ function notifier_run(&$argv, &$argc){
                        intval($item_id)
                );
 
-               if((! count($r)) || (! intval($r[0]['parent']))) {
+               if((! dbm::is_result($r)) || (! intval($r[0]['parent']))) {
                        return;
                }
 
@@ -210,7 +210,7 @@ function notifier_run(&$argv, &$argc){
                intval($uid)
        );
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                return;
 
        $owner = $r[0];
@@ -321,7 +321,7 @@ function notifier_run(&$argv, &$argc){
                                                intval($uid),
                                                dbesc(NETWORK_DFRN)
                                        );
-                                       if(count($r))
+                                       if (dbm::is_result($r))
                                                foreach($r as $rr)
                                                        $recipients_followup[] = $rr['id'];
                                }
@@ -445,7 +445,7 @@ function notifier_run(&$argv, &$argc){
 
                $r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra);
 
-               if(count($r))
+               if (dbm::is_result($r))
                        $contacts = $r;
 
        } else
@@ -463,7 +463,7 @@ function notifier_run(&$argv, &$argc){
                                intval($uid),
                                dbesc(NETWORK_MAIL)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                foreach($r as $rr)
                                        $recipients[] = $rr['id'];
                        }
@@ -491,7 +491,7 @@ function notifier_run(&$argv, &$argc){
 
        // delivery loop
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
 
                foreach($r as $contact) {
                        if(!$contact['self']) {
@@ -592,7 +592,7 @@ function notifier_run(&$argv, &$argc){
 
                $r = array_merge($r2,$r1,$r0);
 
-               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 6a1d72d178f413fb68a94b8f7a64c7c35cb4d045..a30232df4a89a89f990172ccfb018bab4bd73429 100644 (file)
@@ -23,7 +23,7 @@ class FKOAuthDataStore extends OAuthDataStore {
                $r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id='%s'",
                        dbesc($consumer_key)
                );
-               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 @@ class FKOAuthDataStore extends OAuthDataStore {
                        dbesc($token_type),
                        dbesc($token)
                );
-               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 @@ class FKOAuthDataStore extends OAuthDataStore {
                        dbesc($nonce),
                        intval($timestamp)
                );
-               if (count($r))
+               if (dbm::is_result($r))
                        return new OAuthToken($r[0]['id'],$r[0]['secret']);
                return null;
   }
@@ -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(count($r)){
+               if (dbm::is_result($r)){
                        $record = $r[0];
                } else {
                   logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
@@ -162,7 +162,7 @@ class FKOAuth1 extends OAuthServer {
 
                $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
                        intval($_SESSION['uid']));
-               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 @@ class FKOAuth2 extends OAuth2 {
                $r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'",
                                dbesc($oauth_token));
        
-               if (count($r))
+               if (dbm::is_result($r))
                        return $r[0];
                return null;
        }
@@ -247,7 +247,7 @@ class FKOAuth2 extends OAuth2 {
                $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
                                dbesc($code));
                
-               if (count($r))
+               if (dbm::is_result($r))
                        return $r[0];
                return null;
        }
index 5abd03b61769587180e292d9ebdb825e12ddf757..a1945894fcaf3fb877ff36c7e2b5a2ec1e0b7e71 100755 (executable)
@@ -165,12 +165,12 @@ function oembed_format_object($j){
                                $th=120; $tw = $th*$tr;
                                $tpl=get_markup_template('oembed_video.tpl');
                                $ret.=replace_macros($tpl, array(
-                                       '$baseurl' => App::get_baseurl(),
-                                       '$embedurl'=>$embedurl,
-                                       '$escapedhtml'=>base64_encode($jhtml),
-                                       '$tw'=>$tw,
-                                       '$th'=>$th,
-                                       '$turl'=>$j->thumbnail_url,
+                                       '$baseurl'     => App::get_baseurl(),
+                                       '$embedurl'    => $embedurl,
+                                       '$escapedhtml' => base64_encode($jhtml),
+                                       '$tw'          => $tw,
+                                       '$th'          => $th,
+                                       '$turl'        => $j->thumbnail_url,
                                ));
 
                        } else {
@@ -255,12 +255,14 @@ function oembed_format_object($j){
  * @see oembed_format_object()
  */
 function oembed_iframe($src, $width, $height) {
+       $a = get_app();
+
        if (!$height || strstr($height,'%')) {
                $height = '200';
        }
        $width = '100%';
 
-       $s = App::get_baseurl() . '/oembed/'.base64url_encode($src);
+       $s = App::get_baseurl() . '/oembed/' . base64url_encode($src);
        return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
 }
 
index 4ac5f38bee43e919a9901104f0ae64b7a2020086..2834036665bad1c3ef0a6d7629761726acd40711 100644 (file)
@@ -93,7 +93,7 @@ function onepoll_run(&$argv, &$argc){
                        where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
                        intval($contact['id'])
                );
-               if (count($r))
+               if (dbm::is_result($r))
                        if (!$r[0]['total'])
                                poco_load($contact['id'],$importer_uid,0,$contact['poco']);
        }
@@ -143,7 +143,7 @@ function onepoll_run(&$argv, &$argc){
        $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                intval($importer_uid)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                return;
 
        $importer = $r[0];
@@ -393,7 +393,7 @@ function onepoll_run(&$argv, &$argc){
                                                        dbesc($datarray['uri'])
                                                );
 
-                                               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
@@ -446,7 +446,7 @@ function onepoll_run(&$argv, &$argc){
                                                        $r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
                                                                intval($importer_uid)
                                                        );
-                                                       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'];
                                                }
@@ -479,7 +479,7 @@ function onepoll_run(&$argv, &$argc){
                                                                dbesc(protect_sprintf($datarray['title'])),
                                                                intval($importer_uid),
                                                                dbesc(NETWORK_MAIL));
-                                                       if(count($r))
+                                                       if (dbm::is_result($r))
                                                                $datarray['parent-uri'] = $r[0]['parent-uri'];
                                                }
 
index de7cdda9e8575cfa41a3d117062225666e8e2ca2..fb87798ff72712b74acccc8f2d4a93bf6b5ba1f4 100644 (file)
@@ -98,7 +98,7 @@ if(! function_exists('load_translation_table')) {
  * @param string $lang language code to load
  */
 function load_translation_table($lang) {
-       global $a;
+       $a = get_app();
 
        $a->strings = array();
        // load enabled plugins strings
index f6e4a7a88223e651ad5c7ec1131891338571459d..487ab575156d4812d6d959922496ac5f04efdb1a 100644 (file)
@@ -79,7 +79,7 @@ function reload_plugins() {
        if(strlen($plugins)) {
 
                $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
-               if(count($r))
+               if (dbm::is_result($r))
                        $installed = $r;
                else
                        $installed = array();
@@ -150,7 +150,7 @@ function register_hook($hook,$file,$function,$priority=0) {
                dbesc($file),
                dbesc($function)
        );
-       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 @@ function load_hooks() {
        $a = get_app();
        $a->hooks = array();
        $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
-       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();
@@ -473,7 +473,7 @@ function service_class_allows($uid,$property,$usage = false) {
                $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($uid)
                );
-               if($r !== false and count($r)) {
+               if (dbm::is_result($r)) {
                        $service_class = $r[0]['service_class'];
                }
        }
@@ -503,7 +503,7 @@ function service_class_fetch($uid,$property) {
                $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($uid)
                );
-               if($r !== false and count($r)) {
+               if (dbm::is_result($r)) {
                        $service_class = $r[0]['service_class'];
                }
        }
index 925de3fe5b04994cb6102b425850e5d9d6c3e810..44f4895cdbda1991d9d12d1c0e59dee33b055eab 100644 (file)
@@ -39,7 +39,7 @@ function poller_run($argv, $argc){
                return;
        }
 
-       if (App::maxload_reached()) {
+       if ($a->maxload_reached()) {
                return;
        }
 
index a68aa8918fb4ac9fc37e9a3f0949131f3f7f8259..9dcefdd244b59288c9177a401735d186480a680b 100644 (file)
@@ -23,12 +23,11 @@ function remove_queue_item($id) {
  * @return bool The communication with this contact has currently problems
  */
 function was_recently_delayed($cid) {
-
        $was_delayed = false;
 
        // Are there queue entries that were recently added?
        $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
-               AND `last` > UTC_TIMESTAMP() - interval 15 minute LIMIT 1",
+               AND `last` > UTC_TIMESTAMP() - INTERVAL 15 MINUTE LIMIT 1",
                intval($cid)
        );
 
@@ -61,7 +60,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
                WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
                intval($cid)
        );
-       if($r && count($r)) {
+       if (dbm::is_result($r)) {
                if($batch &&  ($r[0]['total'] > $batch_queue)) {
                        logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
                        return;
index ab4f3220cd7d1a1ace36ece544828db9ab96d0a6..8d8a035f1db5fa83c07e388111526c5855416b29 100644 (file)
@@ -36,7 +36,7 @@ function auto_redir(&$a, $contact_nick) {
                dbesc($nurl)
                );
 
-               if((!$r) || (! count($r)) || $r[0]['id'] == remote_user())
+               if((! dbm::is_result($r)) || $r[0]['id'] == remote_user())
                        return;
 
 
@@ -48,7 +48,7 @@ function auto_redir(&$a, $contact_nick) {
                       dbesc($baseurl)
                );
 
-               if(! ($r && count($r)))
+               if(! dbm::is_result($r))
                        return;
 
                $cid = $r[0]['id'];
index b52ddeb2dfa49f6124b78ffe234d898268b80b19..fa698c1b1a62aeb48e5ea9953507eb3c6fec0e81 100644 (file)
@@ -42,7 +42,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                $r = q("select * from user where uid = %d limit 1",
                        intval($_SESSION['submanage'])
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $master_record = $r[0];
        }
 
@@ -50,7 +50,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                dbesc($master_record['password']),
                dbesc($master_record['email'])
        );
-       if($r && count($r))
+       if (dbm::is_result($r))
                $a->identities = $r;
        else
                $a->identities = array();
@@ -60,7 +60,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
                and `manage`.`uid` = %d",
                intval($master_record['uid'])
        );
-       if($r && count($r))
+       if (dbm::is_result($r))
                $a->identities = array_merge($a->identities,$r);
 
        if($login_initial)
@@ -70,7 +70,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
                intval($_SESSION['uid']));
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $a->contact = $r[0];
                $a->cid = $r[0]['id'];
                $_SESSION['cid'] = $a->cid;
@@ -156,7 +156,7 @@ function can_write_wall(&$a,$owner) {
                                intval(PAGE_COMMUNITY)
                        );
 
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $verified = 2;
                                return true;
                        }
@@ -210,7 +210,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
                                intval($remote_user),
                                intval($owner_id)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $remote_verified = true;
                                $groups = init_groups_visitor($remote_user);
                        }
@@ -292,7 +292,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
                                intval($remote_user),
                                intval($owner_id)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $remote_verified = true;
                                $groups = init_groups_visitor($remote_user);
                        }
@@ -403,7 +403,7 @@ function init_groups_visitor($contact_id) {
                WHERE `contact-id` = %d ",
                intval($contact_id)
        );
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        $groups[] = $rr['gid'];
        }
index 765ed5d8912b5fb30d513d6430a07a47bed86fd6..349fd0b2caebcecd5dfff17e050a2129c5161ec1 100644 (file)
@@ -40,7 +40,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                        $r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
                                intval($cid)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $url = $r[0]['poco'];
                                $uid = $r[0]['uid'];
                        }
@@ -213,14 +213,14 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
        $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(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(count($r)) {
+               if (dbm::is_result($r)) {
                        $network = $r[0]["network"];
                        //$profile_url = $r[0]["url"];
                }
@@ -330,7 +330,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
                intval($gcid),
                intval($zcid)
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
                        intval($cid),
                        intval($uid),
@@ -976,7 +976,7 @@ function count_common_friends($uid,$cid) {
        );
 
 //     logger("count_common_friends: $uid $cid {$r[0]['total']}");
-       if(count($r))
+       if (dbm::is_result($r))
                return $r[0]['total'];
        return 0;
 
@@ -1022,7 +1022,7 @@ function count_common_friends_zcid($uid,$zcid) {
                intval($uid)
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r[0]['total'];
        return 0;
 
@@ -1061,7 +1061,7 @@ function count_all_friends($uid,$cid) {
                intval($uid)
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                return $r[0]['total'];
        return 0;
 
@@ -1133,7 +1133,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                intval($limit)
        );
 
-       if (count($r) && count($r) >= ($limit -1)) {
+       if (dbm::is_result($r) && count($r) >= ($limit -1)) {
 // Uncommented because the result of the queries are to big to store it in the cache.
 // We need to decide if we want to change the db column type or if we want to delete it.
 //             Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
@@ -1207,7 +1207,7 @@ function update_suggestions() {
                dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA)
        );
 
-       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 a8bcae86dcc3783c13bbbc8ab6466517db431f1e..6c1d01d74da5063e6b167d3388b1a03b4b913813 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 function create_tags_from_item($itemid) {
-       global $a;
+       $a = get_app();
 
        $profile_base = $a->get_baseurl();
        $profile_data = parse_url($profile_base);
index 1197f24ee169421e9ab45336b454ad79ae8e18db..5856226c3725ea3eac596c69bbf781afce18d8b7 100644 (file)
@@ -491,7 +491,7 @@ function item_new_uri($hostname,$uid, $guid = "") {
 
                $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
                        dbesc($uri));
-               if(count($r))
+               if (dbm::is_result($r))
                        $dups = true;
        } while($dups == true);
        return $uri;
@@ -515,7 +515,7 @@ function photo_new_resource() {
                $r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
                        dbesc($resource)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $found = true;
        } while($found == true);
        return $resource;
@@ -699,7 +699,7 @@ $LOGGER_LEVELS = array();
  * @param int $level
  */
 function logger($msg, $level = 0) {
-       global $a;
+       $a = get_app();
        global $db;
        global $LOGGER_LEVELS;
 
@@ -882,7 +882,7 @@ function contact_block() {
                        dbesc(NETWORK_OSTATUS),
                        dbesc(NETWORK_DIASPORA)
        );
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $total = intval($r[0]['total']);
        }
        if(! $total) {
@@ -901,14 +901,15 @@ function contact_block() {
                                dbesc(NETWORK_DIASPORA),
                                intval($shown)
                );
-               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) {
@@ -1931,7 +1932,7 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
                        //      intval($uid)
                        //);
 
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                unset($deleted_tags[$key]);
                        }
                        else {
@@ -1961,7 +1962,7 @@ function file_tag_save_file($uid,$item,$file) {
                intval($item),
                intval($uid)
        );
-       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) . ']'),
@@ -1999,7 +2000,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
                intval($item),
                intval($uid)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                return false;
 
        q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
@@ -2019,7 +2020,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
        //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
        //);
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                $saved = get_pconfig($uid,'system','filetags');
                set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
 
index df0f8ee1de5a24e5577be553a4871226573c312d..48391174ecd683eaaf9d577f6e1d777d64d1d8c0 100644 (file)
@@ -142,12 +142,12 @@ function add_shadow_entry($itemid) {
 
        // 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 (count($r))
+       if (dbm::is_result($r))
                return;
 
        // Preparing public shadow (removing user specific data)
@@ -174,7 +174,7 @@ function add_shadow_entry($itemid) {
 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"]);
 }
@@ -183,7 +183,7 @@ function update_thread($itemid, $setmention = false) {
        $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];
@@ -241,7 +241,7 @@ function delete_thread($itemid, $itemuri = "") {
                                dbesc($itemuri),
                                intval($item["uid"])
                        );
-               if (!count($r)) {
+               if (!dbm::is_result($r)) {
                        $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0",
                                dbesc($itemuri)
                        );
index 937a16710a9211214547600da5555b4d13134d69..51672d92b6a27919704028408f8aa550b94e719c 100644 (file)
@@ -116,7 +116,7 @@ function import_account(&$a, $file) {
                notice(t('Error! Cannot check nickname'));\r
                return;\r
        }\r
-       if (count($r) > 0) {\r
+       if (dbm::is_result($r) > 0) {\r
                notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));\r
                return;\r
        }\r
@@ -127,7 +127,7 @@ function import_account(&$a, $file) {
                notice(t('Error! Cannot check nickname'));\r
                return;\r
        }\r
-       if (count($r) > 0) {\r
+       if (dbm::is_result($r) > 0) {\r
                notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));\r
                return;\r
        }\r
index 989c8b0e049fdb983639cf62c8ce523c81199cbe..ec15d5b1340f722c0e0de3d2910012ec04855e75 100644 (file)
@@ -130,7 +130,7 @@ function create_user($arr) {
                $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
                        dbesc($email)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $result['message'] .= t('Cannot use that email.') . EOL;
        }
 
@@ -143,7 +143,7 @@ function create_user($arr) {
                WHERE `nickname` = '%s' LIMIT 1",
                dbesc($nickname)
        );
-       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,
@@ -153,7 +153,7 @@ function create_user($arr) {
                WHERE `username` = '%s' LIMIT 1",
                dbesc($nickname)
        );
-       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'])) {
@@ -222,7 +222,7 @@ function create_user($arr) {
                        dbesc($username),
                        dbesc($new_password_encoded)
                );
-               if($r !== false && count($r)) {
+               if (dbm::is_result($r)) {
                        $u = $r[0];
                        $newuid = intval($r[0]['uid']);
                }
@@ -283,7 +283,7 @@ function create_user($arr) {
                        intval($newuid),
                        dbesc(t('Friends'))
                );
-               if($r && count($r)) {
+               if (dbm::is_result($r)) {
                        $def_gid = $r[0]['id'];
 
                        q("UPDATE `user` SET `def_gid` = %d WHERE `uid` = %d",
index d3caaff39023107a6e9951449190c02bc8159fd7..45337ea8fca6054206f3b7851a989e474fe0f981 100644 (file)
@@ -396,7 +396,7 @@ class Text_LanguageDetect
      * Returns the list of detectable languages
      *
      * @access public
-     * @return array        the names of the languages known to this object<<<<<<<
+     * @return array        the names of the languages known to this object
      * @throws   Text_LanguageDetect_Exception
      */
     function getLanguages()
index f852bd58d581752802c6c60073ae80014dbf1d58..cf0d8d9ac6bc043481490a3d054f38a758492369 100644 (file)
@@ -1121,7 +1121,7 @@ function admin_page_dbsync(&$a) {
 
        $failed = array();
        $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')
index 03f78e696e2c4946a112dc2aeecd694472e049e8..240aa524be308ea605076fcb250a9da693a7dd42 100644 (file)
@@ -39,7 +39,7 @@ function allfriends_content(&$a) {
 
        $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                $o .= t('No friends to display.');
                return $o;
        }
index da2c40c3055a54b566cfd92bdcaf6a40680b65a0..406ef26c1c76adf22993b14e27da1badd1c87bb8 100644 (file)
@@ -14,7 +14,7 @@ function oauth_get_client($request){
                        AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
                        dbesc($token));
 
-       if (!count($r))
+       if (!dbm::is_result($r))
                return null;
 
        return $r[0];
index 03f850f0d1749972d7e68e63de295007bf856cb5..274acfc2bed8af1f4e23af00eb267e6fa9925cfd 100644 (file)
@@ -16,7 +16,7 @@ function attach_init(&$a) {
        $r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1",
                intval($item_id)
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('Item was not found.'). EOL);
                return;
        }
@@ -29,7 +29,7 @@ function attach_init(&$a) {
                dbesc($item_id)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index 3a229ebadb607d1424e5f9300b20eefac06e1b05..ba43393284767fe744c46c3598b034dd1bc5d1ca 100644 (file)
@@ -132,7 +132,7 @@ function cal_content(&$a) {
                        intval($contact_id),
                        intval($a->profile['profile_uid'])
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $contact = $r[0];
                        $remote_contact = true;
                }
@@ -227,7 +227,7 @@ function cal_content(&$a) {
 
                $links = 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'));
@@ -240,7 +240,7 @@ function cal_content(&$a) {
                $events=array();
 
                // transform the event in a usable array
-               if(count($r))
+               if (dbm::is_result($r))
                        $r = sort_by_date($r);
                        $events = process_events($r);
 
index 063eafe67b90d3a1925f6571abb7325e9351c8e8..9f9379be57d989cc0dff050ab44eafe7ddb11995 100644 (file)
@@ -57,13 +57,13 @@ function common_content(&$a) {
                                dbesc(normalise_link(get_my_url())),
                                intval($profile_uid)
                        );
-                       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(count($r))
+                               if (dbm::is_result($r))
                                        $zcid = $r[0]['id'];
                        }
                }
@@ -94,7 +94,7 @@ function common_content(&$a) {
                $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
 
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                return $o;
        }
 
index c8d1e0c9ddf10505661db79551ea36464b789470..40d4016f338b2b6738c1abc6e3f7666d888e8b0f 100644 (file)
@@ -59,7 +59,7 @@ function community_content(&$a, $update = 0) {
                        AND `item`.`private` = 0 AND `item`.`wall` = 1"
                );
 
-               if(count($r))
+               if (dbm::is_result($r))
                        $a->set_pager_total($r[0]['total']);
 
                if(! $r[0]['total']) {
@@ -71,7 +71,7 @@ function community_content(&$a, $update = 0) {
 
        $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                info( t('No results.') . EOL);
                return $o;
        }
index bf81afe079118767cd83e3917871e6cf34e510ff..4456db2f5326a4ae5bdd7ba5a9dea9dba8fefa0e 100644 (file)
@@ -14,7 +14,7 @@ function contactgroup_content(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
 
@@ -24,7 +24,7 @@ function contactgroup_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        killme();
                }
 
@@ -47,4 +47,4 @@ function contactgroup_content(&$a) {
        }
 
        killme();
-}
\ No newline at end of file
+}
index 1c1c21638d4e2225254debf94d02874ad6845a3f..735ccec727e191599d53282ec2558c4d88afb37b 100644 (file)
@@ -19,7 +19,7 @@ function contacts_init(&$a) {
                        intval(local_user()),
                        intval($contact_id)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        $contact_id = 0;
                }
        }
@@ -169,7 +169,7 @@ function contacts_post(&$a) {
                        intval($profile_id),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Could not locate selected profile.') . EOL);
                        return;
                }
@@ -211,7 +211,7 @@ function contacts_post(&$a) {
                intval($contact_id),
                intval(local_user())
        );
-       if($r && count($r))
+       if($r && dbm::is_result($r))
                $a->data['contact'] = $r[0];
 
        return;
@@ -765,7 +765,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(count($r)) {
+       if (dbm::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
                $total = $r[0]['total'];
        }
@@ -780,8 +780,8 @@ function contacts_content(&$a) {
 
        $contacts = array();
 
-       if(count($r)) {
-               foreach($r as $rr) {
+       if (dbm::is_result($r)) {
+               foreach ($r as $rr) {
                        $contacts[] = _contact_detail_for_template($rr);
                }
        }
index c4b1f2f68f9a51a11d3f13b1e878544b970de9aa..1e2307f553fd52b26348f9b9b0ce42d521e3163a 100644 (file)
@@ -93,7 +93,7 @@ function content_content(&$a, $update = 0) {
                );
 
                $str = '';
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr)
                                $str .= '<' . $rr['id'] . '>';
                if(strlen($str))
@@ -113,7 +113,7 @@ function content_content(&$a, $update = 0) {
                        intval($group),
                        intval($_SESSION['uid'])
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        if($update)
                                killme();
                        notice( t('No such group') . EOL );
@@ -141,7 +141,7 @@ function content_content(&$a, $update = 0) {
                                AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
                        intval($cid)
                );
-               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 ) ";
 
                }
@@ -197,7 +197,7 @@ function content_content(&$a, $update = 0) {
        }
 
        if($conv) {
-               $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+               $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
                $myurl = substr($myurl,strpos($myurl,'://')+3);
                $myurl = str_replace('www.','',$myurl);
                $diasp_url = str_replace('/profile/','/u/',$myurl);
@@ -259,7 +259,7 @@ function content_content(&$a, $update = 0) {
                $parents_arr = array();
                $parents_str = '';
 
-               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'];
@@ -782,7 +782,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
                                                        intval($item['uid']),
                                                        intval($item['id'])
                                                );
-                                               if (count($r)) {
+                                               if (dbm::is_result($r)) {
                                                        $ignore = array(
                                                                'do' => t("ignore thread"),
                                                                'undo' => t("unignore thread"),
index 3abbe343b26d0d09709fe0bcd9f3e47a50ab9757..b4275f6baa2d4f2a709c57a25de218b6265778c8 100644 (file)
@@ -14,7 +14,7 @@ function crepair_init(&$a) {
                        intval(local_user()),
                        intval($contact_id)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        $contact_id = 0;
                }
        }
@@ -43,7 +43,7 @@ function crepair_post(&$a) {
                );
        }
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                return;
 
        $contact = $r[0];
@@ -110,7 +110,7 @@ function crepair_content(&$a) {
                );
        }
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
index 20d2e605e0a2d91c90e1d664567037d6baf1902d..71628aed0ed4d535854de2a60c90fb0855bbf8c7 100644 (file)
@@ -26,12 +26,12 @@ function delegate_content(&$a) {
                $r = q("select `nickname` from user where uid = %d limit 1",
                        intval($id)
                );
-               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(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 @@ function delegate_content(&$a) {
                dbesc($a->user['email']),
                dbesc($a->user['password'])
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $full_managers = $r;
 
        $delegates = array();
@@ -75,7 +75,7 @@ function delegate_content(&$a) {
                intval(local_user())
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                $delegates = $r;
 
        $uids = array();
@@ -97,14 +97,14 @@ function delegate_content(&$a) {
                dbesc(NETWORK_DFRN)
        ); 
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('No potential page delegates located.') . EOL);
                return;
        }
 
        $nicknames = array();
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
                }
@@ -118,7 +118,7 @@ function delegate_content(&$a) {
 
        $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
 
-       if(count($r))
+       if (dbm::is_result($r))
                foreach($r as $rr)
                        if(! in_array($rr['uid'],$uids))
                                $potentials[] = $rr;
index 5aea4eede967524f4b093dd04657aebadb985479..23c62cb0ab25d127c8c0fd1037a6a998c69e5a03 100644 (file)
@@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        intval($uid)
                );
 
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        logger('Contact not found in DB.');
                        notice( t('Contact not found.') . EOL );
                        notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
@@ -423,7 +423,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($contact_id)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $contact = $r[0];
                else
                        $contact = null;
@@ -443,7 +443,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                                intval($uid)
                        );
 
-                       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');
 
@@ -553,7 +553,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
                        dbesc($node));
 
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        $message = sprintf(t('No user record found for \'%s\' '), $node);
                        xml_status(3,$message); // failure
                        // NOTREACHED
@@ -629,7 +629,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
                        dbesc($decrypted_dfrn_id)
                );
-               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
@@ -640,7 +640,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        dbesc($dfrn_pubkey),
                        intval($dfrn_record)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        $message = t('Unable to set your contact credentials on our system.');
                        xml_status(3,$message);
                }
@@ -661,7 +661,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($dfrn_record));
 
-               if(count($r))
+               if (dbm::is_result($r))
                        $photo = $r[0]['photo'];
                else
                        $photo = $a->get_baseurl() . '/images/person-175.jpg';
@@ -714,10 +714,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        intval($dfrn_record)
                );
 
-               if(count($r))
+               if (dbm::is_result($r))
                        $combined = $r[0];
 
-               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,
@@ -742,7 +742,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                                intval($local_uid)
                        );
 
-                       if((count($r)) && ($r[0]['hide-friends'] == 0)) {
+                       if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
 
                                require_once('include/items.php');
 
index 6f6fc41c12d28078290c9bd85cc66f9dd01cc5db..dfa2af18ce29985901409d3d3149879811a7b8e7 100644 (file)
@@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) {
                dbesc($dfrn_id),
                dbesc($challenge)
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
                xml_status(3);
        }
@@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) {
                dbesc($a->argv[1])
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
                xml_status(3);
                //NOTREACHED
@@ -284,7 +284,7 @@ function dfrn_notify_content(&$a) {
                                dbesc($a->argv[1])
                );
 
-               if(! count($r))
+               if(! dbm::is_result($r))
                        $status = 1;
 
                logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);
index 9613229dab04e3381f63a657448acb447f55e6ca..91cd33f49abf66e1475448aaec6a630914da2594 100644 (file)
@@ -79,7 +79,7 @@ function dfrn_poll_init(&$a) {
                        dbesc($a->argv[1])
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
 
@@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) {
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
-                       if(! count($r)) {
+                       if(! dbm::is_result($r)) {
                                xml_status(3, 'No ticket');
                                // NOTREACHED
                        }
@@ -190,7 +190,7 @@ function dfrn_poll_init(&$a) {
                        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(count($r)) {
+                       if (dbm::is_result($r)) {
                                xml_status(1);
                                return; // NOTREACHED
                        }
@@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) {
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
-                       if(! count($r)) {
+                       if(! dbm::is_result($r)) {
                                xml_status(3, 'No ticket');
                                // NOTREACHED
                        }
@@ -284,7 +284,7 @@ function dfrn_poll_post(&$a) {
                dbesc($challenge)
        );
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        $type = $r[0]['type'];
@@ -319,7 +319,7 @@ function dfrn_poll_post(&$a) {
        $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
 
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        $contact = $r[0];
@@ -335,7 +335,7 @@ function dfrn_poll_post(&$a) {
                $reputation = 0;
                $text = '';
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $reputation = $r[0]['rating'];
                        $text = $r[0]['reason'];
 
@@ -448,7 +448,7 @@ function dfrn_poll_content(&$a) {
                        dbesc($nickname)
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $challenge = '';
                        $encrypted_id = '';
@@ -495,7 +495,7 @@ function dfrn_poll_content(&$a) {
                                ));
                        }
 
-                       $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 d7566905b72f6291f64a7c0ce989f854a34416ad..236970a2e9d8c0bb91ed250b9e9f312b0df7a129 100644 (file)
@@ -91,7 +91,7 @@ function dfrn_request_post(&$a) {
                                        dbesc(normalise_link($dfrn_url))
                                );
 
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        if(strlen($r[0]['dfrn-id'])) {
 
                                                /*
@@ -185,7 +185,7 @@ function dfrn_request_post(&$a) {
                                        dbesc($dfrn_url),
                                        $parms['key'] // this was already escaped
                                );
-                               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);
@@ -273,7 +273,7 @@ function dfrn_request_post(&$a) {
                                dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
                                intval($uid)
                        );
-                       if(count($r) > $maxreq) {
+                       if (dbm::is_result($r) && count($r) > $maxreq) {
                                notice( sprintf( t('%s has received too many connection requests today.'),  $a->profile['name']) . EOL);
                                notice( t('Spam protection measures have been invoked.') . EOL);
                                notice( t('Friends are advised to please try again in 24 hours.') . EOL);
@@ -295,7 +295,7 @@ function dfrn_request_post(&$a) {
                        AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
                        dbesc(NETWORK_MAIL2)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if(! $rr['rel']) {
                                        q("DELETE FROM `contact` WHERE `id` = %d",
@@ -320,7 +320,7 @@ function dfrn_request_post(&$a) {
                        AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
                        dbesc(NETWORK_MAIL2)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if(! $rr['rel']) {
                                        q("DELETE FROM `contact` WHERE `id` = %d",
@@ -370,8 +370,8 @@ function dfrn_request_post(&$a) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval($uid)
                                );
-                               if(! count($r)) {
 
+                               if(! dbm::is_result($r)) {
                                        notice( t('This account has not been configured for email. Request failed.') . EOL);
                                        return;
                                }
@@ -398,7 +398,7 @@ function dfrn_request_post(&$a) {
                                dbesc($poll),
                                intval($uid)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $contact_id = $r[0]['id'];
 
                                $def_gid = get_default_group($uid, $r[0]["network"]);
@@ -431,8 +431,8 @@ function dfrn_request_post(&$a) {
 
                        $hash = random_string();
 
-                       $r = q("insert into intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked )
-                               values( %d , %d, %d, '%s', '%s', '%s', %d ) ",
+                       $r = q("INSERT INTO `intro` ( `uid`, `contact-id`, knowyou, note, hash, datetime, blocked )
+                               VALUES( %d , %d, %d, '%s', '%s', '%s', %d ) ",
                                intval($uid),
                                intval($contact_id),
                                ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
@@ -473,7 +473,7 @@ function dfrn_request_post(&$a) {
                                dbesc($url)
                        );
 
-                       if(count($ret)) {
+                       if (dbm::is_result($ret)) {
                                if(strlen($ret[0]['issued-id'])) {
                                        notice( t('You have already introduced yourself here.') . EOL );
                                        return;
@@ -572,7 +572,7 @@ function dfrn_request_post(&$a) {
                                                $parms['url'],
                                                $parms['issued-id']
                                        );
-                                       if(count($r)) {
+                                       if (dbm::is_result($r)) {
                                                $contact_record = $r[0];
                                                update_contact_avatar($photo, $uid, $contact_record["id"], true);
                                        }
@@ -720,7 +720,7 @@ function dfrn_request_content(&$a) {
                        dbesc($_GET['confirm_key'])
                );
 
-               if(count($intro)) {
+               if (dbm::is_result($intro)) {
 
                        $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
                                WHERE `contact`.`id` = %d LIMIT 1",
@@ -729,7 +729,7 @@ function dfrn_request_content(&$a) {
 
                        $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;
 
@@ -742,7 +742,7 @@ function dfrn_request_content(&$a) {
                                                'to_name'      => $r[0]['username'],
                                                'to_email'     => $r[0]['email'],
                                                'uid'          => $r[0]['uid'],
-                                               'link'             => $a->get_baseurl() . '/notifications/intros',
+                                               'link'         => $a->get_baseurl() . '/notifications/intros',
                                                'source_name'  => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
                                                'source_link'  => $r[0]['url'],
                                                'source_photo' => $r[0]['photo'],
@@ -754,11 +754,11 @@ function dfrn_request_content(&$a) {
                                if($auto_confirm) {
                                        require_once('mod/dfrn_confirm.php');
                                        $handsfree = array(
-                                               'uid' => $r[0]['uid'],
-                                               'node' => $r[0]['nickname'],
-                                               'dfrn_id' => $r[0]['issued-id'],
+                                               'uid'      => $r[0]['uid'],
+                                               'node'     => $r[0]['nickname'],
+                                               'dfrn_id'  => $r[0]['issued-id'],
                                                'intro_id' => $intro[0]['id'],
-                                               'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
+                                               'duplex'   => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
                                                'activity' => intval(get_pconfig($r[0]['uid'],'system','post_newfriend'))
                                        );
                                        dfrn_confirm_post($a,$handsfree);
@@ -842,7 +842,7 @@ function dfrn_request_content(&$a) {
                        $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                intval($a->profile['uid'])
                        );
-                       if(! count($r))
+                       if(! dbm::is_result($r))
                                $mail_disabled = 1;
                }
 
index 06aeec622fffb5d0af21d163b12edeb8f6c6bae3..ddea650de2b5796e8c7dbd065c28f44913ba38ad 100644 (file)
@@ -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(count($r))
+       if (dbm::is_result($r))
                $a->set_pager_total($r[0]['total']);
 
        $order = " ORDER BY `name` ASC ";
@@ -90,7 +90,7 @@ function directory_content(&$a) {
                        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(count($r)) {
+       if (dbm::is_result($r)) {
 
                if(in_array('small', $a->argv))
                        $photo = 'thumb';
index 46a530dce09f49ec5da5058364aac0b88f4fe6df..217d793f5225541fc44745203a02a77f9b307885 100644 (file)
@@ -78,7 +78,7 @@ function editpost_content(&$a) {
                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                        intval(local_user())
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $mail_enabled = true;
                        if(intval($r[0]['pubmail']))
                                $pubmail_enabled = true;
index 16679ff7e7b47d952ea09b1ff87ce6304376cf1a..7cb171f9e5cc65cc1c011699fc4e3ac985da5fb5 100644 (file)
@@ -332,7 +332,7 @@ function events_content(&$a) {
 
                $links = 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'));
@@ -344,9 +344,10 @@ function events_content(&$a) {
                $events=array();
 
                // transform the event in a usable array
-               if(count($r))
+               if (dbm::is_result($r)) {
                        $r = sort_by_date($r);
                        $events = process_events($r);
+               }
 
                if ($a->argv[1] === 'json'){
                        echo json_encode($events); killme();
@@ -403,7 +404,7 @@ function events_content(&$a) {
                        intval($event_id),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $orig_event = $r[0];
        }
 
index 110ca9585c9d2e5ff0e346aaf4ad4328afffadd7..11ac2d82531bf76c5ba3969ac82b3a8bc5514f23 100644 (file)
@@ -63,7 +63,7 @@ function fbrowser_content($a){
                        );
 
                        function _map_files1($rr){
-                               global $a;
+                               $a = get_app();
                                $types = Photo::supportedTypes();
                                $ext = $types[$rr['type']];
 
@@ -110,7 +110,8 @@ function fbrowser_content($a){
                                        intval(local_user())
                                );
 
-                               function _map_files2($rr){ global $a;
+                               function _map_files2($rr){
+                                       $a = get_app();
                                        list($m1,$m2) = explode("/",$rr['filetype']);
                                        $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
 
index 1c73ad37185234328952834fa042bc0f237a8aa3..04bdf518804a84ee49b6da109391b3076feceda4 100644 (file)
@@ -6,7 +6,9 @@ require_once("include/crypto.php");
 require_once("include/diaspora.php");
 require_once("include/xml.php");
 
-function fetch_init($a){
+/// @TODO You always make it like this: function foo(&$a)
+/// @TODO This means that the value of $a can be changed in anything, remove & and use App as type-hint
+function fetch_init(&$a){
 
        if (($a->argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
index aad5964baf6e5d1ddf737e88f46b636cb255d6d7..fb25f40e451cce134059c9e6e60a89f6cbdcaa6f 100644 (file)
@@ -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(count($r))
+                       if (dbm::is_result($r))
                                foreach($r as $rr)
                                        $visible_plugins[] = $rr['name'];
                }
@@ -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(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr)
                                $visible_plugins[] = $rr['name'];
        }
index ad407d5f32a0ca80552fbe36a02e638296282d25..1d56f4573625f175e1e4f9f24adb93bda97c6eb6 100644 (file)
@@ -16,7 +16,7 @@ function fsuggest_post(&$a) {
                intval($contact_id),
                intval(local_user())
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
@@ -33,7 +33,7 @@ function fsuggest_post(&$a) {
                        intval($new_contact),
                        intval(local_user())
                );
-               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 @@ function fsuggest_post(&$a) {
                                dbesc($hash),
                                intval(local_user())
                        );
-                       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),
@@ -88,7 +88,7 @@ function fsuggest_content(&$a) {
                intval($contact_id),
                intval(local_user())
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
index 5b28784f5663cc1b7056125b26619416e9e76b6d..db92ed7de6fb19f1102d6ad4594e6c7c8581d7ba 100644 (file)
@@ -43,7 +43,7 @@ function group_post(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Group not found.') . EOL );
                        goaway($a->get_baseurl() . '/contacts');
                        return; // NOTREACHED
@@ -107,7 +107,7 @@ function group_content(&$a) {
                                intval($a->argv[2]),
                                intval(local_user())
                        );
-                       if(count($r))
+                       if (dbm::is_result($r))
                                $result = group_rmv(local_user(),$r[0]['name']);
                        if($result)
                                info( t('Group removed.') . EOL);
@@ -125,7 +125,7 @@ function group_content(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
 
@@ -136,7 +136,7 @@ function group_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Group not found.') . EOL );
                        goaway($a->get_baseurl() . '/contacts');
                }
@@ -209,7 +209,7 @@ function group_content(&$a) {
                intval(local_user())
        );
 
-       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)) {
index e876b4ef8b929ebb0ba661687b4baf04ea63697d..ba55c55e368925648bad537fec37fe8ede477a8e 100644 (file)
@@ -16,7 +16,7 @@ function ignored_init(&$a) {
                intval(local_user()),
                intval($message_id)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        if(! intval($r[0]['ignored']))
index 97092c140f2f58ef9bd035d1008e5123a0be1f4f..b5af1373a443703b7ec35b862cc4cf84fdbc5c66 100755 (executable)
@@ -165,7 +165,7 @@ function install_content(&$a) {
 
        if($db && $db->connected) {
                $r = q("SELECT COUNT(*) as `total` FROM `user`");
-               if($r && count($r) && $r[0]['total']) {
+               if (dbm::is_result($r) && $r[0]['total']) {
                        $tpl = get_markup_template('install.tpl');
                        return replace_macros($tpl, array(
                                '$title' => $install_title,
index 170bed12a53d6055e3ac2aedb51acf4728744665..9ef82616c35a42adae5326606a30345c317bf660 100644 (file)
@@ -102,7 +102,7 @@ function item_post(&$a) {
                }
 
                // if this isn't the real parent of the conversation, find it
-               if($r !== false && count($r)) {
+               if (dbm::is_result($r)) {
                        $parid = $r[0]['parent'];
                        $parent_uri = $r[0]['uri'];
                        if($r[0]['id'] != $r[0]['parent']) {
@@ -112,7 +112,7 @@ function item_post(&$a) {
                        }
                }
 
-               if(($r === false) || (! count($r))) {
+               if(! dbm::is_result($r)) {
                        notice( t('Unable to locate original post.') . EOL);
                        if(x($_REQUEST,'return'))
                                goaway($return_path);
@@ -141,7 +141,7 @@ function item_post(&$a) {
 
                                $r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
                                        dbesc(normalise_link($thrparent[0]["author-link"])));
-                               if (count($r)) {
+                               if (dbm::is_result($r)) {
                                        $parent_contact = $r[0];
                                        $parent_contact["thumb"] = $parent_contact["photo"];
                                        $parent_contact["micro"] = $parent_contact["photo"];
@@ -330,7 +330,7 @@ function item_post(&$a) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                        intval(local_user())
                                );
-                               if(count($r) && intval($r[0]['pubmail']))
+                               if (dbm::is_result($r) && intval($r[0]['pubmail']))
                                        $pubmail_enabled = true;
                        }
                }
@@ -464,7 +464,7 @@ function item_post(&$a) {
                                        intval($profile_uid)
                                );
 
-                               if(! count($r))
+                               if(! dbm::is_result($r))
                                        continue;
 
                                $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
index 0ae54c8c125f92d07616113a7b52865e3d61fed1..c806fc317550b4d8e1f82ef4ee40fddf178855f0 100644 (file)
@@ -21,7 +21,7 @@ function lockview_content(&$a) {
                dbesc($type),
                intval($item_id)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
        $item = $r[0];
 
@@ -52,7 +52,7 @@ function lockview_content(&$a) {
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        dbesc(implode(', ', $allowed_groups))
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<b>' . $rr['name'] . '</b>';
        }
@@ -60,7 +60,7 @@ function lockview_content(&$a) {
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
                        dbesc(implode(', ',$allowed_users))
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = $rr['name'];
 
@@ -70,7 +70,7 @@ function lockview_content(&$a) {
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        dbesc(implode(', ', $deny_groups))
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
        }
@@ -78,7 +78,7 @@ function lockview_content(&$a) {
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
                        dbesc(implode(', ',$deny_users))
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr) 
                                $l[] = '<strike>' . $rr['name'] . '</strike>';
 
index 938d1cbb008ada25359cf6a68514760a2d98fc6f..3dca3a8b81d51d80137b25c86408a3257094d7e8 100644 (file)
@@ -15,7 +15,7 @@ function lostpass_post(&$a) {
                dbesc($loginame)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('No valid account found.') . EOL);
                goaway(z_root());
        }
@@ -88,7 +88,7 @@ function lostpass_content(&$a) {
                $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
                        dbesc($hash)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        $o =  t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.");
                        return $o;
                }
index adcc3d787aac0d58563cbd5d38e82e50384498d2..66891db720a540fbe659644b4a25a7d0d85b23be 100644 (file)
@@ -15,7 +15,7 @@ function manage_post(&$a) {
                $r = q("select * from user where uid = %d limit 1",
                        intval($_SESSION['submanage'])
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $uid = intval($r[0]['uid']);
                        $orig_record = $r[0];
                }
@@ -56,7 +56,7 @@ function manage_post(&$a) {
                );
        }
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                return;
 
        unset($_SESSION['authenticated']);
index 33e07c91ce40fbcf9614d0aca83040756c49c8b0..f7fe325b3868937786e2b2cc9fd9728c849babd4 100644 (file)
@@ -27,7 +27,7 @@ function match_content(&$a) {
        $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
                intval(local_user())
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                return;
        if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
                notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
index 4bd73d0cee9d36da73e625d467457843d4a4fe2a..9bd5b0d72278bf0367cf79f4c3c7c59454924c17 100644 (file)
@@ -242,7 +242,7 @@ function message_content(&$a) {
                                intval($a->argv[2]),
                                intval(local_user())
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $parent = $r[0]['parent-uri'];
                                $convid = $r[0]['convid'];
 
@@ -309,19 +309,21 @@ function message_content(&$a) {
                                intval(local_user()),
                                intval($a->argv[2])
                        );
-                       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'];
@@ -405,7 +407,7 @@ function message_content(&$a) {
                        intval(local_user()),
                        intval($a->argv[1])
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $contact_id = $r[0]['contact-id'];
                        $convid = $r[0]['convid'];
 
index bba2c2882d065e5fc2320f5ed8582718f5940b9a..d1dabb101b3834aec9d7ef9cbfe5f0d15e5e3920 100644 (file)
@@ -12,7 +12,7 @@ function modexp_init(&$a) {
                        dbesc($nick)
        );
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        $lines = explode("\n",$r[0]['spubkey']);
index f804af0c00819ec0d9ed93714867e44b49396502..c64dd0d9efbe2ae3baa68618d8c0c774115ea9a4 100644 (file)
@@ -36,7 +36,7 @@ function mood_init(&$a) {
                        intval($parent),
                        intval($uid)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $parent_uri = $r[0]['uri'];
                        $private    = $r[0]['private'];
                        $allow_cid  = $r[0]['allow_cid'];
index 89de5b70576f354653ad4daf8645d5aa5b843876..43b200ddf84ecaf7a3abbc16fcaca0056e57a583 100644 (file)
@@ -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 (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)
        );
 
-       $results = array();
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        $results[] = array(
                                'name' => $rr['name'], 
@@ -39,4 +41,4 @@ function msearch_post(&$a) {
 
        killme();
 
-}
\ No newline at end of file
+}
index cafaa11aecca87d53a91943556020f0185b3d977..9cfeda1026b9e8e3f51f8cadaa1a0f4c758e2d82 100644 (file)
@@ -126,7 +126,7 @@ function network_init(&$a) {
                        intval(local_user()),
                        dbesc($search)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
                                intval(local_user()),
                                dbesc($search)
@@ -182,7 +182,7 @@ function saved_searches($search) {
 
        $saved = array();
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $saved[] = array(
                                'id'            => $rr['id'],
@@ -381,7 +381,7 @@ function network_content(&$a, $update = 0) {
                );
 
                $str = '';
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $rr)
                                $str .= '<' . $rr['id'] . '>';
                if(strlen($str))
@@ -463,7 +463,7 @@ function network_content(&$a, $update = 0) {
                        intval($group),
                        intval($_SESSION['uid'])
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        if($update)
                                killme();
                        notice( t('No such group') . EOL );
@@ -507,7 +507,7 @@ function network_content(&$a, $update = 0) {
                                AND (NOT `blocked` OR `pending`) LIMIT 1",
                        intval($cid)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
 
                        $entries[0] = array(
@@ -609,7 +609,7 @@ function network_content(&$a, $update = 0) {
                                intval($_SESSION['uid'])
                        );
 
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $a->set_pager_total($r[0]['total']);
                        }
                }
@@ -705,7 +705,7 @@ function network_content(&$a, $update = 0) {
                $parents_str = '';
                $date_offset = "";
 
-               if(dbm::is_result($r)) {
+               if (dbm::is_result($r)) {
                        foreach($r as $rr)
                                if(! in_array($rr['item_id'],$parents_arr))
                                        $parents_arr[] = $rr['item_id'];
@@ -729,7 +729,9 @@ function network_content(&$a, $update = 0) {
                                        intval($parents),
                                        intval($max_comments + 1)
                                );
-                               $items = array_merge($items, $thread_items);
+       
+                               if (dbm::is_result($thread_items))
+                                       $items = array_merge($items, $thread_items);
                        }
                        $items = conv_sort($items,$ordering);
                } else {
index 2f0985c9dbba0db74ae2be74bfc4d31a110c0f6d..0a014c067668daf5c2a40c34b79bec944fae3137 100644 (file)
@@ -28,11 +28,11 @@ function nogroup_content(&$a) {
 
        require_once('include/Contact.php');
        $r = contacts_not_grouped(local_user());
-       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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
 
                        $contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
index 2a04605469b845745755b2bce39eb3a5f9472972..537aff878f8e79ab81f7453ce4b27b7ff53410f0 100644 (file)
@@ -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(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
@@ -53,7 +53,7 @@ function noscrape_init(&$a) {
                        dbesc(NETWORK_DIASPORA),
                        dbesc(NETWORK_OSTATUS)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $json_info["contacts"] = intval($r[0]['total']);
        }
 
index a25d090ed701faad32ab49fb2dbc7012b13d8e2f..74ab18a6f95f0aeeb16418b584709163a471c981 100644 (file)
@@ -82,7 +82,7 @@ function notes_content(&$a,$update = false) {
 
        );
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
                $a->set_pager_itemspage(40);
        }
@@ -102,7 +102,7 @@ function notes_content(&$a,$update = false) {
        $parents_arr = array();
        $parents_str = '';
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        $parents_arr[] = $rr['item_id'];
                $parents_str = implode(', ', $parents_arr);
@@ -116,7 +116,7 @@ function notes_content(&$a,$update = false) {
                        dbesc($parents_str)
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $items = conv_sort($r,"`commented`");
 
                        $o .= conversation($a,$items,'notes',$update);
index 19cf53189a1476dfb9795026ab9b23139ad0160f..7fdf4493a4f5cf30a801f4c0008df1c8970d2fa9 100644 (file)
@@ -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 (count($r)){
+               if (dbm::is_result($r)){
                        $nick = $r[0]['nickname'];
                        $url = $a->get_baseurl()."/display/$nick/$id";
                        goaway($url);
index af44097c1cb42a508c3267665d37b8fd2de8c52e..3e0bd9cc47d715e79adefe574436f97ff5465238 100644 (file)
@@ -27,7 +27,7 @@ function notifications_post(&$a) {
                        intval(local_user())
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $intro_id = $r[0]['id'];
                        $contact_id = $r[0]['contact-id'];
                }
@@ -305,7 +305,6 @@ function notifications_content(&$a) {
                        $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
        }
 
-
        $o .= replace_macros($notif_tpl, array(
                '$notif_header' => $notif_header,
                '$tabs' => $tabs,
index 938e2ffbe35a908a79162b2a4c692a1d9a0d228c..dceb326a4bdd260faa34824d2350edfac52f8ab6 100644 (file)
@@ -47,7 +47,7 @@ function notify_content(&$a) {
        require_once('include/bbcode.php');
 
        $r = $nm->getAll(array('seen'=>0));
-       if ($r!==false && count($r) > 0) {
+       if (dbm::is_result($r) > 0) {
                foreach ($r as $it) {
                        $notif_content .= replace_macros($not_tpl,array(
                                '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
index 0ebda485d023a5cf090aed7138a824538f71e7f1..60a9c1381b083e5322be743bf4241ac0169887d2 100644 (file)
@@ -38,7 +38,7 @@ function openid_content(&$a) {
                                dbesc($authid), dbesc(normalise_openid($authid))
                        );
 
-                       if($r && count($r)) {
+                       if (dbm::is_result($r)) {
 
                                // successful OpenID login
 
index 8da044e9323916e742b2b1bb24404fefe854acdf..4db8f552962c9f8504c4a6ed1ea3c29971c6de42 100644 (file)
--- a/mod/p.php
+++ b/mod/p.php
@@ -48,7 +48,7 @@ function p_init($a){
        $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();
        }
index 0d60282d5ffc19f7fa39d93f9edfb12722ba25dc..a94a3ac2ce57eb97f260689e6cb699b2766ce94f 100644 (file)
@@ -76,7 +76,7 @@ function photo_init(&$a) {
                        intval($resolution),
                        intval($uid)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $data = $r[0]['data'];
                        $mimetype = $r[0]['type'];
                }
@@ -106,7 +106,7 @@ function photo_init(&$a) {
                        dbesc($photo),
                        intval($resolution)
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $sql_extra = permissions_sql($r[0]['uid']);
 
@@ -117,9 +117,9 @@ function photo_init(&$a) {
                                intval($resolution)
                        );
 
-                       $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)) AND ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid']  == '') AND ($r[0]['deny_gid']  == '');
 
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $resolution = $r[0]['scale'];
                                $data = $r[0]['data'];
                                $mimetype = $r[0]['type'];
index d72a824827dac3f6daabc5f2a24ce4044222d454..24cc8fabbb28b7d25607870d4fd25f9e21da3ea9 100644 (file)
@@ -165,7 +165,7 @@ function photos_post(&$a) {
                intval($page_owner_uid)
        );
 
-       if (! count($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Contact information unavailable') . EOL);
                logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
                killme();
@@ -186,7 +186,7 @@ function photos_post(&$a) {
                        dbesc($album),
                        intval($page_owner_uid)
                );
-               if (! count($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Album not found.') . EOL);
                        goaway($_SESSION['photo_return']);
                        return; // NOTREACHED
@@ -255,7 +255,7 @@ function photos_post(&$a) {
                                );
                        }
                        if (dbm::is_result($r)) {
-                               foreach ($r as $rr) {
+                               foreach($r as $rr) {
                                        $res[] = "'" . dbesc($rr['rid']) . "'" ;
                                }
                        } else {
@@ -277,7 +277,7 @@ function photos_post(&$a) {
                                intval($page_owner_uid)
                        );
                        if (dbm::is_result($r)) {
-                               foreach ($r as $rr) {
+                               foreach($r as $rr) {
                                        q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
                                                dbesc(datetime_convert()),
                                                dbesc($rr['parent-uri']),
@@ -748,7 +748,7 @@ function photos_post(&$a) {
                dbesc($album),
                intval($page_owner_uid)
        );
-       if ((! count($r)) || ($album == t('Profile Photos')))
+       if ((! dbm::is_result($r)) || ($album == t('Profile Photos')))
                $visible = 1;
        else
                $visible = 0;
@@ -1573,7 +1573,7 @@ function photos_content(&$a) {
                        }
 
                        $comments = '';
-                       if (! count($r)) {
+                       if (! dbm::is_result($r)) {
                                if ($can_post || can_write_wall($a,$owner_uid)) {
                                        if ($link_item['last-child']) {
                                                $comments .= replace_macros($cmnt_tpl,array(
@@ -1809,8 +1809,6 @@ function photos_content(&$a) {
                intval($a->pager['itemspage'])
        );
 
-
-
        $photos = array();
        if (dbm::is_result($r)) {
                $twist = 'rotright';
index 7e20b9383d6788cb68bf8c6a08c060a87ee46f36..1ef3cc5b4732b95eeeb396efe1f3beb711a6886e 100644 (file)
@@ -175,7 +175,7 @@ function ping_init(App $a)
                );
 
                $intro_count = count($intros1) + count($intros2);
-               $intros = $intros1+$intros2;
+               $intros = $intros1 + $intros2;
 
                $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
                $mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
@@ -189,7 +189,8 @@ function ping_init(App $a)
                        $regs = qu("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total`
                                FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
                                WHERE `contact`.`self` = 1");
-                       if ($regs) {
+
+                       if (dbm::is_result($regs)) {
                                $register_count = $regs[0]['total'];
                        }
                }
index 1ec5b2d4e1b07e1c91157cfadc31c28e59c30d14..e454d1e668fce7deeea29a82c5017c1eb4719d88 100644 (file)
@@ -45,7 +45,7 @@ function poco_init(&$a) {
                        where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1",
                        dbesc($user)
                );
-               if(! count($r) || $r[0]['hidewall'] || $r[0]['hide-friends'])
+               if(! dbm::is_result($r) || $r[0]['hidewall'] || $r[0]['hide-friends'])
                        http_status_exit(404);
 
                $user = $r[0];
@@ -83,7 +83,7 @@ function poco_init(&$a) {
                        dbesc(NETWORK_STATUSNET)
                );
        }
-       if(count($r))
+       if (dbm::is_result($r))
                $totalResults = intval($r[0]['total']);
        else
                $totalResults = 0;
@@ -173,7 +173,7 @@ function poco_init(&$a) {
        }
 
        if(is_array($r)) {
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        foreach($r as $rr) {
                                if (!isset($rr['generation'])) {
                                        if ($global)
index 435da4dcd4facd27229767709633724529c690be..8102c3697da787e63983e3b753883e52f6bbf4f3 100644 (file)
@@ -52,7 +52,7 @@ function poke_init(&$a) {
                intval($uid)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('poke: no contact ' . $contact_id);
                return;
        }
@@ -66,7 +66,7 @@ function poke_init(&$a) {
                        intval($parent),
                        intval($uid)
                );
-               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 @@ function poke_content(&$a) {
                        intval($_GET['c']),
                        intval(local_user())
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $name = $r[0]['name'];
                        $id = $r[0]['id'];
                }
index c0e783a6aaded3cb6ea126bfd177eb50cb76e4df..76282d29a5390bf706d59957dc9e40769f7830cb 100644 (file)
@@ -23,7 +23,7 @@ function post_post(&$a) {
                                AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($nickname)
                );
-               if(! count($r))
+               if(! dbm::is_result($r))
                        http_status_exit(500);
 
                $importer = $r[0];
index 279f8635231591e8e2444fa54453aa12169023bc..5ab675dd0d589d6c1b9a4f539d217be025dc54cd 100644 (file)
@@ -13,7 +13,7 @@ function profile_init(&$a) {
                $which = htmlspecialchars($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(count($r)) {
+               if (dbm::is_result($r)) {
                        goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
                }
                else {
@@ -136,7 +136,7 @@ function profile_content(&$a, $update = 0) {
                        intval($contact_id),
                        intval($a->profile['profile_uid'])
                );
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        $contact = $r[0];
                        $remote_contact = true;
                }
@@ -256,21 +256,21 @@ function profile_content(&$a, $update = 0) {
                            AND `thread`.`wall` = 1
                            $sql_extra $sql_extra2 ",
                            intval($a->profile['profile_uid'])
-                   );
+                       );
 
-               if(count($r)) {
-                       $a->set_pager_total($r[0]['total']);
+                       if (dbm::is_result($r)) {
+                               $a->set_pager_total($r[0]['total']);
                        }
                }
 
                //  check if we serve a mobile device and get the user settings
                //  accordingly
                if ($a->is_mobile) {
-                   $itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
-                   $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 10);
+                       $itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
+                       $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 10);
                } else {
-                   $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
-                   $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
+                       $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
+                       $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
                }
                //  now that we have the user settings, see if the theme forces
                //  a maximum item number which is lower then the user choice
index 11e671afc58a2f58e5ef51655d55a473e78aa708..20bbbbcbd41e98d2400782cafd71ff7a53576da0 100644 (file)
@@ -32,7 +32,7 @@ function profile_photo_post(&$a) {
                                intval($_REQUEST['profile']),
                                intval(local_user())
                        );
-                       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 @@ function profile_photo_post(&$a) {
                        dbesc(local_user()),
                        intval($scale));
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $base_image = $r[0];
 
@@ -195,7 +195,7 @@ function profile_photo_content(&$a) {
                        intval(local_user()),
                        dbesc($resource_id)
                        );
-               if (!count($r)){
+               if (!dbm::is_result($r)){
                        notice( t('Permission denied.') . EOL );
                        return;
                }
index 943742e3a2edfd7dfbc076656fafd5fa43595d59..f9fde658d2a9766d0a825b2a36928563065a3287 100644 (file)
@@ -15,7 +15,7 @@ function profiles_init(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        goaway('profiles');
                        return; // NOTREACHED
@@ -130,7 +130,7 @@ function profiles_init(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        killme();
                        return;
@@ -286,7 +286,7 @@ function profiles_post(&$a) {
                                                        intval(local_user())
                                                );
                                        }
-                                       if(count($r)) {
+                                       if (dbm::is_result($r)) {
                                                $prf = $r[0]['url'];
                                                $newname = $r[0]['name'];
                                        }
@@ -613,7 +613,7 @@ function profiles_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        return;
                }
@@ -767,7 +767,7 @@ function profiles_content(&$a) {
                                "SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
                                local_user()
                        );
-                       if(count($r)){
+                       if (dbm::is_result($r)){
                                //Go to the default profile.
                                goaway('profiles/'.$r[0]['id']);
                        }
@@ -775,7 +775,7 @@ function profiles_content(&$a) {
 
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                        local_user());
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $tpl = get_markup_template('profile_entry.tpl');
                        foreach($r as $rr) {
index 077f695bea14c15be10f592258847bcd6e3d1198..1c37f84ab2fca78f9703d2c74ac9075d7eeee380 100644 (file)
@@ -42,7 +42,7 @@ function profperm_content(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $change = intval($a->argv[2]);
        }
 
@@ -52,7 +52,7 @@ function profperm_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        notice( t('Invalid profile identifier.') . EOL );
                        return;
                }
@@ -64,7 +64,7 @@ function profperm_content(&$a) {
                );
 
                $ingroup = array();
-               if(count($r))
+               if (dbm::is_result($r))
                        foreach($r as $member)
                                $ingroup[] = $member['id'];
 
@@ -94,7 +94,7 @@ function profperm_content(&$a) {
                        $members = $r;
 
                        $ingroup = array();
-                       if(count($r))
+                       if (dbm::is_result($r))
                                foreach($r as $member)
                                        $ingroup[] = $member['id'];
                }
@@ -138,7 +138,7 @@ function profperm_content(&$a) {
                        dbesc(NETWORK_DFRN)
                );
 
-               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)) {
index de2810dd78e87ba1ae6294a5d4c5b5047401c1bd..612dc910a03978c3212658ba9037f1e4248500a2 100644 (file)
@@ -136,7 +136,7 @@ function proxy_init() {
 
        if (!$direct_cache AND ($cachefile == "")) {
                $r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $img_str = $r[0]['data'];
                        $mime = $r[0]["desc"];
                        if ($mime == "") $mime = "image/jpeg";
@@ -144,7 +144,7 @@ function proxy_init() {
        } 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 6053ee2fbe1553e60d1fa182aff303fbd8e1dad0..ddda7ec228a9e9ff0718e3eb732d7beccaad2ec7 100644 (file)
@@ -47,7 +47,7 @@ function pubsub_init(&$a) {
                $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($nick)
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        logger('pubsub: local account not found: ' . $nick);
                        hub_return(false, '');
                }
@@ -62,7 +62,7 @@ function pubsub_init(&$a) {
                        intval($contact_id),
                        intval($owner['uid'])
                );
-               if(! count($r)) {
+               if(! dbm::is_result($r)) {
                        logger('pubsub: contact '.$contact_id.' not found.');
                        hub_return(false, '');
                }
@@ -117,7 +117,7 @@ function pubsub_post(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                dbesc($nick)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                hub_post_return();
 
        $importer = $r[0];
@@ -131,7 +131,7 @@ function pubsub_post(&$a) {
                dbesc(NETWORK_FEED)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml);
                hub_post_return();
        }
index 5d7621cc745fdf648cd1dc79d83342d09ccbe694..bfe553c44caf1e8c91b5ee7cc74f1e2167fe3408 100644 (file)
@@ -55,7 +55,7 @@ function pubsubhubbub_init(&$a) {
                           " AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                           dbesc($nick));
 
-               if(!count($r)) {
+               if (!dbm::is_result($r)) {
                        logger('pubsubhubbub: local account not found: ' . $nick);
                        http_status_exit(404);
                }
@@ -73,7 +73,7 @@ function pubsubhubbub_init(&$a) {
                $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked`".
                           " AND NOT `pending` AND `self` LIMIT 1",
                           intval($owner['uid']));
-               if(!count($r)) {
+               if (!dbm::is_result($r)) {
                        logger('pubsubhubbub: contact not found.');
                        http_status_exit(404);
                }
@@ -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 (count($r)) {
+                       if (dbm::is_result($r)) {
                                $last_update = $r[0]['last_update'];
                                $push_flag = $r[0]['push'];
                        }
index c35e253b670508c23771013c04187ca482f36a44..a440ea708fe22e0b211ad588468d198abd773202 100644 (file)
@@ -23,7 +23,7 @@ function qsearch_init(&$a) {
                intval($limit)
        );
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
 
                foreach($r as $rr)
                        $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
@@ -38,7 +38,7 @@ function qsearch_init(&$a) {
        );
 
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
 
                foreach($r as $rr)
                        $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
index 4991ac47e81811b473597398a4c129df2c00b330..dd4e61ae4f95ce43cbb4fd8b47b1ae20c6072ae3 100644 (file)
@@ -34,7 +34,7 @@ function receive_post(&$a) {
                $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($guid)
                );
-               if(! count($r))
+               if(! dbm::is_result($r))
                        http_status_exit(500);
 
                $importer = $r[0];
index 632c39578696807b3dfd20e6f6658df50656cc99..5dc5ad372416e2788a376f8dafb1bc903615c217 100644 (file)
@@ -18,7 +18,7 @@ function redir_init(&$a) {
                                intval(local_user())
                        );
 
-                       if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+                       if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
                                goaway(z_root());
 
                        $cid = $r[0]['id'];
@@ -31,7 +31,7 @@ function redir_init(&$a) {
                                intval(local_user())
                        );
 
-                       if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+                       if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
                                goaway(z_root());
                }
 
index bbe733003a56dfe11ea9affceabd03f7be00fcb0..0120017b00dd39c02d964c8951004c0c7e7f1864 100644 (file)
@@ -34,7 +34,7 @@ function user_allow($hash) {
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
                intval($user[0]['uid'])
        );
-       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(PRIORITY_LOW, "include/directory.php", $url);
index 37230a557351ad70e9b4faada55a17a89f6ef69e..78cdc09328685158a9dcc931a7b22963e0471a9d 100644 (file)
@@ -31,7 +31,7 @@ function salmon_post(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                dbesc($nick)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                http_status_exit(500);
 
        $importer = $r[0];
@@ -150,7 +150,7 @@ function salmon_post(&$a) {
                dbesc(normalise_link($author_link)),
                intval($importer['uid'])
        );
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('mod-salmon: Author unknown to us.');
                if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
                        $result = new_contact($importer['uid'],$author_link);
@@ -169,8 +169,8 @@ function salmon_post(&$a) {
        // Have we ignored the person?
        // If so we can not accept this post.
 
-       //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
@@ -179,7 +179,7 @@ function salmon_post(&$a) {
        // Placeholder for hub discovery.
        $hub = '';
 
-       $contact_rec = ((count($r)) ? $r[0] : null);
+       $contact_rec = ((dbm::is_result($r)) ? $r[0] : null);
 
        ostatus::import($data,$importer,$contact_rec, $hub);
 
index a8372599916c4e574b0faca3e11fc1080184a651..d36cc8fcb73ee22f8d64e90b534406fce62da040 100644 (file)
@@ -15,7 +15,7 @@ function search_saved_searches() {
                intval(local_user())
        );
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $saved = array();
                foreach($r as $rr) {
                        $saved[] = array(
@@ -53,7 +53,7 @@ function search_init(&$a) {
                                intval(local_user()),
                                dbesc($search)
                        );
-                       if(! count($r)) {
+                       if(! dbm::is_result($r)) {
                                q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
                                        intval(local_user()),
                                        dbesc($search)
@@ -209,7 +209,6 @@ function search_content(&$a) {
                        $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
                }
 
-
                $r = q("SELECT %s
                        FROM `item` %s
                        WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
@@ -220,7 +219,7 @@ function search_content(&$a) {
                                intval($a->pager['start']), intval($a->pager['itemspage']));
        }
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                info( t('No results.') . EOL);
                return $o;
        }
index 663acd69f0267c974e5bb26776ea65a66261ca1e..a9521db221bd0e6ccbb429f3ae326dbda39a73bf 100644 (file)
@@ -225,7 +225,7 @@ function settings_post(&$a) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if(! count($r)) {
+                               if(! dbm::is_result($r)) {
                                        q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
                                                intval(local_user())
                                        );
@@ -255,7 +255,7 @@ function settings_post(&$a) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        $eacct = $r[0];
                                        require_once('include/email.php');
                                        $mb = construct_mailbox_name($eacct);
@@ -691,7 +691,7 @@ function settings_content(&$a) {
                                        dbesc($a->argv[3]),
                                        local_user());
 
-                       if (!count($r)){
+                       if (!dbm::is_result($r)){
                                notice(t("You can't edit this application."));
                                return;
                        }
@@ -752,7 +752,7 @@ function settings_content(&$a) {
                $settings_addons = "";
 
                $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
-               if(! count($r))
+               if(! dbm::is_result($r))
                        $settings_addons = t('No Plugin settings configured');
 
                call_hooks('plugin_settings', $settings_addons);
@@ -859,15 +859,15 @@ function settings_content(&$a) {
                        $r = null;
                }
 
-               $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 085da4e30d8a8b6f15e343a480d6743f733def15..0a34c6fc50699dd1923872f78d0aae8338be6820 100644 (file)
@@ -12,7 +12,7 @@ function share_init(&$a) {
                intval($post_id),
                intval(local_user())
        );
-       if(! count($r) || ($r[0]['private'] == 1))
+       if(! dbm::is_result($r) || ($r[0]['private'] == 1))
                killme();
 
        if (!intval(get_config('system','old_share'))) {
index 2a89ac768bae20cb3150c48b3d5a841347790611..27f924e44b5452abad9c95ca3ec655019f83b23e 100644 (file)
@@ -18,7 +18,7 @@ function starred_init(&$a) {
                intval(local_user()),
                intval($message_id)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        if(! intval($r[0]['starred']))
index 33cf7489c167764b716f3cee77ca7dae78011667..dc014047a0bdf151fc18b1971b7f646734849d91 100644 (file)
@@ -20,7 +20,7 @@ function subthread_content(&$a) {
                dbesc($item_id)
        );
 
-       if(! $item_id || (! count($r))) {
+       if(! $item_id || (! dbm::is_result($r))) {
                logger('subthread: no item ' . $item_id);
                return;
        }
@@ -41,7 +41,7 @@ function subthread_content(&$a) {
                        intval($item['contact-id']),
                        intval($item['uid'])
                );
-               if(! count($r))
+               if(! dbm::is_result($r))
                        return;
                if(! $r[0]['self'])
                        $remote_owner = $r[0];
@@ -53,7 +53,7 @@ function subthread_content(&$a) {
                WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
                intval($owner_uid)
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $owner = $r[0];
 
        if(! $owner) {
@@ -75,7 +75,7 @@ function subthread_content(&$a) {
                        intval($_SESSION['visitor_id']),
                        intval($owner_uid)
                );
-               if(count($r))
+               if (dbm::is_result($r))
                        $contact = $r[0];
        }
        if(! $contact) {
index 4399450eccf2a1330882886d10e9923bc820e383..8f4315a84146ad4446b2fa0c3d28eab191086aa0 100644 (file)
@@ -67,7 +67,7 @@ function suggest_content(&$a) {
 
        $r = suggestion_query(local_user());
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
                return $o;
        }
index e0ef1ceb02091496c4cf6d963daf02d903d4d88d..e5e5263d81947569a75a9056d906b323c4c962b3 100644 (file)
@@ -27,7 +27,7 @@ function tagger_content(&$a) {
                dbesc($item_id)
        );
 
-       if(! $item_id || (! count($r))) {
+       if(! $item_id || (! dbm::is_result($r))) {
                logger('tagger: no item ' . $item_id);
                return;
        }
@@ -39,7 +39,7 @@ function tagger_content(&$a) {
        $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
                intval($owner_uid)
        );
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $owner_nick = $r[0]['nickname'];
                $blocktags = $r[0]['blocktags'];
        }
@@ -50,7 +50,7 @@ function tagger_content(&$a) {
        $r = q("select * from contact where self = 1 and uid = %d limit 1",
                intval(local_user())
        );
-       if(count($r))
+       if (dbm::is_result($r))
                        $contact = $r[0];
        else {
                logger('tagger: no contact_id');
@@ -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(count($r)) {
+       if (dbm::is_result($r)) {
                $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
                        intval($r[0]['uid'])
                );
index 176986bc38e23cc195918b60b3f0e995e4b28fab..57024b3c3b6f2127a20074849f1c8593cbddf251 100644 (file)
@@ -19,7 +19,7 @@ function tagrm_post(&$a) {
                intval(local_user())
        );
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
 
        $arr = explode(',', $r[0]['tag']);
@@ -68,7 +68,7 @@ function tagrm_content(&$a) {
                intval(local_user())
        );
 
-       if(! count($r))
+       if(! dbm::is_result($r))
                goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
 
        $arr = explode(',', $r[0]['tag']);
index 3114add7e4a56ae325ce024b379fd232a053f9fe..e0a0b071f6e3636663c6f1d2e89634191e8392fe 100644 (file)
@@ -44,7 +44,7 @@ function uexport_content(&$a){
 function _uexport_multirow($query) {
        $result = array();
        $r = q($query);
-//     if(count($r)) {
+//     if (dbm::is_result($r)) {
        if ($r){
                foreach($r as $rr){
             $p = array();
@@ -130,7 +130,7 @@ function uexport_all(&$a) {
        $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ",
                intval(local_user())
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $total = $r[0]['total'];
 
        // chunk the output to avoid exhausting memory
@@ -142,7 +142,7 @@ function uexport_all(&$a) {
                        intval($x),
                        intval(500)
                );
-               /*if(count($r)) {
+               /*if (dbm::is_result($r)) {
                        foreach($r as $rr)
                                foreach($rr as $k => $v)
                                        $item[][$k] = $v;
index 1bb59bc5429e9b614e0cb3596d62eb23fc072f64..1e03c5005a6670d6b4ead8a82f060df201606c90 100644 (file)
@@ -140,7 +140,7 @@ function videos_post(&$a) {
                        dbesc($video_id)
                );
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        q("DELETE FROM `attach` WHERE `uid` = %d AND `id` = '%s'",
                                intval(local_user()),
                                dbesc($video_id)
@@ -259,7 +259,7 @@ function videos_content(&$a) {
                                        intval($contact_id),
                                        intval($owner_uid)
                                );
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        $can_post = true;
                                        $contact = $r[0];
                                        $remote_contact = true;
@@ -287,7 +287,7 @@ function videos_content(&$a) {
                                intval($contact_id),
                                intval($owner_uid)
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $contact = $r[0];
                                $remote_contact = true;
                        }
@@ -347,7 +347,7 @@ function videos_content(&$a) {
                $sql_extra GROUP BY hash",
                intval($a->data['user']['uid'])
        );
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                $a->set_pager_total(count($r));
                $a->set_pager_itemspage(20);
        }
@@ -363,7 +363,7 @@ function videos_content(&$a) {
 
 
        $videos = array();
-       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 6be1f16de0298fcd589dc49353b436db9aa99858..c9f465676cfe6da34991f3290cae8a998b0a10be 100644 (file)
@@ -16,7 +16,7 @@ function viewcontacts_init(&$a) {
                        dbesc($nick)
                );
 
-               if(! count($r))
+               if(! dbm::is_result($r))
                        return;
 
                $a->data['user'] = $r[0];
@@ -54,7 +54,7 @@ function viewcontacts_content(&$a) {
                dbesc(NETWORK_DIASPORA),
                dbesc(NETWORK_OSTATUS)
        );
-       if(count($r))
+       if (dbm::is_result($r))
                $a->set_pager_total($r[0]['total']);
 
        $r = q("SELECT * FROM `contact`
@@ -68,7 +68,7 @@ function viewcontacts_content(&$a) {
                intval($a->pager['start']),
                intval($a->pager['itemspage'])
        );
-       if(!count($r)) {
+       if (!dbm::is_result($r)) {
                info(t('No contacts.').EOL);
                return $o;
        }
index 3fa4eaed53bad2b53686a59aef0af30acf1f5645..904b1442505d6f1aea9e58ae6335ea8dacb92485 100644 (file)
@@ -24,7 +24,7 @@ function viewsrc_content(&$a) {
                dbesc($item_id)
        );
 
-       if(count($r))
+       if (dbm::is_result($r))
                if(is_ajax()) {
                        echo str_replace("\n",'<br />',$r[0]['body']);
                        killme();
index 15e3d3f75e2384f8a8030e31d88c58f2280fb3f2..80fc1c6e796e71c11940e7e3f3f10f40e529f7f6 100644 (file)
@@ -12,7 +12,7 @@ function wall_attach_post(&$a) {
                $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid`  WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
                        dbesc($nick)
                );
-               if(! count($r)){
+               if(! dbm::is_result($r)){
                        if ($r_json) {
                                echo json_encode(array('error'=>t('Invalid request.')));
                                killme();
@@ -55,7 +55,7 @@ function wall_attach_post(&$a) {
                                        intval($contact_id),
                                        intval($page_owner_uid)
                                );
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        $can_post = true;
                                        $visitor = $contact_id;
                                }
@@ -168,7 +168,7 @@ function wall_attach_post(&$a) {
                dbesc($hash)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                $msg = t('File upload failed.');
                if ($r_json) {
                        echo json_encode(array('error'=>$msg));
index f5996d76f5de8dddf66279ea9788ce0b1316911f..21d9bf49cb2de85a9218b05b7086bffe4a6d63cb 100644 (file)
@@ -15,7 +15,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
                                dbesc($nick)
                        );
 
-                       if(! count($r)){
+                       if(! dbm::is_result($r)){
                                if ($r_json) {
                                        echo json_encode(array('error'=>t('Invalid request.')));
                                        killme();
@@ -63,7 +63,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
                                        intval($contact_id),
                                        intval($page_owner_uid)
                                );
-                               if(count($r)) {
+                               if (dbm::is_result($r)) {
                                        $can_post = true;
                                        $visitor = $contact_id;
                                }
index 8642624a476e4b75c3c0f7dbb99cf5ba0e5ebbab..03a0b7a16f57e0e3aafbf3683792ea06dbb68cd6 100644 (file)
@@ -22,7 +22,7 @@ function wallmessage_post(&$a) {
                dbesc($recipient)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                logger('wallmessage: no recipient');
                return;
        }
@@ -91,7 +91,7 @@ function wallmessage_content(&$a) {
                dbesc($recipient)
        );
 
-       if(! count($r)) {
+       if(! dbm::is_result($r)) {
                notice( t('No recipient.') . EOL);
                logger('wallmessage: no recipient');
                return;
index 094211360e03b107c23e7d841d385c96253b2ec1..1250b0812c0bd754558931686e2d0ca1fae4040e 100644 (file)
@@ -21,7 +21,7 @@ function xrd_init(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
                dbesc($name)
        );
-       if(! count($r))
+       if(! dbm::is_result($r))
                killme();
 
        $salmon_key = salmon_key($r[0]['spubkey']);
index 14f0d8fd083a398c6a7af1953d2551c9cd1b782b..2666dc1de572816a01ec53d4522288392e8c5424 100644 (file)
@@ -21,8 +21,7 @@ class BaseObject {
                if(self::$app)
                        return self::$app;
 
-               global $a;
-               self::$app = $a;
+               self::$app = get_app();
 
                return self::$app;
        }
index 36c06c6d62d2c3014f880c8017b1a4f8814c4e9b..eb5b3b9b486985fe67bc0c8958cb3f33912293c8 100644 (file)
@@ -127,7 +127,7 @@ class Conversation extends BaseObject {
         *      _ false on failure
         */
        public function get_template_data($conv_responses) {
-               global $a;
+               $a = get_app();
                $result = array();
 
                $i = 0;
index 9f01ac59b08af0b0c4bd86fbfff7d6da7b9f62f2..45d2dba3edb78c81c68823eecb1d08e312b4b8c0 100644 (file)
@@ -235,7 +235,7 @@ class Item extends BaseObject {
                                        intval($item['uid']),
                                        intval($item['id'])
                                );
-                               if (count($r)) {
+                               if (dbm::is_result($r)) {
                                        $ignore = array(
                                                'do' => t("ignore thread"),
                                                'undo' => t("unignore thread"),
index 40f016747f8a93ea8a971238e958a9904fdd8682..79dcb36a7f4c1800b6e84b89fbe73eb63712795a 100644 (file)
@@ -55,13 +55,13 @@ function q($sql) {
                        return $result; 
                }
                //second call in handle_body, name
-               if($result[0]['name']===$args[1]) {\r
-                       return $result;\r
+               if($result[0]['name']===$args[1]) {
+                       return $result;
                }
        }
        //third call in handle_body, nick or attag
-       if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {\r
-               return $result;\r
+       if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {
+               return $result;
        }
 }
 
@@ -88,23 +88,23 @@ function dbesc($str) {
  */
 class GetTagsTest extends PHPUnit_Framework_TestCase {
        /** the mock to use as app */
-       private $a; \r
+       private $a; 
 
        /**
         * initialize the test. That's a phpUnit function, 
         * don't change its name.
-        */\r
-       public function setUp() {\r
+        */
+       public function setUp() {
                $this->a=new MockApp(); 
        }
 
-       /**\r
-        * test with one Person tag\r
-        */\r
-       public function testGetTagsShortPerson() {\r
-               $text="hi @Mike";\r
-\r
-               $tags=get_tags($text);\r
+       /**
+        * test with one Person tag
+        */
+       public function testGetTagsShortPerson() {
+               $text="hi @Mike";
+
+               $tags=get_tags($text);
 
                $inform=''; 
                $str_tags='';
@@ -113,32 +113,32 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
                }
 
                //correct tags found?
-               $this->assertEquals(1, count($tags)); \r
+               $this->assertEquals(1, count($tags)); 
                $this->assertTrue(in_array("@Mike", $tags));
                
                //correct output from handle_tag?
                $this->assertEquals("cid:15", $inform); 
                $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
-               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);\r
+               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);
        }
        
-       /**\r
+       /**
         * test with one Person tag. 
-        * There's a minor spelling mistake...\r
-        */\r
-       public function testGetTagsShortPersonSpelling() {\r
-               $text="hi @Mike.because";\r
-       \r
-               $tags=get_tags($text);\r
+        * There's a minor spelling mistake...
+        */
+       public function testGetTagsShortPersonSpelling() {
+               $text="hi @Mike.because";
+       
+               $tags=get_tags($text);
        
-               //correct tags found?\r
-               $this->assertEquals(1, count($tags));\r
+               //correct tags found?
+               $this->assertEquals(1, count($tags));
                $this->assertTrue(in_array("@Mike.because", $tags));
-               \r
-               $inform='';\r
-               $str_tags='';\r
-               handle_tag($this->a, $text, $inform, $str_tags, 11, $tags[0]);\r
-       \r
+               
+               $inform='';
+               $str_tags='';
+               handle_tag($this->a, $text, $inform, $str_tags, 11, $tags[0]);
+       
                // (mike) - This is a tricky case.
                // we support mentions as in @mike@example.com - which contains a period.
                // This shouldn't match anything unless you have a contact named "Mike.because".
@@ -147,91 +147,91 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
  
 //             $this->assertEquals("cid:15", $inform); 
 //             $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
-//             $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url].because", $text);\r
+//             $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url].because", $text);
 
                $this->assertEquals("", $inform); 
                $this->assertEquals("", $str_tags);
 
        }
        
-       /**\r
+       /**
         * test with two Person tags. 
-        * There's a minor spelling mistake...\r
-        */\r
+        * There's a minor spelling mistake...
+        */
 
-       public function testGetTagsPerson2Spelling() {\r
-               $text="hi @Mike@campino@friendica.eu";\r
-       \r
-               $tags=get_tags($text);\r
+       public function testGetTagsPerson2Spelling() {
+               $text="hi @Mike@campino@friendica.eu";
+       
+               $tags=get_tags($text);
 
 // This construct is not supported. Results are indeterminate                  
-//             $this->assertEquals(2, count($tags)); \r
+//             $this->assertEquals(2, count($tags)); 
 //             $this->assertTrue(in_array("@Mike", $tags));
-//             $this->assertTrue(in_array("@campino@friendica.eu", $tags));\r
-       }\r
+//             $this->assertTrue(in_array("@campino@friendica.eu", $tags));
+       }
 
        /**
         * Test with one hash tag.
-        */\r
-       public function testGetTagsShortTag() {\r
-               $text="This is a #test_case";\r
-\r
-               $tags=get_tags($text);\r
+        */
+       public function testGetTagsShortTag() {
+               $text="This is a #test_case";
+
+               $tags=get_tags($text);
 
-               $this->assertEquals(1, count($tags));\r
-               $this->assertTrue(in_array("#test_case", $tags));\r
-       }\r
+               $this->assertEquals(1, count($tags));
+               $this->assertTrue(in_array("#test_case", $tags));
+       }
 
        /**
         * test with a person and a hash tag
-        */\r
-       public function testGetTagsShortTagAndPerson() {\r
-               $text="hi @Mike This is a #test_case";\r
-\r
-               $tags=get_tags($text);\r
+        */
+       public function testGetTagsShortTagAndPerson() {
+               $text="hi @Mike This is a #test_case";
+
+               $tags=get_tags($text);
 
                $this->assertEquals(3, count($tags));
                $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("@Mike This", $tags));\r
-               $this->assertTrue(in_array("#test_case", $tags));\r
+               $this->assertTrue(in_array("@Mike This", $tags));
+               $this->assertTrue(in_array("#test_case", $tags));
 
                $inform='';
                $str_tags='';
                foreach($tags as $tag) {
                        handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
                }
-               \r
+               
                $this->assertEquals("cid:15", $inform); 
                $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url],#[url=baseurl/search?tag=test%20case]test case[/url]", $str_tags);
                $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url] This is a #[url=baseurl/search?tag=test%20case]test case[/url]", $text); 
-               \r
-       }\r
+               
+       }
 
        /**
         * test with a person, a hash tag and some special chars.
-        */\r
-       public function testGetTagsShortTagAndPersonSpecialChars() {\r
-               $text="hi @Mike, This is a #test_case.";\r
-\r
-               $tags=get_tags($text);\r
-\r
+        */
+       public function testGetTagsShortTagAndPersonSpecialChars() {
+               $text="hi @Mike, This is a #test_case.";
+
+               $tags=get_tags($text);
+
                $this->assertEquals(2, count($tags));
                $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("#test_case", $tags));\r
-       }\r
+               $this->assertTrue(in_array("#test_case", $tags));
+       }
 
        /**
         * Test with a person tag and text behind it.
-        */\r
-       public function testGetTagsPersonOnly() {\r
-               $text="@Test I saw the Theme Dev group was created.";\r
-\r
-               $tags=get_tags($text);\r
+        */
+       public function testGetTagsPersonOnly() {
+               $text="@Test I saw the Theme Dev group was created.";
+
+               $tags=get_tags($text);
 
-               $this->assertEquals(2, count($tags));\r
+               $this->assertEquals(2, count($tags));
                $this->assertTrue(in_array("@Test I", $tags));
-               $this->assertTrue(in_array("@Test", $tags));\r
-       }\r
+               $this->assertTrue(in_array("@Test", $tags));
+       }
 
        /**
         * this test demonstrates strange behaviour by intval. 
@@ -255,72 +255,72 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
                //happens right now, but it shouldn't be necessary
                $this->assertTrue(in_array("@mike+15 id", $tags));
                
-               $inform='';\r
+               $inform='';
                $str_tags='';
                foreach($tags as $tag) {
                        handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
                }
                
-               $this->assertEquals("Test with @[url=http://justatest.de]Mike Lastname[/url] id tag", $text);\r
-               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);\r
+               $this->assertEquals("Test with @[url=http://justatest.de]Mike Lastname[/url] id tag", $text);
+               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
                // this test may produce two cid:15 entries - which is OK because duplicates are pruned before delivery
                $this->assertContains("cid:15",$inform);
        }
        
        /**
         * test with two persons and one special tag.
-        */\r
-       public function testGetTags2Persons1TagSpecialChars() {\r
-               $text="hi @Mike, I'm just writing #test_cases, so"\r
-               ." so @somebody@friendica.com may change #things.";\r
-\r
-               $tags=get_tags($text);\r
-
-               $this->assertEquals(5, count($tags));\r
-               $this->assertTrue(in_array("@Mike", $tags));\r
+        */
+       public function testGetTags2Persons1TagSpecialChars() {
+               $text="hi @Mike, I'm just writing #test_cases, so"
+               ." so @somebody@friendica.com may change #things.";
+
+               $tags=get_tags($text);
+
+               $this->assertEquals(5, count($tags));
+               $this->assertTrue(in_array("@Mike", $tags));
                $this->assertTrue(in_array("#test_cases", $tags));
-               $this->assertTrue(in_array("@somebody@friendica.com", $tags));\r
-               $this->assertTrue(in_array("@somebody@friendica.com may", $tags));\r
-               $this->assertTrue(in_array("#things", $tags));\r
-       }\r
+               $this->assertTrue(in_array("@somebody@friendica.com", $tags));
+               $this->assertTrue(in_array("@somebody@friendica.com may", $tags));
+               $this->assertTrue(in_array("#things", $tags));
+       }
 
        /**
         * test with a long text.
-        */\r
-       public function testGetTags() {\r
-               $text="hi @Mike, I'm just writing #test_cases, "\r
-               ." so @somebody@friendica.com may change #things. Of course I "\r
-               ."look for a lot of #pitfalls, like #tags at the end of a sentence "\r
-               ."@comment. I hope noone forgets about @fullstops.because that might"\r
-               ." break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "\r
-               ."Now, add a @first_last tag. ";\r
-               \r
-               $tags=get_tags($text);\r
-\r
-               $this->assertTrue(in_array("@Mike", $tags));\r
-               $this->assertTrue(in_array("#test_cases", $tags));\r
-               $this->assertTrue(in_array("@somebody@friendica.com", $tags));\r
-               $this->assertTrue(in_array("#things", $tags));\r
-               $this->assertTrue(in_array("#pitfalls", $tags));\r
-               $this->assertTrue(in_array("#tags", $tags));\r
-               $this->assertTrue(in_array("@comment", $tags));\r
-               $this->assertTrue(in_array("@fullstops.because", $tags));\r
-               $this->assertTrue(in_array("#things", $tags));\r
-               $this->assertTrue(in_array("@Mike", $tags));\r
-               $this->assertTrue(in_array("#nice", $tags));\r
+        */
+       public function testGetTags() {
+               $text="hi @Mike, I'm just writing #test_cases, "
+               ." so @somebody@friendica.com may change #things. Of course I "
+               ."look for a lot of #pitfalls, like #tags at the end of a sentence "
+               ."@comment. I hope noone forgets about @fullstops.because that might"
+               ." break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "
+               ."Now, add a @first_last tag. ";
+               
+               $tags=get_tags($text);
+
+               $this->assertTrue(in_array("@Mike", $tags));
+               $this->assertTrue(in_array("#test_cases", $tags));
+               $this->assertTrue(in_array("@somebody@friendica.com", $tags));
+               $this->assertTrue(in_array("#things", $tags));
+               $this->assertTrue(in_array("#pitfalls", $tags));
+               $this->assertTrue(in_array("#tags", $tags));
+               $this->assertTrue(in_array("@comment", $tags));
+               $this->assertTrue(in_array("@fullstops.because", $tags));
+               $this->assertTrue(in_array("#things", $tags));
+               $this->assertTrue(in_array("@Mike", $tags));
+               $this->assertTrue(in_array("#nice", $tags));
                $this->assertTrue(in_array("@first_last", $tags));
                
                //right now, none of the is matched (unsupported)
-//             $this->assertFalse(in_array("@Mike@campino@friendica.eu", $tags));\r
+//             $this->assertFalse(in_array("@Mike@campino@friendica.eu", $tags));
 //             $this->assertTrue(in_array("@campino@friendica.eu", $tags));
-//             $this->assertTrue(in_array("@campino@friendica.eu is", $tags));\r
-       }\r
+//             $this->assertTrue(in_array("@campino@friendica.eu is", $tags));
+       }
 
        /**
         * test with an empty string
-        */\r
-       public function testGetTagsEmpty() {\r
-               $tags=get_tags("");\r
-               $this->assertEquals(0, count($tags));\r
+        */
+       public function testGetTagsEmpty() {
+               $tags=get_tags("");
+               $this->assertEquals(0, count($tags));
        }
-}
\ No newline at end of file
+}
index 76007ad3aa0d3ac9860ea68a81c6c49303db2832..0679b5a1f8295ce028e3b8b1f7d35117f0dd026a 100644 (file)
@@ -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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $sres=openssl_pkey_new(array('encrypt_key' => false ));
                        $sprvkey = '';
@@ -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(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 @@ 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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $ph = new Photo($rr['data']);
                        if($ph->is_valid()) {
@@ -155,7 +155,7 @@ function update_1014() {
                }
        }
        $r = q("SELECT * FROM `contact` WHERE 1");
-       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",
@@ -308,7 +308,7 @@ function update_1030() {
 function update_1031() {
        // Repair any bad links that slipped into the item table
        $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
-       if($r && count($r)) {
+       if($r && dbm::is_result($r)) {
                foreach($r as $rr) {
                        if(strstr($rr['object'],'type=&quot;http')) {
                                q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
@@ -356,7 +356,7 @@ function update_1035() {
 function update_1036() {
 
        $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
-       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 @@ 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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
                                intval($rr['uid'])
@@ -606,7 +606,7 @@ function update_1074() {
 function update_1075() {
        q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
        $r = q("SELECT `uid` FROM `user` WHERE 1");
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = true;
                        do {
@@ -685,10 +685,10 @@ function update_1082() {
                ADD INDEX ( `guid` )  ");
        // make certain the following code is only executed once
        $r = q("select `id` from `photo` where `guid` != '' limit 1");
-       if($r && count($r))
+       if (dbm::is_result($r))
                return;
        $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
-       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 @@ 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(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 @@ function update_1100() {
        require_once('include/text.php');
 
        $r = q("select id, url from contact where url != '' and nurl = '' ");
-       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'])),
@@ -1030,7 +1030,7 @@ function update_1120() {
        // might be missing on new installs. We'll check.
 
        $r = q("describe item");
-       if($r && count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr)
                        if($rr['Field'] == 'spam')
                                return;
@@ -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(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
@@ -1187,7 +1187,7 @@ function update_1136() {
 
        $arr = array();
        $r = q("select * from pconfig where 1 order by id desc");
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
@@ -1692,7 +1692,7 @@ function update_1190() {
        );
 
        // convert old forumlist addon entries in new config entries
-       if (count($r)) {
+       if (dbm::is_result($r)) {
                foreach ($r as $rr) {
                        $uid = $rr['uid'];
                        $family = $rr['cat'];
index 085d4d941f42e8db269d9cf73fae14a54d17a3c8..279edd64eced18f25f8f2d26b1b93908247bf4a6 100644 (file)
@@ -221,7 +221,7 @@ function frio_remote_nav($a,&$nav) {
                // user info
                $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
                
-               $r[0]['photo'] = (count($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg");
+               $r[0]['photo'] = (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg");
                $r[0]['name'] = $a->user['username'];
 
        } elseif(!local_user() && remote_user()) {
@@ -235,9 +235,9 @@ function frio_remote_nav($a,&$nav) {
                $nav['remote'] = t("Visitor");
        }
 
-       if(count($r)){
+       if (dbm::is_result($r)){
                        $nav['userinfo'] = array(
-                               'icon' => (count($r) ? $r[0]['photo'] : "images/person-48.jpg"),
+                               'icon' => (dbm::is_result($r) ? $r[0]['photo'] : "images/person-48.jpg"),
                                'name' => $r[0]['name'],
                        );
                }
@@ -299,7 +299,7 @@ function frio_acl_lookup($a, &$results) {
                $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(count($r)) {
+               if (dbm::is_result($r)) {
                        $total = $r[0]["total"];
                }
 
@@ -311,7 +311,7 @@ function frio_acl_lookup($a, &$results) {
 
                $contacts = array();
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
                        foreach($r as $rr) {
                                $contacts[] = _contact_detail_for_template($rr);
                        }
index 67bab16a1958b22e3e9112ddd8eefddabebfaabf..cbb850c130afadabf98f70ff17455936bc2abee1 100644 (file)
@@ -24,69 +24,69 @@ img {
 }
 
 #pending-update {
-  float:right;
-  color: #ffffff;
-  font-weight: bold;
-  background-color: #FF0000;
-  padding: 0em 0.3em;
+       float:right;
+       color: #ffffff;
+       font-weight: bold;
+       background-color: #FF0000;
+       padding: 0em 0.3em;
 }
 
 .admin.linklist {
-  border: 0px;
-  padding: 0px;
-  list-style: none;
-  margin-top: 0px;
+       border: 0px;
+       padding: 0px;
+       list-style: none;
+       margin-top: 0px;
 }
 
 .admin.link {
-  list-style-position: inside;
-  font-size: 1em;
-/*  padding-left: 5px;
-    margin: 5px; */
+       list-style-position: inside;
+       font-size: 1em;
+/*        padding-left: 5px;
+       margin: 5px; */
 }
 
 #adminpage dl {
-  clear: left;
-  margin-bottom: 2px;
-  padding-bottom: 2px;
-  border-bottom: 1px solid black;
+       clear: left;
+       margin-bottom: 2px;
+       padding-bottom: 2px;
+       border-bottom: 1px solid black;
 }
 
 #adminpage dt {
-  width: 200px;
-  float: left;
-  font-weight: bold;
+       width: 200px;
+       float: left;
+       font-weight: bold;
 }
 
 #adminpage dd {
-  margin-left: 200px;
+       margin-left: 200px;
 }
 #adminpage h3 {
-  border-bottom: 1px solid #898989;
-  margin-bottom: 5px;
-  margin-top: 10px;
+       border-bottom: 1px solid #898989;
+       margin-bottom: 5px;
+       margin-top: 10px;
 }
 
 #adminpage .submit {
-  clear:left;
+       clear:left;
 }
 
 #adminpage #pluginslist {
-  margin: 0px; padding: 0px;
+       margin: 0px; padding: 0px;
 }
 
 #adminpage .plugin {
-  list-style: none;
-  display: block;
-  /* border: 1px solid #888888; */
-  padding: 1em;
-  margin-bottom: 5px;
-  clear: left;
+       list-style: none;
+       display: block;
+       /* border: 1px solid #888888; */
+       padding: 1em;
+       margin-bottom: 5px;
+       clear: left;
 }
 
 #adminpage .toggleplugin {
-  float:left;
-  margin-right: 1em;
+       float:left;
+       margin-right: 1em;
 }
 
 #adminpage table {width:100%; border-bottom: 1px solid #000000; margin: 5px 0px;}
index 925ac76a1fe2284b4798a34268ceb95e7189b314..50b292f6b7941342ffea3780874af73979fce248 100644 (file)
@@ -147,7 +147,7 @@ function vier_community_info() {
                $r = suggestion_query(local_user(), 0, 9);
 
                $tpl = get_markup_template('ch_directory_item.tpl');
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $aside['$comunity_profiles_title'] = t('Community Profiles');
                        $aside['$comunity_profiles_items'] = array();
@@ -170,13 +170,14 @@ function vier_community_info() {
                $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
                $order = " ORDER BY `register_date` DESC ";
 
+               $tpl = get_markup_template('ch_directory_item.tpl');
+
                $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
                                FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
                                WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
                                0, 9);
 
-               $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();
@@ -367,7 +368,7 @@ function vier_community_info() {
 
                $tpl = get_markup_template('ch_connectors.tpl');
 
-               if(count($r)) {
+               if (dbm::is_result($r)) {
 
                        $con_services = array();
                        $con_services['title'] = Array("", t('Connect Services'), "", "");