Rename Friendica\Database\dba to Friendica\Database\DBA

This commit is contained in:
Hypolite Petovan 2018-07-20 08:19:26 -04:00
parent b6a1df0598
commit af6dbc654f
127 changed files with 1169 additions and 1169 deletions

View file

@ -10,7 +10,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
// Ensure that daemon.php is executed from the base path of the installation
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
@ -114,7 +114,7 @@ if (!$foreground) {
// fclose(STDOUT); // file descriptors as we
// fclose(STDERR); // are running as a daemon.
dba::disconnect();
DBA::disconnect();
register_shutdown_function('shutdown');
@ -155,7 +155,7 @@ while (true) {
if ($do_cron) {
// We force a reconnect of the database connection.
// This is done to ensure that the connection don't get lost over time.
dba::reconnect();
DBA::reconnect();
$last_cron = time();
}

View file

@ -19,7 +19,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
@ -231,7 +231,7 @@ function api_login(App $a)
} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id !== false) {
$record = dba::selectFirst('user', [], ['uid' => $user_id]);
$record = DBA::selectFirst('user', [], ['uid' => $user_id]);
}
}
@ -499,7 +499,7 @@ function api_rss_extra(App $a, $arr, $user_info)
*/
function api_unique_id_to_nurl($id)
{
$r = dba::selectFirst('contact', ['nurl'], ['id' => $id]);
$r = DBA::selectFirst('contact', ['nurl'], ['id' => $id]);
if (DBM::is_result($r)) {
return $r["nurl"];
@ -696,8 +696,8 @@ function api_get_user(App $a, $contact_id = null)
$uinfo[0]['network'] = NETWORK_DFRN;
}
$usr = dba::selectFirst('user', ['default-location'], ['uid' => api_user()]);
$profile = dba::selectFirst('profile', ['about'], ['uid' => api_user(), 'is-default' => true]);
$usr = DBA::selectFirst('user', ['default-location'], ['uid' => api_user()]);
$profile = DBA::selectFirst('profile', ['about'], ['uid' => api_user(), 'is-default' => true]);
}
$countitems = 0;
$countfriends = 0;
@ -770,7 +770,7 @@ function api_get_user(App $a, $contact_id = null)
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
$theme_info = dba::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
$theme_info = DBA::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
@ -1131,7 +1131,7 @@ function api_statuses_update($type)
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_day = dba::count('item', $condition);
$posts_day = DBA::count('item', $condition);
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1145,7 +1145,7 @@ function api_statuses_update($type)
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_week = dba::count('item', $condition);
$posts_week = DBA::count('item', $condition);
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1159,7 +1159,7 @@ function api_statuses_update($type)
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_month = dba::count('item', $condition);
$posts_month = DBA::count('item', $condition);
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -2768,7 +2768,7 @@ function api_format_items_activities(&$item, $type = "json")
}
}
dba::close($ret);
DBA::close($ret);
if ($type == "xml") {
$xml_activities = [];
@ -3048,7 +3048,7 @@ function api_lists_ownerships($type)
$user_info = api_get_user($a);
$uid = $user_info['uid'];
$groups = dba::select('group', [], ['deleted' => 0, 'uid' => $uid]);
$groups = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid]);
// loop through all groups
$lists = [];
@ -3867,7 +3867,7 @@ function api_fr_photoalbum_delete($type)
}
// now let's delete all photos from the album
$result = dba::delete('photo', ['uid' => api_user(), 'album' => $album]);
$result = DBA::delete('photo', ['uid' => api_user(), 'album' => $album]);
// return success of deletion or error message
if ($result) {
@ -3901,11 +3901,11 @@ function api_fr_photoalbum_update($type)
throw new BadRequestException("no new albumname specified");
}
// check if album is existing
if (!dba::exists('photo', ['uid' => api_user(), 'album' => $album])) {
if (!DBA::exists('photo', ['uid' => api_user(), 'album' => $album])) {
throw new BadRequestException("album not available");
}
// now let's update all photos to the albumname
$result = dba::update('photo', ['album' => $album_new], ['uid' => api_user(), 'album' => $album]);
$result = DBA::update('photo', ['album' => $album_new], ['uid' => api_user(), 'album' => $album]);
// return success of updating or error message
if ($result) {
@ -4139,7 +4139,7 @@ function api_fr_photo_delete($type)
throw new BadRequestException("photo not available");
}
// now we can perform on the deletion of the photo
$result = dba::delete('photo', ['uid' => api_user(), 'resource-id' => $photo_id]);
$result = DBA::delete('photo', ['uid' => api_user(), 'resource-id' => $photo_id]);
// return success of deletion or error message
if ($result) {
@ -4212,7 +4212,7 @@ function api_account_update_profile_image($type)
// check if specified profile id is valid
if ($profile_id != 0) {
$profile = dba::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
$profile = DBA::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
// error message if specified profile id is not in database
if (!DBM::is_result($profile)) {
throw new BadRequestException("profile_id not available");
@ -4249,11 +4249,11 @@ function api_account_update_profile_image($type)
// change specified profile or all profiles to the new resource-id
if ($is_default_profile) {
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], api_user()];
dba::update('photo', ['profile' => false], $condition);
DBA::update('photo', ['profile' => false], $condition);
} else {
$fields = ['photo' => System::baseUrl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype,
'thumb' => System::baseUrl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype];
dba::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => api_user()]);
DBA::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => api_user()]);
}
Contact::updateSelfFromUserID(api_user(), true);
@ -4298,16 +4298,16 @@ function api_account_update_profile($type)
$api_user = api_get_user(get_app());
if (!empty($_POST['name'])) {
dba::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
dba::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
dba::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
dba::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
DBA::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
DBA::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
DBA::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
}
if (isset($_POST['description'])) {
dba::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
dba::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
dba::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
DBA::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
DBA::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', $local_user);
@ -4701,7 +4701,7 @@ function api_friendica_remoteauth()
// traditional DFRN
$contact = dba::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
$contact = DBA::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($contact) || ($contact['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");
@ -4724,7 +4724,7 @@ function api_friendica_remoteauth()
$fields = ['uid' => api_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id,
'sec' => $sec, 'expire' => time() + 45];
dba::insert('profile_check', $fields);
DBA::insert('profile_check', $fields);
logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = ($url ? '&destination_url=' . $url : '');
@ -5252,7 +5252,7 @@ function api_lists_destroy($type)
}
// get data of the specified group id
$group = dba::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
$group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new BadRequestException('gid not available');
@ -5506,7 +5506,7 @@ function api_lists_update($type)
}
// get data of the specified group id
$group = dba::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
$group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new BadRequestException('gid not available');
@ -5676,13 +5676,13 @@ function api_friendica_direct_messages_setseen($type)
}
// error message if specified id is not in database
if (!dba::exists('mail', ['id' => $id, 'uid' => $uid])) {
if (!DBA::exists('mail', ['id' => $id, 'uid' => $uid])) {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
return api_format_data("direct_messages_setseen", $type, ['$result' => $answer]);
}
// update seen indicator
$result = dba::update('mail', ['seen' => true], ['id' => $id]);
$result = DBA::update('mail', ['seen' => true], ['id' => $id]);
if ($result) {
// return success
@ -5852,7 +5852,7 @@ api_register_func('api/friendica/profile/show', 'api_friendica_profile_show', tr
*/
function api_saved_searches_list($type)
{
$terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]);
$terms = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
$result = [];
while ($term = $terms->fetch()) {
@ -5866,7 +5866,7 @@ function api_saved_searches_list($type)
];
}
dba::close($terms);
DBA::close($terms);
return api_format_data("terms", $type, ['terms' => $result]);
}

View file

@ -12,7 +12,7 @@ use Friendica\Core\Config;
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\Model\Contact;
use Friendica\Model\Item;
@ -829,7 +829,7 @@ function item_photo_menu($item) {
$network = '';
$rel = 0;
$condition = ['uid' => local_user(), 'nurl' => normalise_link($item['author-link'])];
$contact = dba::selectFirst('contact', ['id', 'network', 'rel'], $condition);
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
$network = $contact['network'];

View file

@ -1,10 +1,10 @@
<?php
use Friendica\Database\dba;
use Friendica\Database\DBA;
function dbesc($str) {
if (dba::$connected) {
return(dba::escape($str));
if (DBA::$connected) {
return(DBA::escape($str));
} else {
return(str_replace("'","\\'",$str));
}
@ -24,24 +24,24 @@ function q($sql) {
$args = func_get_args();
unset($args[0]);
if (!dba::$connected) {
if (!DBA::$connected) {
return false;
}
$sql = dba::clean_query($sql);
$sql = dba::any_value_fallback($sql);
$sql = DBA::clean_query($sql);
$sql = DBA::any_value_fallback($sql);
$stmt = @vsprintf($sql, $args);
$ret = dba::p($stmt);
$ret = DBA::p($stmt);
if (is_bool($ret)) {
return $ret;
}
$columns = dba::columnCount($ret);
$columns = DBA::columnCount($ret);
$data = dba::inArray($ret);
$data = DBA::inArray($ret);
if ((count($data) == 0) && ($columns == 0)) {
return true;

View file

@ -8,7 +8,7 @@ use Friendica\Core\Addon;
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\Model\Item;
use Friendica\Util\DateTimeFormat;
@ -50,7 +50,7 @@ function notification($params)
$sender_email = $a->getSenderEmailAddress();
if ($params['type'] != SYSTEM_EMAIL) {
$user = dba::selectFirst('user', ['nickname', 'page-flags'],
$user = DBA::selectFirst('user', ['nickname', 'page-flags'],
['uid' => $params['uid']]);
// There is no need to create notifications for forum accounts
@ -107,7 +107,7 @@ function notification($params)
}
if ($params['type'] == NOTIFY_COMMENT) {
$thread = dba::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
$thread = DBA::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($thread) && $thread["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
@ -506,7 +506,7 @@ function notification($params)
);
if ($p && (count($p) > 1)) {
for ($d = 1; $d < count($p); $d ++) {
dba::delete('notify', ['id' => $p[$d]['id']]);
DBA::delete('notify', ['id' => $p[$d]['id']]);
}
// only continue on if we stored the first one
@ -666,13 +666,13 @@ function notification($params)
*/
function check_user_notification($itemid) {
// fetch all users in the thread
$users = dba::p("SELECT DISTINCT(`contact`.`uid`) FROM `item`
$users = DBA::p("SELECT DISTINCT(`contact`.`uid`) FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` != 0
WHERE `parent` IN (SELECT `parent` FROM `item` WHERE `id`=?)", $itemid);
while ($user = dba::fetch($users)) {
while ($user = DBA::fetch($users)) {
check_item_notification($itemid, $user['uid']);
}
dba::close($users);
DBA::close($users);
}
/**
@ -689,12 +689,12 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles = $notification_data["profiles"];
$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
$user = dba::selectFirst('user', $fields, ['uid' => $uid]);
$user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
$owner = dba::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
$owner = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
return false;
}
@ -727,17 +727,17 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles = $profiles2;
$ret = dba::select('contact', ['id'], ['uid' => 0, 'nurl' => $profiles]);
$ret = DBA::select('contact', ['id'], ['uid' => 0, 'nurl' => $profiles]);
$contacts = [];
while ($contact = dba::fetch($ret)) {
while ($contact = DBA::fetch($ret)) {
$contacts[] = $contact['id'];
}
$contact_list = implode(',', $contacts);
dba::close($ret);
DBA::close($ret);
// Only act if it is a "real" post
// We need the additional check for the "local_profile" because of mixed situations on connector networks
@ -767,7 +767,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
if ($item["parent-uri"] === $item["uri"]) {
// Send a notification for every new post?
$send_notification = dba::exists('contact', ['id' => $item['contact-id'], 'notify_new_posts' => true]);
$send_notification = DBA::exists('contact', ['id' => $item['contact-id'], 'notify_new_posts' => true]);
if (!$send_notification) {
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
@ -776,7 +776,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
if (DBM::is_result($tags)) {
foreach ($tags AS $tag) {
$condition = ['nurl' => normalise_link($tag["url"]), 'uid' => $uid, 'notify_new_posts' => true];
$r = dba::exists('contact', $condition);
$r = DBA::exists('contact', $condition);
if ($r) {
$send_notification = true;
}

View file

@ -9,7 +9,7 @@ use Friendica\Core\Config;
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\Model\Item;
use Friendica\Protocol\DFRN;
@ -304,7 +304,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
dba::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
}
Network::post($url, $params);

View file

@ -8,7 +8,7 @@ use Friendica\Core\Config;
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\Model\Group;
use Friendica\Util\DateTimeFormat;
@ -100,7 +100,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$master_record = $a->user;
if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
$user = dba::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
$user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
if (DBM::is_result($user)) {
$master_record = $user;
}
@ -113,38 +113,38 @@ function authenticate_success($user_record, $login_initial = false, $interactive
'nickname' => $master_record['nickname']]];
// Then add all the children
$r = dba::select('user', ['uid', 'username', 'nickname'],
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
$a->identities = array_merge($a->identities, dba::inArray($r));
$a->identities = array_merge($a->identities, DBA::inArray($r));
}
} else {
// Just ensure that the array is always defined
$a->identities = [];
// First entry is our parent
$r = dba::select('user', ['uid', 'username', 'nickname'],
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
$a->identities = dba::inArray($r);
$a->identities = DBA::inArray($r);
}
// Then add all siblings
$r = dba::select('user', ['uid', 'username', 'nickname'],
$r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
$a->identities = array_merge($a->identities, dba::inArray($r));
$a->identities = array_merge($a->identities, DBA::inArray($r));
}
}
$r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
$r = DBA::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
FROM `manage`
INNER JOIN `user` ON `manage`.`mid` = `user`.`uid`
WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?",
$master_record['uid']
);
if (DBM::is_result($r)) {
$a->identities = array_merge($a->identities, dba::inArray($r));
$a->identities = array_merge($a->identities, DBA::inArray($r));
}
if ($login_initial) {
@ -154,7 +154,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
logger('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG);
}
$contact = dba::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
$contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($contact)) {
$a->contact = $contact;
$a->cid = $contact['id'];
@ -164,10 +164,10 @@ function authenticate_success($user_record, $login_initial = false, $interactive
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
if ($login_initial || $login_refresh) {
dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user
dba::update('user', ['login_date' => DateTimeFormat::utcNow()],
DBA::update('user', ['login_date' => DateTimeFormat::utcNow()],
['parent-uid' => $master_record['uid'], 'account_removed' => false]);
}

View file

@ -17,7 +17,7 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Module\Login;
@ -94,7 +94,7 @@ if (!$a->is_backend()) {
*/
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we haven't loaded user data yet, but we need user language
$user = dba::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
if (DBM::is_result($user)) {
$_SESSION['language'] = $user['language'];

View file

@ -6,7 +6,7 @@ use Friendica\App;
use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
@ -264,7 +264,7 @@ function acl_content(App $a)
while ($author = Item::fetch($authors)) {
$item_authors[$author['author-link']] = $author['author-link'];
}
dba::close($authors);
DBA::close($authors);
foreach ($item_authors as $author) {
if (in_array($author, $known_contacts)) {

View file

@ -14,7 +14,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
@ -472,14 +472,14 @@ function admin_page_contactblock(App $a)
{
$condition = ['uid' => 0, 'blocked' => true];
$total = dba::count('contact', $condition);
$total = DBA::count('contact', $condition);
$a->set_pager_total($total);
$a->set_pager_itemspage(30);
$statement = dba::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
$statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
$contacts = dba::inArray($statement);
$contacts = DBA::inArray($statement);
$t = get_markup_template('admin/contactblock.tpl');
$o = replace_macros($t, [
@ -781,8 +781,8 @@ function admin_page_queue(App $a)
function admin_page_workerqueue(App $a)
{
// get jobs from the workerqueue table
$statement = dba::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
$r = dba::inArray($statement);
$statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
$r = DBA::inArray($statement);
for($i = 0; $i < count($r); $i++) {
$r[$i]['parameter'] = stripslashes(implode(': ', explode('","', $r[$i]['parameter'])));
@ -817,7 +817,7 @@ function admin_page_workerqueue(App $a)
function admin_page_summary(App $a)
{
// are there MyISAM tables in the DB? If so, trigger a warning message
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(dba::database_name()));
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(DBA::database_name()));
$showwarning = false;
$warningtext = [];
if (DBM::is_result($r)) {
@ -963,7 +963,7 @@ function admin_page_site_post(App $a)
$r = q("UPDATE %s SET %s;", $table_name, $upds);
if (!DBM::is_result($r)) {
notice("Failed updating '$table_name': " . dba::errorMessage());
notice("Failed updating '$table_name': " . DBA::errorMessage());
goaway('admin/site');
}
}
@ -1731,7 +1731,7 @@ function admin_page_users(App $a)
{
if ($a->argc > 2) {
$uid = $a->argv[3];
$user = dba::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
$user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (!DBM::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');

View file

@ -7,7 +7,7 @@ use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
@ -35,7 +35,7 @@ function allfriends_content(App $a)
$uid = $a->user['uid'];
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;

View file

@ -5,7 +5,7 @@
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
@ -22,7 +22,7 @@ function attach_init(App $a)
// Check for existence, which will also provide us the owner uid
$r = dba::selectFirst('attach', [], ['id' => $item_id]);
$r = DBA::selectFirst('attach', [], ['id' => $item_id]);
if (!DBM::is_result($r)) {
notice(L10n::t('Item was not found.'). EOL);
return;

View file

@ -13,7 +13,7 @@ use Friendica\Content\Widget;
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\Model\Contact;
use Friendica\Model\Event;
@ -37,7 +37,7 @@ function cal_init(App $a)
if ($a->argc > 1) {
$nick = $a->argv[1];
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBM::is_result($user)) {
return;
}

View file

@ -6,7 +6,7 @@
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
@ -38,14 +38,14 @@ function common_content(App $a)
}
if ($cmd === 'loc' && $cid) {
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
}
} else {
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
if (DBM::is_result($contact)) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
@ -66,11 +66,11 @@ function common_content(App $a)
}
if (!$cid && Profile::getMyURL()) {
$contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
$contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
$gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}

View file

@ -9,7 +9,7 @@ use Friendica\Core\ACL;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
function community_init(App $a)
@ -190,7 +190,7 @@ function community_content(App $a, $update = 0)
function community_getitems($start, $itemspage, $content)
{
if ($content == 'local') {
$r = dba::p("SELECT `item`.`uri`, `author`.`url` AS `author-link` FROM `thread`
$r = DBA::p("SELECT `item`.`uri`, `author`.`url` AS `author-link` FROM `thread`
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
@ -198,14 +198,14 @@ function community_getitems($start, $itemspage, $content)
AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
);
return dba::inArray($r);
return DBA::inArray($r);
} elseif ($content == 'global') {
$r = dba::p("SELECT `uri` FROM `thread`
$r = DBA::p("SELECT `uri` FROM `thread`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked`
ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage));
return dba::inArray($r);
return DBA::inArray($r);
}
// Should never happen

View file

@ -12,7 +12,7 @@ use Friendica\Core\Addon;
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\Model\Contact;
use Friendica\Model\GContact;
@ -42,7 +42,7 @@ function contacts_init(App $a)
$contact = null;
if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}
if (DBM::is_result($contact)) {
@ -181,7 +181,7 @@ function contacts_post(App $a)
return;
}
if (!dba::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
notice(L10n::t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@ -191,7 +191,7 @@ function contacts_post(App $a)
$profile_id = intval($_POST['profile-assign']);
if ($profile_id) {
if (!dba::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
notice(L10n::t('Could not locate selected profile.') . EOL);
return;
}
@ -231,7 +231,7 @@ function contacts_post(App $a)
notice(L10n::t('Failed to update contact record.') . EOL);
}
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$a->data['contact'] = $contact;
}
@ -243,7 +243,7 @@ function contacts_post(App $a)
function _contact_update($contact_id)
{
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -264,7 +264,7 @@ function _contact_update($contact_id)
function _contact_update_profile($contact_id)
{
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -396,7 +396,7 @@ function contacts_content(App $a)
$cmd = $a->argv[2];
$orig_record = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
if (!DBM::is_result($orig_record)) {
notice(L10n::t('Could not access contact record.') . EOL);
goaway('contacts');
@ -910,7 +910,7 @@ function contact_posts($a, $contact_id)
{
$o = contacts_tab($a, $contact_id, 1);
$contact = dba::selectFirst('contact', ['url'], ['id' => $contact_id]);
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));

View file

@ -6,7 +6,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
@ -21,7 +21,7 @@ function crepair_init(App $a)
$contact = null;
if (($a->argc == 2) && intval($a->argv[1])) {
$contact = dba::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
$contact = DBA::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
}
if (!x($a->page, 'aside')) {
@ -44,7 +44,7 @@ function crepair_post(App $a)
$contact = null;
if ($cid) {
$contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}
if (!DBM::is_result($contact)) {
@ -105,7 +105,7 @@ function crepair_content(App $a)
$contact = null;
if ($cid) {
$contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}
if (!DBM::is_result($contact)) {

View file

@ -6,7 +6,7 @@
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\dba;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
@ -34,7 +34,7 @@ function delegate_post(App $a)
$parent_password = defaults($_POST, 'parent_password', '');
if ($parent_uid != 0) {
$user = dba::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
if (!DBM::is_result($user)) {
notice(L10n::t('Parent user not found.') . EOL);
return;
@ -47,7 +47,7 @@ function delegate_post(App $a)
}
}
dba::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
}
function delegate_content(App $a)
@ -65,14 +65,14 @@ function delegate_content(App $a)
$user_id = $a->argv[2];
$user = dba::selectFirst('user', ['nickname'], ['uid' => $user_id]);
$user = DBA::selectFirst('user', ['nickname'], ['uid' => $user_id]);
if (DBM::is_result($user)) {
$condition = [
'uid' => local_user(),
'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname'])
];
if (dba::exists('contact', $condition)) {
dba::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
if (DBA::exists('contact', $condition)) {
DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
}
}
goaway(System::baseUrl() . '/delegate');
@ -84,7 +84,7 @@ function delegate_content(App $a)
goaway(System::baseUrl() . '/delegate');
}
dba::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
goaway(System::baseUrl() . '/delegate');
}
@ -136,19 +136,19 @@ function delegate_content(App $a)
settings_init($a);
$user = dba::selectFirst('user', ['parent-uid', 'email'], ['uid' => local_user()]);
$user = DBA::selectFirst('user', ['parent-uid', 'email'], ['uid' => local_user()]);
$parent_user = null;
if (DBM::is_result($user)) {
if (!dba::exists('user', ['parent-uid' => local_user()])) {
if (!DBA::exists('user', ['parent-uid' => local_user()])) {
$parent_uid = $user['parent-uid'];
$parents = [0 => L10n::t('No parent user')];
$fields = ['uid', 'username', 'nickname'];
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
$parent_users = dba::select('user', $fields, $condition);
while ($parent = dba::fetch($parent_users)) {
$parent_users = DBA::select('user', $fields, $condition);
while ($parent = DBA::fetch($parent_users)) {
if ($parent['uid'] != local_user()) {
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
}

View file

@ -21,7 +21,7 @@ use Friendica\App;
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\Model\Contact;
use Friendica\Model\Group;
@ -67,7 +67,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
return;
}
$user = dba::selectFirst('user', [], ['uid' => $uid]);
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
if (!DBM::is_result($user)) {
notice(L10n::t('Profile not found.') . EOL);
return;
@ -280,13 +280,13 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
if (($status == 0) && $intro_id) {
$intro = dba::selectFirst('intro', ['note'], ['id' => $intro_id]);
$intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
if (DBM::is_result($intro)) {
dba::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
}
// Success. Delete the notification.
dba::delete('intro', ['id' => $intro_id]);
DBA::delete('intro', ['id' => $intro_id]);
}
if ($status != 0) {
@ -358,7 +358,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
}
dba::delete('intro', ['id' => $intro_id]);
DBA::delete('intro', ['id' => $intro_id]);
$r = q("UPDATE `contact` SET `name-date` = '%s',
`uri-date` = '%s',
@ -391,7 +391,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
// reload contact info
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
if (DBM::is_result($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
$ret = Diaspora::sendShare($user, $contact);
@ -443,7 +443,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
// Find our user's account
$user = dba::selectFirst('user', [], ['nickname' => $node]);
$user = DBA::selectFirst('user', [], ['nickname' => $node]);
if (!DBM::is_result($user)) {
$message = L10n::t('No user record found for \'%s\' ', $node);
System::xmlExit(3, $message); // failure
@ -471,7 +471,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
// NOTREACHED
}
$contact = dba::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
$contact = DBA::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
if (strstr($decrypted_source_url, 'http:')) {
$newurl = str_replace('http:', 'https:', $decrypted_source_url);
@ -479,7 +479,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$newurl = str_replace('https:', 'http:', $decrypted_source_url);
}
$contact = dba::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
$contact = DBA::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = L10n::t('Contact record was not found for you on our site.');