use Friendica\Core\Cache;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Item;
$rules = Cache::get('rules_' . local_user());
if (!isset($rules)) {
- $rules = dba::inArray(dba::select(
+ $rules = DBA::inArray(DBA::select(
'advancedcontentfilter_rules',
['name', 'expression', 'serialized'],
['uid' => local_user(), 'active' => true]
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
}
- $rules = dba::inArray(dba::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
+ $rules = DBA::inArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
return json_encode($rules);
}
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
}
- $rule = dba::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => local_user()]);
+ $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => local_user()]);
return json_encode($rule);
}
$fields['uid'] = local_user();
$fields['created'] = DateTimeFormat::utcNow();
- if (!dba::insert('advancedcontentfilter_rules', $fields)) {
- throw new HTTPException\ServiceUnavaiableException(dba::errorMessage());
+ if (!DBA::insert('advancedcontentfilter_rules', $fields)) {
+ throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage());
}
- $rule = dba::selectFirst('advancedcontentfilter_rules', [], ['id' => dba::lastInsertId()]);
+ $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]);
return json_encode(['message' => L10n::t('Rule successfully added'), 'rule' => $rule]);
}
throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.'));
}
- if (!dba::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) {
+ if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) {
throw new HTTPException\NotFoundException(L10n::t('Rule doesn\'t exist or doesn\'t belong to you.'));
}
throw new HTTPException\BadRequestException($e->getMessage(), 0, $e);
}
- if (!dba::update('advancedcontentfilter_rules', $fields, ['id' => $args['id']])) {
- throw new HTTPException\ServiceUnavaiableException(dba::errorMessage());
+ if (!DBA::update('advancedcontentfilter_rules', $fields, ['id' => $args['id']])) {
+ throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage());
}
return json_encode(['message' => L10n::t('Rule successfully updated')]);
throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.'));
}
- if (!dba::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) {
+ if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) {
throw new HTTPException\NotFoundException(L10n::t('Rule doesn\'t exist or doesn\'t belong to you.'));
}
- if (!dba::delete('advancedcontentfilter_rules', ['id' => $args['id']])) {
- throw new HTTPException\ServiceUnavaiableException(dba::errorMessage());
+ if (!DBA::delete('advancedcontentfilter_rules', ['id' => $args['id']])) {
+ throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage());
}
return json_encode(['message' => L10n::t('Rule successfully deleted')]);
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\ItemContent;
function buffer_install() {
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
// delete the current cached cat avatar
$condition = ['uid' => local_user(), 'blocked' => false,
'account_expired' => false, 'account_removed' => false];
- $user = dba::selectFirst('user', ['email'], $condition);
+ $user = DBA::selectFirst('user', ['email'], $condition);
$seed = PConfig::get(local_user(), 'catavatar', 'seed', md5(trim(strtolower($user['email']))));
if (!empty($_POST['catavatar-usecat'])) {
$url = $a->get_baseurl() . '/catavatar/' . local_user() . '?ts=' . time();
- $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)) {
notice(L10n::t("The cat hadn't found itself."));
return;
Photo::importProfilePhoto($url, local_user(), $self['id']);
$condition = ['uid' => local_user(), 'contact-id' => $self['id']];
- $photo = dba::selectFirst('photo', ['resource-id'], $condition);
+ $photo = DBA::selectFirst('photo', ['resource-id'], $condition);
if (!DBM::is_result($photo)) {
notice(L10n::t('There was an error, the cat ran away.'));
return;
}
- dba::update('photo', ['profile' => false], ['profile' => true, 'uid' => local_user()]);
+ DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => local_user()]);
$fields = ['profile' => true, 'album' => L10n::t('Profile Photos'), 'contact-id' => 0];
- dba::update('photo', $fields, ['uid' => local_user(), 'resource-id' => $photo['resource-id']]);
+ DBA::update('photo', $fields, ['uid' => local_user(), 'resource-id' => $photo['resource-id']]);
Photo::importProfilePhoto($url, local_user(), $self['id']);
*/
function catavatar_lookup(App $a, &$b)
{
- $user = dba::selectFirst('user', ['uid'], ['email' => $b['email']]);
+ $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
$url = $a->get_baseurl() . '/catavatar/' . $user['uid'];
switch($b['size']) {
$condition = ['uid' => $uid, 'blocked' => false,
'account_expired' => false, 'account_removed' => false];
- $user = dba::selectFirst('user', ['email'], $condition);
+ $user = DBA::selectFirst('user', ['email'], $condition);
if ($user === false) {
throw new NotFoundException();
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Queue;
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
$nickname = $a->argv[1];
- $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]);
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBM::is_result($user)) {
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
return;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Util\Network;
function libertree_install() {
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
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\Util\DateTimeFormat;
}
$fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days'), 'expire' => $days_posts];
- dba::update('user', $fields, ['uid' => $uid]);
+ DBA::update('user', $fields, ['uid' => $uid]);
}
function public_server_cron($a, $b)
]);
$fields = ['expire_notification_sent' => DateTimeFormat::utcNow()];
- dba::update('user', $fields, ['uid' => $rr['uid']]);
+ DBA::update('user', $fields, ['uid' => $rr['uid']]);
}
}
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
- dba::update('user', $fields, ['uid' => $rr['uid']]);
+ DBA::update('user', $fields, ['uid' => $rr['uid']]);
}
}
}
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
- dba::update('user', $fields, ['uid' => $rr['uid']]);
+ DBA::update('user', $fields, ['uid' => $rr['uid']]);
}
}
}
intval($flagposts), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
foreach ($r as $rr) {
- dba::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
+ DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
}
}
}
$fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days')];
$condition = ["`uid` = ? AND `account_expires_on` > ?", local_user(), NULL_DATE];
- dba::update('user', $fields, $condition);
+ DBA::update('user', $fields, $condition);
}
function public_server_addon_admin_post(&$a)
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
}
$condition = ['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
- if (dba::exists('item', $condition)) {
+ if (DBA::exists('item', $condition)) {
logger("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
return;
}
{
// Two queries for speed issues
$condition = ['uri' => $post->object->id, 'uid' => $uid];
- if (dba::exists('item', $condition)) {
+ if (DBA::exists('item', $condition)) {
Item::delete($condition);
return true;
}
$condition = ['extid' => $post->object->id, 'uid' => $uid];
- if (dba::exists('item', $condition)) {
+ if (DBA::exists('item', $condition)) {
Item::delete($condition);
return true;
}
if ($post->verb != "update") {
// Two queries for speed issues
- if (dba::exists('item', ['uri' => $post->object->id, 'uid' => $uid])) {
+ if (DBA::exists('item', ['uri' => $post->object->id, 'uid' => $uid])) {
return false;
}
- if (dba::exists('item', ['extid' => $post->object->id, 'uid' => $uid])) {
+ if (DBA::exists('item', ['extid' => $post->object->id, 'uid' => $uid])) {
return false;
}
}
}
// Checking if the comment already exists - Two queries for speed issues
- if (dba::exists('item', ['uri' => $item->id, 'uid' => $uid])) {
+ if (DBA::exists('item', ['uri' => $item->id, 'uid' => $uid])) {
continue;
}
- if (dba::exists('item', ['extid' => $item->id, 'uid' => $uid])) {
+ if (DBA::exists('item', ['extid' => $item->id, 'uid' => $uid])) {
continue;
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Group;
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
$postarray['uri'] = $hostname . "::" . $content->id;
- if (dba::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
+ if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
return [];
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
function tumblr_install() {
Addon::registerHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
return;
}
- $r = dba::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
- while ($row = dba::fetch($r)) {
- dba::delete('item', ['id' => $row['id']]);
- if (!empty($row['iaid']) && !dba::exists('item', ['iaid' => $row['iaid']])) {
- dba::delete('item-activity', ['id' => $row['iaid']]);
+ $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
+ while ($row = DBA::fetch($r)) {
+ DBA::delete('item', ['id' => $row['id']]);
+ if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
+ DBA::delete('item-activity', ['id' => $row['iaid']]);
}
- if (!empty($row['icid']) && !dba::exists('item', ['icid' => $row['icid']])) {
- dba::delete('item-content', ['id' => $row['icid']]);
+ if (!empty($row['icid']) && !DBA::exists('item', ['icid' => $row['icid']])) {
+ DBA::delete('item-content', ['id' => $row['icid']]);
}
}
- dba::close($r);
+ DBA::close($r);
require_once "include/items.php";
$cid = Contact::getIdForURL($url, 0, true, $fields);
if (!empty($cid)) {
- dba::update('contact', $fields, ['id' => $cid]);
+ DBA::update('contact', $fields, ['id' => $cid]);
Contact::updateAvatar($avatar, 0, $cid);
}
- $contact = dba::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
+ $contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
if (!DBM::is_result($contact) && !$create_user) {
return 0;
}
$fields['readonly'] = false;
$fields['pending'] = false;
- if (!dba::insert('contact', $fields)) {
+ if (!DBA::insert('contact', $fields)) {
return false;
}
- $contact_id = dba::lastInsertId();
+ $contact_id = DBA::lastInsertId();
Group::addMember(User::getDefaultGroup($uid), $contact_id);
$fields['name-date'] = DateTimeFormat::utcNow();
$fields['uri-date'] = DateTimeFormat::utcNow();
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
}
}
// $postarray['object'] = json_encode($post); // Activate for debugging
// Don't import our own comments
- if (dba::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
+ if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG);
return [];
}
break;
}
- if (dba::exists('item', ['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) {
+ if (DBA::exists('item', ['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) {
break;
}
$notify = false;
if ($postarray['uri'] == $postarray['parent-uri']) {
- $contact = dba::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
if (DBM::is_result($contact)) {
$notify = Item::isRemoteSelf($contact, $postarray);
}
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\User;
$user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW']));
if ($user_id) {
- $record = dba::selectFirst('user', [], ['uid' => $user_id]);
+ $record = DBA::selectFirst('user', [], ['uid' => $user_id]);
} else {
logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Util\Network;
function wppost_install() {
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}