use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
}
// Servers that want to get all content
- $servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
- while ($server = dba::fetch($servers)) {
+ $servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
+ while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
// All tags of the current post
$condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $parent['parent']];
- $tags = dba::select('term', ['term'], $condition);
+ $tags = DBA::select('term', ['term'], $condition);
$taglist = [];
- while ($tag = dba::fetch($tags)) {
+ while ($tag = DBA::fetch($tags)) {
$taglist[] = $tag['term'];
}
// All servers who wants content with this tag
$tagserverlist = [];
if (!empty($taglist)) {
- $tagserver = dba::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
- while ($server = dba::fetch($tagserver)) {
+ $tagserver = DBA::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
+ while ($server = DBA::fetch($tagserver)) {
$tagserverlist[] = $server['gserver-id'];
}
}
// All adresses with the given id
if (!empty($tagserverlist)) {
- $servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
- while ($server = dba::fetch($servers)) {
+ $servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
+ while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
}
// Fetch the relay contact
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
if ($contact['archive'] || $contact['blocked']) {
} else {
self::setRelayContact($server_url);
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
return $contact;
}
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
- if (dba::exists('contact', $condition)) {
+ if (DBA::exists('contact', $condition)) {
unset($fields['created']);
}
- dba::update('contact', $fields, $condition, true);
+ DBA::update('contact', $fields, $condition, true);
}
/**
*/
public static function participantsForThread($thread, array $contacts)
{
- $r = dba::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
+ $r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
`fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
WHERE `participation`.`iid` = ?", $thread);
- while ($contact = dba::fetch($r)) {
+ while ($contact = DBA::fetch($r)) {
if (!empty($contact['fnetwork'])) {
$contact['network'] = $contact['fnetwork'];
}
$contacts[] = $contact;
}
}
- dba::close($r);
+ DBA::close($r);
return $contacts;
}
{
$update = false;
- $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+ $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (DBM::is_result($person)) {
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
self::updateFContact($r);
// Fetch the updated or added contact
- $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+ $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (!DBM::is_result($person)) {
$person = $r;
}
$condition = ['url' => $arr["url"], 'network' => $arr["network"]];
- dba::update('fcontact', $fields, $condition, true);
+ DBA::update('fcontact', $fields, $condition, true);
}
/**
private static function authorContactByUrl($def_contact, $person, $uid)
{
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
- $contact = dba::selectFirst('contact', ['id', 'network'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
if (DBM::is_result($contact)) {
$cid = $contact["id"];
$network = $contact["network"];
'notify' => $data['notify'], 'poll' => $data['poll'],
'network' => $data['network']];
- dba::update('contact', $fields, ['addr' => $old_handle]);
+ DBA::update('contact', $fields, ['addr' => $old_handle]);
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
'name' => $data['name'], 'nick' => $data['nick'],
'notify' => $data['notify'], 'photo' => $data['photo'],
'server_url' => $data['baseurl'], 'network' => $data['network']];
- dba::update('gcontact', $fields, ['addr' => $old_handle]);
+ DBA::update('gcontact', $fields, ['addr' => $old_handle]);
logger('Contacts are updated.');
{
$author = notags(unxmlify($data->author));
- $contacts = dba::select('contact', ['id'], ['addr' => $author]);
- while ($contact = dba::fetch($contacts)) {
+ $contacts = DBA::select('contact', ['id'], ['addr' => $author]);
+ while ($contact = DBA::fetch($contacts)) {
Contact::remove($contact["id"]);
}
- dba::delete('gcontact', ['addr' => $author]);
+ DBA::delete('gcontact', ['addr' => $author]);
logger('Removed contacts for ' . $author);
$item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]);
if (DBM::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
- $contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
+ $contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
if (DBM::is_result($contact)) {
return $contact;
}
$person = self::personByHandle($msg_author);
- dba::lock('mail');
+ DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($msg_created_at)
);
- dba::unlock();
+ DBA::unlock();
- dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
+ DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
notification(
[
$body = self::replacePeopleGuid($body, $person["url"]);
- dba::lock('mail');
+ DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($created_at)
);
- dba::unlock();
+ DBA::unlock();
- dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
+ DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
return true;
}
logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG);
- if (!dba::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
- dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
+ if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
+ DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
}
// Send all existing comments and likes to the requesting server
logger("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG);
Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id);
}
- dba::close($comments);
+ DBA::close($comments);
return true;
}
$fields['bd'] = $birthday;
}
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
$gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
"photo" => $image_url, "name" => $name, "location" => $location,
$a = get_app();
if ($contact["rel"] == CONTACT_IS_SHARING) {
- dba::update(
+ DBA::update(
'contact',
['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
// If the item belongs to a user, we take this user id.
if ($item['uid'] == 0) {
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
- $first_user = dba::selectFirst('user', ['uid'], $condition);
+ $first_user = DBA::selectFirst('user', ['uid'], $condition);
$owner = User::getOwnerDataById($first_user['uid']);
} else {
$owner = User::getOwnerDataById($item['uid']);
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
- dba::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
+ DBA::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora like signature');
return true;
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
- dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
+ DBA::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora comment signature');
return true;