1
1
Fork 0

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

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

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]);
}