use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
+use Friendica\Database\DBM;
function statusnet_install()
{
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
- if (!count($orig_post)) {
+ if (!DBM::is_result($orig_post)) {
logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
return;
} else {
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
- if (count($orig_post)) {
+ if (DBM::is_result($orig_post)) {
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
logger('statusnet: cron_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
- if (count($r)) {
+ if (DBM::is_result($r)) {
foreach ($r as $rr) {
logger('statusnet: fetching for user ' . $rr['uid']);
statusnet_fetchtimeline($a, $rr['uid']);
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
- if (count($r)) {
+ if (DBM::is_result($r)) {
foreach ($r as $rr) {
if ($abandon_days != 0) {
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
- if (!count($user)) {
+ if (!DBM::is_result($user)) {
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
continue;
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
- if (!count($r) && !$create_user) {
+ if (!DBM::is_result($r) && !$create_user) {
return 0;
}
- if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
+ if (DBM::is_result($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
return -1;
}
- if (!count($r)) {
+ if (!DBM::is_result($r)) {
// create contact record
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
intval($uid),
dbesc(NETWORK_STATUSNET));
- if (!count($r)) {
+ if (!DBM::is_result($r)) {
return false;
}
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if (DBM::is_result($r)) {
$self = $r[0];
} else {
return;
intval($uid)
);
- if (count($r)) {
+ if (DBM::is_result($r)) {
return [];
}
dbesc($parent),
intval($uid)
);
- if (count($r)) {
+ if (DBM::is_result($r)) {
$postarray['thr-parent'] = $r[0]["uri"];
$postarray['parent-uri'] = $r[0]["parent-uri"];
$postarray['parent'] = $r[0]["parent"];
dbesc($parent),
intval($uid)
);
- if (count($r)) {
+ if (DBM::is_result($r)) {
$postarray['thr-parent'] = $r[0]['uri'];
$postarray['parent-uri'] = $r[0]['parent-uri'];
$postarray['parent'] = $r[0]['parent'];
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if (DBM::is_result($r)) {
$contactid = $r[0]["id"];
$postarray['owner-name'] = $r[0]["name"];
intval($own_contact),
intval($uid));
- if (count($r)) {
+ if (DBM::is_result($r)) {
$nick = $r[0]["nick"];
} else {
logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if (DBM::is_result($r)) {
$self = $r[0];
} else {
logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
intval($uid));
- if (!count($u)) {
+ if (!DBM::is_result($u)) {
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
return;
}
} else {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc($own_url));
- if (count($r)) {
+ if (DBM::is_result($r)) {
$contact_id = $r[0]["id"];
} else {
PConfig::delete($uid, 'statusnet', 'own_url');