Replace dba::select(limit => 1) by dba::selectOne
- Convert array declarations to new style
This commit is contained in:
parent
a2d3cee006
commit
da60893590
51 changed files with 206 additions and 219 deletions
|
@ -1551,8 +1551,8 @@ function admin_page_users(App $a)
|
|||
{
|
||||
if ($a->argc > 2) {
|
||||
$uid = $a->argv[3];
|
||||
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
|
||||
if (count($user) == 0) {
|
||||
$user = dba::selectOne('user', ['username', 'blocked'], ['uid' => $uid]);
|
||||
if (DBM::is_result($user)) {
|
||||
notice('User not found' . EOL);
|
||||
goaway('admin/users');
|
||||
return ''; // NOTREACHED
|
||||
|
@ -1563,15 +1563,15 @@ function admin_page_users(App $a)
|
|||
// delete user
|
||||
User::remove($uid);
|
||||
|
||||
notice(t("User '%s' deleted", $user[0]['username']) . EOL);
|
||||
notice(t("User '%s' deleted", $user['username']) . EOL);
|
||||
break;
|
||||
case "block":
|
||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
||||
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
|
||||
intval(1 - $user[0]['blocked']),
|
||||
intval(1 - $user['blocked']),
|
||||
intval($uid)
|
||||
);
|
||||
notice(sprintf(($user[0]['blocked'] ? t("User '%s' unblocked") : t("User '%s' blocked")), $user[0]['username']) . EOL);
|
||||
notice(sprintf(($user['blocked'] ? t("User '%s' unblocked") : t("User '%s' blocked")), $user['username']) . EOL);
|
||||
break;
|
||||
}
|
||||
goaway('admin/users');
|
||||
|
|
11
mod/cal.php
11
mod/cal.php
|
@ -32,16 +32,13 @@ function cal_init(App $a)
|
|||
|
||||
if ($a->argc > 1) {
|
||||
$nick = $a->argv[1];
|
||||
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||
dbesc($nick)
|
||||
);
|
||||
|
||||
if (!count($user)) {
|
||||
$user = dba::selectOne('user', [], ['nickname' => $nick, 'blocked' => false]);
|
||||
if (!DBM::is_result($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->data['user'] = $user[0];
|
||||
$a->profile_uid = $user[0]['uid'];
|
||||
$a->data['user'] = $user;
|
||||
$a->profile_uid = $user['uid'];
|
||||
|
||||
// if it's a json request abort here becaus we don't
|
||||
// need the widget data
|
||||
|
|
|
@ -63,19 +63,13 @@ function common_content(App $a)
|
|||
}
|
||||
|
||||
if (!$cid && get_my_url()) {
|
||||
/// @todo : Initialize $profile_uid
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$cid = $r[0]['id'];
|
||||
$contact = dba::selectOne('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$cid = $contact['id'];
|
||||
} else {
|
||||
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$zcid = $r[0]['id'];
|
||||
$gcontact = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
|
||||
if (DBM::is_result($gcontact)) {
|
||||
$zcid = $gcontact['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ function contacts_init(App $a)
|
|||
$contact = [];
|
||||
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::select('contact', [], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
|
||||
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
|
||||
}
|
||||
|
||||
if (DBM::is_result($contact)) {
|
||||
|
@ -222,7 +222,7 @@ function contacts_post(App $a)
|
|||
notice(t('Failed to update contact record.') . EOL);
|
||||
}
|
||||
|
||||
$contact = dba::select('contact', [], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
|
||||
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$a->data['contact'] = $contact;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ function contacts_post(App $a)
|
|||
|
||||
function _contact_update($contact_id)
|
||||
{
|
||||
$contact = dba::select('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
|
||||
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ function _contact_update($contact_id)
|
|||
|
||||
function _contact_update_profile($contact_id)
|
||||
{
|
||||
$contact = dba::select('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
|
||||
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ function contacts_content(App $a)
|
|||
|
||||
$cmd = $a->argv[2];
|
||||
|
||||
$orig_record = dba::select('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false], ['limit' => 1]);
|
||||
$orig_record = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
|
||||
if (!DBM::is_result($orig_record)) {
|
||||
notice(t('Could not access contact record.') . EOL);
|
||||
goaway('contacts');
|
||||
|
@ -904,7 +904,7 @@ function contact_posts($a, $contact_id)
|
|||
{
|
||||
$o = contacts_tab($a, $contact_id, 1);
|
||||
|
||||
$contact = dba::select('contact', ['url'], ['id' => $contact_id], ['limit' => 1]);
|
||||
$contact = dba::selectOne('contact', ['url'], ['id' => $contact_id]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$a->page['aside'] = "";
|
||||
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
||||
|
|
|
@ -202,7 +202,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
|||
|
||||
if ($update) {
|
||||
$item_id = $_REQUEST['item_id'];
|
||||
$item = dba::select('item', ['uid', 'parent'], ['id' => $item_id], ['limit' => 1]);
|
||||
$item = dba::selectOne('item', ['uid', 'parent'], ['id' => $item_id]);
|
||||
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
|
||||
$item_parent = $item['parent'];
|
||||
} else {
|
||||
|
@ -345,7 +345,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
|||
$s = dba::inArray($r);
|
||||
|
||||
if (local_user() && (local_user() == $a->profile['uid'])) {
|
||||
$unseen = dba::select('item', array('id'), array('parent' => $s[0]['parent'], 'unseen' => true), array('limit' => 1));
|
||||
$unseen = dba::selectOne('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
|
||||
if (DBM::is_result($unseen)) {
|
||||
dba::update('item', array('unseen' => false), array('parent' => $s[0]['parent'], 'unseen' => true));
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ function hovercard_content()
|
|||
$cid = 0;
|
||||
if (local_user() && strpos($profileurl, 'redir/') === 0) {
|
||||
$cid = intval(substr($profileurl, 6));
|
||||
$r = dba::select('contact', array('nurl'), array('id' => $cid), array('limit' => 1));
|
||||
$r = dba::selectOne('contact', ['nurl'], ['id' => $cid]);
|
||||
$profileurl = defaults($r, 'nurl', '');
|
||||
}
|
||||
|
||||
|
|
|
@ -580,8 +580,8 @@ function networkThreadedView(App $a, $update = 0) {
|
|||
|
||||
if ($cid) {
|
||||
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
|
||||
$condition = array("`id` = ? AND (`forum` OR `prv`)", $cid);
|
||||
$contact = dba::select('contact', array('addr', 'nick'), $condition, array('limit' => 1));
|
||||
$condition = ["`id` = ? AND (`forum` OR `prv`)", $cid];
|
||||
$contact = dba::selectOne('contact', ['addr', 'nick'], $condition);
|
||||
if (DBM::is_result($contact)) {
|
||||
if ($contact["addr"] != '') {
|
||||
$content = "!".$contact["addr"];
|
||||
|
@ -632,7 +632,7 @@ function networkThreadedView(App $a, $update = 0) {
|
|||
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
|
||||
|
||||
if ($group) {
|
||||
$r = dba::select('group', array('name'), array('id' => $group, 'uid' => $_SESSION['uid']), array('limit' => 1));
|
||||
$r = dba::selectOne('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
|
||||
if (!DBM::is_result($r)) {
|
||||
if ($update)
|
||||
killme();
|
||||
|
@ -647,7 +647,7 @@ function networkThreadedView(App $a, $update = 0) {
|
|||
$contact_str_self = "";
|
||||
|
||||
$contact_str = implode(',',$contacts);
|
||||
$self = dba::select('contact', array('id'), array('uid' => $_SESSION['uid'], 'self' => true), array('limit' => 1));
|
||||
$self = dba::selectOne('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
|
||||
if (DBM::is_result($self)) {
|
||||
$contact_str_self = $self["id"];
|
||||
}
|
||||
|
@ -665,10 +665,10 @@ function networkThreadedView(App $a, $update = 0) {
|
|||
)) . $o;
|
||||
|
||||
} elseif ($cid) {
|
||||
$fields = array('id', 'name', 'network', 'writable', 'nurl',
|
||||
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location');
|
||||
$condition = array("`id` = ? AND (NOT `blocked` OR `pending`)", $cid);
|
||||
$r = dba::select('contact', $fields, $condition, array('limit' => 1));
|
||||
$fields = ['id', 'name', 'network', 'writable', 'nurl',
|
||||
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location'];
|
||||
$condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid];
|
||||
$r = dba::selectOne('contact', $fields, $condition);
|
||||
if (DBM::is_result($r)) {
|
||||
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
|
||||
|
||||
|
|
|
@ -67,14 +67,14 @@ function noscrape_init(App $a) {
|
|||
|
||||
// We display the last activity (post or login), reduced to year and week number
|
||||
$last_active = 0;
|
||||
$condition = array('uid' => $a->profile['uid'], 'self' => true);
|
||||
$contact = dba::select('contact', array('last-item'), $condition, array('limit' => 1));
|
||||
$condition = ['uid' => $a->profile['uid'], 'self' => true];
|
||||
$contact = dba::selectOne('contact', ['last-item'], $condition);
|
||||
if (DBM::is_result($contact)) {
|
||||
$last_active = strtotime($contact['last-item']);
|
||||
}
|
||||
|
||||
$condition = array('uid' => $a->profile['uid']);
|
||||
$user = dba::select('user', array('login_date'), $condition, array('limit' => 1));
|
||||
$condition = ['uid' => $a->profile['uid']];
|
||||
$user = dba::selectOne('user', ['login_date'], $condition);
|
||||
if (DBM::is_result($user)) {
|
||||
if ($last_active < strtotime($user['login_date'])) {
|
||||
$last_active = strtotime($user['login_date']);
|
||||
|
|
|
@ -148,7 +148,7 @@ function proxy_init(App $a) {
|
|||
$r = array();
|
||||
|
||||
if (!$direct_cache && ($cachefile == '')) {
|
||||
$r = dba::select('photo', array('data', 'desc'), array('resource-id' => $urlhash), array('limit' => 1));
|
||||
$r = dba::selectOne('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
|
||||
if (DBM::is_result($r)) {
|
||||
$img_str = $r['data'];
|
||||
$mime = $r['desc'];
|
||||
|
|
|
@ -32,7 +32,7 @@ function receive_post(App $a)
|
|||
}
|
||||
$guid = $a->argv[2];
|
||||
|
||||
$importer = dba::select('user', array(), array('guid' => $guid, 'account_expired' => false, 'account_removed' => false), array('limit' => 1));
|
||||
$importer = dba::selectOne('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
|
||||
if (!DBM::is_result($importer)) {
|
||||
http_status_exit(500);
|
||||
}
|
||||
|
|
|
@ -997,7 +997,7 @@ function settings_content(App $a)
|
|||
|
||||
require_once('include/acl_selectors.php');
|
||||
|
||||
$profile = dba::select('profile', [], ['is-default' => true, 'uid' => local_user()], ['limit' => 1]);
|
||||
$profile = dba::selectOne('profile', [], ['is-default' => true, 'uid' => local_user()]);
|
||||
if (!DBM::is_result($profile)) {
|
||||
notice(t('Unable to find your profile. Please contact your admin.') . EOL);
|
||||
return;
|
||||
|
|
|
@ -23,10 +23,10 @@ function unfollow_post(App $a) {
|
|||
$url = notags(trim($_REQUEST['url']));
|
||||
$return_url = $_SESSION['return_url'];
|
||||
|
||||
$condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
|
||||
$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::select('contact', array(), $condition, array('limit' => 1));
|
||||
normalise_link($url), $url, NETWORK_STATUSNET];
|
||||
$contact = dba::selectOne('contact', [], $condition);
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
notice(t("Contact wasn't found or can't be unfollowed."));
|
||||
|
@ -62,10 +62,10 @@ function unfollow_content(App $a) {
|
|||
|
||||
$submit = t('Submit Request');
|
||||
|
||||
$condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
|
||||
$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::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
|
||||
normalise_link($url), $url, NETWORK_STATUSNET];
|
||||
$contact = dba::selectOne('contact', ['url', 'network', 'addr', 'name'], $condition);
|
||||
|
||||
if (!DBM::is_result($contact)) {
|
||||
notice(t("You aren't a friend of this contact.").EOL);
|
||||
|
|
|
@ -35,7 +35,7 @@ function xrd_init(App $a)
|
|||
$name = substr($local, 0, strpos($local, '@'));
|
||||
}
|
||||
|
||||
$r = dba::select('user', array(), array('nickname' => $name), array('limit' => 1));
|
||||
$r = dba::selectOne('user', [], ['nickname' => $name]);
|
||||
if (!DBM::is_result($r)) {
|
||||
killme();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue