Fix forumdirectory reference to deleted files/functions

- Fix formatting
- Fix reference to nav_set_selected
- Fix reference to widget_findpeople
This commit is contained in:
Hypolite Petovan 2018-01-18 19:36:05 -05:00
parent 38db18b624
commit 0ec16922e7

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Name: Forum Directory * Name: Forum Directory
* Description: Add a directory of forums hosted on your server, with verbose descriptions. * Description: Add a directory of forums hosted on your server, with verbose descriptions.
@ -6,63 +7,66 @@
* Author: Thomas Willingham <https://beardyunixer.com/profile/beardyunixer> * Author: Thomas Willingham <https://beardyunixer.com/profile/beardyunixer>
*/ */
use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\DBM;
function forumdirectory_install() { function forumdirectory_install()
{
register_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu'); register_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
} }
function forumdirectory_uninstall() { function forumdirectory_uninstall()
{
unregister_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu'); unregister_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
} }
function forumdirectory_module() { function forumdirectory_module()
{
return; return;
} }
function forumdirectory_app_menu($a,&$b) { function forumdirectory_app_menu($a, &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="forumdirectory">' . t('Forum Directory') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="forumdirectory">' . t('Forum Directory') . '</a></div>';
} }
function forumdirectory_init(&$a) { function forumdirectory_init(&$a)
{
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/forumdirectory/forumdirectory.css" media="all" />'; $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/forumdirectory/forumdirectory.css" media="all" />';
$a->set_pager_itemspage(60); $a->set_pager_itemspage(60);
if (local_user()) { if (local_user()) {
require_once('include/contact_widgets.php'); $a->page['aside'] .= Widget::findPeople();
} else {
$a->page['aside'] .= findpeople_widget();
}
else
unset($_SESSION['theme']); unset($_SESSION['theme']);
}
} }
function forumdirectory_post(&$a)
function forumdirectory_post(&$a) { {
if(x($_POST,'search')) if (x($_POST, 'search')) {
$a->data['search'] = $_POST['search']; $a->data['search'] = $_POST['search'];
} }
}
function forumdirectory_content(&$a)
{
function forumdirectory_content(&$a) {
if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) { if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
notice(t('Public access denied.') . EOL); notice(t('Public access denied.') . EOL);
return; return;
} }
$o = ''; $o = '';
nav_set_selected('directory'); Nav::setSelected('directory');
if(x($a->data,'search')) if (x($a->data, 'search')) {
$search = notags(trim($a->data['search'])); $search = notags(trim($a->data['search']));
else } else {
$search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); $search = ((x($_GET, 'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
}
$tpl = get_markup_template('directory_header.tpl'); $tpl = get_markup_template('directory_header.tpl');
@ -85,85 +89,91 @@ function forumdirectory_content(&$a) {
'$submit' => t('Find') '$submit' => t('Find')
]); ]);
if($search) $sql_extra = '';
$search = dbesc($search); if (strlen($search)) {
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); $sql_extra = " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,"
. "`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` )"
. " AGAINST ('" . dbesc($search) . "' IN BOOLEAN MODE) ";
}
$publish = ((Config::get('system','publish_all')) ? '' : " AND `publish` = 1 " ); $publish = Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ";
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`"
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra "); . " WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
if(count($r)) if (DBM::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
}
$order = " ORDER BY `name` ASC "; $order = " ORDER BY `name` ASC ";
$r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`"
$r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ", . " FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish"
. " AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ",
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
if(count($r)) { if (DBM::is_result($r)) {
if (in_array('small', $a->argv)) {
if(in_array('small', $a->argv))
$photo = 'thumb'; $photo = 'thumb';
else } else {
$photo = 'photo'; $photo = 'photo';
}
foreach ($r as $rr) { foreach ($r as $rr) {
$profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']); $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : ''); $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = ''; $details = '';
if(strlen($rr['locality'])) if (strlen($rr['locality'])) {
$details .= $rr['locality']; $details .= $rr['locality'];
}
if (strlen($rr['region'])) { if (strlen($rr['region'])) {
if(strlen($rr['locality'])) if (strlen($rr['locality'])) {
$details .= ', '; $details .= ', ';
}
$details .= $rr['region']; $details .= $rr['region'];
} }
if (strlen($rr['country-name'])) { if (strlen($rr['country-name'])) {
if(strlen($details)) if (strlen($details)) {
$details .= ', '; $details .= ', ';
}
$details .= $rr['country-name']; $details .= $rr['country-name'];
} }
if(strlen($rr['dob'])) {
if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) if (strlen($rr['dob']) && ($years = age($rr['dob'], $rr['timezone'], '')) != 0) {
$details .= '<br />' . t('Age: ') . $years; $details .= '<br />' . t('Age: ') . $years;
} }
if(strlen($rr['gender']))
$details .= '<br />' . t('Gender: ') . $rr['gender'];
if($rr['page-flags'] == PAGE_NORMAL) if (strlen($rr['gender'])) {
$page_type = "Personal Profile"; $details .= '<br />' . t('Gender: ') . $rr['gender'];
if($rr['page-flags'] == PAGE_SOAPBOX) }
$page_type = "Fan Page";
if($rr['page-flags'] == PAGE_COMMUNITY) switch ($rr['page-flags']) {
$page_type = "Community Forum"; case PAGE_NORMAL : $page_type = "Personal Profile"; break;
if($rr['page-flags'] == PAGE_FREELOVE) case PAGE_SOAPBOX : $page_type = "Fan Page" ; break;
$page_type = "Open Forum"; case PAGE_COMMUNITY: $page_type = "Community Forum" ; break;
if($rr['page-flags'] == PAGE_PRVGROUP) case PAGE_FREELOVE : $page_type = "Open Forum" ; break;
$page_type = "Private Group"; case PAGE_PRVGROUP : $page_type = "Private Group" ; break;
}
$profile = $rr; $profile = $rr;
if((x($profile,'address') == 1) $location = '';
|| (x($profile,'locality') == 1) if (x($profile, 'address') == 1
|| (x($profile,'region') == 1) || x($profile, 'locality') == 1
|| (x($profile,'postal-code') == 1) || x($profile, 'region') == 1
|| (x($profile,'country-name') == 1)) || x($profile, 'postal-code') == 1
|| x($profile, 'country-name') == 1
) {
$location = t('Location:'); $location = t('Location:');
}
$gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); $gender = x($profile, 'gender') == 1 ? t('Gender:') : false;
$marital = x($profile, 'marital') == 1 ? t('Status:') : false;
$marital = ((x($profile,'marital') == 1) ? t('Status:') : False); $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : false;
$about = x($profile, 'about') == 1 ? t('About:') : false;
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
$about = ((x($profile,'about') == 1) ? t('About:') : False);
# $tpl = file_get_contents( dirname(__file__).'/forumdirectory_item.tpl'); # $tpl = file_get_contents( dirname(__file__).'/forumdirectory_item.tpl');
$tpl = get_markup_template('forumdirectory_item.tpl', 'addon/forumdirectory/'); $tpl = get_markup_template('forumdirectory_item.tpl', 'addon/forumdirectory/');
@ -183,24 +193,16 @@ function forumdirectory_content(&$a) {
'$marital' => $marital, '$marital' => $marital,
'$homepage' => $homepage, '$homepage' => $homepage,
'$about' => $about, '$about' => $about,
]); ]);
$arr = ['contact' => $rr, 'entry' => $entry];
unset($profile);
unset($location);
$o .= $entry; $o .= $entry;
} }
$o .= "<div class=\"directory-end\" ></div>\r\n"; $o .= "<div class=\"directory-end\" ></div>\r\n";
$o .= paginate($a); $o .= paginate($a);
} else {
}
else
info(t("No entries \x28some entries may be hidden\x29.") . EOL); info(t("No entries \x28some entries may be hidden\x29.") . EOL);
}
return $o; return $o;
} }