Merge branch 'rewrites/dbm_is_result' of github.com:Quix0r/friendica into rewrites/dbm_is_result

Signed-off-by: Roland Häder <roland@mxchange.org>

Conflicts:
	include/Photo.php
	include/api.php
	include/cache.php
	include/dbstructure.php
	include/enotify.php
	include/items.php
	include/onepoll.php
	include/queue_fn.php
	include/session.php
	include/text.php
	mod/contacts.php
	mod/dfrn_request.php
	mod/display.php
	mod/events.php
	mod/item.php
	mod/message.php
	mod/msearch.php
	mod/photos.php
	mod/poco.php
	mod/profile.php
	mod/proxy.php
	mod/videos.php
	update.php
	view/theme/diabook/theme.php
	view/theme/vier/theme.php
This commit is contained in:
Roland Häder 2016-12-13 11:00:44 +01:00
commit 63610c7b73
33 changed files with 320 additions and 260 deletions

View file

@ -47,4 +47,4 @@ function contactgroup_content(&$a) {
}
killme();
}
}

View file

@ -772,6 +772,8 @@ function contacts_content(&$a) {
$sql_extra3 = unavailable_networks();
$contacts = array();
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ",
intval($_SESSION['uid']),
intval($a->pager['start']),

View file

@ -273,7 +273,7 @@ function dfrn_request_post(&$a) {
dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid)
);
if(dbm::is_result($r) > $maxreq) {
if(dbm::is_result($r) && count($r) > $maxreq) {
notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL);
notice( t('Spam protection measures have been invoked.') . EOL);
notice( t('Friends are advised to please try again in 24 hours.') . EOL);
@ -370,8 +370,8 @@ function dfrn_request_post(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid)
);
if(! dbm::is_result($r)) {
if(! dbm::is_result($r)) {
notice( t('This account has not been configured for email. Request failed.') . EOL);
return;
}
@ -431,8 +431,8 @@ function dfrn_request_post(&$a) {
$hash = random_string();
$r = q("insert into intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked )
values( %d , %d, %d, '%s', '%s', '%s', %d ) ",
$r = q("INSERT INTO intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked )
VALUES( %d , %d, %d, '%s', '%s', '%s', %d ) ",
intval($uid),
intval($contact_id),
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
@ -449,9 +449,13 @@ function dfrn_request_post(&$a) {
$data = probe_url($url);
$network = $data["network"];
logger('dfrn_request: url=' . $url . ',network=' . $network . ',hcard=' . $hcard . ' - BEFORE!', LOGGER_DEBUG);
// Canonicalise email-style profile locator
$url = Probe::webfinger_dfrn($url,$hcard);
logger('dfrn_request: url=' . $url . ',network=' . $network . ',hcard=' . $hcard . ' - AFTER!', LOGGER_DEBUG);
if (substr($url,0,5) === 'stat:') {
// Every time we detect the remote subscription we define this as OStatus.
@ -473,7 +477,7 @@ function dfrn_request_post(&$a) {
dbesc($url)
);
if(count($ret)) {
if(dbm::is_result($ret)) {
if(strlen($ret[0]['issued-id'])) {
notice( t('You have already introduced yourself here.') . EOL );
return;
@ -720,7 +724,9 @@ function dfrn_request_content(&$a) {
dbesc($_GET['confirm_key'])
);
if(count($intro)) {
if(dbm::is_result($intro)) {
$auto_confirm = false;
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`id` = %d LIMIT 1",

View file

@ -303,7 +303,7 @@ function display_content(&$a, $update = 0) {
intval($contact_id),
intval($a->profile['uid'])
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
@ -319,7 +319,7 @@ function display_content(&$a, $update = 0) {
$r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($a->profile['uid'])
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$a->page_contact = $r[0];
}
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);

View file

@ -344,9 +344,10 @@ function events_content(&$a) {
$events=array();
// transform the event in a usable array
if(dbm::is_result($r))
if(dbm::is_result($r)) {
$r = sort_by_date($r);
$events = process_events($r);
}
if ($a->argv[1] === 'json'){
echo json_encode($events); killme();

View file

@ -130,7 +130,7 @@ function item_post(&$a) {
intval($parent_item['contact-id']),
intval($uid)
);
if (dbm::is_result($r))
if(dbm::is_result($r))
$parent_contact = $r[0];
// If the contact id doesn't fit with the contact, then set the contact to null
@ -234,7 +234,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($profile_uid)
);
if (dbm::is_result($r))
if(dbm::is_result($r))
$user = $r[0];
if($orig_post) {
@ -399,7 +399,7 @@ function item_post(&$a) {
}
}
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$author = $r[0];
$contact_id = $author['id'];
}
@ -413,7 +413,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($profile_uid)
);
if (dbm::is_result($r))
if(dbm::is_result($r))
$contact_record = $r[0];
}
@ -496,7 +496,7 @@ function item_post(&$a) {
intval($profile_uid),
intval($attach)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `uid` = %d AND `id` = %d",
dbesc($str_contact_allow),
@ -637,7 +637,7 @@ function item_post(&$a) {
intval($profile_uid),
intval($mtch)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
if(strlen($attachments))
$attachments .= ',';
$attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';

View file

@ -309,18 +309,20 @@ function message_content(&$a) {
intval(local_user()),
intval($a->argv[2])
);
if(!$r) {
if(!dbm::is_result($r)) {
$r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval(local_user()),
dbesc(normalise_link(base64_decode($a->argv[2])))
);
}
if(!$r) {
if(!dbm::is_result($r)) {
$r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1",
intval(local_user()),
dbesc(base64_decode($a->argv[2]))
);
}
if(dbm::is_result($r)) {
$prename = $r[0]['name'];
$preurl = $r[0]['url'];

View file

@ -13,9 +13,12 @@ function msearch_post(&$a) {
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
dbesc($search)
);
if(dbm::is_result($r))
$total = $r[0]['total'];
$results = array();
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
dbesc($search),
intval($startrec),
@ -23,6 +26,7 @@ function msearch_post(&$a) {
);
$results = array();
if(dbm::is_result($r)) {
foreach($r as $rr)
$results[] = array(
@ -39,4 +43,4 @@ function msearch_post(&$a) {
killme();
}
}

View file

@ -729,7 +729,9 @@ function network_content(&$a, $update = 0) {
intval($parents),
intval($max_comments + 1)
);
$items = array_merge($items, $thread_items);
if (dbm::is_result($thread_items))
$items = array_merge($items, $thread_items);
}
$items = conv_sort($items,$ordering);
} else {

View file

@ -305,7 +305,6 @@ function notifications_content(&$a) {
$notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
}
$o .= replace_macros($notif_tpl, array(
'$notif_header' => $notif_header,
'$tabs' => $tabs,

View file

@ -48,7 +48,7 @@ function p_init($a){
$r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d", intval($item[0]["uid"]));
if (!$r) {
if (!dbm::is_result($r)) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
killme();
}

View file

@ -117,7 +117,7 @@ function photo_init(&$a) {
intval($resolution)
);
$public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
$public = (dbm::is_result($r)) && ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
if(dbm::is_result($r)) {
$resolution = $r[0]['scale'];

View file

@ -254,8 +254,8 @@ function photos_post(&$a) {
dbesc($album)
);
}
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if(dbm::is_result($r)) {
foreach($r as $rr) {
$res[] = "'" . dbesc($rr['rid']) . "'" ;
}
} else {
@ -276,8 +276,8 @@ function photos_post(&$a) {
$r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
intval($page_owner_uid)
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if(dbm::is_result($r)) {
foreach($r as $rr) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($rr['parent-uri']),
@ -337,7 +337,7 @@ function photos_post(&$a) {
dbesc($a->argv[2])
);
}
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
intval($page_owner_uid),
dbesc($r[0]['resource-id'])
@ -393,7 +393,7 @@ function photos_post(&$a) {
dbesc($resource_id),
intval($page_owner_uid)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$ph = new Photo($r[0]['data'], $r[0]['type']);
if ($ph->is_valid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
@ -510,7 +510,7 @@ function photos_post(&$a) {
intval($page_owner_uid)
);
}
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$old_tag = $r[0]['tag'];
$old_inform = $r[0]['inform'];
}
@ -594,7 +594,7 @@ function photos_post(&$a) {
intval($page_owner_uid)
);
}*/
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$newname = $r[0]['name'];
$profile = $r[0]['url'];
$notify = 'cid:' . $r[0]['id'];
@ -1008,7 +1008,7 @@ function photos_content(&$a) {
intval($contact_id),
intval($owner_uid)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$can_post = true;
$contact = $r[0];
$remote_contact = true;
@ -1036,7 +1036,7 @@ function photos_content(&$a) {
intval($contact_id),
intval($owner_uid)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
@ -1188,7 +1188,7 @@ function photos_content(&$a) {
intval($owner_uid),
dbesc($album)
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(20);
}
@ -1243,7 +1243,7 @@ function photos_content(&$a) {
$photos = array();
if (dbm::is_result($r))
if(dbm::is_result($r))
$twist = 'rotright';
foreach ($r as $rr) {
if ($twist == 'rotright')
@ -1435,7 +1435,7 @@ function photos_content(&$a) {
);
if (dbm::is_result($r))
if(dbm::is_result($r))
$a->set_pager_total($r[0]['total']);
@ -1611,7 +1611,7 @@ function photos_content(&$a) {
// display comments
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
foreach ($r as $item) {
builtin_activity_puller($item, $conv_responses);
@ -1794,7 +1794,7 @@ function photos_content(&$a) {
dbesc('Contact Photos'),
dbesc( t('Contact Photos'))
);
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(20);
}
@ -1812,7 +1812,7 @@ function photos_content(&$a) {
$photos = array();
if (dbm::is_result($r)) {
if(dbm::is_result($r)) {
$twist = 'rotright';
foreach ($r as $rr) {
//hide profile photos to others

View file

@ -173,7 +173,7 @@ function poco_init(&$a) {
}
if(is_array($r)) {
if(count($r) > 0) {
if(dbm::is_result($r)) {
foreach($r as $rr) {
if (!isset($rr['generation'])) {
if ($global)

View file

@ -256,21 +256,21 @@ function profile_content(&$a, $update = 0) {
AND `thread`.`wall` = 1
$sql_extra $sql_extra2 ",
intval($a->profile['profile_uid'])
);
);
if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']);
if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']);
}
}
// check if we serve a mobile device and get the user settings
// accordingly
if ($a->is_mobile) {
$itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 10);
$itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 10);
} else {
$itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
$itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
}
// now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice

View file

@ -209,7 +209,6 @@ function search_content(&$a) {
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
$r = q("SELECT %s
FROM `item` %s
WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))