Continued rewriting:

- use dba::is_result() everywhere (where I found the old, bad way)
- converted some spaces -> tabs for code
- converted some CRLF -> LF as mixures of both is not good

Signed-off-by: Roland Haeder <roland@mxchange.org>
pull/3010/head
Roland Häder 7 years ago
parent 56a2bbc740
commit 3e701b90ac
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78

@ -368,7 +368,7 @@ function random_profile() {
ORDER BY rand() LIMIT 1",
dbesc(NETWORK_DFRN));
if(count($r))
if(dba::is_result($r))
return dirname($r[0]['url']);
return '';
}

@ -589,7 +589,7 @@ class Photo {
$r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1",
dbesc($rid)
);
if(count($r))
if(dba::is_result($r))
$guid = $r[0]['guid'];
else
$guid = get_guid();

@ -33,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks($a->module . '_pre_' . $selname, $arr);
if(count($r)) {
if(dba::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(dba::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(dba::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(dba::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(dba::is_result($r)) {
foreach($r as $g){
$contacts[] = array(
"type" => "c",

@ -207,7 +207,7 @@
dbesc(trim($user)),
dbesc($encrypted)
);
if(count($r))
if(dba::is_result($r))
$record = $r[0];
}
@ -1249,7 +1249,7 @@
if (!count($r))
$r = q("SELECT `id` FROM `gcontact` WHERE `nick`='%s'", dbesc($_GET["q"]));
if (count($r)) {
if (dba::is_result($r)) {
foreach ($r AS $user) {
$user_info = api_get_user($a, $user["id"]);
//echo print_r($user_info, true)."\n";

@ -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 (dba::is_result($r)) {
$a->contact = $r[0];
}
}
@ -169,7 +169,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
dbesc(trim($_POST['username'])),
dbesc($encrypted)
);
if (count($r))
if (dba::is_result($r))
$record = $r[0];
}

@ -10,7 +10,7 @@
dbesc($key)
);
if (count($r))
if (dba::is_result($r))
return $r[0]['v'];
return null;
@ -38,7 +38,7 @@
* $r = q("SELECT * FROM `cache` WHERE `k`='%s' limit 1",
* dbesc($key)
* );
* if(count($r)) {
* if(dba::is_result($r)) {
* q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s'",
* dbesc($value),
* dbesc(datetime_convert()),

@ -20,7 +20,7 @@ function load_config($family) {
global $a;
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr) {
$k = $rr['k'];
if ($family === 'config') {
@ -174,7 +174,7 @@ function load_pconfig($uid,$family) {
dbesc($family),
intval($uid)
);
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr) {
$k = $rr['k'];
$a->config[$uid][$family][$k] = $rr['v'];

@ -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(dba::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";

@ -93,7 +93,7 @@ function networks_widget($baseurl,$selected = '') {
);
$nets = array();
if(count($r)) {
if(dba::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(dba::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(dba::is_result($r))
$zcid = $r[0]['id'];
}
}

@ -544,7 +544,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(dba::is_result($r)) {
foreach($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);

@ -236,7 +236,7 @@ class dba {
* @param $array mixed A filled array with at least one entry
* @return Whether $array is a filled array
*/
public function is_result ($array) {
public static function is_result ($array) {
return (is_array($array) && count($array) > 0);
}

@ -254,7 +254,7 @@ function delivery_run(&$argv, &$argc){
intval($contact_id)
);
if (count($r))
if (dba::is_result($r))
$contact = $r[0];
if ($contact['self'])
@ -416,7 +416,7 @@ function delivery_run(&$argv, &$argc){
intval($argv[2]),
intval($uid)
);
if (count($r))
if (dba::is_result($r))
$it = $r[0];
}
if (!$it)

@ -1430,7 +1430,7 @@ class dfrn {
dbesc(normalise_link($suggest["url"])),
intval($suggest["uid"])
);
if(count($r))
if(dba::is_result($r))
return false;
// Do we already have an fcontact record for this person?
@ -1441,7 +1441,7 @@ class dfrn {
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
if(count($r)) {
if(dba::is_result($r)) {
$fid = $r[0]["id"];
// OK, we do. Do we already have an introduction for this person ?
@ -1449,7 +1449,7 @@ class dfrn {
intval($suggest["uid"]),
intval($fid)
);
if(count($r))
if(dba::is_result($r))
return false;
}
if(!$fid)
@ -1464,7 +1464,7 @@ class dfrn {
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
if(count($r))
if(dba::is_result($r))
$fid = $r[0]["id"];
else
// database record did not get created. Quietly give up.
@ -2120,7 +2120,7 @@ class dfrn {
dbesc($item["uri"]),
intval($importer["uid"])
);
if(count($r))
if(dba::is_result($r))
$ev["id"] = $r[0]["id"];
$event_id = event_store($ev);
@ -2141,7 +2141,7 @@ class dfrn {
}
// Update content if 'updated' changes
if(count($r)) {
if(dba::is_result($r)) {
if (self::update_content($r[0], $item, $importer, $entrytype))
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
else
@ -2163,7 +2163,7 @@ class dfrn {
intval($posted_id),
intval($importer["importer_uid"])
);
if(count($r)) {
if(dba::is_result($r)) {
$parent = $r[0]["parent"];
$parent_uri = $r[0]["parent-uri"];
}
@ -2345,7 +2345,7 @@ class dfrn {
dbesc($item["parent-uri"]),
intval($importer["uid"])
);
if(count($r)) {
if(dba::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]["id"])
);

@ -401,7 +401,7 @@ function notification($params) {
$hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash));
if(count($r))
if(dba::is_result($r))
$dups = true;
} while($dups == true);
@ -718,7 +718,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
foreach ($tags AS $tag) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
normalise_link($tag["url"]), intval($uid));
if (count($r))
if (dba::is_result($r))
$send_notification = true;
}
}

@ -276,7 +276,7 @@ function event_store($arr) {
intval($arr['id']),
intval($arr['uid'])
);
return((count($r)) ? $r[0]['id'] : 0);
return((dba::is_result($r)) ? $r[0]['id'] : 0);
}
// The event changed. Update it.
@ -317,7 +317,7 @@ function event_store($arr) {
intval($arr['id']),
intval($arr['uid'])
);
if(count($r)) {
if(dba::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";
@ -376,7 +376,7 @@ function event_store($arr) {
dbesc($arr['uri']),
intval($arr['uid'])
);
if(count($r))
if(dba::is_result($r))
$event = $r[0];
$item_arr = array();
@ -418,7 +418,7 @@ function event_store($arr) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($arr['uid'])
);
//if(count($r))
//if(dba::is_result($r))
// $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;

@ -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(dba::is_result($r)) {
foreach($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']);

@ -10,7 +10,7 @@ function fcontact_store($url,$name,$photo) {
dbesc($nurl)
);
if(count($r))
if(dba::is_result($r))
return $r[0]['id'];
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
@ -23,7 +23,7 @@ function fcontact_store($url,$name,$photo) {
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
dbesc($nurl)
);
if(count($r))
if(dba::is_result($r))
return $r[0]['id'];
}

@ -178,7 +178,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
);
if(count($r)) {
if(dba::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",
@ -196,7 +196,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(dba::is_result($r))
$total_contacts = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
@ -208,7 +208,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid),
dbesc($network)
);
if(count($r))
if(dba::is_result($r))
$total_network = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
@ -295,7 +295,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid)
);
if(count($r)) {
if(dba::is_result($r)) {
if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
require_once('include/salmon.php');
slapper($r[0],$contact['notify'],$slap);

@ -65,7 +65,7 @@ function gprobe_run(&$argv, &$argc){
dbesc(normalise_link($url))
);
}
if(count($r)) {
if(dba::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']));

@ -44,7 +44,7 @@ function group_rmv($uid,$name) {
intval($uid),
dbesc($name)
);
if(count($r))
if(dba::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(dba::is_result($r))
return $r[0]['id'];
return false;
}
@ -139,7 +139,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
intval($gid),
intval($member)
);
if(count($r))
if(dba::is_result($r))
return true; // You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
@ -164,7 +164,7 @@ function group_get_members($gid) {
intval($gid),
intval(local_user())
);
if(count($r))
if(dba::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(dba::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(dba::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(dba::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(dba::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(dba::is_result($r)) {
foreach($r as $rr)
$ret[] = $rr['gid'];
}

@ -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(dba::is_result($r))
$profile = $r[0]['profile-id'];
break;
}
@ -230,7 +230,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 (dba::is_result($r))
$connect = false;
}
@ -263,7 +263,7 @@ function profile_sidebar($profile, $block = 0) {
'entries' => array(),
);
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr) {
$profile['menu']['entries'][] = array(
@ -344,7 +344,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(dba::is_result($r))
$updated = date("c", strtotime($r[0]['updated']));
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
@ -354,7 +354,7 @@ function profile_sidebar($profile, $block = 0) {
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS)
);
if(count($r))
if(dba::is_result($r))
$contacts = intval($r[0]['total']);
}
}

@ -413,7 +413,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(dba::is_result($r)) {
$expire_interval = $r[0]['expire'];
if ($expire_interval>0) {
$expire_date = new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC'));
@ -535,7 +535,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
intval($arr['uid'])
);
if(count($r))
if(dba::is_result($r))
$arr['network'] = $r[0]["network"];
// Fallback to friendica (why is it empty in some cases?)
@ -583,7 +583,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(dba::is_result($r)) {
logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG);
return 0;
}
@ -612,7 +612,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
intval($arr['uid'])
);
if(count($r)) {
if(dba::is_result($r)) {
// is the new message multi-level threaded?
// even though we don't support it now, preserve the info
@ -768,7 +768,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
intval($r[0]["id"])
);
return 0;
} elseif(count($r)) {
} elseif(dba::is_result($r)) {
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
@ -979,7 +979,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 (dba::is_result($r))
return($r[0]["guid"]);
else
return("");
@ -998,7 +998,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 (dba::is_result($r)) {
$id = $r[0]["id"];
$nick = $r[0]["nickname"];
}
@ -1012,7 +1012,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 (dba::is_result($r)) {
$id = $r[0]["id"];
$nick = $r[0]["nickname"];
}
@ -1313,7 +1313,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 (dba::is_result($r)) {
$datarray['contact-id'] = $r[0]["id"];
$datarray['owner-name'] = $r[0]["name"];
@ -1390,7 +1390,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
intval($importer['uid']),
dbesc($url)
);
if(count($r)) {
if(dba::is_result($r)) {
$contact_record = $r[0];
$photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
@ -1982,7 +1982,7 @@ function drop_item($id,$interactive = true) {
dbesc($item['parent-uri']),
intval($item['uid'])
);
if(count($r)) {
if(dba::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]['id'])
);
@ -2019,7 +2019,7 @@ function first_post_date($uid,$wall = false) {
intval($uid),
intval($wall ? 1 : 0)
);
if(count($r)) {
if(dba::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);
}

@ -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(dba::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(dba::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(dba::is_result($r)) {
$like_item = $r[0];
// Already voted, undo it

@ -16,7 +16,7 @@ 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((dba::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)

@ -41,7 +41,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
dbesc($replyto),
dbesc($replyto)
);
if(count($r))
if(dba::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(dba::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(dba::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(dba::is_result($r))
$convid = $r[0]['id'];
if(! $convid) {

@ -314,7 +314,7 @@ function notifier_run(&$argv, &$argc){
intval($uid),
dbesc(NETWORK_DFRN)
);
if(count($r))
if(dba::is_result($r))
foreach($r as $rr)
$recipients_followup[] = $rr['id'];
}
@ -425,7 +425,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(dba::is_result($r))
$contacts = $r;
} else
@ -443,7 +443,7 @@ function notifier_run(&$argv, &$argc){
intval($uid),
dbesc(NETWORK_MAIL)
);
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr)
$recipients[] = $rr['id'];
}
@ -471,7 +471,7 @@ function notifier_run(&$argv, &$argc){
// delivery loop
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $contact) {
if(!$contact['self']) {
@ -572,7 +572,7 @@ function notifier_run(&$argv, &$argc){
$r = array_merge($r2,$r1,$r0);
if(count($r)) {
if(dba::is_result($r)) {
logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
// throw everything into the queue in case we get killed

@ -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 (dba::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 (dba::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 (dba::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(dba::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(dba::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 (dba::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 (dba::is_result($r))
return $r[0];
return null;
}

@ -94,7 +94,7 @@ function onepoll_run(&$argv, &$argc){
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['id'])
);
if (count($r))
if (dba::is_result($r))
if (!$r[0]['total'])
poco_load($contact['id'],$importer_uid,0,$contact['poco']);
}
@ -394,7 +394,7 @@ function onepoll_run(&$argv, &$argc){
dbesc($datarray['uri'])
);
if(count($r)) {
if(dba::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
@ -447,7 +447,7 @@ function onepoll_run(&$argv, &$argc){
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",
intval($importer_uid)
);
if(count($r))
if(dba::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){
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid));
if(count($r))
if(dba::is_result($r))
$datarray['parent-uri'] = $r[0]['parent-uri'];
}

@ -79,7 +79,7 @@ function reload_plugins() {
if(strlen($plugins)) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if(count($r))
if(dba::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(dba::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(dba::is_result($r)) {
foreach($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array();

@ -21,16 +21,14 @@ function was_recently_delayed($cid) {
and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
intval($cid)
);
if(count($r))
if(dba::is_result($r))
return true;
$r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
intval($cid)
);
if(count($r))
return true;
return false;
return (dba::is_result($r));
}

@ -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(dba::is_result($r))
$master_record = $r[0];
}
@ -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(dba::is_result($r)) {
$a->contact = $r[0];
$a->cid = $r[0]['id'];
$_SESSION['cid'] = $a->cid;
@ -158,7 +158,7 @@ function can_write_wall(&$a,$owner) {
intval(PAGE_COMMUNITY)
);
if(count($r)) {
if(dba::is_result($r)) {
$verified = 2;
return true;
}
@ -212,7 +212,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
intval($remote_user),
intval($owner_id)
);
if(count($r)) {
if(dba::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
@ -294,7 +294,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
intval($remote_user),
intval($owner_id)
);
if(count($r)) {
if(dba::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
@ -405,7 +405,7 @@ function init_groups_visitor($contact_id) {
WHERE `contact-id` = %d ",
intval($contact_id)
);
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr)
$groups[] = $rr['gid'];
}

@ -17,7 +17,7 @@ function ref_session_read ($id) {
if(x($id))
$r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
if(count($r)) {
if(dba::is_result($r)) {
$session_exists = true;
return $r[0]['data'];
} else {

@ -39,7 +39,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(dba::is_result($r)) {
$url = $r[0]['poco'];
$uid = $r[0]['uid'];
}
@ -205,14 +205,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(dba::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(dba::is_result($r)) {
$network = $r[0]["network"];
//$profile_url = $r[0]["url"];
}
@ -948,7 +948,7 @@ function count_common_friends($uid,$cid) {
);
// logger("count_common_friends: $uid $cid {$r[0]['total']}");
if(count($r))
if(dba::is_result($r))
return $r[0]['total'];
return 0;
@ -994,7 +994,7 @@ function count_common_friends_zcid($uid,$zcid) {
intval($uid)
);
if(count($r))
if(dba::is_result($r))
return $r[0]['total'];
return 0;
@ -1033,7 +1033,7 @@ function count_all_friends($uid,$cid) {
intval($uid)
);
if(count($r))
if(dba::is_result($r))
return $r[0]['total'];
return 0;
@ -1162,7 +1162,7 @@ function update_suggestions() {
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA)
);
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
if(! in_array($base,$done))

@ -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(dba::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(dba::is_result($r))
$found = true;
} while($found == true);
return $resource;
@ -859,7 +859,7 @@ function contact_block() {
dbesc(NETWORK_OSTATUS),
dbesc(NETWORK_DIASPORA)
);
if(count($r)) {
if(dba::is_result($r)) {
$total = intval($r[0]['total']);
}
if(! $total) {
@ -877,7 +877,7 @@ function contact_block() {
dbesc(NETWORK_DIASPORA),
intval($shown)
);
if(count($r)) {
if(dba::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array();
foreach($r as $rr) {
@ -2050,7 +2050,7 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
// intval($uid)
//);
if(count($r)) {
if(dba::is_result($r)) {
unset($deleted_tags[$key]);
}
else {
@ -2080,7 +2080,7 @@ function file_tag_save_file($uid,$item,$file) {
intval($item),
intval($uid)
);
if(count($r)) {
if(dba::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) . ']'),

@ -88,7 +88,7 @@ function add_shadow_entry($item) {
// 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 (dba::is_result($r))
return;
// Preparing public shadow (removing user specific data)

@ -130,7 +130,7 @@ function create_user($arr) {
$r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
dbesc($email)
);
if(count($r))
if(dba::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(dba::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(dba::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'])) {

@ -1078,7 +1078,7 @@ function admin_page_dbsync(&$a) {
$failed = array();
$r = q("select k, v from config where `cat` = 'database' ");
if(count($r)) {
if(dba::is_result($r)) {
foreach($r as $rr) {
$upd = intval(substr($rr['k'],7));
if($upd < 1139 || $rr['v'] === 'success')

@ -57,13 +57,13 @@ function common_content(&$a) {
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if(count($r))
if(dba::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(dba::is_result($r))
$zcid = $r[0]['id'];
}
}

@ -59,7 +59,7 @@ function community_content(&$a, $update = 0) {
AND `item`.`private` = 0 AND `item`.`wall` = 1"
);
if(count($r))
if(dba::is_result($r))
$a->set_pager_total($r[0]['total']);
if(! $r[0]['total']) {

@ -14,7 +14,7 @@ function contactgroup_content(&$a) {
intval($a->argv[2]),
intval(local_user())
);
if(count($r))
if(dba::is_result($r))
$change = intval($a->argv[2]);
}
@ -47,4 +47,4 @@ function contactgroup_content(&$a) {
}
killme();
}
}

@ -758,22 +758,22 @@ 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(dba::is_result($r)) {
$a->set_pager_total($r[0]['total']);
$total = $r[0]['total'];
}
$sql_extra3 = unavailable_networks();
$contacts = array();
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ",
intval($_SESSION['uid']),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
</