Merge pull request #4537 from rabuzarus/20180303_-_fix_directory_search

Bugfix: search in local directory didn't work
This commit is contained in:
Hypolite Petovan 2018-03-03 09:18:41 -05:00 committed by GitHub
commit 9cf2183524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,12 +12,12 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
function directory_init(App $a) {
function directory_init(App $a)
{
$a->set_pager_itemspage(60);
if (local_user()) {
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
} else {
unset($_SESSION['theme']);
@ -25,16 +25,20 @@ function directory_init(App $a) {
}
}
function directory_post(App $a) {
if(x($_POST,'search'))
function directory_post(App $a)
{
if (x($_POST, 'search')) {
$a->data['search'] = $_POST['search'];
}
}
function directory_content(App $a) {
function directory_content(App $a)
{
require_once("mod/proxy.php");
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user()) ||
(Config::get('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
if ((Config::get('system', 'block_public') && !local_user() && !remote_user())
|| (Config::get('system', 'block_local_dir') && !local_user() && !remote_user())
) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
@ -42,10 +46,11 @@ function directory_content(App $a) {
$o = '';
Nav::setSelected('directory');
if(x($a->data,'search'))
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
else
} else {
$search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
}
$gdirpath = '';
$dirurl = Config::get('system', 'directory');
@ -76,32 +81,32 @@ function directory_content(App $a) {
$publish = ((Config::get('system', 'publish_all')) ? '' : " AND `publish` = 1 " );
$r = q("SELECT COUNT(*) AS `total` FROM `profile`
$total = q("SELECT COUNT(*) AS `total` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
if (DBM::is_result($r))
$a->set_pager_total($r[0]['total']);
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "
);
if (DBM::is_result($total)) {
$a->set_pager_total($total[0]['total']);
}
$order = " ORDER BY `name` ASC ";
$limit = intval($a->pager['start'])."," . intval($a->pager['itemspage']);
$r = q("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`
WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit
);
if (DBM::is_result($r)) {
if (in_array('small', $a->argv)) {
$photo = 'thumb';
}
else {
} else {
$photo = 'photo';
}
foreach ($r as $rr) {
while ($rr = dba::fetch($r)) {
$itemurl= '';
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@ -111,16 +116,19 @@ function directory_content(App $a) {
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = '';
if(strlen($rr['locality']))
if (strlen($rr['locality'])) {
$details .= $rr['locality'];
}
if (strlen($rr['region'])) {
if(strlen($rr['locality']))
if (strlen($rr['locality'])) {
$details .= ', ';
}
$details .= $rr['region'];
}
if (strlen($rr['country-name'])) {
if(strlen($details))
if (strlen($details)) {
$details .= ', ';
}
$details .= $rr['country-name'];
}
// if(strlen($rr['dob'])) {
@ -136,16 +144,15 @@ function directory_content(App $a) {
|| (x($profile, 'locality') == 1)
|| (x($profile, 'region') == 1)
|| (x($profile, 'postal-code') == 1)
|| (x($profile,'country-name') == 1))
|| (x($profile, 'country-name') == 1)
) {
$location = L10n::t('Location:');
}
$gender = ((x($profile,'gender') == 1) ? L10n::t('Gender:') : False);
$marital = ((x($profile,'marital') == 1) ? L10n::t('Status:') : False);
$homepage = ((x($profile,'homepage') == 1) ? L10n::t('Homepage:') : False);
$about = ((x($profile,'about') == 1) ? L10n::t('About:') : False);
$gender = ((x($profile, 'gender') == 1) ? L10n::t('Gender:') : false);
$marital = ((x($profile, 'marital') == 1) ? L10n::t('Status:') : false);
$homepage = ((x($profile, 'homepage') == 1) ? L10n::t('Homepage:') : false);
$about = ((x($profile, 'about') == 1) ? L10n::t('About:') : false);
$location_e = $location;
@ -187,6 +194,7 @@ function directory_content(App $a) {
$entries[] = $arr['entry'];
}
dba::close($r);
$tpl = get_markup_template('directory_header.tpl');