diff --git a/bin/daemon.php b/bin/daemon.php index 6ab2f76102..475bafc09d 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -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(); } diff --git a/include/api.php b/include/api.php index a6196852bf..b119177d28 100644 --- a/include/api.php +++ b/include/api.php @@ -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]); } diff --git a/include/conversation.php b/include/conversation.php index 9b37e32687..5dfd571ea5 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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']; diff --git a/include/dba.php b/include/dba.php index a560c02312..57a277f340 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1,10 +1,10 @@ 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; } diff --git a/include/items.php b/include/items.php index 14a74c8e51..69472e96f6 100644 --- a/include/items.php +++ b/include/items.php @@ -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); diff --git a/include/security.php b/include/security.php index 64f32bd55e..987f3b08e2 100644 --- a/include/security.php +++ b/include/security.php @@ -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]); } diff --git a/index.php b/index.php index 8cdef23ccb..f3655ff723 100644 --- a/index.php +++ b/index.php @@ -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']; diff --git a/mod/acl.php b/mod/acl.php index 32b86d90bb..c1467d5930 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -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)) { diff --git a/mod/admin.php b/mod/admin.php index 9a289dda5a..03035d9e11 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -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'); diff --git a/mod/allfriends.php b/mod/allfriends.php index e9d964847c..585f787cd7 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -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; diff --git a/mod/attach.php b/mod/attach.php index 0b88fe28fc..e76fe84869 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -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; diff --git a/mod/cal.php b/mod/cal.php index 246d8a6447..3c55a9cc81 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -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; } diff --git a/mod/common.php b/mod/common.php index f6f826789b..3fb67b20ea 100644 --- a/mod/common.php +++ b/mod/common.php @@ -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']; } diff --git a/mod/community.php b/mod/community.php index 97ecf00831..7775fdba4a 100644 --- a/mod/community.php +++ b/mod/community.php @@ -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 diff --git a/mod/contacts.php b/mod/contacts.php index 736d16dfb9..8832862b87 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -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"])); diff --git a/mod/crepair.php b/mod/crepair.php index e23e082240..12ec9672f4 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -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)) { diff --git a/mod/delegate.php b/mod/delegate.php index 60cf130464..7a98be7551 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -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']); } diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 32a9d59f9e..317eb9e2e7 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -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.'); @@ -511,7 +511,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) $dfrn_pubkey = $public_key; } - if (dba::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) { + if (DBA::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) { $message = L10n::t('The ID provided by your system is a duplicate on our system. It should work if you try again.'); System::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id // NOTREACHED @@ -537,7 +537,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) } // We're good but now we have to scrape the profile photo and send notifications. - $contact = dba::selectFirst('contact', ['photo'], ['id' => $dfrn_record]); + $contact = DBA::selectFirst('contact', ['photo'], ['id' => $dfrn_record]); if (DBM::is_result($contact)) { $photo = $contact['photo']; } else { diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index e356996572..726f8335db 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -9,7 +9,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Protocol\DFRN; @@ -27,7 +27,7 @@ function dfrn_notify_post(App $a) { if (is_object($data)) { $nick = defaults($a->argv, 1, ''); - $user = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); + $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); if (!DBM::is_result($user)) { System::httpExit(500); } @@ -63,12 +63,12 @@ function dfrn_notify_post(App $a) { $dfrn_id = substr($dfrn_id, 2); } - if (!dba::exists('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge])) { + if (!DBA::exists('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge])) { logger('could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); System::xmlExit(3, 'Could not match challenge'); } - dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]); + DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]); // find the local user who owns this relationship. @@ -121,7 +121,7 @@ function dfrn_notify_post(App $a) { if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) { $fields = ['writable' => ($writable == (-1)) ? $importer['writable'] : $writable, 'forum' => $forum, 'prv' => $prv]; - dba::update('contact', $fields, ['id' => $importer['id']]); + DBA::update('contact', $fields, ['id' => $importer['id']]); if ($writable != (-1)) { $importer['writable'] = $writable; @@ -213,7 +213,7 @@ function dfrn_dispatch_public($postdata) } // We now have some contact, so we fetch it - $importer = dba::fetch_first("SELECT *, `name` as `senderName` + $importer = DBA::fetch_first("SELECT *, `name` as `senderName` FROM `contact` WHERE NOT `blocked` AND `id` = ? LIMIT 1", $contact['id']); @@ -252,7 +252,7 @@ function dfrn_dispatch_private($user, $postdata) } // We now have some contact, so we fetch it - $importer = dba::fetch_first("SELECT *, `name` as `senderName` + $importer = DBA::fetch_first("SELECT *, `name` as `senderName` FROM `contact` WHERE NOT `blocked` AND `id` = ? LIMIT 1", $cid); @@ -302,11 +302,11 @@ function dfrn_notify_content(App $a) { $status = 0; - dba::delete('challenge', ["`expire` < ?", time()]); + DBA::delete('challenge', ["`expire` < ?", time()]); $fields = ['challenge' => $hash, 'dfrn-id' => $dfrn_id, 'expire' => time() + 90, 'type' => $type, 'last_update' => $last_update]; - dba::insert('challenge', $fields); + DBA::insert('challenge', $fields); logger('challenge=' . $hash, LOGGER_DATA); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 32a8013c31..fa9ad13f56 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -8,7 +8,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\Module\Login; use Friendica\Protocol\DFRN; @@ -143,7 +143,7 @@ function dfrn_poll_init(App $a) if ($type === 'profile-check' && $dfrn_version < 2.2) { if ((strlen($challenge)) && (strlen($sec))) { - dba::delete('profile_check', ["`expire` < ?", time()]); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); @@ -208,7 +208,7 @@ function dfrn_poll_init(App $a) break; } - dba::delete('profile_check', ["`expire` < ?", time()]); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC", dbesc($dfrn_id)); if (DBM::is_result($r)) { @@ -235,7 +235,7 @@ function dfrn_poll_post(App $a) if (strlen($challenge) && strlen($sec)) { logger('dfrn_poll: POST: profile-check'); - dba::delete('profile_check', ["`expire` < ?", time()]); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); @@ -308,7 +308,7 @@ function dfrn_poll_post(App $a) $type = $r[0]['type']; $last_update = $r[0]['last_update']; - dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]); + DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]); $sql_extra = ''; switch ($direction) { @@ -413,7 +413,7 @@ function dfrn_poll_content(App $a) $status = 0; - dba::delete('challenge', ["`expire` < ?", time()]); + DBA::delete('challenge', ["`expire` < ?", time()]); if ($type !== 'profile') { $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 8713785ad4..fd0498a5f2 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -16,7 +16,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; @@ -262,9 +262,9 @@ function dfrn_request_post(App $a) if (DBM::is_result($r)) { foreach ($r as $rr) { if (!$rr['rel']) { - dba::delete('contact', ['id' => $rr['cid'], 'self' => false]); + DBA::delete('contact', ['id' => $rr['cid'], 'self' => false]); } - dba::delete('intro', ['id' => $rr['iid']]); + DBA::delete('intro', ['id' => $rr['iid']]); } } diff --git a/mod/directory.php b/mod/directory.php index 85bcbf8130..2f5d364e91 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -9,7 +9,7 @@ use Friendica\Content\Widget; use Friendica\Core\Addon; 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; @@ -83,7 +83,7 @@ function directory_content(App $a) $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " ); - $cnt = dba::fetch_first("SELECT COUNT(*) AS `total` FROM `profile` + $cnt = DBA::fetch_first("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra"); if (DBM::is_result($cnt)) { @@ -94,7 +94,7 @@ function directory_content(App $a) $limit = intval($a->pager['start'])."," . intval($a->pager['itemspage']); - $r = dba::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`, + $r = DBA::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`, `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid` @@ -108,7 +108,7 @@ function directory_content(App $a) $photo = 'photo'; } - while ($rr = dba::fetch($r)) { + while ($rr = DBA::fetch($r)) { $itemurl= ''; $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']); @@ -196,7 +196,7 @@ function directory_content(App $a) $entries[] = $arr['entry']; } - dba::close($r); + DBA::close($r); $tpl = get_markup_template('directory_header.tpl'); diff --git a/mod/dirfind.php b/mod/dirfind.php index 257c8b11aa..04fb104de9 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -10,7 +10,7 @@ use Friendica\Core\Config; 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; @@ -203,7 +203,7 @@ function dirfind_content(App $a, $prefix = "") { if ($jj->cid > 0) { $connlnk = ""; $conntxt = ""; - $contact = dba::selectFirst('contact', [], ['id' => $jj->cid]); + $contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]); if (DBM::is_result($contact)) { $photo_menu = Contact::photoMenu($contact); $details = _contact_detail_for_template($contact); diff --git a/mod/display.php b/mod/display.php index 3775d263c8..e615b68437 100644 --- a/mod/display.php +++ b/mod/display.php @@ -11,7 +11,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Group; @@ -87,7 +87,7 @@ function display_init(App $a) $nickname = str_replace(normalise_link(System::baseUrl())."/profile/", "", normalise_link($profiledata["url"])); if (($nickname != $a->user["nickname"])) { - $profile = dba::fetch_first("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` + $profile = DBA::fetch_first("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`nickname` = ? AND `profile`.`is-default` AND `contact`.`self` LIMIT 1", $nickname @@ -106,7 +106,7 @@ function display_init(App $a) function display_fetchauthor($a, $item) { - $author = dba::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]); + $author = DBA::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]); $profiledata = []; $profiledata['uid'] = -1; @@ -248,7 +248,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } // We are displaying an "alternate" link if that post was public. See issue 2864 - $is_public = dba::exists('item', ['id' => $item_id, 'private' => [0, 2]]); + $is_public = DBA::exists('item', ['id' => $item_id, 'private' => [0, 2]]); if ($is_public) { // For the atom feed the nickname doesn't matter at all, we only need the item id. $alternate = System::baseUrl().'/display/feed-item/'.$item_id.'.atom'; @@ -280,7 +280,7 @@ function display_content(App $a, $update = false, $update_uid = 0) if ($contact_id) { $groups = Group::getIdsByContactId($contact_id); - $remote_contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $a->profile['uid']]); + $remote_contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $a->profile['uid']]); if (DBM::is_result($remote_contact)) { $contact = $remote_contact; $is_remote_contact = true; @@ -294,7 +294,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } } - $page_contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]); + $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]); if (DBM::is_result($page_contact)) { $a->page_contact = $page_contact; } @@ -325,7 +325,7 @@ function display_content(App $a, $update = false, $update_uid = 0) if (local_user() && (local_user() == $a->profile['uid'])) { $condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true]; - $unseen = dba::exists('item', $condition); + $unseen = DBA::exists('item', $condition); } else { $unseen = false; } diff --git a/mod/feedtest.php b/mod/feedtest.php index a96b1f5d03..d9a9abb91f 100644 --- a/mod/feedtest.php +++ b/mod/feedtest.php @@ -6,7 +6,7 @@ use Friendica\App; use Friendica\Core\L10n; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Protocol\Feed; use Friendica\Util\Network; @@ -26,11 +26,11 @@ function feedtest_content(App $a) if (!empty($_REQUEST['url'])) { $url = $_REQUEST['url']; - $importer = dba::selectFirst('user', [], ['uid' => local_user()]); + $importer = DBA::selectFirst('user', [], ['uid' => local_user()]); $contact_id = Contact::getIdForURL($url, local_user(), true); - $contact = dba::selectFirst('contact', [], ['id' => $contact_id]); + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]); $ret = Network::curl($contact['poll']); $xml = $ret['body']; diff --git a/mod/hovercard.php b/mod/hovercard.php index dfec168541..f0dbe4873c 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -11,7 +11,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\GContact; @@ -47,7 +47,7 @@ function hovercard_content() $cid = 0; if (strpos($profileurl, 'redir/') === 0) { $cid = intval(substr($profileurl, 6)); - $remote_contact = dba::selectFirst('contact', ['nurl'], ['id' => $cid]); + $remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]); $profileurl = defaults($remote_contact, 'nurl', ''); } diff --git a/mod/install.php b/mod/install.php index 59dcf92c56..d55ee6ea8b 100644 --- a/mod/install.php +++ b/mod/install.php @@ -7,7 +7,7 @@ use Friendica\App; use Friendica\Core\Install; use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Util\Temporal; @@ -53,7 +53,7 @@ function install_post(App $a) { $phpath = notags(trim($_POST['phpath'])); require_once("include/dba.php"); - if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata)) { + if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { $a->data['db_conn_failed'] = true; } @@ -71,7 +71,7 @@ function install_post(App $a) { $adminmail = notags(trim($_POST['adminmail'])); // connect to db - dba::connect($dbhost, $dbuser, $dbpass, $dbdata); + DBA::connect($dbhost, $dbuser, $dbpass, $dbdata); Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail); @@ -112,7 +112,7 @@ function install_content(App $a) { $db_return_text .= $txt; } - if (dba::$connected) { + if (DBA::$connected) { $r = q("SELECT COUNT(*) as `total` FROM `user`"); if (DBM::is_result($r) && $r[0]['total']) { $tpl = get_markup_template('install.tpl'); diff --git a/mod/item.php b/mod/item.php index 7bcfdfbe35..72e9f5252a 100644 --- a/mod/item.php +++ b/mod/item.php @@ -23,7 +23,7 @@ use Friendica\Core\Config; 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\Item; @@ -146,7 +146,7 @@ function item_post(App $a) { // Check for multiple posts with the same message id (when the post was created via API) if (($message_id != '') && ($profile_uid != 0)) { - if (dba::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) { + if (DBA::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) { logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG); return; } @@ -174,7 +174,7 @@ function item_post(App $a) { $orig_post = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); } - $user = dba::selectFirst('user', [], ['uid' => $profile_uid]); + $user = DBA::selectFirst('user', [], ['uid' => $profile_uid]); if (!DBM::is_result($user) && !$parent) { return; @@ -268,7 +268,7 @@ function item_post(App $a) { // if using the API, we won't see pubmail_enable - figure out if it should be set if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) { if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) { - $pubmail_enabled = dba::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']); + $pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']); } } @@ -305,7 +305,7 @@ function item_post(App $a) { if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) { $self = true; - $author = dba::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]); + $author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]); } elseif (remote_user()) { if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $v) { @@ -316,7 +316,7 @@ function item_post(App $a) { } } if ($contact_id) { - $author = dba::selectFirst('contact', [], ['id' => $contact_id]); + $author = DBA::selectFirst('contact', [], ['id' => $contact_id]); } } @@ -328,7 +328,7 @@ function item_post(App $a) { if ($profile_uid == local_user() || $allow_comment) { $contact_record = $author; } else { - $contact_record = dba::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]); + $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]); } // Look for any tags and linkify them @@ -458,14 +458,14 @@ function item_post(App $a) { $condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'resource-id' => $image_uri, 'uid' => $profile_uid]; - if (!dba::exists('photo', $condition)) { + if (!DBA::exists('photo', $condition)) { continue; } $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny]; $condition = ['resource-id' => $image_uri, 'uid' => $profile_uid, 'album' => L10n::t('Wall Photos')]; - dba::update('photo', $fields, $condition); + DBA::update('photo', $fields, $condition); } } } @@ -486,14 +486,14 @@ function item_post(App $a) { $condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'id' => $attach]; - if (!dba::exists('attach', $condition)) { + if (!DBA::exists('attach', $condition)) { continue; } $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny]; $condition = ['id' => $attach]; - dba::update('attach', $fields, $condition); + DBA::update('attach', $fields, $condition); } } } @@ -536,7 +536,7 @@ function item_post(App $a) { if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) { foreach ($match[2] as $mtch) { $fields = ['id', 'filename', 'filesize', 'filetype']; - $attachment = dba::selectFirst('attach', $fields, ['id' => $mtch]); + $attachment = DBA::selectFirst('attach', $fields, ['id' => $mtch]); if (DBM::is_result($attachment)) { if (strlen($attachments)) { $attachments .= ','; @@ -636,7 +636,7 @@ function item_post(App $a) { // This field is for storing the raw conversation data $datarray['protocol'] = PROTOCOL_DFRN; - $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]); + $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]); if (DBM::is_result($conversation)) { if ($conversation['conversation-uri'] != '') { $datarray['conversation-uri'] = $conversation['conversation-uri']; @@ -960,32 +960,32 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n if (strrpos($name, '+')) { // Is it in format @nick+number? $tagcid = intval(substr($name, strrpos($name, '+') + 1)); - $contact = dba::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]); + $contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]); } // select someone by nick or attag in the current network if (!DBM::is_result($contact) && ($network != "")) { $condition = ["(`nick` = ? OR `attag` = ?) AND `network` = ? AND `uid` = ?", $name, $name, $network, $profile_uid]; - $contact = dba::selectFirst('contact', $fields, $condition); + $contact = DBA::selectFirst('contact', $fields, $condition); } //select someone by name in the current network if (!DBM::is_result($contact) && ($network != "")) { $condition = ['name' => $name, 'network' => $network, 'uid' => $profile_uid]; - $contact = dba::selectFirst('contact', $fields, $condition); + $contact = DBA::selectFirst('contact', $fields, $condition); } // select someone by nick or attag in any network if (!DBM::is_result($contact)) { $condition = ["(`nick` = ? OR `attag` = ?) AND `uid` = ?", $name, $name, $profile_uid]; - $contact = dba::selectFirst('contact', $fields, $condition); + $contact = DBA::selectFirst('contact', $fields, $condition); } // select someone by name in any network if (!DBM::is_result($contact)) { $condition = ['name' => $name, 'uid' => $profile_uid]; - $contact = dba::selectFirst('contact', $fields, $condition); + $contact = DBA::selectFirst('contact', $fields, $condition); } } diff --git a/mod/lostpass.php b/mod/lostpass.php index 07c24f1580..59071b1045 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -7,7 +7,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\User; use Friendica\Util\DateTimeFormat; @@ -24,7 +24,7 @@ function lostpass_post(App $a) } $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame]; - $user = dba::selectFirst('user', ['uid', 'username', 'email'], $condition); + $user = DBA::selectFirst('user', ['uid', 'username', 'email'], $condition); if (!DBM::is_result($user)) { notice(L10n::t('No valid account found.') . EOL); goaway(System::baseUrl()); @@ -36,7 +36,7 @@ function lostpass_post(App $a) 'pwdreset' => $pwdreset_token, 'pwdreset_time' => DateTimeFormat::utcNow() ]; - $result = dba::update('user', $fields, ['uid' => $user['uid']]); + $result = DBA::update('user', $fields, ['uid' => $user['uid']]); if ($result) { info(L10n::t('Password reset request issued. Check your email.') . EOL); } @@ -86,7 +86,7 @@ function lostpass_content(App $a) if ($a->argc > 1) { $pwdreset_token = $a->argv[1]; - $user = dba::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time'], ['pwdreset' => $pwdreset_token]); + $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time'], ['pwdreset' => $pwdreset_token]); if (!DBM::is_result($user)) { notice(L10n::t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.")); @@ -99,7 +99,7 @@ function lostpass_content(App $a) 'pwdreset' => null, 'pwdreset_time' => null ]; - dba::update('user', $fields, ['uid' => $user['uid']]); + DBA::update('user', $fields, ['uid' => $user['uid']]); notice(L10n::t('Request has expired, please make a new one.')); diff --git a/mod/message.php b/mod/message.php index ccdb377b2f..61af605302 100644 --- a/mod/message.php +++ b/mod/message.php @@ -10,7 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\ACL; 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\Mail; @@ -150,7 +150,7 @@ function message_content(App $a) $cmd = $a->argv[1]; if ($cmd === 'drop') { - if (dba::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { + if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { info(L10n::t('Message deleted.') . EOL); } @@ -165,7 +165,7 @@ function message_content(App $a) $parent = $r[0]['parent-uri']; $convid = $r[0]['convid']; - if (dba::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { + if (DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { info(L10n::t('Conversation removed.') . EOL); } } diff --git a/mod/network.php b/mod/network.php index af9e111c9f..79910152b3 100644 --- a/mod/network.php +++ b/mod/network.php @@ -15,7 +15,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\Group; @@ -41,13 +41,13 @@ function network_init(App $a) } if (x($_GET, 'save')) { - $exists = dba::exists('search', ['uid' => local_user(), 'term' => $search]); + $exists = DBA::exists('search', ['uid' => local_user(), 'term' => $search]); if (!$exists) { - dba::insert('search', ['uid' => local_user(), 'term' => $search]); + DBA::insert('search', ['uid' => local_user(), 'term' => $search]); } } if (x($_GET, 'remove')) { - dba::delete('search', ['uid' => local_user(), 'term' => $search]); + DBA::delete('search', ['uid' => local_user(), 'term' => $search]); } $is_a_date_query = false; @@ -182,10 +182,10 @@ function saved_searches($search) $o = ''; - $terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]); + $terms = DBA::select('search', ['id', 'term'], ['uid' => local_user()]); $saved = []; - while ($rr = dba::fetch($terms)) { + while ($rr = DBA::fetch($terms)) { $saved[] = [ 'id' => $rr['id'], 'term' => $rr['term'], @@ -317,7 +317,7 @@ function networkSetSeen($condition) return; } - $unseen = dba::exists('item', $condition); + $unseen = DBA::exists('item', $condition); if ($unseen) { $r = Item::update(['unseen' => false], $condition); @@ -442,13 +442,13 @@ function networkFlatView(App $a, $update = 0) $condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?", $file, TERM_OBJ_POST, TERM_FILE, local_user()]; $params = ['order' => ['tid' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; - $result = dba::select('term', ['oid'], $condition); + $result = DBA::select('term', ['oid'], $condition); $posts = []; - while ($term = dba::fetch($result)) { + while ($term = DBA::fetch($result)) { $posts[] = $term['oid']; } - dba::close($terms); + DBA::close($terms); $condition = ['uid' => local_user(), 'id' => $posts]; } else { @@ -525,10 +525,10 @@ function networkThreadedView(App $a, $update, $parent) } if ($nets) { - $r = dba::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]); + $r = DBA::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]); $str = ''; - while ($rr = dba::fetch($r)) { + while ($rr = DBA::fetch($r)) { $str .= '<' . $rr['id'] . '>'; } if (strlen($str)) { @@ -556,7 +556,7 @@ function networkThreadedView(App $a, $update, $parent) if ($cid) { // If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor $condition = ["`id` = ? AND (`forum` OR `prv`)", $cid]; - $contact = dba::selectFirst('contact', ['addr', 'nick'], $condition); + $contact = DBA::selectFirst('contact', ['addr', 'nick'], $condition); if (DBM::is_result($contact)) { if ($contact['addr'] != '') { $content = '!' . $contact['addr']; @@ -609,7 +609,7 @@ function networkThreadedView(App $a, $update, $parent) $sql_tag_nets = (($nets) ? sprintf(" AND `item`.`network` = '%s' ", dbesc($nets)) : ''); if ($gid) { - $group = dba::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]); + $group = DBA::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]); if (!DBM::is_result($group)) { if ($update) { killme(); @@ -625,7 +625,7 @@ function networkThreadedView(App $a, $update, $parent) $contact_str_self = ''; $contact_str = implode(',', $contacts); - $self = dba::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]); + $self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]); if (DBM::is_result($self)) { $contact_str_self = $self['id']; } @@ -645,7 +645,7 @@ function networkThreadedView(App $a, $update, $parent) $fields = ['id', 'name', 'network', 'writable', 'nurl', 'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location']; $condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid]; - $contact = dba::selectFirst('contact', $fields, $condition); + $contact = DBA::selectFirst('contact', $fields, $condition); if (DBM::is_result($contact)) { $sql_extra = " AND " . $sql_table . ".`contact-id` = " . intval($cid); @@ -835,7 +835,7 @@ function networkThreadedView(App $a, $update, $parent) $top_limit = DateTimeFormat::utcNow(); } - $items = dba::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item` + $items = DBA::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item` STRAIGHT_JOIN (SELECT `oid` FROM `term` WHERE `term` IN (SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `otype` = ? AND `type` = ? AND `uid` = 0) AS `term` ON `item`.`id` = `term`.`oid` @@ -845,7 +845,7 @@ function networkThreadedView(App $a, $update, $parent) local_user(), TERM_OBJ_POST, TERM_HASHTAG, $top_limit, $bottom_limit); - $data = dba::inArray($items); + $data = DBA::inArray($items); if (count($data) > 0) { $tag_top_limit = current($data)['order_date']; @@ -862,7 +862,7 @@ function networkThreadedView(App $a, $update, $parent) // Don't show hash tag posts from blocked or ignored contacts $condition = ["`nurl` = ? AND `uid` = ? AND (`blocked` OR `readonly`)", normalise_link($item['author-link']), local_user()]; - if (!dba::exists('contact', $condition)) { + if (!DBA::exists('contact', $condition)) { $s[$item['uri']] = $item; } } diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 57b083a761..84a0bae09f 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -9,7 +9,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Util\Network; require_once 'include/dba.php'; @@ -215,11 +215,11 @@ function nodeinfo_cron() { logger('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG); } - $local_posts = dba::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]); + $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_posts', $local_posts); logger('local_posts: ' . $local_posts, LOGGER_DEBUG); - $local_comments = dba::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]); + $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_comments', $local_comments); logger('local_comments: ' . $local_comments, LOGGER_DEBUG); diff --git a/mod/noscrape.php b/mod/noscrape.php index d17937ff5d..e9ced2518c 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -5,7 +5,7 @@ use Friendica\App; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Profile; @@ -45,7 +45,7 @@ function noscrape_init(App $a) $keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords); $keywords = explode(',', $keywords); - $contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]); + $contactPhoto = DBA::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]); $json_info['fn'] = $a->profile['name']; $json_info['photo'] = $contactPhoto["photo"]; @@ -74,13 +74,13 @@ function noscrape_init(App $a) // We display the last activity (post or login), reduced to year and week number $last_active = 0; $condition = ['uid' => $a->profile['uid'], 'self' => true]; - $contact = dba::selectFirst('contact', ['last-item'], $condition); + $contact = DBA::selectFirst('contact', ['last-item'], $condition); if (DBM::is_result($contact)) { $last_active = strtotime($contact['last-item']); } $condition = ['uid' => $a->profile['uid']]; - $user = dba::selectFirst('user', ['login_date'], $condition); + $user = DBA::selectFirst('user', ['login_date'], $condition); if (DBM::is_result($user)) { if ($last_active < strtotime($user['login_date'])) { $last_active = strtotime($user['login_date']); diff --git a/mod/notes.php b/mod/notes.php index af7bd71793..f83195ff1c 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -6,7 +6,7 @@ use Friendica\App; use Friendica\Content\Nav; use Friendica\Core\L10n; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Item; use Friendica\Model\Profile; @@ -74,7 +74,7 @@ function notes_content(App $a, $update = false) while ($rr = Item::fetch($r)) { $parents_arr[] = $rr['id']; } - dba::close($r); + DBA::close($r); $condition = ['uid' => local_user(), 'parent' => $parents_arr]; $result = Item::selectForUser(local_user(), [], $condition); diff --git a/mod/notifications.php b/mod/notifications.php index 0b7ac14d45..b639b089f8 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -10,7 +10,7 @@ use Friendica\Content\Nav; use Friendica\Core\L10n; use Friendica\Core\NotificationsManager; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; function notifications_post(App $a) @@ -26,7 +26,7 @@ function notifications_post(App $a) } if ($request_id) { - $intro = dba::selectFirst('intro', ['id', 'contact-id', 'fid'], ['id' => $request_id, 'uid' => local_user()]); + $intro = DBA::selectFirst('intro', ['id', 'contact-id', 'fid'], ['id' => $request_id, 'uid' => local_user()]); if (DBM::is_result($intro)) { $intro_id = $intro['id']; @@ -42,20 +42,20 @@ function notifications_post(App $a) $fid = $intro['fid']; if ($_POST['submit'] == L10n::t('Discard')) { - dba::delete('intro', ['id' => $intro_id]); + DBA::delete('intro', ['id' => $intro_id]); if (!$fid) { // The check for blocked and pending is in case the friendship was already approved // and we just want to get rid of the now pointless notification $condition = ['id' => $contact_id, 'uid' => local_user(), 'self' => false, 'blocked' => true, 'pending' => true]; - dba::delete('contact', $condition); + DBA::delete('contact', $condition); } goaway('notifications/intros'); } if ($_POST['submit'] == L10n::t('Ignore')) { - dba::update('intro', ['ignore' => true], ['id' => $intro_id]); + DBA::update('intro', ['ignore' => true], ['id' => $intro_id]); goaway('notifications/intros'); } } diff --git a/mod/photos.php b/mod/photos.php index 4058ac5c18..de691de4ff 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -13,7 +13,7 @@ use Friendica\Core\Config; 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\Group; @@ -1350,7 +1350,7 @@ function photos_content(App $a) $link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]); $condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']]; - $a->set_pager_total(dba::count('item', $condition)); + $a->set_pager_total(DBA::count('item', $condition)); $params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; $result = Item::selectForUser($link_item['uid'], [], $condition, $params); diff --git a/mod/profile.php b/mod/profile.php index 6ac7d41fe0..9550fe25e1 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -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\Group; use Friendica\Model\Item; @@ -347,7 +347,7 @@ function profile_content(App $a, $update = 0) if ($is_owner) { - $unseen = dba::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]); + $unseen = DBA::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]); if ($unseen) { $r = Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]); diff --git a/mod/profiles.php b/mod/profiles.php index db4a7deae5..448463554d 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -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\Model\Contact; use Friendica\Model\GContact; @@ -123,7 +123,7 @@ function profiles_init(App $a) { $r1[0]['net-publish'] = 0; $r1[0]['profile-name'] = dbesc($name); - dba::insert('profile', $r1[0]); + DBA::insert('profile', $r1[0]); $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", intval(local_user()), diff --git a/mod/proxy.php b/mod/proxy.php index 6dc3967876..6546ce435e 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -7,7 +7,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Photo; use Friendica\Object\Image; @@ -150,7 +150,7 @@ function proxy_init(App $a) { $valid = true; $photo = null; if (!$direct_cache && ($cachefile == '')) { - $photo = dba::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]); + $photo = DBA::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]); if (DBM::is_result($photo)) { $img_str = $photo['data']; $mime = $photo['desc']; @@ -193,7 +193,7 @@ function proxy_init(App $a) { 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime]; - dba::insert('photo', $fields); + DBA::insert('photo', $fields); } else { $Image = new Image($img_str, $mime); if ($Image->isValid() && !$direct_cache && ($cachefile == '')) { diff --git a/mod/pubsub.php b/mod/pubsub.php index fb6de40523..7843f7352c 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -1,7 +1,7 @@ $nick, 'account_expired' => false, 'account_removed' => false]); + $owner = DBA::selectFirst('user', ['uid'], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); if (!DBM::is_result($owner)) { logger('Local account not found: ' . $nick); hub_return(false, ''); @@ -56,7 +56,7 @@ function pubsub_init(App $a) $condition['hub-verify'] = $hub_verify; } - $contact = dba::selectFirst('contact', ['id', 'poll'], $condition); + $contact = DBA::selectFirst('contact', ['id', 'poll'], $condition); if (!DBM::is_result($contact)) { logger('Contact ' . $contact_id . ' not found.'); hub_return(false, ''); @@ -76,7 +76,7 @@ function pubsub_init(App $a) } if (!empty($hub_mode)) { - dba::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]); + DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]); logger($hub_mode . ' success for contact ' . $contact_id . '.'); } hub_return(true, $hub_challenge); @@ -93,19 +93,19 @@ function pubsub_post(App $a) $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); - $importer = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); + $importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); if (!DBM::is_result($importer)) { hub_post_return(); } $condition = ['id' => $contact_id, 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false]; - $contact = dba::selectFirst('contact', [], $condition); + $contact = DBA::selectFirst('contact', [], $condition); if (!DBM::is_result($contact)) { $author = OStatus::salmonAuthor($xml, $importer); if (!empty($author['contact-id'])) { $condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false]; - $contact = dba::selectFirst('contact', [], $condition); + $contact = DBA::selectFirst('contact', [], $condition); logger('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.'); } if (!DBM::is_result($contact)) { diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index 53b9c01c15..1128e8b454 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -3,7 +3,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\PushSubscriber; use Friendica\Util\Network; @@ -64,7 +64,7 @@ function pubsubhubbub_init(App $a) { // fetch user from database given the nickname $condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]; - $owner = dba::selectFirst('user', ['uid', 'hidewall'], $condition); + $owner = DBA::selectFirst('user', ['uid', 'hidewall'], $condition); if (!DBM::is_result($owner)) { logger('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback); System::httpExit(404); @@ -79,7 +79,7 @@ function pubsubhubbub_init(App $a) { // get corresponding row from contact table $condition = ['uid' => $owner['uid'], 'blocked' => false, 'pending' => false, 'self' => true]; - $contact = dba::selectFirst('contact', ['poll'], $condition); + $contact = DBA::selectFirst('contact', ['poll'], $condition); if (!DBM::is_result($contact)) { logger('Self contact for user ' . $owner['uid'] . ' not found.'); System::httpExit(404); diff --git a/mod/receive.php b/mod/receive.php index 352ba94986..ebc20cfcd8 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -7,7 +7,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Protocol\Diaspora; @@ -34,7 +34,7 @@ function receive_post(App $a) } $guid = $a->argv[2]; - $importer = dba::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]); + $importer = DBA::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]); if (!DBM::is_result($importer)) { System::httpExit(500); } diff --git a/mod/redir.php b/mod/redir.php index 8f112a3c5d..20e2050764 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -3,7 +3,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\Contact; use Friendica\Model\Profile; @@ -24,7 +24,7 @@ function redir_init(App $a) { if (!empty($cid)) { $fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name', 'network', 'poll', 'issued-id', 'dfrn-id', 'duplex']; - $contact = dba::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]); + $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]); if (!DBM::is_result($contact)) { notice(L10n::t('Contact not found.')); goaway(System::baseUrl()); @@ -42,7 +42,7 @@ function redir_init(App $a) { if ($contact['uid'] == 0 && local_user()) { // Let's have a look if there is an established connection // between the puplic contact we have found and the local user. - $contact = dba::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]); if (DBM::is_result($contact)) { $cid = $contact['id']; @@ -96,7 +96,7 @@ function redir_init(App $a) { $fields = ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]; - dba::insert('profile_check', $fields); + DBA::insert('profile_check', $fields); logger('mod_redir: ' . $contact['name'] . ' ' . $sec, LOGGER_DEBUG); diff --git a/mod/regmod.php b/mod/regmod.php index b96cd02448..283b23dfb0 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -8,7 +8,7 @@ use Friendica\Core\Config; 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\User; use Friendica\Module\Login; @@ -89,8 +89,8 @@ function user_deny($hash) intval($register[0]['uid']) ); - dba::delete('user', ['uid' => $register[0]['uid']]); - dba::delete('register', ['hash' => $register[0]['hash']]); + DBA::delete('user', ['uid' => $register[0]['uid']]); + DBA::delete('register', ['hash' => $register[0]['hash']]); notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL); return true; diff --git a/mod/removeme.php b/mod/removeme.php index adc788983e..1676b7b571 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -7,7 +7,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\User; @@ -39,7 +39,7 @@ function removeme_post(App $a) // send email to admins $admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email'))); foreach ($admin_mails as $mail) { - $admin = dba::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]); + $admin = DBA::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]); if (!DBM::is_result($admin)) { continue; } diff --git a/mod/search.php b/mod/search.php index b425464dcc..8f3d897ae4 100644 --- a/mod/search.php +++ b/mod/search.php @@ -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\Model\Item; @@ -69,11 +69,11 @@ function search_init(App $a) { dbesc($search) ); if (!DBM::is_result($r)) { - dba::insert('search', ['uid' => local_user(), 'term' => $search]); + DBA::insert('search', ['uid' => local_user(), 'term' => $search]); } } if (x($_GET,'remove') && $search) { - dba::delete('search', ['uid' => local_user(), 'term' => $search]); + DBA::delete('search', ['uid' => local_user(), 'term' => $search]); } /// @todo Check if there is a case at all that "aside" is prefilled here @@ -210,13 +210,13 @@ function search_content(App $a) { local_user(), TERM_OBJ_POST, TERM_HASHTAG, $search]; $params = ['order' => ['created' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; - $terms = dba::select('term', ['oid'], $condition, $params); + $terms = DBA::select('term', ['oid'], $condition, $params); $itemids = []; - while ($term = dba::fetch($terms)) { + while ($term = DBA::fetch($terms)) { $itemids[] = $term['oid']; } - dba::close($terms); + DBA::close($terms); if (!empty($itemids)) { $params = ['order' => ['id' => true]]; diff --git a/mod/settings.php b/mod/settings.php index c4a114ab81..d984819593 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -14,7 +14,7 @@ use Friendica\Core\PConfig; 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\Contact; use Friendica\Model\GContact; @@ -150,7 +150,7 @@ function settings_post(App $a) check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth'); $key = $_POST['remove']; - dba::delete('tokens', ['id' => $key, 'uid' => local_user()]); + DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]); goaway(System::baseUrl(true)."/settings/oauth/"); return; } @@ -241,12 +241,12 @@ function settings_post(App $a) intval(local_user()) ); if (!DBM::is_result($r)) { - dba::insert('mailacct', ['uid' => local_user()]); + DBA::insert('mailacct', ['uid' => local_user()]); } if (strlen($mail_pass)) { $pass = ''; openssl_public_encrypt($mail_pass, $pass, $a->user['pubkey']); - dba::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]); + DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]); } $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s', `action` = %d, `movetofolder` = '%s', @@ -706,7 +706,7 @@ function settings_content(App $a) if (($a->argc > 3) && ($a->argv[2] === 'delete')) { check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't'); - dba::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]); + DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]); goaway(System::baseUrl(true)."/settings/oauth/"); return; } @@ -989,7 +989,7 @@ function settings_content(App $a) * ACCOUNT SETTINGS */ - $profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]); + $profile = DBA::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]); if (!DBM::is_result($profile)) { notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL); return; diff --git a/mod/suggest.php b/mod/suggest.php index 86c11803be..51ec06b10a 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -8,7 +8,7 @@ use Friendica\Content\ContactSelector; use Friendica\Content\Widget; 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; @@ -46,7 +46,7 @@ function suggest_init(App $a) { } // Now check how the user responded to the confirmation query if (!$_REQUEST['canceled']) { - dba::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]); + DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]); } } diff --git a/mod/unfollow.php b/mod/unfollow.php index 9ee92b3ba9..545faf8fda 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -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\Contact; use Friendica\Model\Profile; @@ -30,7 +30,7 @@ function unfollow_post(App $a) $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", $uid, CONTACT_IS_FRIEND, normalise_link($url), normalise_link($url), $url, NETWORK_STATUSNET]; - $contact = dba::selectFirst('contact', [], $condition); + $contact = DBA::selectFirst('contact', [], $condition); if (!DBM::is_result($contact)) { notice(L10n::t("Contact wasn't found or can't be unfollowed.")); @@ -44,7 +44,7 @@ function unfollow_post(App $a) Contact::terminateFriendship($r[0], $contact); } } - dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]); + DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]); info(L10n::t('Contact unfollowed').EOL); goaway(System::baseUrl().'/contacts/'.$contact['id']); @@ -69,7 +69,7 @@ function unfollow_content(App $a) $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", local_user(), CONTACT_IS_FRIEND, normalise_link($url), normalise_link($url), $url, NETWORK_STATUSNET]; - $contact = dba::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition); + $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition); if (!DBM::is_result($contact)) { notice(L10n::t("You aren't a friend of this contact.").EOL); diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 69763c2fe5..cf5d11f8bf 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -7,7 +7,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\Util\DateTimeFormat; use Friendica\Util\Mimetype; @@ -130,7 +130,7 @@ function wall_attach_post(App $a) { 'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created, 'allow_cid' => '<' . $page_owner_cid . '>', 'allow_gid' => '','deny_cid' => '', 'deny_gid' => '']; - $r = dba::insert('attach', $fields); + $r = DBA::insert('attach', $fields); @unlink($src); diff --git a/mod/worker.php b/mod/worker.php index da354445f4..c18155c5fe 100644 --- a/mod/worker.php +++ b/mod/worker.php @@ -6,7 +6,7 @@ use Friendica\Core\Config; use Friendica\Core\Worker; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; function worker_init() @@ -44,7 +44,7 @@ function worker_init() $fields = ['executed' => DateTimeFormat::utcNow(), 'pid' => getmypid(), 'done' => false]; $condition = ['id' => $r[0]["id"], 'pid' => 0]; - if (dba::update('workerqueue', $fields, $condition)) { + if (DBA::update('workerqueue', $fields, $condition)) { Worker::execute($r[0]); } } diff --git a/mod/xrd.php b/mod/xrd.php index 230cdbf637..cd72e50188 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -6,7 +6,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\System; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Protocol\Salmon; @@ -39,7 +39,7 @@ function xrd_init(App $a) $name = substr($local, 0, strpos($local, '@')); } - $user = dba::selectFirst('user', [], ['nickname' => $name]); + $user = DBA::selectFirst('user', [], ['nickname' => $name]); if (!DBM::is_result($user)) { killme(); } diff --git a/src/App.php b/src/App.php index 0359d8309c..1e24c3214f 100644 --- a/src/App.php +++ b/src/App.php @@ -10,7 +10,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; require_once 'boot.php'; @@ -490,13 +490,13 @@ class App $this->mode |= App::MODE_LOCALCONFIGPRESENT; - if (!dba::connected()) { + if (!DBA::connected()) { return; } $this->mode |= App::MODE_DBAVAILABLE; - if (dba::fetch_first("SHOW TABLES LIKE 'config'") === false) { + if (DBA::fetch_first("SHOW TABLES LIKE 'config'") === false) { return; } @@ -511,7 +511,7 @@ class App public function loadDatabase() { - if (dba::connected()) { + if (DBA::connected()) { return; } @@ -542,7 +542,7 @@ class App $stamp1 = microtime(true); - dba::connect($db_host, $db_user, $db_pass, $db_data, $charset); + DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset); unset($db_host, $db_user, $db_pass, $db_data, $charset); $this->save_timestamp($stamp1, 'network'); @@ -1383,7 +1383,7 @@ class App if ($this->profile_uid && ($this->profile_uid != local_user())) { // Allow folks to override user themes and always use their own on their own site. // This works only if the user is on the same server - $user = dba::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]); + $user = DBA::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]); if (DBM::is_result($user) && !PConfig::get(local_user(), 'system', 'always_my_theme')) { $page_theme = $user['theme']; } diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index 47df84f7a6..797ec78610 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -6,7 +6,7 @@ namespace Friendica\Content; use Friendica\Core\Addon; use Friendica\Core\L10n; -use Friendica\Database\dba; +use Friendica\Database\DBA; use Friendica\Database\DBM; /** @@ -26,8 +26,8 @@ class ContactSelector $o .= "\r\n"; } - $stmt = dba::p("SELECT `id`, `name`, `url`, `network` FROM `contact` + $stmt = DBA::p("SELECT `id`, `name`, `url`, `network` FROM `contact` WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' $sql_extra ORDER BY `name` ASC ", intval(local_user()) ); - $contacts = dba::inArray($stmt); + $contacts = DBA::inArray($stmt); $arr = ['contact' => $contacts, 'entry' => $o]; @@ -165,13 +165,13 @@ class ACL extends BaseObject $o .= "