Merge pull request #10798 from annando/q-calls

Some more "q" calls replaced
This commit is contained in:
Hypolite Petovan 2021-10-02 14:41:25 -04:00 committed by GitHub
commit 606b0257ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 32 deletions

View file

@ -242,17 +242,11 @@ function events_content(App $a)
} }
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) { if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) {
q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d", DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
intval(DI::args()->getArgv()[2]),
intval(local_user())
);
} }
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) { if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) {
q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d", DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
intval(DI::args()->getArgv()[2]),
intval(local_user())
);
} }
if ($a->getThemeInfoValue('events_in_profile')) { if ($a->getThemeInfoValue('events_in_profile')) {
@ -444,13 +438,7 @@ function events_content(App $a)
} }
if (($mode === 'edit' || $mode === 'copy') && $event_id) { if (($mode === 'edit' || $mode === 'copy') && $event_id) {
$r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", $orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => local_user()]);
intval($event_id),
intval(local_user())
);
if (DBA::isResult($r)) {
$orig_event = $r[0];
}
} }
// Passed parameters overrides anything found in the DB // Passed parameters overrides anything found in the DB

View file

@ -158,12 +158,9 @@ function message_content(App $a)
DI::baseUrl()->redirect('message/' . $conversation['id'] ); DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else { } else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", $parentmail = DBA::selectFirst('mail', ['parent-uri'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
intval(DI::args()->getArgv()[2]), if (DBA::isResult($parentmail)) {
intval(local_user()) $parent = $parentmail['parent-uri'];
);
if (DBA::isResult($r)) {
$parent = $r[0]['parent-uri'];
if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
notice(DI::l10n()->t('Conversation was not removed.')); notice(DI::l10n()->t('Conversation was not removed.'));

View file

@ -200,12 +200,7 @@ function photos_post(App $a)
return; // NOTREACHED return; // NOTREACHED
} }
$r = q("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d", if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid])) {
DBA::escape($album),
intval($page_owner_uid)
);
if (!DBA::isResult($r)) {
notice(DI::l10n()->t('Album not found.')); notice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
return; // NOTREACHED return; // NOTREACHED
@ -321,7 +316,7 @@ function photos_post(App $a)
} }
if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) { if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) {
Logger::log('rotate'); Logger::notice('rotate');
$photo = Photo::getPhotoForUser($page_owner_uid, $resource_id); $photo = Photo::getPhotoForUser($page_owner_uid, $resource_id);
@ -681,7 +676,7 @@ function photos_post(App $a)
$type = Images::getMimeTypeBySource($src, $filename, $type); $type = Images::getMimeTypeBySource($src, $filename, $type);
Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', Logger::DEBUG); Logger::info('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes');
$maximagesize = DI::config()->get('system', 'maximagesize'); $maximagesize = DI::config()->get('system', 'maximagesize');
@ -701,14 +696,14 @@ function photos_post(App $a)
return; return;
} }
Logger::log('mod/photos.php: photos_post(): loading the contents of ' . $src , Logger::DEBUG); Logger::info('loading the contents of ' . $src);
$imagedata = @file_get_contents($src); $imagedata = @file_get_contents($src);
$image = new Image($imagedata, $type); $image = new Image($imagedata, $type);
if (!$image->isValid()) { if (!$image->isValid()) {
Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG); Logger::info('unable to process image');
notice(DI::l10n()->t('Unable to process image.')); notice(DI::l10n()->t('Unable to process image.'));
@unlink($src); @unlink($src);
$foo = 0; $foo = 0;
@ -737,7 +732,7 @@ function photos_post(App $a)
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if (!$r) { if (!$r) {
Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG); Logger::info('image store failed');
notice(DI::l10n()->t('Image upload failed.')); notice(DI::l10n()->t('Image upload failed.'));
return; return;
} }