mirror of
https://github.com/friendica/friendica
synced 2025-04-25 20:30:11 +00:00
Rename Friendica\Database\dba to Friendica\Database\DBA
This commit is contained in:
parent
b6a1df0598
commit
af6dbc654f
127 changed files with 1169 additions and 1169 deletions
|
@ -11,7 +11,7 @@ use Friendica\Core\L10n;
|
|||
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\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
|
@ -41,7 +41,7 @@ class Contact extends BaseObject
|
|||
{
|
||||
$return = [];
|
||||
if (intval($gid)) {
|
||||
$stmt = dba::p('SELECT `group_member`.`contact-id`, `contact`.*
|
||||
$stmt = DBA::p('SELECT `group_member`.`contact-id`, `contact`.*
|
||||
FROM `contact`
|
||||
INNER JOIN `group_member`
|
||||
ON `contact`.`id` = `group_member`.`contact-id`
|
||||
|
@ -55,7 +55,7 @@ class Contact extends BaseObject
|
|||
local_user()
|
||||
);
|
||||
if (DBM::is_result($stmt)) {
|
||||
$return = dba::inArray($stmt);
|
||||
$return = DBA::inArray($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Contact extends BaseObject
|
|||
{
|
||||
$return = 0;
|
||||
if (intval($gid)) {
|
||||
$contacts = dba::fetch_first('SELECT COUNT(*) AS `count`
|
||||
$contacts = DBA::fetch_first('SELECT COUNT(*) AS `count`
|
||||
FROM `contact`
|
||||
INNER JOIN `group_member`
|
||||
ON `contact`.`id` = `group_member`.`contact-id`
|
||||
|
@ -99,16 +99,16 @@ class Contact extends BaseObject
|
|||
public static function createSelfFromUserId($uid)
|
||||
{
|
||||
// Only create the entry if it doesn't exist yet
|
||||
if (dba::exists('contact', ['uid' => $uid, 'self' => true])) {
|
||||
if (DBA::exists('contact', ['uid' => $uid, 'self' => true])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$user = dba::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = dba::insert('contact', [
|
||||
$return = DBA::insert('contact', [
|
||||
'uid' => $user['uid'],
|
||||
'created' => DateTimeFormat::utcNow(),
|
||||
'self' => 1,
|
||||
|
@ -146,20 +146,20 @@ class Contact extends BaseObject
|
|||
{
|
||||
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'gender', 'avatar',
|
||||
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'nurl'];
|
||||
$self = dba::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
|
||||
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
|
||||
if (!DBM::is_result($self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = ['nickname', 'page-flags', 'account-type'];
|
||||
$user = dba::selectFirst('user', $fields, ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
|
||||
'country-name', 'gender', 'pub_keywords', 'xmpp'];
|
||||
$profile = dba::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
|
||||
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
|
||||
if (!DBM::is_result($profile)) {
|
||||
return;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ class Contact extends BaseObject
|
|||
'gender' => $profile['gender'], 'avatar' => $profile['photo'],
|
||||
'contact-type' => $user['account-type'], 'xmpp' => $profile['xmpp']];
|
||||
|
||||
$avatar = dba::selectFirst('photo', ['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
|
||||
$avatar = DBA::selectFirst('photo', ['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
|
||||
if (DBM::is_result($avatar)) {
|
||||
if ($update_avatar) {
|
||||
$fields['avatar-date'] = DateTimeFormat::utcNow();
|
||||
|
@ -223,15 +223,15 @@ class Contact extends BaseObject
|
|||
|
||||
if ($update) {
|
||||
$fields['name-date'] = DateTimeFormat::utcNow();
|
||||
dba::update('contact', $fields, ['id' => $self['id']]);
|
||||
DBA::update('contact', $fields, ['id' => $self['id']]);
|
||||
|
||||
// Update the public contact as well
|
||||
dba::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
|
||||
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
|
||||
|
||||
// Update the profile
|
||||
$fields = ['photo' => System::baseUrl() . '/photo/profile/' .$uid . '.jpg',
|
||||
'thumb' => System::baseUrl() . '/photo/avatar/' . $uid .'.jpg'];
|
||||
dba::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
|
||||
DBA::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,18 +244,18 @@ class Contact extends BaseObject
|
|||
public static function remove($id)
|
||||
{
|
||||
// We want just to make sure that we don't delete our "self" contact
|
||||
$contact = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
$contact = DBA::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
if (!DBM::is_result($contact) || !intval($contact['uid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
|
||||
if ($archive) {
|
||||
dba::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
|
||||
DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
|
||||
return;
|
||||
}
|
||||
|
||||
dba::delete('contact', ['id' => $id]);
|
||||
DBA::delete('contact', ['id' => $id]);
|
||||
|
||||
// Delete the rest in the background
|
||||
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
|
||||
|
@ -305,10 +305,10 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if ($contact['term-date'] <= NULL_DATE) {
|
||||
dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
||||
if ($contact['url'] != '') {
|
||||
dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
|
||||
DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
|
||||
}
|
||||
} else {
|
||||
/* @todo
|
||||
|
@ -326,10 +326,10 @@ class Contact extends BaseObject
|
|||
* delete, though if the owner tries to unarchive them we'll start
|
||||
* the whole process over again.
|
||||
*/
|
||||
dba::update('contact', ['archive' => 1], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['archive' => 1], ['id' => $contact['id']]);
|
||||
|
||||
if ($contact['url'] != '') {
|
||||
dba::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
|
||||
DBA::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ class Contact extends BaseObject
|
|||
public static function unmarkForArchival(array $contact)
|
||||
{
|
||||
$condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE];
|
||||
$exists = dba::exists('contact', $condition);
|
||||
$exists = DBA::exists('contact', $condition);
|
||||
|
||||
// We don't need to update, we never marked this contact for archival
|
||||
if (!$exists) {
|
||||
|
@ -355,15 +355,15 @@ class Contact extends BaseObject
|
|||
|
||||
// It's a miracle. Our dead contact has inexplicably come back to life.
|
||||
$fields = ['term-date' => NULL_DATE, 'archive' => false];
|
||||
dba::update('contact', $fields, ['id' => $contact['id']]);
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
|
||||
if (!empty($contact['url'])) {
|
||||
dba::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
|
||||
DBA::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
|
||||
}
|
||||
|
||||
if (!empty($contact['batch'])) {
|
||||
$condition = ['batch' => $contact['batch'], 'contact-type' => ACCOUNT_TYPE_RELAY];
|
||||
dba::update('contact', $fields, $condition);
|
||||
DBA::update('contact', $fields, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,41 +398,41 @@ class Contact extends BaseObject
|
|||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
|
||||
// Fetch contact data from the contact table for the given user
|
||||
$s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
$s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
|
||||
FROM `contact` WHERE `nurl` = ? AND `uid` = ?", normalise_link($url), $uid);
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
|
||||
// Fetch contact data from the contact table for the given user, checking with the alias
|
||||
if (!DBM::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
$s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
|
||||
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ?", normalise_link($url), $url, $ssl_url, $uid);
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
|
||||
if (!DBM::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
$s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
|
||||
FROM `contact` WHERE `nurl` = ? AND `uid` = 0", normalise_link($url));
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the contact table with "uid=0" (which is filled automatically) - checked with the alias
|
||||
if (!DBM::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
$s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
|
||||
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = 0", normalise_link($url), $url, $ssl_url);
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the gcontact table
|
||||
if (!DBM::is_result($r)) {
|
||||
$s = dba::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
|
||||
$s = DBA::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, 0 AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
|
||||
FROM `gcontact` WHERE `nurl` = ?", normalise_link($url));
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
}
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
|
@ -602,7 +602,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
// Look for our own contact if the uid doesn't match and isn't public
|
||||
$contact_own = dba::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
|
||||
$contact_own = DBA::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
|
||||
if (DBM::is_result($contact_own)) {
|
||||
return self::photoMenu($contact_own, $uid);
|
||||
} else {
|
||||
|
@ -746,11 +746,11 @@ class Contact extends BaseObject
|
|||
|
||||
/// @todo Verify if we can't use Contact::getDetailsByUrl instead of the following
|
||||
// We first try the nurl (http://server.tld/nick), most common case
|
||||
$contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
|
||||
|
||||
// Then the addr (nick@server.tld)
|
||||
if (!DBM::is_result($contact)) {
|
||||
$contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
// Then the alias (which could be anything)
|
||||
|
@ -758,7 +758,7 @@ class Contact extends BaseObject
|
|||
// The link could be provided as http although we stored it as https
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid];
|
||||
$contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], $condition);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], $condition);
|
||||
}
|
||||
|
||||
if (DBM::is_result($contact)) {
|
||||
|
@ -790,30 +790,30 @@ class Contact extends BaseObject
|
|||
|
||||
// Get data from the gcontact table
|
||||
$fields = ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'];
|
||||
$contact = dba::selectFirst('gcontact', $fields, ['nurl' => normalise_link($url)]);
|
||||
$contact = DBA::selectFirst('gcontact', $fields, ['nurl' => normalise_link($url)]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
$contact = dba::selectFirst('contact', $fields, ['nurl' => normalise_link($url)]);
|
||||
$contact = DBA::selectFirst('contact', $fields, ['nurl' => normalise_link($url)]);
|
||||
}
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
$fields = ['url', 'addr', 'alias', 'notify', 'poll', 'name', 'nick',
|
||||
'photo', 'keywords', 'location', 'about', 'network',
|
||||
'priority', 'batch', 'request', 'confirm', 'poco'];
|
||||
$contact = dba::selectFirst('contact', $fields, ['addr' => $url]);
|
||||
$contact = DBA::selectFirst('contact', $fields, ['addr' => $url]);
|
||||
}
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
// The link could be provided as http although we stored it as https
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
$condition = ['alias' => [$url, normalise_link($url), $ssl_url]];
|
||||
$contact = dba::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
$fields = ['url', 'addr', 'alias', 'notify', 'poll', 'name', 'nick',
|
||||
'photo', 'network', 'priority', 'batch', 'request', 'confirm'];
|
||||
$condition = ['url' => [$url, normalise_link($url), $ssl_url]];
|
||||
$contact = dba::selectFirst('fcontact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('fcontact', $fields, $condition);
|
||||
}
|
||||
|
||||
if (!empty($default)) {
|
||||
|
@ -833,7 +833,7 @@ class Contact extends BaseObject
|
|||
|
||||
$url = $data["url"];
|
||||
if (!$contact_id) {
|
||||
dba::insert('contact', [
|
||||
DBA::insert('contact', [
|
||||
'uid' => $uid,
|
||||
'created' => DateTimeFormat::utcNow(),
|
||||
'url' => $data["url"],
|
||||
|
@ -865,8 +865,8 @@ class Contact extends BaseObject
|
|||
'pending' => 0]
|
||||
);
|
||||
|
||||
$s = dba::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
|
||||
$contacts = dba::inArray($s);
|
||||
$s = DBA::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
|
||||
$contacts = DBA::inArray($s);
|
||||
if (!DBM::is_result($contacts)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ class Contact extends BaseObject
|
|||
$contact_id = $contacts[0]["id"];
|
||||
|
||||
// Update the newly created contact from data in the gcontact table
|
||||
$gcontact = dba::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
|
||||
$gcontact = DBA::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
|
||||
if (DBM::is_result($gcontact)) {
|
||||
// Only use the information when the probing hadn't fetched these values
|
||||
if ($data['keywords'] != '') {
|
||||
|
@ -886,11 +886,11 @@ class Contact extends BaseObject
|
|||
if ($data['about'] != '') {
|
||||
unset($gcontact['about']);
|
||||
}
|
||||
dba::update('contact', $gcontact, ['id' => $contact_id]);
|
||||
DBA::update('contact', $gcontact, ['id' => $contact_id]);
|
||||
}
|
||||
|
||||
if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $data["url"] != "") {
|
||||
dba::delete('contact', ["`nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`",
|
||||
DBA::delete('contact', ["`nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`",
|
||||
normalise_link($data["url"]), $contact_id]);
|
||||
}
|
||||
}
|
||||
|
@ -898,7 +898,7 @@ class Contact extends BaseObject
|
|||
self::updateAvatar($data["photo"], $uid, $contact_id);
|
||||
|
||||
$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
|
||||
$contact = dba::selectFirst('contact', $fields, ['id' => $contact_id]);
|
||||
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact_id]);
|
||||
|
||||
// This condition should always be true
|
||||
if (!DBM::is_result($contact)) {
|
||||
|
@ -953,7 +953,7 @@ class Contact extends BaseObject
|
|||
|
||||
$updated['avatar-date'] = DateTimeFormat::utcNow();
|
||||
|
||||
dba::update('contact', $updated, ['id' => $contact_id], $contact);
|
||||
DBA::update('contact', $updated, ['id' => $contact_id], $contact);
|
||||
|
||||
return $contact_id;
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ class Contact extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$blocked = dba::selectFirst('contact', ['blocked'], ['id' => $cid]);
|
||||
$blocked = DBA::selectFirst('contact', ['blocked'], ['id' => $cid]);
|
||||
if (!DBM::is_result($blocked)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -991,7 +991,7 @@ class Contact extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$hidden = dba::selectFirst('contact', ['hidden'], ['id' => $cid]);
|
||||
$hidden = DBA::selectFirst('contact', ['hidden'], ['id' => $cid]);
|
||||
if (!DBM::is_result($hidden)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1107,7 +1107,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function block($uid)
|
||||
{
|
||||
$return = dba::update('contact', ['blocked' => true], ['id' => $uid]);
|
||||
$return = DBA::update('contact', ['blocked' => true], ['id' => $uid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -1120,7 +1120,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function unblock($uid)
|
||||
{
|
||||
$return = dba::update('contact', ['blocked' => false], ['id' => $uid]);
|
||||
$return = DBA::update('contact', ['blocked' => false], ['id' => $uid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function updateAvatar($avatar, $uid, $cid, $force = false)
|
||||
{
|
||||
$contact = dba::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
|
||||
$contact = DBA::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1148,7 +1148,7 @@ class Contact extends BaseObject
|
|||
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
|
||||
|
||||
if ($photos) {
|
||||
dba::update(
|
||||
DBA::update(
|
||||
'contact',
|
||||
['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()],
|
||||
['id' => $cid]
|
||||
|
@ -1156,7 +1156,7 @@ class Contact extends BaseObject
|
|||
|
||||
// Update the public contact (contact id = 0)
|
||||
if ($uid != 0) {
|
||||
$pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]);
|
||||
$pcontact = DBA::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]);
|
||||
if (DBM::is_result($pcontact)) {
|
||||
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
|
||||
}
|
||||
|
@ -1181,7 +1181,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
|
||||
$fields = ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'];
|
||||
$contact = dba::selectFirst('contact', $fields, ['id' => $id]);
|
||||
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1210,7 +1210,7 @@ class Contact extends BaseObject
|
|||
return true;
|
||||
}
|
||||
|
||||
dba::update(
|
||||
DBA::update(
|
||||
'contact', [
|
||||
'url' => $ret['url'],
|
||||
'nurl' => normalise_link($ret['url']),
|
||||
|
@ -1378,12 +1378,12 @@ class Contact extends BaseObject
|
|||
$new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
|
||||
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
|
||||
dba::update('contact', $fields, ['id' => $r[0]['id']]);
|
||||
DBA::update('contact', $fields, ['id' => $r[0]['id']]);
|
||||
} else {
|
||||
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
|
||||
// create contact record
|
||||
dba::insert('contact', [
|
||||
DBA::insert('contact', [
|
||||
'uid' => $uid,
|
||||
'created' => DateTimeFormat::utcNow(),
|
||||
'url' => $ret['url'],
|
||||
|
@ -1409,7 +1409,7 @@ class Contact extends BaseObject
|
|||
]);
|
||||
}
|
||||
|
||||
$contact = dba::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
|
||||
$contact = DBA::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
$result['message'] .= L10n::t('Unable to retrieve contact information.') . EOL;
|
||||
return $result;
|
||||
|
@ -1479,7 +1479,7 @@ class Contact extends BaseObject
|
|||
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
|
||||
'notify' => $contact['notify'], 'poll' => $contact['poll'],
|
||||
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
|
||||
dba::update('contact', $fields, ['id' => $contact['id']]);
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
return $contact;
|
||||
|
@ -1503,12 +1503,12 @@ class Contact extends BaseObject
|
|||
if (is_array($contact)) {
|
||||
if (($contact['rel'] == CONTACT_IS_SHARING)
|
||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
|
||||
['id' => $contact['id'], 'uid' => $importer['uid']]);
|
||||
}
|
||||
// send email notification to owner?
|
||||
} else {
|
||||
if (dba::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
|
||||
if (DBA::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
|
||||
logger('ignoring duplicated connection request from pending contact ' . $url);
|
||||
return;
|
||||
}
|
||||
|
@ -1529,7 +1529,7 @@ class Contact extends BaseObject
|
|||
);
|
||||
|
||||
$contact_record = [
|
||||
'id' => dba::lastInsertId(),
|
||||
'id' => DBA::lastInsertId(),
|
||||
'network' => NETWORK_OSTATUS,
|
||||
'name' => $name,
|
||||
'url' => $url,
|
||||
|
@ -1540,13 +1540,13 @@ class Contact extends BaseObject
|
|||
|
||||
/// @TODO Encapsulate this into a function/method
|
||||
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
|
||||
$user = dba::selectFirst('user', $fields, ['uid' => $importer['uid']]);
|
||||
$user = DBA::selectFirst('user', $fields, ['uid' => $importer['uid']]);
|
||||
if (DBM::is_result($user) && !in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
|
||||
if (is_array($contact_record)) {
|
||||
dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
|
||||
DBA::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
|
||||
'blocked' => false, 'knowyou' => false,
|
||||
'hash' => $hash, 'datetime' => DateTimeFormat::utcNow()]);
|
||||
}
|
||||
|
@ -1584,7 +1584,7 @@ class Contact extends BaseObject
|
|||
public static function removeFollower($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
||||
dba::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
|
@ -1593,7 +1593,7 @@ class Contact extends BaseObject
|
|||
public static function removeSharer($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
|
@ -1664,14 +1664,14 @@ class Contact extends BaseObject
|
|||
|
||||
$str = dbesc(implode(',', $contact_ids));
|
||||
|
||||
$stmt = dba::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
|
||||
$stmt = DBA::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
|
||||
|
||||
$return = [];
|
||||
while($contact = dba::fetch($stmt)) {
|
||||
while($contact = DBA::fetch($stmt)) {
|
||||
$return[] = $contact['id'];
|
||||
}
|
||||
|
||||
dba::close($stmt);
|
||||
DBA::close($stmt);
|
||||
|
||||
$contact_ids = $return;
|
||||
}
|
||||
|
@ -1704,7 +1704,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function magicLinkbyId($cid, $url = '')
|
||||
{
|
||||
$contact = dba::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
|
||||
|
||||
return self::magicLinkbyContact($contact, $url);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once "include/dba.php";
|
||||
|
@ -53,7 +53,7 @@ class Conversation
|
|||
}
|
||||
|
||||
$fields = ['item-uri', 'reply-to-uri', 'conversation-uri', 'conversation-href', 'protocol', 'source'];
|
||||
$old_conv = dba::selectFirst('conversation', $fields, ['item-uri' => $conversation['item-uri']]);
|
||||
$old_conv = DBA::selectFirst('conversation', $fields, ['item-uri' => $conversation['item-uri']]);
|
||||
if (DBM::is_result($old_conv)) {
|
||||
// Don't update when only the source has changed.
|
||||
// Only do this when there had been no source before.
|
||||
|
@ -65,11 +65,11 @@ class Conversation
|
|||
unset($conversation['protocol']);
|
||||
unset($conversation['source']);
|
||||
}
|
||||
if (!dba::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
|
||||
if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
|
||||
logger('Conversation: update for '.$conversation['item-uri'].' from '.$old_conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
|
||||
}
|
||||
} else {
|
||||
if (!dba::insert('conversation', $conversation, true)) {
|
||||
if (!DBA::insert('conversation', $conversation, true)) {
|
||||
logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
|
@ -213,7 +213,7 @@ class Event extends BaseObject
|
|||
return;
|
||||
}
|
||||
|
||||
dba::delete('event', ['id' => $event_id]);
|
||||
DBA::delete('event', ['id' => $event_id]);
|
||||
logger("Deleted event ".$event_id, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
|
@ -261,12 +261,12 @@ class Event extends BaseObject
|
|||
$conditions['self'] = true;
|
||||
}
|
||||
|
||||
$contact = dba::selectFirst('contact', [], $conditions);
|
||||
$contact = DBA::selectFirst('contact', [], $conditions);
|
||||
|
||||
// Existing event being modified.
|
||||
if ($event['id']) {
|
||||
// has the event actually changed?
|
||||
$existing_event = dba::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
|
||||
$existing_event = DBA::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
|
||||
if (!DBM::is_result($existing_event) || ($existing_event['edited'] === $event['edited'])) {
|
||||
|
||||
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||
|
@ -286,7 +286,7 @@ class Event extends BaseObject
|
|||
'nofinish' => $event['nofinish'],
|
||||
];
|
||||
|
||||
dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
|
||||
DBA::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
|
||||
|
||||
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||
if (DBM::is_result($item)) {
|
||||
|
@ -307,9 +307,9 @@ class Event extends BaseObject
|
|||
$event['guid'] = System::createGUID(32);
|
||||
|
||||
// New event. Store it.
|
||||
dba::insert('event', $event);
|
||||
DBA::insert('event', $event);
|
||||
|
||||
$event['id'] = dba::lastInsertId();
|
||||
$event['id'] = DBA::lastInsertId();
|
||||
|
||||
$item_arr = [];
|
||||
|
||||
|
@ -737,9 +737,9 @@ class Event extends BaseObject
|
|||
$conditions += ['allow_cid' => '', 'allow_gid' => ''];
|
||||
}
|
||||
|
||||
$events = dba::select('event', $fields, $conditions);
|
||||
$events = DBA::select('event', $fields, $conditions);
|
||||
if (DBM::is_result($events)) {
|
||||
$return = dba::inArray($events);
|
||||
$return = DBA::inArray($events);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -761,7 +761,7 @@ class Event extends BaseObject
|
|||
{
|
||||
$process = false;
|
||||
|
||||
$user = dba::selectFirst('user', ['timezone'], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', ['timezone'], ['uid' => $uid]);
|
||||
if (DBM::is_result($user)) {
|
||||
$timezone = $user['timezone'];
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use Exception;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
@ -60,7 +60,7 @@ class GContact
|
|||
|
||||
$search .= "%";
|
||||
|
||||
$results = dba::p("SELECT `nurl` FROM `gcontact`
|
||||
$results = DBA::p("SELECT `nurl` FROM `gcontact`
|
||||
WHERE NOT `hide` AND `network` IN (?, ?, ?) AND
|
||||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
|
||||
|
@ -69,7 +69,7 @@ class GContact
|
|||
);
|
||||
|
||||
$gcontacts = [];
|
||||
while ($result = dba::fetch($results)) {
|
||||
while ($result = DBA::fetch($results)) {
|
||||
$urlparts = parse_url($result["nurl"]);
|
||||
|
||||
// Ignore results that look strange.
|
||||
|
@ -237,8 +237,8 @@ class GContact
|
|||
|
||||
if ($alternate && ($gcontact['network'] == NETWORK_OSTATUS)) {
|
||||
// Delete the old entry - if it exists
|
||||
if (dba::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
|
||||
dba::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
|
||||
if (DBA::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
|
||||
DBA::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ class GContact
|
|||
$contact["url"] = self::cleanContactUrl($contact["url"]);
|
||||
}
|
||||
|
||||
dba::lock('gcontact');
|
||||
DBA::lock('gcontact');
|
||||
$r = q(
|
||||
"SELECT `id`, `last_contact`, `last_failure`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link($contact["url"]))
|
||||
|
@ -735,7 +735,7 @@ class GContact
|
|||
$doprobing = in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""]);
|
||||
}
|
||||
}
|
||||
dba::unlock();
|
||||
DBA::unlock();
|
||||
|
||||
if ($doprobing) {
|
||||
logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG);
|
||||
|
@ -871,13 +871,13 @@ class GContact
|
|||
'generation' => $contact['generation'], 'updated' => $contact['updated'],
|
||||
'server_url' => $contact['server_url'], 'connect' => $contact['connect']];
|
||||
|
||||
dba::update('gcontact', $updated, $condition, $fields);
|
||||
DBA::update('gcontact', $updated, $condition, $fields);
|
||||
|
||||
// Now update the contact entry with the user id "0" as well.
|
||||
// This is used for the shadow copies of public items.
|
||||
/// @todo Check if we really should do this.
|
||||
// The quality of the gcontact table is mostly lower than the public contact
|
||||
$public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
|
||||
$public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
|
||||
if (DBM::is_result($public_contact)) {
|
||||
logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
|
||||
|
||||
|
@ -887,7 +887,7 @@ class GContact
|
|||
'network', 'bd', 'gender',
|
||||
'keywords', 'alias', 'contact-type',
|
||||
'url', 'location', 'about'];
|
||||
$old_contact = dba::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
|
||||
$old_contact = DBA::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
|
||||
|
||||
// Update it with the current values
|
||||
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'],
|
||||
|
@ -903,7 +903,7 @@ class GContact
|
|||
}
|
||||
|
||||
|
||||
dba::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
|
||||
DBA::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
@ -38,17 +38,17 @@ class Group extends BaseObject
|
|||
// all the old members are gone, but the group remains so we don't break any security
|
||||
// access lists. What we're doing here is reviving the dead group, but old content which
|
||||
// was restricted to this group may now be seen by the new group members.
|
||||
$group = dba::selectFirst('group', ['deleted'], ['id' => $gid]);
|
||||
$group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
|
||||
if (DBM::is_result($group) && $group['deleted']) {
|
||||
dba::update('group', ['deleted' => 0], ['id' => $gid]);
|
||||
DBA::update('group', ['deleted' => 0], ['id' => $gid]);
|
||||
notice(L10n::t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$return = dba::insert('group', ['uid' => $uid, 'name' => $name]);
|
||||
$return = DBA::insert('group', ['uid' => $uid, 'name' => $name]);
|
||||
if ($return) {
|
||||
$return = dba::lastInsertId();
|
||||
$return = DBA::lastInsertId();
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
@ -64,7 +64,7 @@ class Group extends BaseObject
|
|||
*/
|
||||
public static function update($id, $name)
|
||||
{
|
||||
return dba::update('group', ['name' => $name], ['id' => $id]);
|
||||
return DBA::update('group', ['name' => $name], ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,11 +76,11 @@ class Group extends BaseObject
|
|||
public static function getIdsByContactId($cid)
|
||||
{
|
||||
$condition = ['contact-id' => $cid];
|
||||
$stmt = dba::select('group_member', ['gid'], $condition);
|
||||
$stmt = DBA::select('group_member', ['gid'], $condition);
|
||||
|
||||
$return = [];
|
||||
|
||||
while ($group = dba::fetch($stmt)) {
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$return[] = $group['gid'];
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class Group extends BaseObject
|
|||
*/
|
||||
public static function countUnseen()
|
||||
{
|
||||
$stmt = dba::p("SELECT `group`.`id`, `group`.`name`,
|
||||
$stmt = DBA::p("SELECT `group`.`id`, `group`.`name`,
|
||||
(SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`)
|
||||
WHERE `uid` = ?
|
||||
AND `unseen`
|
||||
|
@ -114,7 +114,7 @@ class Group extends BaseObject
|
|||
local_user()
|
||||
);
|
||||
|
||||
return dba::inArray($stmt);
|
||||
return DBA::inArray($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = dba::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
|
||||
$group = DBA::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
|
||||
if (DBM::is_result($group)) {
|
||||
return $group['id'];
|
||||
}
|
||||
|
@ -151,13 +151,13 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = dba::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (!DBM::is_result($group)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove group from default posting lists
|
||||
$user = dba::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
|
||||
$user = DBA::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
|
||||
if (DBM::is_result($user)) {
|
||||
$change = false;
|
||||
|
||||
|
@ -175,15 +175,15 @@ class Group extends BaseObject
|
|||
}
|
||||
|
||||
if ($change) {
|
||||
dba::update('user', $user, ['uid' => $group['uid']]);
|
||||
DBA::update('user', $user, ['uid' => $group['uid']]);
|
||||
}
|
||||
}
|
||||
|
||||
// remove all members
|
||||
dba::delete('group_member', ['gid' => $gid]);
|
||||
DBA::delete('group_member', ['gid' => $gid]);
|
||||
|
||||
// remove group
|
||||
$return = dba::update('group', ['deleted' => 1], ['id' => $gid]);
|
||||
$return = DBA::update('group', ['deleted' => 1], ['id' => $gid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -221,12 +221,12 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$row_exists = dba::exists('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
$row_exists = DBA::exists('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
if ($row_exists) {
|
||||
// Row already existing, nothing to do
|
||||
$return = true;
|
||||
} else {
|
||||
$return = dba::insert('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
$return = DBA::insert('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -245,7 +245,7 @@ class Group extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$return = dba::delete('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
$return = DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $cid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -293,11 +293,11 @@ class Group extends BaseObject
|
|||
$stmt = call_user_func_array('dba::p', $param_arr);
|
||||
} else {
|
||||
$condition_array = array_merge([$condition], $group_ids);
|
||||
$stmt = dba::select('group_member', ['contact-id'], $condition_array);
|
||||
$stmt = DBA::select('group_member', ['contact-id'], $condition_array);
|
||||
}
|
||||
|
||||
$return = [];
|
||||
while($group_member = dba::fetch($stmt)) {
|
||||
while($group_member = DBA::fetch($stmt)) {
|
||||
$return[] = $group_member['contact-id'];
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ class Group extends BaseObject
|
|||
{
|
||||
$o = '';
|
||||
|
||||
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name']]);
|
||||
$stmt = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name']]);
|
||||
|
||||
$display_groups = [
|
||||
[
|
||||
|
@ -328,7 +328,7 @@ class Group extends BaseObject
|
|||
'selected' => ''
|
||||
]
|
||||
];
|
||||
while ($group = dba::fetch($stmt)) {
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$display_groups[] = [
|
||||
'name' => $group['name'],
|
||||
'id' => $group['id'],
|
||||
|
@ -378,14 +378,14 @@ class Group extends BaseObject
|
|||
]
|
||||
];
|
||||
|
||||
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
|
||||
$stmt = DBA::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
|
||||
|
||||
$member_of = [];
|
||||
if ($cid) {
|
||||
$member_of = self::getIdsByContactId($cid);
|
||||
}
|
||||
|
||||
while ($group = dba::fetch($stmt)) {
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
||||
|
||||
if ($editmode == 'full') {
|
||||
|
|
|
@ -14,7 +14,7 @@ use Friendica\Core\Lock;
|
|||
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\Object\Image;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
|
@ -142,7 +142,7 @@ class Item extends BaseObject
|
|||
*/
|
||||
public static function fetch($stmt)
|
||||
{
|
||||
$row = dba::fetch($stmt);
|
||||
$row = DBA::fetch($stmt);
|
||||
|
||||
if (is_bool($row)) {
|
||||
return $row;
|
||||
|
@ -254,7 +254,7 @@ class Item extends BaseObject
|
|||
$data[] = $row;
|
||||
}
|
||||
if ($do_close) {
|
||||
dba::close($stmt);
|
||||
DBA::close($stmt);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
@ -272,10 +272,10 @@ class Item extends BaseObject
|
|||
if (is_bool($stmt)) {
|
||||
$retval = $stmt;
|
||||
} else {
|
||||
$retval = (dba::num_rows($stmt) > 0);
|
||||
$retval = (DBA::num_rows($stmt) > 0);
|
||||
}
|
||||
|
||||
dba::close($stmt);
|
||||
DBA::close($stmt);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ class Item extends BaseObject
|
|||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @see dba::select
|
||||
* @see DBA::select
|
||||
*/
|
||||
public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
|
@ -331,7 +331,7 @@ class Item extends BaseObject
|
|||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @see dba::select
|
||||
* @see DBA::select
|
||||
*/
|
||||
public static function selectFirst(array $fields = [], array $condition = [], $params = [])
|
||||
{
|
||||
|
@ -343,7 +343,7 @@ class Item extends BaseObject
|
|||
return $result;
|
||||
} else {
|
||||
$row = self::fetch($result);
|
||||
dba::close($result);
|
||||
DBA::close($result);
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ class Item extends BaseObject
|
|||
|
||||
$select_fields = self::constructSelectFields($fields, $selected);
|
||||
|
||||
$condition_string = dba::buildCondition($condition);
|
||||
$condition_string = DBA::buildCondition($condition);
|
||||
|
||||
$condition_string = self::addTablesToFields($condition_string, $fields);
|
||||
|
||||
|
@ -379,13 +379,13 @@ class Item extends BaseObject
|
|||
$condition_string = $condition_string . ' AND ' . self::condition(false);
|
||||
}
|
||||
|
||||
$param_string = self::addTablesToFields(dba::buildParameter($params), $fields);
|
||||
$param_string = self::addTablesToFields(DBA::buildParameter($params), $fields);
|
||||
|
||||
$table = "`item` " . self::constructJoins($uid, $select_fields . $condition_string . $param_string, false, $usermode);
|
||||
|
||||
$sql = "SELECT " . $select_fields . " FROM " . $table . $condition_string . $param_string;
|
||||
|
||||
return dba::p($sql, $condition);
|
||||
return DBA::p($sql, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -418,7 +418,7 @@ class Item extends BaseObject
|
|||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @see dba::select
|
||||
* @see DBA::select
|
||||
*/
|
||||
public static function selectFirstThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
|
@ -439,7 +439,7 @@ class Item extends BaseObject
|
|||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @see dba::select
|
||||
* @see DBA::select
|
||||
*/
|
||||
public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ class Item extends BaseObject
|
|||
return $result;
|
||||
} else {
|
||||
$row = self::fetch($result);
|
||||
dba::close($result);
|
||||
DBA::close($result);
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ class Item extends BaseObject
|
|||
|
||||
$select_fields = self::constructSelectFields($fields, $selected);
|
||||
|
||||
$condition_string = dba::buildCondition($condition);
|
||||
$condition_string = DBA::buildCondition($condition);
|
||||
|
||||
$condition_string = self::addTablesToFields($condition_string, $threadfields);
|
||||
$condition_string = self::addTablesToFields($condition_string, $fields);
|
||||
|
@ -492,7 +492,7 @@ class Item extends BaseObject
|
|||
$condition_string = $condition_string . ' AND ' . self::condition(true);
|
||||
}
|
||||
|
||||
$param_string = dba::buildParameter($params);
|
||||
$param_string = DBA::buildParameter($params);
|
||||
$param_string = self::addTablesToFields($param_string, $threadfields);
|
||||
$param_string = self::addTablesToFields($param_string, $fields);
|
||||
|
||||
|
@ -500,7 +500,7 @@ class Item extends BaseObject
|
|||
|
||||
$sql = "SELECT " . $select_fields . " FROM " . $table . $condition_string . $param_string;
|
||||
|
||||
return dba::p($sql, $condition);
|
||||
return DBA::p($sql, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -752,12 +752,12 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// To ensure the data integrity we do it in an transaction
|
||||
dba::transaction();
|
||||
DBA::transaction();
|
||||
|
||||
// We cannot simply expand the condition to check for origin entries
|
||||
// The condition needn't to be a simple array but could be a complex condition.
|
||||
// And we have to execute this query before the update to ensure to fetch the same data.
|
||||
$items = dba::select('item', ['id', 'origin', 'uri', 'created', 'uri-hash', 'iaid', 'icid', 'tag', 'file'], $condition);
|
||||
$items = DBA::select('item', ['id', 'origin', 'uri', 'created', 'uri-hash', 'iaid', 'icid', 'tag', 'file'], $condition);
|
||||
|
||||
$content_fields = [];
|
||||
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
|
||||
|
@ -799,35 +799,35 @@ class Item extends BaseObject
|
|||
$fields['inform'] = null;
|
||||
|
||||
if (!empty($fields)) {
|
||||
$success = dba::update('item', $fields, $condition);
|
||||
$success = DBA::update('item', $fields, $condition);
|
||||
|
||||
if (!$success) {
|
||||
dba::close($items);
|
||||
dba::rollback();
|
||||
DBA::close($items);
|
||||
DBA::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// When there is no content for the "old" item table, this will count the fetched items
|
||||
$rows = dba::affected_rows();
|
||||
$rows = DBA::affected_rows();
|
||||
|
||||
while ($item = dba::fetch($items)) {
|
||||
while ($item = DBA::fetch($items)) {
|
||||
|
||||
// This part here can safely be removed when the legacy fields in the item had been removed
|
||||
if (empty($item['uri-hash']) && !empty($item['uri']) && !empty($item['created'])) {
|
||||
|
||||
// Fetch the uri-hash from an existing item entry if there is one
|
||||
$item_condition = ["`uri` = ? AND `uri-hash` != ''", $item['uri']];
|
||||
$existing = dba::selectfirst('item', ['uri-hash'], $item_condition);
|
||||
$existing = DBA::selectfirst('item', ['uri-hash'], $item_condition);
|
||||
if (DBM::is_result($existing)) {
|
||||
$item['uri-hash'] = $existing['uri-hash'];
|
||||
} else {
|
||||
$item['uri-hash'] = self::itemHash($item['uri'], $item['created']);
|
||||
}
|
||||
|
||||
dba::update('item', ['uri-hash' => $item['uri-hash']], ['id' => $item['id']]);
|
||||
dba::update('item-activity', ['uri-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-hash` = ''", $item['uri']]);
|
||||
dba::update('item-content', ['uri-plink-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-plink-hash` = ''", $item['uri']]);
|
||||
DBA::update('item', ['uri-hash' => $item['uri-hash']], ['id' => $item['id']]);
|
||||
DBA::update('item-activity', ['uri-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-hash` = ''", $item['uri']]);
|
||||
DBA::update('item-content', ['uri-plink-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-plink-hash` = ''", $item['uri']]);
|
||||
}
|
||||
|
||||
if (!empty($item['iaid']) || (!empty($content_fields['verb']) && (self::activityToIndex($content_fields['verb']) >= 0))) {
|
||||
|
@ -839,7 +839,7 @@ class Item extends BaseObject
|
|||
self::updateActivity($content_fields, $update_condition);
|
||||
|
||||
if (empty($item['iaid'])) {
|
||||
$item_activity = dba::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
|
||||
$item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
|
||||
if (DBM::is_result($item_activity)) {
|
||||
$item_fields = ['iaid' => $item_activity['id'], 'icid' => null];
|
||||
foreach (self::MIXED_CONTENT_FIELDLIST as $field) {
|
||||
|
@ -849,17 +849,17 @@ class Item extends BaseObject
|
|||
unset($item_fields[$field]);
|
||||
}
|
||||
}
|
||||
dba::update('item', $item_fields, ['id' => $item['id']]);
|
||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||
|
||||
if (!empty($item['icid']) && !dba::exists('item', ['icid' => $item['icid']])) {
|
||||
dba::delete('item-content', ['id' => $item['icid']]);
|
||||
if (!empty($item['icid']) && !DBA::exists('item', ['icid' => $item['icid']])) {
|
||||
DBA::delete('item-content', ['id' => $item['icid']]);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($item['icid'])) {
|
||||
dba::update('item', ['icid' => null], ['id' => $item['id']]);
|
||||
DBA::update('item', ['icid' => null], ['id' => $item['id']]);
|
||||
|
||||
if (!dba::exists('item', ['icid' => $item['icid']])) {
|
||||
dba::delete('item-content', ['id' => $item['icid']]);
|
||||
if (!DBA::exists('item', ['icid' => $item['icid']])) {
|
||||
DBA::delete('item-content', ['id' => $item['icid']]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -871,7 +871,7 @@ class Item extends BaseObject
|
|||
self::updateContent($content_fields, $update_condition);
|
||||
|
||||
if (empty($item['icid'])) {
|
||||
$item_content = dba::selectFirst('item-content', [], ['uri-plink-hash' => $item['uri-hash']]);
|
||||
$item_content = DBA::selectFirst('item-content', [], ['uri-plink-hash' => $item['uri-hash']]);
|
||||
if (DBM::is_result($item_content)) {
|
||||
$item_fields = ['icid' => $item_content['id']];
|
||||
// Clear all fields in the item table that have a content in the item-content table
|
||||
|
@ -884,7 +884,7 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
}
|
||||
dba::update('item', $item_fields, ['id' => $item['id']]);
|
||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -892,14 +892,14 @@ class Item extends BaseObject
|
|||
if (!empty($tags)) {
|
||||
Term::insertFromTagFieldByItemId($item['id'], $tags);
|
||||
if (!empty($item['tag'])) {
|
||||
dba::update('item', ['tag' => ''], ['id' => $item['id']]);
|
||||
DBA::update('item', ['tag' => ''], ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($files)) {
|
||||
Term::insertFromFileFieldByItemId($item['id'], $files);
|
||||
if (!empty($item['file'])) {
|
||||
dba::update('item', ['file' => ''], ['id' => $item['id']]);
|
||||
DBA::update('item', ['file' => ''], ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -914,8 +914,8 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
dba::close($items);
|
||||
dba::commit();
|
||||
DBA::close($items);
|
||||
DBA::commit();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -927,11 +927,11 @@ class Item extends BaseObject
|
|||
*/
|
||||
public static function delete($condition, $priority = PRIORITY_HIGH)
|
||||
{
|
||||
$items = dba::select('item', ['id'], $condition);
|
||||
while ($item = dba::fetch($items)) {
|
||||
$items = DBA::select('item', ['id'], $condition);
|
||||
while ($item = DBA::fetch($items)) {
|
||||
self::deleteById($item['id'], $priority);
|
||||
}
|
||||
dba::close($items);
|
||||
DBA::close($items);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -946,18 +946,18 @@ class Item extends BaseObject
|
|||
return;
|
||||
}
|
||||
|
||||
$items = dba::select('item', ['id', 'uid'], $condition);
|
||||
while ($item = dba::fetch($items)) {
|
||||
$items = DBA::select('item', ['id', 'uid'], $condition);
|
||||
while ($item = DBA::fetch($items)) {
|
||||
// "Deleting" global items just means hiding them
|
||||
if ($item['uid'] == 0) {
|
||||
dba::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
|
||||
DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
|
||||
} elseif ($item['uid'] == $uid) {
|
||||
self::deleteById($item['id'], PRIORITY_HIGH);
|
||||
} else {
|
||||
logger('Wrong ownership. Not deleting item ' . $item['id']);
|
||||
}
|
||||
}
|
||||
dba::close($items);
|
||||
DBA::close($items);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1016,7 +1016,7 @@ class Item extends BaseObject
|
|||
* generate a resource-id and therefore aren't intimately linked to the item.
|
||||
*/
|
||||
if (strlen($item['resource-id'])) {
|
||||
dba::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
|
||||
DBA::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
// If item is a link to an event, delete the event.
|
||||
|
@ -1028,7 +1028,7 @@ class Item extends BaseObject
|
|||
foreach (explode(", ", $item['attach']) as $attach) {
|
||||
preg_match("|attach/(\d+)|", $attach, $matches);
|
||||
if (is_array($matches) && count($matches) > 1) {
|
||||
dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
|
||||
DBA::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ class Item extends BaseObject
|
|||
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow(),
|
||||
'body' => '', 'title' => '', 'content-warning' => '', 'rendered-hash' => '', 'rendered-html' => '',
|
||||
'object' => '', 'target' => '', 'tag' => '', 'postopts' => '', 'attach' => '', 'file' => ''];
|
||||
dba::update('item', $item_fields, ['id' => $item['id']]);
|
||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||
|
||||
Term::insertFromTagFieldByItemId($item['id'], '');
|
||||
Term::insertFromFileFieldByItemId($item['id'], '');
|
||||
|
@ -1051,7 +1051,7 @@ class Item extends BaseObject
|
|||
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
|
||||
}
|
||||
|
||||
dba::delete('item-delivery-data', ['iid' => $item['id']]);
|
||||
DBA::delete('item-delivery-data', ['iid' => $item['id']]);
|
||||
|
||||
// If it's the parent of a comment thread, kill all the kids
|
||||
if ($item['id'] == $item['parent']) {
|
||||
|
@ -1071,7 +1071,7 @@ class Item extends BaseObject
|
|||
// When we delete just our local user copy of an item, we have to set a marker to hide it
|
||||
$global_item = self::selectFirst(['id'], ['uri' => $item['uri'], 'uid' => 0, 'deleted' => false]);
|
||||
if (DBM::is_result($global_item)) {
|
||||
dba::update('user-item', ['hidden' => true], ['iid' => $global_item['id'], 'uid' => $item['uid']], true);
|
||||
DBA::update('user-item', ['hidden' => true], ['iid' => $global_item['id'], 'uid' => $item['uid']], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ class Item extends BaseObject
|
|||
|
||||
// Still missing? Then use the "self" contact of the current user
|
||||
if ($contact_id == 0) {
|
||||
$self = dba::selectFirst('contact', ['id'], ['self' => true, 'uid' => $item['uid']]);
|
||||
$self = DBA::selectFirst('contact', ['id'], ['self' => true, 'uid' => $item['uid']]);
|
||||
if (DBM::is_result($self)) {
|
||||
$contact_id = $self["id"];
|
||||
}
|
||||
|
@ -1279,7 +1279,7 @@ class Item extends BaseObject
|
|||
// check for create date and expire time
|
||||
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
|
||||
|
||||
$user = dba::selectFirst('user', ['expire'], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', ['expire'], ['uid' => $uid]);
|
||||
if (DBM::is_result($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
|
||||
$expire_interval = $user['expire'];
|
||||
}
|
||||
|
@ -1314,7 +1314,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Ensure to always have the same creation date.
|
||||
$existing = dba::selectfirst('item', ['created', 'uri-hash'], ['uri' => $item['uri']]);
|
||||
$existing = DBA::selectfirst('item', ['created', 'uri-hash'], ['uri' => $item['uri']]);
|
||||
if (DBM::is_result($existing)) {
|
||||
$item['created'] = $existing['created'];
|
||||
$item['uri-hash'] = $existing['uri-hash'];
|
||||
|
@ -1510,13 +1510,13 @@ class Item extends BaseObject
|
|||
|
||||
// If its a post from myself then tag the thread as "mention"
|
||||
logger("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], LOGGER_DEBUG);
|
||||
$user = dba::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
|
||||
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
|
||||
if (DBM::is_result($user)) {
|
||||
$self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
|
||||
$self_id = Contact::getIdForURL($self, 0, true);
|
||||
logger("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG);
|
||||
if (($item['author-id'] == $self_id) || ($item['owner-id'] == $self_id)) {
|
||||
dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
|
||||
DBA::update('thread', ['mention' => true], ['iid' => $parent_id]);
|
||||
logger("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
@ -1568,7 +1568,7 @@ class Item extends BaseObject
|
|||
$item["global"] = true;
|
||||
|
||||
// Set the global flag on all items if this was a global item entry
|
||||
dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
|
||||
DBA::update('item', ['global' => true], ['uri' => $item["uri"]]);
|
||||
} else {
|
||||
$item["global"] = self::exists(['uid' => 0, 'uri' => $item["uri"]]);
|
||||
}
|
||||
|
@ -1652,15 +1652,15 @@ class Item extends BaseObject
|
|||
unset($item['postopts']);
|
||||
unset($item['inform']);
|
||||
|
||||
dba::transaction();
|
||||
$ret = dba::insert('item', $item);
|
||||
DBA::transaction();
|
||||
$ret = DBA::insert('item', $item);
|
||||
|
||||
// When the item was successfully stored we fetch the ID of the item.
|
||||
if (DBM::is_result($ret)) {
|
||||
$current_post = dba::lastInsertId();
|
||||
$current_post = DBA::lastInsertId();
|
||||
} else {
|
||||
// This can happen - for example - if there are locking timeouts.
|
||||
dba::rollback();
|
||||
DBA::rollback();
|
||||
|
||||
// Store the data into a spool file so that we can try again later.
|
||||
|
||||
|
@ -1689,26 +1689,26 @@ class Item extends BaseObject
|
|||
if ($current_post == 0) {
|
||||
// This is one of these error messages that never should occur.
|
||||
logger("couldn't find created item - we better quit now.");
|
||||
dba::rollback();
|
||||
DBA::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// How much entries have we created?
|
||||
// We wouldn't need this query when we could use an unique index - but MySQL has length problems with them.
|
||||
$entries = dba::count('item', ['uri' => $item['uri'], 'uid' => $item['uid'], 'network' => $item['network']]);
|
||||
$entries = DBA::count('item', ['uri' => $item['uri'], 'uid' => $item['uid'], 'network' => $item['network']]);
|
||||
|
||||
if ($entries > 1) {
|
||||
// There are duplicates. We delete our just created entry.
|
||||
logger('Duplicated post occurred. uri = ' . $item['uri'] . ' uid = ' . $item['uid']);
|
||||
|
||||
// Yes, we could do a rollback here - but we are having many users with MyISAM.
|
||||
dba::delete('item', ['id' => $current_post]);
|
||||
dba::commit();
|
||||
DBA::delete('item', ['id' => $current_post]);
|
||||
DBA::commit();
|
||||
return 0;
|
||||
} elseif ($entries == 0) {
|
||||
// This really should never happen since we quit earlier if there were problems.
|
||||
logger("Something is terribly wrong. We haven't found our created entry.");
|
||||
dba::rollback();
|
||||
DBA::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1720,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Set parent id
|
||||
dba::update('item', ['parent' => $parent_id], ['id' => $current_post]);
|
||||
DBA::update('item', ['parent' => $parent_id], ['id' => $current_post]);
|
||||
|
||||
$item['id'] = $current_post;
|
||||
$item['parent'] = $parent_id;
|
||||
|
@ -1728,9 +1728,9 @@ class Item extends BaseObject
|
|||
// update the commented timestamp on the parent
|
||||
// Only update "commented" if it is really a comment
|
||||
if (($item['gravity'] != GRAVITY_ACTIVITY) || !Config::get("system", "like_no_comment")) {
|
||||
dba::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||
DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||
} else {
|
||||
dba::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||
DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||
}
|
||||
|
||||
if ($dsprsig) {
|
||||
|
@ -1743,14 +1743,14 @@ class Item extends BaseObject
|
|||
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
dba::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
|
||||
DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
|
||||
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
|
||||
}
|
||||
|
||||
if (!empty($diaspora_signed_text)) {
|
||||
// Formerly we stored the signed text, the signature and the author in different fields.
|
||||
// We now store the raw data so that we are more flexible.
|
||||
dba::insert('sign', ['iid' => $current_post, 'signed_text' => $diaspora_signed_text]);
|
||||
DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $diaspora_signed_text]);
|
||||
}
|
||||
|
||||
$deleted = self::tagDeliver($item['uid'], $current_post);
|
||||
|
@ -1782,7 +1782,7 @@ class Item extends BaseObject
|
|||
|
||||
self::insertDeliveryData($delivery_data);
|
||||
|
||||
dba::commit();
|
||||
DBA::commit();
|
||||
|
||||
/*
|
||||
* Due to deadlock issues with the "term" table we are doing these steps after the commit.
|
||||
|
@ -1824,7 +1824,7 @@ class Item extends BaseObject
|
|||
return;
|
||||
}
|
||||
|
||||
dba::insert('item-delivery-data', $delivery_data);
|
||||
DBA::insert('item-delivery-data', $delivery_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1839,7 +1839,7 @@ class Item extends BaseObject
|
|||
return;
|
||||
}
|
||||
|
||||
dba::update('item-delivery-data', $delivery_data, ['iid' => $id], true);
|
||||
DBA::update('item-delivery-data', $delivery_data, ['iid' => $id], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1870,12 +1870,12 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Do we already have this content?
|
||||
$item_activity = dba::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
|
||||
$item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
|
||||
if (DBM::is_result($item_activity)) {
|
||||
$item['iaid'] = $item_activity['id'];
|
||||
logger('Fetched activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')');
|
||||
} elseif (dba::insert('item-activity', $fields)) {
|
||||
$item['iaid'] = dba::lastInsertId();
|
||||
} elseif (DBA::insert('item-activity', $fields)) {
|
||||
$item['iaid'] = DBA::lastInsertId();
|
||||
logger('Inserted activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')');
|
||||
} else {
|
||||
// This shouldn't happen.
|
||||
|
@ -1911,12 +1911,12 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Do we already have this content?
|
||||
$item_content = dba::selectFirst('item-content', ['id'], ['uri-plink-hash' => $item['uri-hash']]);
|
||||
$item_content = DBA::selectFirst('item-content', ['id'], ['uri-plink-hash' => $item['uri-hash']]);
|
||||
if (DBM::is_result($item_content)) {
|
||||
$item['icid'] = $item_content['id'];
|
||||
logger('Fetched content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')');
|
||||
} elseif (dba::insert('item-content', $fields)) {
|
||||
$item['icid'] = dba::lastInsertId();
|
||||
} elseif (DBA::insert('item-content', $fields)) {
|
||||
$item['icid'] = DBA::lastInsertId();
|
||||
logger('Inserted content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')');
|
||||
} else {
|
||||
// This shouldn't happen.
|
||||
|
@ -1948,7 +1948,7 @@ class Item extends BaseObject
|
|||
|
||||
logger('Update activity for ' . json_encode($condition));
|
||||
|
||||
dba::update('item-activity', $fields, $condition, true);
|
||||
DBA::update('item-activity', $fields, $condition, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1977,7 +1977,7 @@ class Item extends BaseObject
|
|||
|
||||
logger('Update content for ' . json_encode($condition));
|
||||
|
||||
dba::update('item-content', $fields, $condition, true);
|
||||
DBA::update('item-content', $fields, $condition, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2016,8 +2016,8 @@ class Item extends BaseObject
|
|||
|
||||
$condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)",
|
||||
$parent['owner-id'], CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
|
||||
$contacts = dba::select('contact', ['uid'], $condition);
|
||||
while ($contact = dba::fetch($contacts)) {
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
$users[$contact['uid']] = $contact['uid'];
|
||||
}
|
||||
|
||||
|
@ -2025,7 +2025,7 @@ class Item extends BaseObject
|
|||
|
||||
if ($item['uri'] != $item['parent-uri']) {
|
||||
$parents = self::select(['uid', 'origin'], ["`uri` = ? AND `uid` != 0", $item['parent-uri']]);
|
||||
while ($parent = dba::fetch($parents)) {
|
||||
while ($parent = DBA::fetch($parents)) {
|
||||
$users[$parent['uid']] = $parent['uid'];
|
||||
if ($parent['origin'] && !$origin) {
|
||||
$origin_uid = $parent['uid'];
|
||||
|
@ -2060,7 +2060,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
if (empty($item['contact-id'])) {
|
||||
$self = dba::selectFirst('contact', ['id'], ['self' => true, 'uid' => $uid]);
|
||||
$self = DBA::selectFirst('contact', ['id'], ['self' => true, 'uid' => $uid]);
|
||||
if (!DBM::is_result($self)) {
|
||||
return;
|
||||
}
|
||||
|
@ -2071,7 +2071,7 @@ class Item extends BaseObject
|
|||
|
||||
$notify = false;
|
||||
if ($item['uri'] == $item['parent-uri']) {
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$notify = self::isRemoteSelf($contact, $item);
|
||||
}
|
||||
|
@ -2272,7 +2272,7 @@ class Item extends BaseObject
|
|||
|
||||
$hostname = self::getApp()->get_hostname();
|
||||
|
||||
$user = dba::selectFirst('user', ['nickname'], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]);
|
||||
|
||||
$uri = "urn:X-dfrn:" . $hostname . ':' . $user['nickname'] . ':' . $guid;
|
||||
|
||||
|
@ -2291,13 +2291,13 @@ class Item extends BaseObject
|
|||
private static function updateContact($arr)
|
||||
{
|
||||
// Unarchive the author
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $arr["author-id"]]);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $arr["author-id"]]);
|
||||
if (DBM::is_result($contact)) {
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
// Unarchive the contact if it's not our own contact
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"], 'self' => false]);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $arr["contact-id"], 'self' => false]);
|
||||
if (DBM::is_result($contact)) {
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
@ -2306,22 +2306,22 @@ class Item extends BaseObject
|
|||
|
||||
// Is it a forum? Then we don't care about the rules from above
|
||||
if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
|
||||
if (dba::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
|
||||
if (DBA::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['contact-id']]);
|
||||
}
|
||||
// Now do the same for the system wide contacts with uid=0
|
||||
if (!$arr['private']) {
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['owner-id']]);
|
||||
|
||||
if ($arr['owner-id'] != $arr['author-id']) {
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['author-id']]);
|
||||
}
|
||||
}
|
||||
|
@ -2416,7 +2416,7 @@ class Item extends BaseObject
|
|||
|
||||
// Does the given user have this item?
|
||||
if ($uid) {
|
||||
$item = dba::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
|
||||
$item = DBA::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
|
||||
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
||||
AND `item`.`guid` = ? AND `item`.`uid` = ?", $guid, $uid);
|
||||
|
@ -2428,7 +2428,7 @@ class Item extends BaseObject
|
|||
|
||||
// Or is it anywhere on the server?
|
||||
if ($nick == "") {
|
||||
$item = dba::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
|
||||
$item = DBA::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
|
||||
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
||||
AND NOT `item`.`private` AND `item`.`wall`
|
||||
|
@ -2451,7 +2451,7 @@ class Item extends BaseObject
|
|||
{
|
||||
$mention = false;
|
||||
|
||||
$user = dba::selectFirst('user', [], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return;
|
||||
}
|
||||
|
@ -2488,7 +2488,7 @@ class Item extends BaseObject
|
|||
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
|
||||
// delete it!
|
||||
logger("no-mention top-level post to community or private group. delete.");
|
||||
dba::delete('item', ['id' => $item_id]);
|
||||
DBA::delete('item', ['id' => $item_id]);
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
|
@ -2512,7 +2512,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// now change this copy of the post to a forum head message and deliver to all the tgroup members
|
||||
$self = dba::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
|
||||
$self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
|
||||
if (!DBM::is_result($self)) {
|
||||
return;
|
||||
}
|
||||
|
@ -2528,7 +2528,7 @@ class Item extends BaseObject
|
|||
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
|
||||
'owner-id' => $owner_id, 'owner-link' => $self['url'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
|
||||
'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
|
||||
dba::update('item', $fields, ['id' => $item_id]);
|
||||
DBA::update('item', $fields, ['id' => $item_id]);
|
||||
|
||||
self::updateThread($item_id);
|
||||
|
||||
|
@ -2569,7 +2569,7 @@ class Item extends BaseObject
|
|||
$datarray2 = $datarray;
|
||||
logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
|
||||
if ($contact['remote_self'] == 2) {
|
||||
$self = dba::selectFirst('contact', ['id', 'name', 'url', 'thumb'],
|
||||
$self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'],
|
||||
['uid' => $contact['uid'], 'self' => true]);
|
||||
if (DBM::is_result($self)) {
|
||||
$datarray['contact-id'] = $self["id"];
|
||||
|
@ -2664,7 +2664,7 @@ class Item extends BaseObject
|
|||
$res = substr($i, $x + 1);
|
||||
$i = substr($i, 0, $x);
|
||||
$fields = ['data', 'type', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
||||
$photo = dba::selectFirst('photo', $fields, ['resource-id' => $i, 'scale' => $res, 'uid' => $uid]);
|
||||
$photo = DBA::selectFirst('photo', $fields, ['resource-id' => $i, 'scale' => $res, 'uid' => $uid]);
|
||||
if (DBM::is_result($photo)) {
|
||||
/*
|
||||
* Check to see if we should replace this photo link with an embedded image
|
||||
|
@ -2870,7 +2870,7 @@ class Item extends BaseObject
|
|||
|
||||
++$expired;
|
||||
}
|
||||
dba::close($items);
|
||||
DBA::close($items);
|
||||
logger('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
|
||||
}
|
||||
|
||||
|
@ -2878,7 +2878,7 @@ class Item extends BaseObject
|
|||
{
|
||||
$condition = ['uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true, 'moderated' => false];
|
||||
$params = ['order' => ['created' => false]];
|
||||
$thread = dba::selectFirst('thread', ['created'], $condition, $params);
|
||||
$thread = DBA::selectFirst('thread', ['created'], $condition, $params);
|
||||
if (DBM::is_result($thread)) {
|
||||
return substr(DateTimeFormat::local($thread['created']), 0, 10);
|
||||
}
|
||||
|
@ -2955,7 +2955,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Retrieves the local post owner
|
||||
$owner_self_contact = dba::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
|
||||
$owner_self_contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
|
||||
if (!DBM::is_result($owner_self_contact)) {
|
||||
logger('like: unknown owner ' . $uid);
|
||||
return false;
|
||||
|
@ -2964,7 +2964,7 @@ class Item extends BaseObject
|
|||
// Retrieve the current logged in user's public contact
|
||||
$author_id = public_contact();
|
||||
|
||||
$author_contact = dba::selectFirst('contact', ['url'], ['id' => $author_id]);
|
||||
$author_contact = DBA::selectFirst('contact', ['url'], ['id' => $author_id]);
|
||||
if (!DBM::is_result($author_contact)) {
|
||||
logger('like: unknown author ' . $author_id);
|
||||
return false;
|
||||
|
@ -2976,7 +2976,7 @@ class Item extends BaseObject
|
|||
$item_contact = $owner_self_contact;
|
||||
} else {
|
||||
$item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true);
|
||||
$item_contact = dba::selectFirst('contact', [], ['id' => $item_contact_id]);
|
||||
$item_contact = DBA::selectFirst('contact', [], ['id' => $item_contact_id]);
|
||||
if (!DBM::is_result($item_contact)) {
|
||||
logger('like: unknown item contact ' . $item_contact_id);
|
||||
return false;
|
||||
|
@ -3008,10 +3008,10 @@ class Item extends BaseObject
|
|||
// Already voted, undo it
|
||||
$fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
|
||||
/// @todo Consider using self::update - but before doing so, check the side effects
|
||||
dba::update('item', $fields, ['id' => $like_item['id']]);
|
||||
DBA::update('item', $fields, ['id' => $like_item['id']]);
|
||||
|
||||
// Clean up the Diaspora signatures for this like
|
||||
dba::delete('sign', ['iid' => $like_item['id']]);
|
||||
DBA::delete('sign', ['iid' => $like_item['id']]);
|
||||
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item['id']);
|
||||
|
||||
|
@ -3086,7 +3086,7 @@ class Item extends BaseObject
|
|||
$item['iid'] = $itemid;
|
||||
|
||||
if (!$onlyshadow) {
|
||||
$result = dba::insert('thread', $item);
|
||||
$result = DBA::insert('thread', $item);
|
||||
|
||||
logger("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -3118,28 +3118,28 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
$result = dba::update('thread', $fields, ['iid' => $itemid]);
|
||||
$result = DBA::update('thread', $fields, ['iid' => $itemid]);
|
||||
|
||||
logger("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
private static function deleteThread($itemid, $itemuri = "")
|
||||
{
|
||||
$item = dba::selectFirst('thread', ['uid'], ['iid' => $itemid]);
|
||||
$item = DBA::selectFirst('thread', ['uid'], ['iid' => $itemid]);
|
||||
if (!DBM::is_result($item)) {
|
||||
logger('No thread found for id '.$itemid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
// Using dba::delete at this time could delete the associated item entries
|
||||
$result = dba::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid);
|
||||
$result = DBA::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid);
|
||||
|
||||
logger("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
|
||||
if ($itemuri != "") {
|
||||
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
|
||||
if (!self::exists($condition)) {
|
||||
dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
||||
DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
||||
logger("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Friendica\Model;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -40,8 +40,8 @@ class Mail
|
|||
$subject = L10n::t('[no subject]');
|
||||
}
|
||||
|
||||
$me = dba::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
|
||||
$me = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
|
||||
|
||||
if (!(count($me) && (count($contact)))) {
|
||||
return -2;
|
||||
|
@ -84,8 +84,8 @@ class Mail
|
|||
$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $handles];
|
||||
if (dba::insert('conv', $fields)) {
|
||||
$convid = dba::lastInsertId();
|
||||
if (DBA::insert('conv', $fields)) {
|
||||
$convid = DBA::lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class Mail
|
|||
}
|
||||
|
||||
$post_id = null;
|
||||
$success = dba::insert(
|
||||
$success = DBA::insert(
|
||||
'mail',
|
||||
[
|
||||
'uid' => local_user(),
|
||||
|
@ -121,7 +121,7 @@ class Mail
|
|||
);
|
||||
|
||||
if ($success) {
|
||||
$post_id = dba::lastInsertId();
|
||||
$post_id = DBA::lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,7 +145,7 @@ class Mail
|
|||
}
|
||||
$image_uri = substr($image, strrpos($image, '/') + 1);
|
||||
$image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
|
||||
dba::update('photo', ['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
|
||||
DBA::update('photo', ['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ class Mail
|
|||
$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $handles];
|
||||
if (dba::insert('conv', $fields)) {
|
||||
$convid = dba::lastInsertId();
|
||||
if (DBA::insert('conv', $fields)) {
|
||||
$convid = DBA::lastInsertId();
|
||||
}
|
||||
|
||||
if (!$convid) {
|
||||
|
@ -207,7 +207,7 @@ class Mail
|
|||
return -4;
|
||||
}
|
||||
|
||||
dba::insert(
|
||||
DBA::insert(
|
||||
'mail',
|
||||
[
|
||||
'uid' => $recipient['uid'],
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -33,7 +33,7 @@ class OpenWebAuthToken
|
|||
"meta" => $meta,
|
||||
"created" => DateTimeFormat::utcNow()
|
||||
];
|
||||
return dba::insert("openwebauth-token", $fields);
|
||||
return DBA::insert("openwebauth-token", $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,9 +49,9 @@ class OpenWebAuthToken
|
|||
{
|
||||
$condition = ["type" => $type, "uid" => $uid, "token" => $token];
|
||||
|
||||
$entry = dba::selectFirst("openwebauth-token", ["id", "meta"], $condition);
|
||||
$entry = DBA::selectFirst("openwebauth-token", ["id", "meta"], $condition);
|
||||
if (DBM::is_result($entry)) {
|
||||
dba::delete("openwebauth-token", ["id" => $entry["id"]]);
|
||||
DBA::delete("openwebauth-token", ["id" => $entry["id"]]);
|
||||
|
||||
return $entry["meta"];
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class OpenWebAuthToken
|
|||
public static function purge($type, $interval)
|
||||
{
|
||||
$condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
|
||||
dba::delete("openwebauth-token", $condition);
|
||||
DBA::delete("openwebauth-token", $condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -29,12 +29,12 @@ class PermissionSet extends BaseObject
|
|||
'deny_cid' => self::sortPermissions(defaults($postarray, 'deny_cid', '')),
|
||||
'deny_gid' => self::sortPermissions(defaults($postarray, 'deny_gid', ''))];
|
||||
|
||||
$set = dba::selectFirst('permissionset', ['id'], $condition);
|
||||
$set = DBA::selectFirst('permissionset', ['id'], $condition);
|
||||
|
||||
if (!DBM::is_result($set)) {
|
||||
dba::insert('permissionset', $condition, true);
|
||||
DBA::insert('permissionset', $condition, true);
|
||||
|
||||
$set = dba::selectFirst('permissionset', ['id'], $condition);
|
||||
$set = DBA::selectFirst('permissionset', ['id'], $condition);
|
||||
}
|
||||
return $set['id'];
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -41,14 +41,14 @@ class Photo
|
|||
*/
|
||||
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
|
||||
{
|
||||
$photo = dba::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
|
||||
$photo = DBA::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
|
||||
if (DBM::is_result($photo)) {
|
||||
$guid = $photo['guid'];
|
||||
} else {
|
||||
$guid = System::createGUID();
|
||||
}
|
||||
|
||||
$existing_photo = dba::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
|
||||
$existing_photo = DBA::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
|
||||
|
||||
$fields = [
|
||||
'uid' => $uid,
|
||||
|
@ -74,9 +74,9 @@ class Photo
|
|||
];
|
||||
|
||||
if (DBM::is_result($existing_photo)) {
|
||||
$r = dba::update('photo', $fields, ['id' => $existing_photo['id']]);
|
||||
$r = DBA::update('photo', $fields, ['id' => $existing_photo['id']]);
|
||||
} else {
|
||||
$r = dba::insert('photo', $fields);
|
||||
$r = DBA::insert('photo', $fields);
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
@ -94,7 +94,7 @@ class Photo
|
|||
$thumb = '';
|
||||
$micro = '';
|
||||
|
||||
$photo = dba::selectFirst(
|
||||
$photo = DBA::selectFirst(
|
||||
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
|
||||
);
|
||||
if (x($photo['resource-id'])) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -30,13 +30,13 @@ class Process extends BaseObject
|
|||
$pid = getmypid();
|
||||
}
|
||||
|
||||
dba::transaction();
|
||||
DBA::transaction();
|
||||
|
||||
if (!dba::exists('process', ['pid' => $pid])) {
|
||||
$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
|
||||
if (!DBA::exists('process', ['pid' => $pid])) {
|
||||
$return = DBA::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
|
||||
}
|
||||
|
||||
dba::commit();
|
||||
DBA::commit();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Process extends BaseObject
|
|||
$pid = getmypid();
|
||||
}
|
||||
|
||||
return dba::delete('process', ['pid' => $pid]);
|
||||
return DBA::delete('process', ['pid' => $pid]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,15 +61,15 @@ class Process extends BaseObject
|
|||
*/
|
||||
public static function deleteInactive()
|
||||
{
|
||||
dba::transaction();
|
||||
DBA::transaction();
|
||||
|
||||
$processes = dba::select('process', ['pid']);
|
||||
while($process = dba::fetch($processes)) {
|
||||
$processes = DBA::select('process', ['pid']);
|
||||
while($process = DBA::fetch($processes)) {
|
||||
if (!posix_kill($process['pid'], 0)) {
|
||||
self::deleteByPid($process['pid']);
|
||||
}
|
||||
}
|
||||
|
||||
dba::commit();
|
||||
DBA::commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use Friendica\Core\L10n;
|
|||
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\Protocol\Diaspora;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -89,7 +89,7 @@ class Profile
|
|||
*/
|
||||
public static function load(App $a, $nickname, $profile = 0, array $profiledata = [], $show_connect = true)
|
||||
{
|
||||
$user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
|
||||
|
||||
if (!DBM::is_result($user) && empty($profiledata)) {
|
||||
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
||||
|
@ -198,7 +198,7 @@ class Profile
|
|||
if (remote_user() && count($_SESSION['remote'])) {
|
||||
foreach ($_SESSION['remote'] as $visitor) {
|
||||
if ($visitor['uid'] == $uid) {
|
||||
$contact = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
|
||||
$contact = DBA::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$profile_id = $contact['profile-id'];
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ class Profile
|
|||
$profile = null;
|
||||
|
||||
if ($profile_id) {
|
||||
$profile = dba::fetch_first(
|
||||
$profile = DBA::fetch_first(
|
||||
"SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
|
||||
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
||||
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
||||
|
@ -224,7 +224,7 @@ class Profile
|
|||
);
|
||||
}
|
||||
if (!DBM::is_result($profile)) {
|
||||
$profile = dba::fetch_first(
|
||||
$profile = DBA::fetch_first(
|
||||
"SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
|
||||
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
||||
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
||||
|
@ -312,7 +312,7 @@ class Profile
|
|||
$profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
|
||||
}
|
||||
|
||||
if (dba::exists('contact', ['pending' => false, 'uid' => local_user(), 'nurl' => $profile_url])) {
|
||||
if (DBA::exists('contact', ['pending' => false, 'uid' => local_user(), 'nurl' => $profile_url])) {
|
||||
$connect = false;
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ class Profile
|
|||
$cachekey = 'get_birthdays:' . local_user();
|
||||
$r = Cache::get($cachekey);
|
||||
if (is_null($r)) {
|
||||
$s = dba::p(
|
||||
$s = DBA::p(
|
||||
"SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
|
||||
WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
|
||||
|
@ -557,7 +557,7 @@ class Profile
|
|||
DateTimeFormat::utcNow()
|
||||
);
|
||||
if (DBM::is_result($s)) {
|
||||
$r = dba::inArray($s);
|
||||
$r = DBA::inArray($s);
|
||||
Cache::set($cachekey, $r, CACHE_HOUR);
|
||||
}
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ class Profile
|
|||
$bd_format = L10n::t('g A l F d'); // 8 AM Friday January 18
|
||||
$classtoday = '';
|
||||
|
||||
$s = dba::p(
|
||||
$s = DBA::p(
|
||||
"SELECT `event`.*
|
||||
FROM `event`
|
||||
INNER JOIN `item`
|
||||
|
@ -661,7 +661,7 @@ class Profile
|
|||
if (DBM::is_result($s)) {
|
||||
$istoday = false;
|
||||
|
||||
while ($rr = dba::fetch($s)) {
|
||||
while ($rr = DBA::fetch($s)) {
|
||||
if (strlen($rr['name'])) {
|
||||
$total ++;
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ class Profile
|
|||
|
||||
$r[] = $rr;
|
||||
}
|
||||
dba::close($s);
|
||||
DBA::close($s);
|
||||
$classtoday = (($istoday) ? 'event-today' : '');
|
||||
}
|
||||
$tpl = get_markup_template('events_reminder.tpl');
|
||||
|
@ -1025,7 +1025,7 @@ class Profile
|
|||
return;
|
||||
}
|
||||
|
||||
$contact = dba::selectFirst('contact',['id', 'url'], ['id' => $cid]);
|
||||
$contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
|
||||
|
||||
if (DBM::is_result($contact) && remote_user() && remote_user() == $contact['id']) {
|
||||
// The visitor is already authenticated.
|
||||
|
@ -1081,7 +1081,7 @@ class Profile
|
|||
return;
|
||||
}
|
||||
|
||||
$visitor = dba::selectFirst('contact', [], ['id' => $cid]);
|
||||
$visitor = DBA::selectFirst('contact', [], ['id' => $cid]);
|
||||
|
||||
// Authenticate the visitor.
|
||||
$_SESSION['authenticated'] = 1;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -22,7 +22,7 @@ class PushSubscriber
|
|||
public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
|
||||
{
|
||||
$condition = ['push' => 0, 'uid' => $uid];
|
||||
dba::update('push_subscriber', ['push' => 1, 'next_try' => NULL_DATE], $condition);
|
||||
DBA::update('push_subscriber', ['push' => 1, 'next_try' => NULL_DATE], $condition);
|
||||
|
||||
self::requeue($default_priority);
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ class PushSubscriber
|
|||
{
|
||||
// We'll push to each subscriber that has push > 0,
|
||||
// i.e. there has been an update (set in notifier.php).
|
||||
$subscribers = dba::select('push_subscriber', ['id', 'push', 'callback_url', 'nickname'], ["`push` > 0 AND `next_try` < UTC_TIMESTAMP()"]);
|
||||
$subscribers = DBA::select('push_subscriber', ['id', 'push', 'callback_url', 'nickname'], ["`push` > 0 AND `next_try` < UTC_TIMESTAMP()"]);
|
||||
|
||||
while ($subscriber = dba::fetch($subscribers)) {
|
||||
while ($subscriber = DBA::fetch($subscribers)) {
|
||||
// We always handle retries with low priority
|
||||
if ($subscriber['push'] > 1) {
|
||||
$priority = PRIORITY_LOW;
|
||||
|
@ -50,7 +50,7 @@ class PushSubscriber
|
|||
Worker::add($priority, 'PubSubPublish', (int)$subscriber['id']);
|
||||
}
|
||||
|
||||
dba::close($subscribers);
|
||||
DBA::close($subscribers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,10 +66,10 @@ class PushSubscriber
|
|||
public static function renew($uid, $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret)
|
||||
{
|
||||
// fetch the old subscription if it exists
|
||||
$subscriber = dba::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
|
||||
$subscriber = DBA::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
|
||||
|
||||
// delete old subscription if it exists
|
||||
dba::delete('push_subscriber', ['callback_url' => $hub_callback]);
|
||||
DBA::delete('push_subscriber', ['callback_url' => $hub_callback]);
|
||||
|
||||
if ($subscribe) {
|
||||
// if we are just updating an old subscription, keep the
|
||||
|
@ -87,7 +87,7 @@ class PushSubscriber
|
|||
'topic' => $hub_topic, 'nickname' => $nick, 'push' => $push_flag,
|
||||
'last_update' => $last_update, 'renewed' => DateTimeFormat::utcNow(),
|
||||
'secret' => $hub_secret];
|
||||
dba::insert('push_subscriber', $fields);
|
||||
DBA::insert('push_subscriber', $fields);
|
||||
|
||||
logger("Successfully subscribed [$hub_callback] for $nick");
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ class PushSubscriber
|
|||
*/
|
||||
public static function delay($id)
|
||||
{
|
||||
$subscriber = dba::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
|
||||
$subscriber = DBA::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
|
||||
if (!DBM::is_result($subscriber)) {
|
||||
return;
|
||||
}
|
||||
|
@ -115,10 +115,10 @@ class PushSubscriber
|
|||
$days = round((time() - strtotime($subscriber['renewed'])) / (60 * 60 * 24));
|
||||
|
||||
if ($days > 60) {
|
||||
dba::update('push_subscriber', ['push' => -1, 'next_try' => NULL_DATE], ['id' => $id]);
|
||||
DBA::update('push_subscriber', ['push' => -1, 'next_try' => NULL_DATE], ['id' => $id]);
|
||||
logger('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG);
|
||||
} else {
|
||||
dba::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], ['id' => $id]);
|
||||
DBA::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], ['id' => $id]);
|
||||
logger('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG);
|
||||
}
|
||||
} else {
|
||||
|
@ -128,7 +128,7 @@ class PushSubscriber
|
|||
|
||||
$retrial = $retrial + 1;
|
||||
|
||||
dba::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]);
|
||||
DBA::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]);
|
||||
logger('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
@ -141,14 +141,14 @@ class PushSubscriber
|
|||
*/
|
||||
public static function reset($id, $last_update)
|
||||
{
|
||||
$subscriber = dba::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
|
||||
$subscriber = DBA::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
|
||||
if (!DBM::is_result($subscriber)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set last_update to the 'created' date of the last item, and reset push=0
|
||||
$fields = ['push' => 0, 'next_try' => NULL_DATE, 'last_update' => $last_update];
|
||||
dba::update('push_subscriber', $fields, ['id' => $id]);
|
||||
DBA::update('push_subscriber', $fields, ['id' => $id]);
|
||||
logger('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -19,7 +19,7 @@ class Queue
|
|||
public static function updateTime($id)
|
||||
{
|
||||
logger('queue: requeue item ' . $id);
|
||||
$queue = dba::selectFirst('queue', ['retrial'], ['id' => $id]);
|
||||
$queue = DBA::selectFirst('queue', ['retrial'], ['id' => $id]);
|
||||
if (!DBM::is_result($queue)) {
|
||||
return;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Queue
|
|||
$delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1));
|
||||
$next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
|
||||
|
||||
dba::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]);
|
||||
DBA::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ class Queue
|
|||
public static function removeItem($id)
|
||||
{
|
||||
logger('queue: remove queue item ' . $id);
|
||||
dba::delete('queue', ['id' => $id]);
|
||||
DBA::delete('queue', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ class Queue
|
|||
}
|
||||
}
|
||||
|
||||
dba::insert('queue', [
|
||||
DBA::insert('queue', [
|
||||
'cid' => $cid,
|
||||
'network' => $network,
|
||||
'guid' => $guid,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\dba;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
@ -18,8 +18,8 @@ class Term
|
|||
{
|
||||
$tag_text = '';
|
||||
$condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]];
|
||||
$tags = dba::select('term', [], $condition);
|
||||
while ($tag = dba::fetch($tags)) {
|
||||
$tags = DBA::select('term', [], $condition);
|
||||
while ($tag = DBA::fetch($tags)) {
|
||||
if ($tag_text != '') {
|
||||
$tag_text .= ',';
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ class Term
|
|||
{
|
||||
$file_text = '';
|
||||
$condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]];
|
||||
$tags = dba::select('term', [], $condition);
|
||||
while ($tag = dba::fetch($tags)) {
|
||||
$tags = DBA::select('term', [], $condition);
|
||||
while ($tag = DBA::fetch($tags)) {
|
||||
if ($tag['type'] == TERM_CATEGORY) {
|
||||
$file_text .= '<' . $tag['term'] . '>';
|
||||
} else {
|
||||
|
@ -66,7 +66,7 @@ class Term
|
|||
$message['tag'] = $tags;
|
||||
|
||||
// Clean up all tags
|
||||
dba::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
|
||||
DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
|
||||
|
||||
if ($message['deleted']) {
|
||||
return;
|
||||
|
@ -128,12 +128,12 @@ class Term
|
|||
|
||||
if ($message['uid'] == 0) {
|
||||
$global = true;
|
||||
dba::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
|
||||
DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
|
||||
} else {
|
||||
$global = dba::exists('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
|
||||
$global = DBA::exists('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
|
||||
}
|
||||
|
||||
dba::insert('term', [
|
||||
DBA::insert('term', [
|
||||
'uid' => $message['uid'],
|
||||
'oid' => $itemid,
|
||||
'otype' => TERM_OBJ_POST,
|
||||
|
@ -152,8 +152,8 @@ class Term
|
|||
foreach ($users AS $user) {
|
||||
if ($user['uid'] == $message['uid']) {
|
||||
/// @todo This function is called frim Item::update - so we mustn't call that function here
|
||||
dba::update('item', ['mention' => true], ['id' => $itemid]);
|
||||
dba::update('thread', ['mention' => true], ['iid' => $message['parent']]);
|
||||
DBA::update('item', ['mention' => true], ['id' => $itemid]);
|
||||
DBA::update('thread', ['mention' => true], ['iid' => $message['parent']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class Term
|
|||
}
|
||||
|
||||
// Clean up all tags
|
||||
dba::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]]);
|
||||
DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]]);
|
||||
|
||||
if ($message["deleted"]) {
|
||||
return;
|
||||
|
@ -182,7 +182,7 @@ class Term
|
|||
|
||||
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
|
||||
foreach ($files[1] as $file) {
|
||||
dba::insert('term', [
|
||||
DBA::insert('term', [
|
||||
'uid' => $message["uid"],
|
||||
'oid' => $itemid,
|
||||
'otype' => TERM_OBJ_POST,
|
||||
|
@ -194,7 +194,7 @@ class Term
|
|||
|
||||
if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
|
||||
foreach ($files[1] as $file) {
|
||||
dba::insert('term', [
|
||||
DBA::insert('term', [
|
||||
'uid' => $message["uid"],
|
||||
'oid' => $itemid,
|
||||
'otype' => TERM_OBJ_POST,
|
||||
|
@ -222,14 +222,14 @@ class Term
|
|||
|
||||
$searchpath = System::baseUrl() . "/search?tag=";
|
||||
|
||||
$taglist = dba::select(
|
||||
$taglist = DBA::select(
|
||||
'term',
|
||||
['type', 'term', 'url'],
|
||||
["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
|
||||
['order' => ['tid']]
|
||||
);
|
||||
|
||||
while ($tag = dba::fetch($taglist)) {
|
||||
while ($tag = DBA::fetch($taglist)) {
|
||||
if ($tag["url"] == "") {
|
||||
$tag["url"] = $searchpath . $tag["term"];
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ class Term
|
|||
|
||||
$return['tags'][] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
|
||||
}
|
||||
dba::close($taglist);
|
||||
DBA::close($taglist);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use Friendica\Core\L10n;
|
|||
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\Object\Image;
|
||||
use Friendica\Util\Crypto;
|
||||
|
@ -38,7 +38,7 @@ class User
|
|||
* @return boolean|array
|
||||
*/
|
||||
public static function getOwnerDataById($uid) {
|
||||
$r = dba::fetch_first("SELECT
|
||||
$r = DBA::fetch_first("SELECT
|
||||
`contact`.*,
|
||||
`user`.`prvkey` AS `uprvkey`,
|
||||
`user`.`timezone`,
|
||||
|
@ -70,7 +70,7 @@ class User
|
|||
*/
|
||||
public static function getOwnerDataByNick($nick)
|
||||
{
|
||||
$user = dba::selectFirst('user', ['uid'], ['nickname' => $nick]);
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class User
|
|||
return $default_group;
|
||||
}
|
||||
|
||||
$user = dba::selectFirst('user', ['def_gid'], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]);
|
||||
|
||||
if (DBM::is_result($user)) {
|
||||
$default_group = $user["def_gid"];
|
||||
|
@ -198,7 +198,7 @@ class User
|
|||
}
|
||||
} elseif (is_int($user_info) || is_string($user_info)) {
|
||||
if (is_int($user_info)) {
|
||||
$user = dba::selectFirst('user', ['uid', 'password', 'legacy_password'],
|
||||
$user = DBA::selectFirst('user', ['uid', 'password', 'legacy_password'],
|
||||
[
|
||||
'uid' => $user_info,
|
||||
'blocked' => 0,
|
||||
|
@ -212,7 +212,7 @@ class User
|
|||
$condition = ["(`email` = ? OR `username` = ? OR `nickname` = ?)
|
||||
AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified`",
|
||||
$user_info, $user_info, $user_info];
|
||||
$user = dba::selectFirst('user', $fields, $condition);
|
||||
$user = DBA::selectFirst('user', $fields, $condition);
|
||||
}
|
||||
|
||||
if (!DBM::is_result($user)) {
|
||||
|
@ -298,7 +298,7 @@ class User
|
|||
'pwdreset_time' => null,
|
||||
'legacy_password' => false
|
||||
];
|
||||
return dba::update('user', $fields, ['uid' => $uid]);
|
||||
return DBA::update('user', $fields, ['uid' => $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +379,7 @@ class User
|
|||
throw new Exception(L10n::t('An invitation is required.'));
|
||||
}
|
||||
|
||||
if (!dba::exists('register', ['hash' => $invite_id])) {
|
||||
if (!DBA::exists('register', ['hash' => $invite_id])) {
|
||||
throw new Exception(L10n::t('Invitation could not be verified.'));
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ class User
|
|||
throw new Exception(L10n::t('The nickname was blocked from registration by the nodes admin.'));
|
||||
}
|
||||
|
||||
if (Config::get('system', 'block_extended_register', false) && dba::exists('user', ['email' => $email])) {
|
||||
if (Config::get('system', 'block_extended_register', false) && DBA::exists('user', ['email' => $email])) {
|
||||
throw new Exception(L10n::t('Cannot use that email.'));
|
||||
}
|
||||
|
||||
|
@ -465,8 +465,8 @@ class User
|
|||
}
|
||||
|
||||
// Check existing and deleted accounts for this nickname.
|
||||
if (dba::exists('user', ['nickname' => $nickname])
|
||||
|| dba::exists('userd', ['username' => $nickname])
|
||||
if (DBA::exists('user', ['nickname' => $nickname])
|
||||
|| DBA::exists('userd', ['username' => $nickname])
|
||||
) {
|
||||
throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ class User
|
|||
$sprvkey = $sres['prvkey'];
|
||||
$spubkey = $sres['pubkey'];
|
||||
|
||||
$insert_result = dba::insert('user', [
|
||||
$insert_result = DBA::insert('user', [
|
||||
'guid' => generate_user_guid(),
|
||||
'username' => $username,
|
||||
'password' => $new_password_encoded,
|
||||
|
@ -509,8 +509,8 @@ class User
|
|||
]);
|
||||
|
||||
if ($insert_result) {
|
||||
$uid = dba::lastInsertId();
|
||||
$user = dba::selectFirst('user', [], ['uid' => $uid]);
|
||||
$uid = DBA::lastInsertId();
|
||||
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
|
||||
} else {
|
||||
throw new Exception(L10n::t('An error occurred during registration. Please try again.'));
|
||||
}
|
||||
|
@ -521,14 +521,14 @@ class User
|
|||
|
||||
// if somebody clicked submit twice very quickly, they could end up with two accounts
|
||||
// due to race condition. Remove this one.
|
||||
$user_count = dba::count('user', ['nickname' => $nickname]);
|
||||
$user_count = DBA::count('user', ['nickname' => $nickname]);
|
||||
if ($user_count > 1) {
|
||||
dba::delete('user', ['uid' => $uid]);
|
||||
DBA::delete('user', ['uid' => $uid]);
|
||||
|
||||
throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
|
||||
}
|
||||
|
||||
$insert_result = dba::insert('profile', [
|
||||
$insert_result = DBA::insert('profile', [
|
||||
'uid' => $uid,
|
||||
'name' => $username,
|
||||
'photo' => System::baseUrl() . "/photo/profile/{$uid}.jpg",
|
||||
|
@ -539,14 +539,14 @@ class User
|
|||
'profile-name' => L10n::t('default')
|
||||
]);
|
||||
if (!$insert_result) {
|
||||
dba::delete('user', ['uid' => $uid]);
|
||||
DBA::delete('user', ['uid' => $uid]);
|
||||
|
||||
throw new Exception(L10n::t('An error occurred creating your default profile. Please try again.'));
|
||||
}
|
||||
|
||||
// Create the self contact
|
||||
if (!Contact::createSelfFromUserId($uid)) {
|
||||
dba::delete('user', ['uid' => $uid]);
|
||||
DBA::delete('user', ['uid' => $uid]);
|
||||
|
||||
throw new Exception(L10n::t('An error occurred creating your self contact. Please try again.'));
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ class User
|
|||
// right away as a default group for new contacts.
|
||||
$def_gid = Group::create($uid, L10n::t('Friends'));
|
||||
if (!$def_gid) {
|
||||
dba::delete('user', ['uid' => $uid]);
|
||||
DBA::delete('user', ['uid' => $uid]);
|
||||
|
||||
throw new Exception(L10n::t('An error occurred creating your default contact group. Please try again.'));
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ class User
|
|||
$fields['allow_gid'] = '<' . $def_gid . '>';
|
||||
}
|
||||
|
||||
dba::update('user', $fields, ['uid' => $uid]);
|
||||
DBA::update('user', $fields, ['uid' => $uid]);
|
||||
|
||||
// if we have no OpenID photo try to look up an avatar
|
||||
if (!strlen($photo)) {
|
||||
|
@ -610,7 +610,7 @@ class User
|
|||
}
|
||||
|
||||
if (!$photo_failure) {
|
||||
dba::update('photo', ['profile' => 1], ['resource-id' => $hash]);
|
||||
DBA::update('photo', ['profile' => 1], ['resource-id' => $hash]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -714,16 +714,16 @@ class User
|
|||
|
||||
logger('Removing user: ' . $uid);
|
||||
|
||||
$user = dba::selectFirst('user', [], ['uid' => $uid]);
|
||||
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
|
||||
|
||||
Addon::callHooks('remove_user', $user);
|
||||
|
||||
// save username (actually the nickname as it is guaranteed
|
||||
// unique), so it cannot be re-registered in the future.
|
||||
dba::insert('userd', ['username' => $user['nickname']]);
|
||||
DBA::insert('userd', ['username' => $user['nickname']]);
|
||||
|
||||
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
|
||||
dba::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
|
||||
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
|
||||
|
||||
// Send an update to the directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue