mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-21 20:03:40 +00:00
Rename DBM method calls to DBA method calls
This commit is contained in:
parent
8cdacf34b1
commit
332ea212b5
11 changed files with 79 additions and 87 deletions
|
@ -40,7 +40,6 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Term;
|
||||
|
@ -414,7 +413,7 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
|
|||
$params = ['order' => ['uid' => true]];
|
||||
$item = Item::selectFirstForUser(local_user(), [], $condition, $params);
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid']));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
@ -86,7 +85,7 @@ function catavatar_addon_settings_post(App $a, &$s)
|
|||
$url = $a->get_baseurl() . '/catavatar/' . local_user() . '?ts=' . time();
|
||||
|
||||
$self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
|
||||
if (!DBM::is_result($self)) {
|
||||
if (!DBA::is_result($self)) {
|
||||
notice(L10n::t("The cat hadn't found itself."));
|
||||
return;
|
||||
}
|
||||
|
@ -95,7 +94,7 @@ function catavatar_addon_settings_post(App $a, &$s)
|
|||
|
||||
$condition = ['uid' => local_user(), 'contact-id' => $self['id']];
|
||||
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
||||
if (!DBM::is_result($photo)) {
|
||||
if (!DBA::is_result($photo)) {
|
||||
notice(L10n::t('There was an error, the cat ran away.'));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Queue;
|
||||
|
||||
function diaspora_install() {
|
||||
|
@ -141,7 +140,7 @@ function diaspora_settings(&$a,&$s) {
|
|||
$status = "";
|
||||
|
||||
$r = q("SELECT `addr` FROM `contact` WHERE `self` AND `uid` = %d", intval(local_user()));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$status = L10n::t("Please remember: You can always be reached from Diaspora with your Friendica handle %s. ", $r[0]['addr']);
|
||||
$status .= L10n::t('This connector is only meant if you still want to use your old Diaspora account for some time. ');
|
||||
$status .= L10n::t('However, it is preferred that you tell your Diaspora contacts the new handle %s instead.', $r[0]['addr']);
|
||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\Content\Widget;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
|
@ -107,7 +107,7 @@ function forumdirectory_content(&$a)
|
|||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`"
|
||||
. " WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ function forumdirectory_content(&$a)
|
|||
intval($a->pager['itemspage'])
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
if (in_array('small', $a->argv)) {
|
||||
$photo = 'thumb';
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
function ifttt_install()
|
||||
|
@ -102,7 +101,7 @@ function ifttt_post(App $a)
|
|||
$nickname = $a->argv[1];
|
||||
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
||||
if (!DBM::is_result($user)) {
|
||||
if (!DBA::is_result($user)) {
|
||||
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
|
@ -173,7 +173,7 @@ function mailstream_do_images($a, &$item, &$attachments) {
|
|||
|
||||
function mailstream_sender($item) {
|
||||
$r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']);
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact = $r[0];
|
||||
if ($contact['name'] != $item['author-name']) {
|
||||
return $contact['name'] . ' - ' . $item['author-name'];
|
||||
|
@ -214,7 +214,7 @@ function mailstream_subject($item) {
|
|||
// Don't look more than 100 levels deep for a subject, in case of loops
|
||||
for ($i = 0; ($i < 100) && $parent; $i++) {
|
||||
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
|
||||
if (!DBM::is_result($parent_item)) {
|
||||
if (!DBA::is_result($parent_item)) {
|
||||
break;
|
||||
}
|
||||
if ($parent_item['thr-parent'] === $parent) {
|
||||
|
|
|
@ -10,7 +10,6 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
function public_server_install()
|
||||
|
@ -60,7 +59,7 @@ function public_server_cron($a, $b)
|
|||
`expire_notification_sent` <= '%s'",
|
||||
dbesc(NULL_DATE), dbesc(NULL_DATE));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
notification([
|
||||
'uid' => $rr['uid'],
|
||||
|
@ -83,7 +82,7 @@ function public_server_cron($a, $b)
|
|||
if ($nologin) {
|
||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
|
||||
dbesc(NULL_DATE), intval($nologin), dbesc(NULL_DATE));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||
|
@ -95,7 +94,7 @@ function public_server_cron($a, $b)
|
|||
if ($flagusers) {
|
||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' AND `page-flags` = 0",
|
||||
intval($flagusers), dbesc(NULL_DATE));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||
|
@ -108,7 +107,7 @@ function public_server_cron($a, $b)
|
|||
if ($flagposts && $flagpostsexpire) {
|
||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' and `expire` = 0 AND `page-flags` = 0",
|
||||
intval($flagposts), dbesc(NULL_DATE));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
|
@ -421,7 +420,7 @@ function pumpio_send(App $a, array &$b)
|
|||
$condition = ['id' => $b['parent'], 'network' => NETWORK_PUMPIO];
|
||||
$orig_post = Item::selectFirst([], $condition);
|
||||
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
logger("pumpio_send: no pumpio post ".$b["parent"]);
|
||||
return;
|
||||
} else {
|
||||
|
@ -573,7 +572,7 @@ function pumpio_send(App $a, array &$b)
|
|||
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
||||
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$a->contact = $r[0]["id"];
|
||||
}
|
||||
|
||||
|
@ -601,7 +600,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
|
|||
|
||||
$orig_post = Item::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
|
||||
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -650,7 +649,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
|
|||
logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
|
||||
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$a->contact = $r[0]["id"];
|
||||
}
|
||||
|
||||
|
@ -665,7 +664,7 @@ function pumpio_sync(App $a)
|
|||
{
|
||||
$r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'");
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -683,7 +682,7 @@ function pumpio_sync(App $a)
|
|||
logger('pumpio: cron_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger('pumpio: mirroring user '.$rr['uid']);
|
||||
pumpio_fetchtimeline($a, $rr['uid']);
|
||||
|
@ -698,11 +697,11 @@ function pumpio_sync(App $a)
|
|||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::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 (!DBM::is_result($user)) {
|
||||
if (!DBA::is_result($user)) {
|
||||
logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
||||
continue;
|
||||
}
|
||||
|
@ -871,9 +870,9 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
|
|||
// Searching for the unliked post
|
||||
// Two queries for speed issues
|
||||
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -888,7 +887,7 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contactid = $r[0]['id'];
|
||||
}
|
||||
|
||||
|
@ -899,7 +898,7 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
|
|||
|
||||
Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||
} else {
|
||||
logger("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||
|
@ -918,9 +917,9 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
|
|||
// Searching for the liked post
|
||||
// Two queries for speed issues
|
||||
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -943,7 +942,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contactid = $r[0]['id'];
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1017,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
|
|||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc(normalise_link($contact->url)));
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
|
@ -1048,7 +1047,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1176,7 +1175,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact_id = $r[0]['id'];
|
||||
} else {
|
||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||
|
@ -1184,7 +1183,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact_id = $r[0]['id'];
|
||||
} else {
|
||||
$contact_id = $self[0]['id'];
|
||||
|
@ -1405,7 +1404,7 @@ function pumpio_queue_hook(App $a, array &$b)
|
|||
dbesc(NETWORK_PUMPIO)
|
||||
);
|
||||
|
||||
if (!DBM::is_result($qi)) {
|
||||
if (!DBA::is_result($qi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1419,7 @@ function pumpio_queue_hook(App $a, array &$b)
|
|||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
||||
intval($x['cid'])
|
||||
);
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1512,7 +1511,7 @@ function pumpio_getreceiver(App $a, array $b)
|
|||
dbesc(NETWORK_PUMPIO)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$receiver["bcc"][] = [
|
||||
"displayName" => $r[0]["name"],
|
||||
"objectType" => "person",
|
||||
|
@ -1555,7 +1554,7 @@ function pumpio_getreceiver(App $a, array $b)
|
|||
dbesc(NETWORK_PUMPIO)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$receiver["to"][] = [
|
||||
"displayName" => $r[0]["name"],
|
||||
"objectType" => "person",
|
||||
|
@ -1587,7 +1586,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
|
|||
// Fetching the original post
|
||||
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
|
||||
$item = Item::selectFirst(['extid'], $condition);
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -465,7 +464,7 @@ function statusnet_post_hook(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
|
@ -686,7 +685,7 @@ function statusnet_prepare_body(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||
if (DBM::is_result($orig_post)) {
|
||||
if (DBA::is_result($orig_post)) {
|
||||
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
|
||||
|
||||
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
|
||||
|
@ -731,7 +730,7 @@ function statusnet_cron(App $a, $b)
|
|||
logger('statusnet: cron_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger('statusnet: fetching for user ' . $rr['uid']);
|
||||
statusnet_fetchtimeline($a, $rr['uid']);
|
||||
|
@ -746,11 +745,11 @@ function statusnet_cron(App $a, $b)
|
|||
$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 (DBM::is_result($r)) {
|
||||
if (DBA::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 (!DBM::is_result($user)) {
|
||||
if (!DBA::is_result($user)) {
|
||||
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
||||
continue;
|
||||
}
|
||||
|
@ -902,16 +901,16 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
|||
|
||||
$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 (!DBM::is_result($r) && !$create_user) {
|
||||
if (!DBA::is_result($r) && !$create_user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (DBM::is_result($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
||||
if (DBA::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 (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
|
@ -941,7 +940,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
|||
intval($uid),
|
||||
dbesc(NETWORK_STATUSNET));
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1025,7 +1024,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
return;
|
||||
|
@ -1087,11 +1086,11 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
$fields = ['uri', 'parent-uri', 'parent'];
|
||||
$item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
$item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
if (DBA::is_result($item)) {
|
||||
$postarray['thr-parent'] = $item['uri'];
|
||||
$postarray['parent-uri'] = $item['parent-uri'];
|
||||
$postarray['parent'] = $item['parent'];
|
||||
|
@ -1109,7 +1108,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contactid = $r[0]["id"];
|
||||
|
||||
$postarray['owner-name'] = $r[0]["name"];
|
||||
|
@ -1213,7 +1212,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
intval($own_contact),
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$nick = $r[0]["nick"];
|
||||
} else {
|
||||
logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1223,7 +1222,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1232,7 +1231,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
|||
|
||||
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid));
|
||||
if (!DBM::is_result($u)) {
|
||||
if (!DBA::is_result($u)) {
|
||||
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
@ -1522,7 +1521,7 @@ function statusnet_fetch_own_contact(App $a, $uid)
|
|||
} else {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc($own_url));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact_id = $r[0]["id"];
|
||||
} else {
|
||||
PConfig::delete($uid, 'statusnet', 'own_url');
|
||||
|
|
|
@ -72,7 +72,6 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
|
@ -185,7 +184,7 @@ function twitter_follow(App $a, &$contact)
|
|||
FROM `contact` WHERE `uid` = %d AND `nick` = '%s'",
|
||||
intval($uid),
|
||||
dbesc($nickname));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact["contact"] = $r[0];
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +467,7 @@ function twitter_post_hook(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
||||
$orig_post = Item::selectFirst([], $condition);
|
||||
if (!DBM::is_result($orig_post)) {
|
||||
if (!DBA::is_result($orig_post)) {
|
||||
logger("twitter_post_hook: no parent found " . $b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
|
@ -622,7 +621,7 @@ function twitter_post_hook(App $a, &$b)
|
|||
logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
||||
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$a->contact = $r[0]["id"];
|
||||
}
|
||||
|
||||
|
@ -677,7 +676,7 @@ function twitter_cron(App $a, $b)
|
|||
logger('twitter: cron_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1'");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger('twitter: fetching for user ' . $rr['uid']);
|
||||
Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int) $rr['uid']);
|
||||
|
@ -692,11 +691,11 @@ function twitter_cron(App $a, $b)
|
|||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::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 (!DBM::is_result($user)) {
|
||||
if (!DBA::is_result($user)) {
|
||||
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
||||
continue;
|
||||
}
|
||||
|
@ -751,7 +750,7 @@ function twitter_expire(App $a, $b)
|
|||
logger('twitter_expire: expire_start');
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger('twitter_expire: user ' . $rr['uid']);
|
||||
Item::expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
||||
|
@ -774,7 +773,7 @@ function twitter_prepare_body(App $a, &$b)
|
|||
|
||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||
$orig_post = Item::selectFirst(['author-link'], $condition);
|
||||
if (DBM::is_result($orig_post)) {
|
||||
if (DBA::is_result($orig_post)) {
|
||||
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
|
||||
$nicknameplain = "@" . $nicknameplain;
|
||||
|
@ -925,7 +924,7 @@ function twitter_queue_hook(App $a, &$b)
|
|||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||
dbesc(NETWORK_TWITTER)
|
||||
);
|
||||
if (!DBM::is_result($qi)) {
|
||||
if (!DBA::is_result($qi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -940,7 +939,7 @@ function twitter_queue_hook(App $a, &$b)
|
|||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
||||
intval($x['cid'])
|
||||
);
|
||||
if (!DBM::is_result($r)) {
|
||||
if (!DBA::is_result($r)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1019,11 +1018,11 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
|||
}
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
|
||||
if (!DBM::is_result($contact) && !$create_user) {
|
||||
if (!DBA::is_result($contact) && !$create_user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
if (!DBA::is_result($contact)) {
|
||||
// create contact record
|
||||
$fields['uid'] = $uid;
|
||||
$fields['created'] = DateTimeFormat::utcNow();
|
||||
|
@ -1083,7 +1082,7 @@ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
return;
|
||||
|
@ -1354,11 +1353,11 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis
|
|||
|
||||
$fields = ['uri', 'parent-uri', 'parent'];
|
||||
$parent_item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
||||
if (!DBM::is_result($parent_item)) {
|
||||
if (!DBA::is_result($parent_item)) {
|
||||
$parent_item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
if (DBM::is_result($parent_item)) {
|
||||
if (DBA::is_result($parent_item)) {
|
||||
$postarray['thr-parent'] = $parent_item['uri'];
|
||||
$postarray['parent-uri'] = $parent_item['parent-uri'];
|
||||
$postarray['parent'] = $parent_item['parent'];
|
||||
|
@ -1376,7 +1375,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contactid = $r[0]["id"];
|
||||
|
||||
$postarray['owner-name'] = $r[0]["name"];
|
||||
|
@ -1575,7 +1574,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
|||
intval($own_contact),
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$own_id = $r[0]["nick"];
|
||||
} else {
|
||||
logger("twitter_fetchhometimeline: Own twitter contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1585,7 +1584,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
|||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$self = $r[0];
|
||||
} else {
|
||||
logger("twitter_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
||||
|
@ -1594,7 +1593,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
|||
|
||||
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid));
|
||||
if (!DBM::is_result($u)) {
|
||||
if (!DBA::is_result($u)) {
|
||||
logger("twitter_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
@ -1661,7 +1660,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
|||
|
||||
if ($postarray['uri'] == $postarray['parent-uri']) {
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
|
||||
if (DBM::is_result($contact)) {
|
||||
if (DBA::is_result($contact)) {
|
||||
$notify = Item::isRemoteSelf($contact, $postarray);
|
||||
}
|
||||
}
|
||||
|
@ -1753,7 +1752,7 @@ function twitter_fetch_own_contact(App $a, $uid)
|
|||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc("twitter::" . $own_id));
|
||||
if (DBM::is_result($r)) {
|
||||
if (DBA::is_result($r)) {
|
||||
$contact_id = $r[0]["id"];
|
||||
} else {
|
||||
PConfig::delete($uid, 'twitter', 'own_id');
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
function viewsrc_install() {
|
||||
Addon::registerHook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
||||
|
@ -43,7 +43,7 @@ function viewsrc_item_photo_menu(&$a, &$b)
|
|||
|
||||
if (local_user() != $b['item']['uid']) {
|
||||
$item = Item::selectFirstForUser(local_user(), ['id'], ['uid' => local_user(), 'guid' => $b['item']['guid']]);
|
||||
if (!DBM::is_result($item)) {
|
||||
if (!DBA::is_result($item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue