ORDER BY rand() LIMIT 1",
dbesc(NETWORK_DFRN));
- if(count($r))
+ if(dba::is_result($r))
return dirname($r[0]['url']);
return '';
}
$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();
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\" ";
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\" ";
$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\" ";
$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;
$r = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $g){
$contacts[] = array(
"type" => "c",
dbesc(trim($user)),
dbesc($encrypted)
);
- if(count($r))
+ if(dba::is_result($r))
$record = $r[0];
}
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";
$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];
}
}
dbesc(trim($_POST['username'])),
dbesc($encrypted)
);
- if (count($r))
+ if (dba::is_result($r))
$record = $r[0];
}
dbesc($key)
);
- if (count($r))
+ if (dba::is_result($r))
return $r[0]['v'];
return null;
* $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()),
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') {
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'];
$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";
);
$nets = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
require_once('include/contact_selectors.php');
foreach($r as $rr) {
if($rr['network'])
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'];
}
}
// 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']);
* @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);
}
intval($contact_id)
);
- if (count($r))
+ if (dba::is_result($r))
$contact = $r[0];
if ($contact['self'])
intval($argv[2]),
intval($uid)
);
- if (count($r))
+ if (dba::is_result($r))
$it = $r[0];
}
if (!$it)
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?
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 ?
intval($suggest["uid"]),
intval($fid)
);
- if(count($r))
+ if(dba::is_result($r))
return false;
}
if(!$fid)
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.
dbesc($item["uri"]),
intval($importer["uid"])
);
- if(count($r))
+ if(dba::is_result($r))
$ev["id"] = $r[0]["id"];
$event_id = event_store($ev);
}
// 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
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"];
}
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"])
);
$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);
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;
}
}
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.
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";
dbesc($arr['uri']),
intval($arr['uid'])
);
- if(count($r))
+ if(dba::is_result($r))
$event = $r[0];
$item_arr = array();
$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;
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']);
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' ) ",
$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'];
}
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",
$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)) {
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)) {
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);
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']));
intval($uid),
dbesc($name)
);
- if(count($r))
+ if(dba::is_result($r))
$group_id = $r[0]['id'];
if(! $group_id)
return false;
intval($uid),
dbesc($name)
);
- if(count($r))
+ if(dba::is_result($r))
return $r[0]['id'];
return false;
}
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
intval($gid),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$ret = $r;
}
return $ret;
intval(local_user()),
dbesc(NETWORK_OSTATUS)
);
- if(count($r))
+ if(dba::is_result($r))
$ret = count($r);
}
return $ret;
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' : ''));
}
$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' : '');
$ret = array();
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$ret[] = $rr['contact-id'];
if($check_dead AND !$use_gcontact) {
);
$ret = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$ret[] = $rr['gid'];
}
$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;
}
$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;
}
'entries' => array(),
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$profile['menu']['entries'][] = array(
if(is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid']));
- if(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
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS)
);
- if(count($r))
+ if(dba::is_result($r))
$contacts = intval($r[0]['total']);
}
}
/* 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'));
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?)
$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;
}
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
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);
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("");
$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"];
}
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"];
}
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"];
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"]);
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'])
);
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);
}
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) {
intval($_SESSION['visitor_id']),
intval($owner_uid)
);
- if(count($r))
+ if(dba::is_result($r))
$contact = $r[0];
}
if(! $contact) {
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
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)
dbesc($replyto),
dbesc($replyto)
);
- if(count($r))
+ if(dba::is_result($r))
$convid = $r[0]['convid'];
}
dbesc($conv_guid),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$convid = $r[0]['id'];
}
dbesc($uri),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$post_id = $r[0]['id'];
/**
dbesc($conv_guid),
intval($recipient['uid'])
);
- if(count($r))
+ if(dba::is_result($r))
$convid = $r[0]['id'];
if(! $convid) {
intval($uid),
dbesc(NETWORK_DFRN)
);
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$recipients_followup[] = $rr['id'];
}
$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
intval($uid),
dbesc(NETWORK_MAIL)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$recipients[] = $rr['id'];
}
// delivery loop
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $contact) {
if(!$contact['self']) {
$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
$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;
}
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'];
dbesc($nonce),
intval($timestamp)
);
- if (count($r))
+ if (dba::is_result($r))
return new OAuthToken($r[0]['id'],$r[0]['secret']);
return null;
}
$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);
$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;
$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;
}
$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;
}
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']);
}
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
$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'];
}
$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'];
}
if(strlen($plugins)) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
- if(count($r))
+ if(dba::is_result($r))
$installed = $r;
else
$installed = array();
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' ) ",
$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();
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));
}
$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];
}
$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;
intval(PAGE_COMMUNITY)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$verified = 2;
return true;
}
intval($remote_user),
intval($owner_id)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
intval($remote_user),
intval($owner_id)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$remote_verified = true;
$groups = init_groups_visitor($remote_user);
}
WHERE `contact-id` = %d ",
intval($contact_id)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$groups[] = $rr['gid'];
}
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 {
$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'];
}
$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"];
}
);
// logger("count_common_friends: $uid $cid {$r[0]['total']}");
- if(count($r))
+ if(dba::is_result($r))
return $r[0]['total'];
return 0;
intval($uid)
);
- if(count($r))
+ if(dba::is_result($r))
return $r[0]['total'];
return 0;
intval($uid)
);
- if(count($r))
+ if(dba::is_result($r))
return $r[0]['total'];
return 0;
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))
$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;
$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;
dbesc(NETWORK_OSTATUS),
dbesc(NETWORK_DIASPORA)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$total = intval($r[0]['total']);
}
if(! $total) {
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) {
// intval($uid)
//);
- if(count($r)) {
+ if(dba::is_result($r)) {
unset($deleted_tags[$key]);
}
else {
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) . ']'),
// 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)
$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;
}
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,
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'])) {
$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')
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'];
}
}
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']) {
intval($a->argv[2]),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$change = intval($a->argv[2]);
}
}
killme();
-}
\ No newline at end of file
+}
$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'])
);
- $contacts = array();
-
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$contacts[] = _contact_detail_for_template($rr);
}
);
$str = '';
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$str .= '<' . $rr['id'] . '>';
if(strlen($str))
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($cid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
}
$parents_arr = array();
$parents_str = '';
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
if(! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$r = q("select `nickname` from user where uid = %d limit 1",
intval($id)
);
- if(count($r)) {
+ if(dba::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(dba::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
intval($a->argv[2]),
intval(local_user())
dbesc($a->user['email']),
dbesc($a->user['password'])
);
- if(count($r))
+ if(dba::is_result($r))
$full_managers = $r;
$delegates = array();
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$delegates = $r;
$uids = array();
$nicknames = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
}
$r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
if(! in_array($rr['uid'],$uids))
$potentials[] = $rr;
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id)
);
- if(count($r))
+ if(dba::is_result($r))
$contact = $r[0];
else
$contact = null;
intval($uid)
);
- if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
+ if((dba::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
require_once('include/items.php');
$r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
dbesc($decrypted_dfrn_id)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
xml_status(1,$message); // Birthday paradox - duplicate dfrn-id
// NOTREACHED
$r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($dfrn_record));
- if(count($r))
+ if(dba::is_result($r))
$photo = $r[0]['photo'];
else
$photo = $a->get_baseurl() . '/images/person-175.jpg';
intval($dfrn_record)
);
- if(count($r))
+ if(dba::is_result($r))
$combined = $r[0];
- if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
+ if((dba::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
intval($local_uid)
);
- if((count($r)) && ($r[0]['hide-friends'] == 0)) {
+ if((dba::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
require_once('include/items.php');
dbesc($a->argv[1])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id));
- if(count($r)) {
+ if(dba::is_result($r)) {
xml_status(1);
return; // NOTREACHED
}
$reputation = 0;
$text = '';
- if(count($r)) {
+ if(dba::is_result($r)) {
$reputation = $r[0]['rating'];
$text = $r[0]['reason'];
dbesc($nickname)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$challenge = '';
$encrypted_id = '';
));
}
- $profile = ((count($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
+ $profile = ((dba::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
switch($destination_url) {
case 'profile':
dbesc(normalise_link($dfrn_url))
);
- if(count($r)) {
+ if(dba::is_result($r)) {
if(strlen($r[0]['dfrn-id'])) {
/**
dbesc($dfrn_url),
$parms['key'] // this was already escaped
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$def_gid = get_default_group(local_user(), $r[0]["network"]);
if(intval($def_gid))
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
dbesc(NETWORK_MAIL2)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d",
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
dbesc(NETWORK_MAIL2)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d",
dbesc($poll),
intval($uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact_id = $r[0]['id'];
$def_gid = get_default_group($uid, $r[0]["network"]);
$parms['url'],
$parms['issued-id']
);
- if(count($r))
+ if(dba::is_result($r))
$contact_record = $r[0];
}
dbesc($_GET['confirm_key'])
);
- if(count($intro)) {
+ if(dba::is_result($intro)) {
+
+ $auto_confirm = false;
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`id` = %d LIMIT 1",
intval($intro[0]['contact-id'])
);
- $auto_confirm = false;
-
- if(count($r)) {
+ if(dba::is_result($r)) {
if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
$auto_confirm = true;
$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(dba::is_result($r))
$a->set_pager_total($r[0]['total']);
$order = " ORDER BY `name` ASC ";
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(dba::is_result($r)) {
if(in_array('small', $a->argv))
$photo = 'thumb';
$r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
- if (count($r)) {
+ if (dba::is_result($r)) {
$nick = $a->user["nickname"];
$itemuid = local_user();
}
AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
- if (count($r)) {
+ if (dba::is_result($r)) {
$nick = $r[0]["nickname"];
$itemuid = $r[0]["uid"];
}
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
}
- if (count($r)) {
+ if (dba::is_result($r)) {
if ($r[0]["id"] != $r[0]["parent"])
$r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
dbesc($nickname)
);
- if (count($r))
+ if (dba::is_result($r))
$profiledata = $r[0];
$profiledata["network"] = NETWORK_DFRN;
dbesc(normalise_link($profiledata["url"])), intval(local_user()),
intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if (count($r)) {
+ if (dba::is_result($r)) {
$profiledata["name"] = $r[0]["name"];
$profiledata["photo"] = $r[0]["photo"];
$profiledata["nickname"] = $r[0]["nick"];
// Fetching profile data from global contacts
if ($profiledata["network"] != NETWORK_FEED) {
$r = q("SELECT `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`, `network` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"])));
- if (count($r)) {
+ if (dba::is_result($r)) {
$profiledata["name"] = $r[0]["name"];
$profiledata["photo"] = $r[0]["photo"];
$profiledata["nickname"] = $r[0]["nick"];
$r = q("SELECT `id` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
- if (count($r)) {
+ if (dba::is_result($r)) {
$item_id = $r[0]["id"];
$nick = $a->user["nickname"];
}
AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
- if (count($r)) {
+ if (dba::is_result($r)) {
$item_id = $r[0]["id"];
$nick = $r[0]["nickname"];
}
AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
- if (count($r)) {
+ if (dba::is_result($r)) {
$item_id = $r[0]["id"];
}
}
intval($contact_id),
intval($a->profile['uid'])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($a->profile['uid'])
);
- if(count($r))
+ if(dba::is_result($r))
$a->page_contact = $r[0];
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
$r = q("SELECT * 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;
$links = array();
- if(count($r)) {
+ if(dba::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'));
$last_date = '';
$fmt = t('l, F j');
- if(count($r)) {
+ if(dba::is_result($r)) {
$r = sort_by_date($r);
foreach($r as $rr) {
intval($event_id),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$orig_event = $r[0];
}
$visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0");
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$visible_plugins[] = $rr['name'];
}
$visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0");
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$visible_plugins[] = $rr['name'];
}
intval($new_contact),
intval(local_user())
);
- if(count($r)) {
+ if(dba::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')",
dbesc($hash),
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$fsuggest_id = $r[0]['id'];
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($note),
intval($a->argv[2]),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$result = group_rmv(local_user(),$r[0]['name']);
if($result)
info( t('Group removed.') . EOL);
intval($a->argv[2]),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$change = intval($a->argv[2]);
}
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) {
if(! in_array($member['id'],$preselected)) {
intval($parent_item['contact-id']),
intval($uid)
);
- if(count($r))
+ if(dba::is_result($r))
$parent_contact = $r[0];
// If the contact id doesn't fit with the contact, then set the contact to null
$r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($thrparent[0]["author-link"])));
- if (count($r)) {
+ if (dba::is_result($r)) {
$parent_contact = $r[0];
$parent_contact["thumb"] = $parent_contact["photo"];
$parent_contact["micro"] = $parent_contact["photo"];
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($profile_uid)
);
- if(count($r))
+ if(dba::is_result($r))
$user = $r[0];
if($orig_post) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
- if(count($r) && intval($r[0]['pubmail']))
+ if(dba::is_result($r) && intval($r[0]['pubmail']))
$pubmail_enabled = true;
}
}
}
}
- if(count($r)) {
+ if(dba::is_result($r)) {
$author = $r[0];
$contact_id = $author['id'];
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($profile_uid)
);
- if(count($r))
+ if(dba::is_result($r))
$contact_record = $r[0];
}
intval($profile_uid),
intval($attach)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `uid` = %d AND `id` = %d",
dbesc($str_contact_allow),
intval($profile_uid),
intval($mtch)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
if(strlen($attachments))
$attachments .= ',';
$attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $allowed_groups))
);
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$l[] = '<b>' . $rr['name'] . '</b>';
}
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$allowed_users))
);
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$l[] = $rr['name'];
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $deny_groups))
);
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
}
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$deny_users))
);
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$l[] = '<strike>' . $rr['name'] . '</strike>';
$r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage'])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$uid = intval($r[0]['uid']);
$orig_record = $r[0];
}
intval($a->argv[2]),
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$parent = $r[0]['parent-uri'];
$convid = $r[0]['convid'];
intval(local_user()),
intval($a->argv[2])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$prename = $r[0]['name'];
$preurl = $r[0]['url'];
$preid = $r[0]['id'];
intval(local_user()),
intval($a->argv[1])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact_id = $r[0]['contact-id'];
$convid = $r[0]['convid'];
intval($parent),
intval($uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$parent_uri = $r[0]['uri'];
$private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid'];
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
dbesc($search)
);
- if(count($r))
+
+ if(dba::is_result($r))
$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(dba::is_result($r)) {
foreach($r as $rr)
$results[] = array(
'name' => $rr['name'],
killme();
-}
\ No newline at end of file
+}
$saved = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$saved[] = array(
'id' => $rr['id'],
);
$str = '';
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $rr)
$str .= '<' . $rr['id'] . '>';
if(strlen($str))
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($cid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
$entries[0] = array(
intval($_SESSION['uid'])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$a->set_pager_total($r[0]['total']);
}
}
require_once('include/Contact.php');
$r = contacts_not_grouped(local_user());
- if(count($r)) {
+ if(dba::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(dba::is_result($r)) {
foreach($r as $rr) {
$contact_details = get_contact_details_by_url($rr['url'], local_user());
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))
$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
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS)
);
- if(count($r))
+ if(dba::is_result($r))
$json_info["contacts"] = intval($r[0]['total']);
}
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40);
}
$parents_arr = array();
$parents_str = '';
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
dbesc($parents_str)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$items = conv_sort($r,"`commented`");
$o .= conversation($a,$items,'notes',$update);
$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 (dba::is_result($r)){
$nick = $r[0]['nickname'];
$url = $a->get_baseurl()."/display/$nick/$id";
goaway($url);
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$intro_id = $r[0]['id'];
$contact_id = $r[0]['contact-id'];
}
WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
intval($_SESSION['uid']));
- if(($r !== false) && (count($r))) {
+ if(dba::is_result($r)) {
$sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl");
intval(local_user())
);
- if (count($r) > 0) {
+ if (dba::is_result($r)) {
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
'$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
$notif_content = '';
- if (count($r) > 0) {
+ if (dba::is_result($r)) {
foreach ($r as $it) {
switch($it['verb']){
$notif_content = '';
- if (count($r) > 0) {
+ if (dba::is_result($r)) {
foreach ($r as $it) {
switch($it['verb']){
intval($resolution),
intval($uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$data = $r[0]['data'];
$mimetype = $r[0]['type'];
}
dbesc($photo),
intval($resolution)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$sql_extra = permissions_sql($r[0]['uid']);
intval($resolution)
);
- $public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
+ $public = (dba::is_result($r)) && ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
- if(count($r)) {
+ if(dba::is_result($r)) {
$resolution = $r[0]['scale'];
$data = $r[0]['data'];
$mimetype = $r[0]['type'];
intval($cid),
intval($page_owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$can_post = true;
$visitor = $cid;
}
dbesc($album)
);
}
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$res[] = "'" . dbesc($rr['rid']) . "'" ;
}
$r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
intval($page_owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($a->argv[2])
);
}
- if(count($r)) {
+ if(dba::is_result($r)) {
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
intval($page_owner_uid),
dbesc($r[0]['resource-id'])
dbesc($resource_id),
intval($page_owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$ph = new Photo($r[0]['data'], $r[0]['type']);
if($ph->is_valid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
intval($page_owner_uid)
);
}
- if(count($r)) {
+ if(dba::is_result($r)) {
$old_tag = $r[0]['tag'];
$old_inform = $r[0]['inform'];
}
intval($page_owner_uid)
);
}*/
- if(count($r)) {
+ if(dba::is_result($r)) {
$newname = $r[0]['name'];
$profile = $r[0]['url'];
$notify = 'cid:' . $r[0]['id'];
intval($contact_id),
intval($owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$can_post = true;
$contact = $r[0];
$remote_contact = true;
intval($contact_id),
intval($owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
intval($owner_uid),
dbesc($album)
);
- if(count($r)) {
- $a->set_pager_total(count($r));
+ if(dba::is_result($r)) {
+ $a->set_pager_total(dba::is_result($r));
$a->set_pager_itemspage(20);
}
$photos = array();
- if(count($r))
+ if(dba::is_result($r))
$twist = 'rotright';
foreach($r as $rr) {
if($twist == 'rotright')
);
- if(count($r))
+ if(dba::is_result($r))
$a->set_pager_total($r[0]['total']);
// display comments
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $item) {
builtin_activity_puller($item, $conv_responses);
dbesc('Contact Photos'),
dbesc( t('Contact Photos'))
);
- if(count($r)) {
- $a->set_pager_total(count($r));
+ if(dba::is_result($r)) {
+ $a->set_pager_total(dba::is_result($r));
$a->set_pager_itemspage(20);
}
$photos = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
$twist = 'rotright';
foreach($r as $rr) {
//hide profile photos to others
dbesc(NETWORK_STATUSNET)
);
}
- if(count($r))
+ if(dba::is_result($r))
$totalResults = intval($r[0]['total']);
else
$totalResults = 0;
}
if(is_array($r)) {
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
if (!isset($rr['generation'])) {
if ($global)
intval($parent),
intval($uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$parent_uri = $r[0]['uri'];
$private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid'];
intval($_GET['c']),
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$name = $r[0]['name'];
$id = $r[0]['id'];
}
$which = $a->argv[1];
else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
- if(count($r)) {
+ if(dba::is_result($r)) {
goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
}
else {
intval($contact_id),
intval($a->profile['profile_uid'])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
AND `thread`.`wall` = 1
$sql_extra $sql_extra2 ",
intval($a->profile['profile_uid'])
- );
+ );
- if(count($r)) {
- $a->set_pager_total($r[0]['total']);
+ if(dba::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
intval($_REQUEST['profile']),
intval(local_user())
);
- if(count($r) && (! intval($r[0]['is-default'])))
+ if(dba::is_result($r) && (! intval($r[0]['is-default'])))
$is_default_profile = 0;
}
dbesc(local_user()),
intval($scale));
- if(count($r)) {
+ if(dba::is_result($r)) {
$base_image = $r[0];
intval(local_user())
);
}
- if(count($r)) {
+ if(dba::is_result($r)) {
$prf = $r[0]['url'];
$newname = $r[0]['name'];
}
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user()
);
- if(count($r)){
+ if(dba::is_result($r)){
//Go to the default profile.
goaway('profiles/'.$r[0]['id']);
}
$r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user());
- if(count($r)) {
+ if(dba::is_result($r)) {
$tpl_header = get_markup_template('profile_listing_header.tpl');
$o .= replace_macros($tpl_header,array(
intval($a->argv[2]),
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$change = intval($a->argv[2]);
}
);
$ingroup = array();
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $member)
$ingroup[] = $member['id'];
$members = $r;
$ingroup = array();
- if(count($r))
+ if(dba::is_result($r))
foreach($r as $member)
$ingroup[] = $member['id'];
}
dbesc(NETWORK_DFRN)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) {
if(! in_array($member['id'],$ingroup)) {
if (!$direct_cache AND ($cachefile == "")) {
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
- if (count($r)) {
+ if (dba::is_result($r)) {
$img_str = $r[0]['data'];
$mime = $r[0]["desc"];
if ($mime == "") $mime = "image/jpeg";
// if we are just updating an old subscription, keep the
// old values for push and last_update
- if (count($r)) {
+ if (dba::is_result($r)) {
$last_update = $r[0]['last_update'];
$push_flag = $r[0]['push'];
}
intval($limit)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
);
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr)
$results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
intval($user[0]['uid'])
);
- if(count($r) && $r[0]['net-publish']) {
+ if(dba::is_result($r) && $r[0]['net-publish']) {
$url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
if($url && strlen(get_config('system','directory')))
proc_run('php',"include/directory.php","$url");
// 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((dba::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
+ if(dba::is_result($r) && $r[0]['blocked']) {
logger('mod-salmon: Ignoring this author.');
http_status_exit(202);
// NOTREACHED
// Placeholder for hub discovery.
$hub = '';
- $contact_rec = ((count($r)) ? $r[0] : null);
+ $contact_rec = ((dba::is_result($r)) ? $r[0] : null);
ostatus::import($data,$importer,$contact_rec, $hub);
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$saved = array();
foreach($r as $rr) {
$saved[] = array(
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$eacct = $r[0];
require_once('include/email.php');
$mb = construct_mailbox_name($eacct);
$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 = ((dba::is_result($r)) ? $r[0]['server'] : '');
+ $mail_port = ((dba::is_result($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
+ $mail_ssl = ((dba::is_result($r)) ? $r[0]['ssltype'] : '');
+ $mail_user = ((dba::is_result($r)) ? $r[0]['user'] : '');
+ $mail_replyto = ((dba::is_result($r)) ? $r[0]['reply_to'] : '');
+ $mail_pubmail = ((dba::is_result($r)) ? $r[0]['pubmail'] : 0);
+ $mail_action = ((dba::is_result($r)) ? $r[0]['action'] : 0);
+ $mail_movetofolder = ((dba::is_result($r)) ? $r[0]['movetofolder'] : '');
+ $mail_chk = ((dba::is_result($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
$tpl = get_markup_template("settings_connectors.tpl");
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) {
intval($_SESSION['visitor_id']),
intval($owner_uid)
);
- if(count($r))
+ if(dba::is_result($r))
$contact = $r[0];
}
if(! $contact) {
$r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
intval($owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$owner_nick = $r[0]['nickname'];
$blocktags = $r[0]['blocktags'];
}
$r = q("select * from contact where self = 1 and uid = %d limit 1",
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$contact = $r[0];
else {
logger('tagger: no contact_id');
$r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1",
dbesc($item['uri'])
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
intval($r[0]['uid'])
);
function _uexport_multirow($query) {
$result = array();
$r = q($query);
-// if(count($r)) {
+// if(dba::is_result($r)) {
if ($r){
foreach($r as $rr){
$p = array();
$r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ",
intval(local_user())
);
- if(count($r))
+ if(dba::is_result($r))
$total = $r[0]['total'];
// chunk the output to avoid exhausting memory
intval($x),
intval(500)
);
- /*if(count($r)) {
+ /*if(dba::is_result($r)) {
foreach($r as $rr)
foreach($rr as $k => $v)
$item[][$k] = $v;
dbesc($video_id)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
q("DELETE FROM `attach` WHERE `uid` = %d AND `id` = '%s'",
intval(local_user()),
dbesc($video_id)
intval($contact_id),
intval($owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$can_post = true;
$contact = $r[0];
$remote_contact = true;
intval($contact_id),
intval($owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
$sql_extra GROUP BY hash",
intval($a->data['user']['uid'])
);
- if(count($r)) {
- $a->set_pager_total(count($r));
+ if(dba::is_result($r)) {
+ $a->set_pager_total(dba::is_result($r));
$a->set_pager_itemspage(20);
}
$videos = array();
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
if($a->theme['template_engine'] === 'internal') {
$alt_e = template_escape($rr['filename']);
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS)
);
- if(count($r))
+ if(dba::is_result($r))
$a->set_pager_total($r[0]['total']);
$r = q("SELECT * FROM `contact`
dbesc($item_id)
);
- if(count($r))
+ if(dba::is_result($r))
if(is_ajax()) {
echo str_replace("\n",'<br />',$r[0]['body']);
killme();
intval($cid),
intval($page_owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$can_post = true;
$visitor = $cid;
}
intval($cid),
intval($page_owner_uid)
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$can_post = true;
$visitor = $cid;
}
intval($item['uid']),
intval($item['id'])
);
- if (count($r)) {
+ if (dba::is_result($r)) {
$ignore = array(
'do' => t("ignore thread"),
'undo' => t("unignore thread"),
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;
}
}
*/
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='';
}
//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".
// $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.
//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
+}
// create 's' keys for everybody that does not have one
$r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$sres=openssl_pkey_new(array('encrypt_key' => false ));
$sprvkey = '';
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(dba::is_result($r)) {
foreach($r as $rr) {
q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
dbesc(basename($rr['url'])),
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(dba::is_result($r)) {
foreach($r as $rr) {
$ph = new Photo($rr['data']);
if($ph->is_valid()) {
}
}
$r = q("SELECT * FROM `contact` WHERE 1");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
if(stristr($rr['thumb'],'avatar'))
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
function update_1036() {
$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
- if(count($r)) {
+ if(dba::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'])),
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(dba::is_result($r)) {
foreach($r as $rr)
q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
intval($rr['uid'])
function update_1075() {
q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
$r = q("SELECT `uid` FROM `user` WHERE 1");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$found = true;
do {
if($r && count($r))
return;
$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$guid = get_guid();
q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
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(dba::is_result($r)) {
foreach($r as $rr) {
$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
intval($rr['id'])
require_once('include/text.php');
$r = q("select id, url from contact where url != '' and nurl = '' ");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
q("update contact set nurl = '%s' where id = %d",
dbesc(normalise_link($rr['url'])),
// 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(dba::is_result($r)) {
foreach($r as $rr) {
$found = false;
foreach($arr as $x) {
$arr = array();
$r = q("select * from pconfig where 1 order by id desc");
- if(count($r)) {
+ if(dba::is_result($r)) {
foreach($r as $rr) {
$found = false;
foreach($arr as $x) {
);
// convert old forumlist addon entries in new config entries
- if (count($r)) {
+ if (dba::is_result($r)) {
foreach ($r as $rr) {
$uid = $rr['uid'];
$family = $rr['cat'];
$r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id
where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
$tpl = get_markup_template('ch_directory_item.tpl');
- if(count($r)) {
+ if(dba::is_result($r)) {
$photo = 'photo';
foreach($r as $rr) {
$profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
9
);
$tpl = get_markup_template('ch_directory_item.tpl');
- if(count($r)) {
+ if(dba::is_result($r)) {
$photo = 'thumb';
foreach($r as $rr) {
$profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
dbesc(t('Contact Photos')),
dbesc(t('Profile Photos'))
);
- if(count($r)) {
+ if(dba::is_result($r)) {
$tpl = get_markup_template('ch_directory_item.tpl');
foreach($r as $rr) {
$photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
$r = suggestion_query(local_user(), 0, 9);
$tpl = get_markup_template('ch_directory_item.tpl');
- if(count($r)) {
+ if(dba::is_result($r)) {
$aside['$comunity_profiles_title'] = t('Community Profiles');
$aside['$comunity_profiles_items'] = array();
$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(dba::is_result($r)) {
$aside['$lastusers_title'] = t('Last users');
$aside['$lastusers_items'] = array();
$tpl = get_markup_template('ch_connectors.tpl');
- if(count($r)) {
+ if(dba::is_result($r)) {
$con_services = array();
$con_services['title'] = Array("", t('Connect Services'), "", "");