Merge pull request #490 from MrPetovan/bug/fix-forumdirectory

Fix forumdirectory reference to deleted files/functions
This commit is contained in:
Michael Vogel 2018-01-19 06:13:49 +01:00 committed by GitHub
commit ba5eeed5df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 123 additions and 121 deletions

View File

@ -1,206 +1,208 @@
<?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.
* Version: 1.0 * Version: 1.0
* 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())) {
notice(t('Public access denied.') . EOL);
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
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');
$globaldir = ''; $globaldir = '';
$gdirpath = Config::get('system','directory'); $gdirpath = Config::get('system', 'directory');
if(strlen($gdirpath)) { if (strlen($gdirpath)) {
$globaldir = '<ul><li><div id="global-directory-link"><a href="' $globaldir = '<ul><li><div id="global-directory-link"><a href="'
. zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>'; . zrl($gdirpath, true) . '">' . t('Global Directory') . '</a></div></li></ul>';
} }
$admin = ''; $admin = '';
$o .= replace_macros($tpl, [ $o .= replace_macros($tpl, [
'$search' => $search, '$search' => $search,
'$globaldir' => $globaldir, '$globaldir' => $globaldir,
'$desc' => t('Find on this site'), '$desc' => t('Find on this site'),
'$admin' => $admin, '$admin' => $admin,
'$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""), '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
'$sitedir' => t('Site Directory'), '$sitedir' => t('Site Directory'),
'$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['locality']))
if (strlen($rr['region'])) {
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)
$details .= '<br />' . t('Age: ') . $years ;
}
if(strlen($rr['gender']))
$details .= '<br />' . t('Gender: ') . $rr['gender'];
if($rr['page-flags'] == PAGE_NORMAL) if (strlen($rr['dob']) && ($years = age($rr['dob'], $rr['timezone'], '')) != 0) {
$page_type = "Personal Profile"; $details .= '<br />' . t('Age: ') . $years;
if($rr['page-flags'] == PAGE_SOAPBOX) }
$page_type = "Fan Page";
if($rr['page-flags'] == PAGE_COMMUNITY) if (strlen($rr['gender'])) {
$page_type = "Community Forum"; $details .= '<br />' . t('Gender: ') . $rr['gender'];
if($rr['page-flags'] == PAGE_FREELOVE) }
$page_type = "Open Forum";
if($rr['page-flags'] == PAGE_PRVGROUP) switch ($rr['page-flags']) {
$page_type = "Private Group"; case PAGE_NORMAL : $page_type = "Personal Profile"; break;
case PAGE_SOAPBOX : $page_type = "Fan Page" ; break;
case PAGE_COMMUNITY: $page_type = "Community Forum" ; break;
case PAGE_FREELOVE : $page_type = "Open Forum" ; break;
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
$location = t('Location:'); || x($profile, 'country-name') == 1
) {
$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/');
$entry = replace_macros($tpl,[ $entry = replace_macros($tpl, [
'$id' => $rr['id'], '$id' => $rr['id'],
'$profile_link' => $profile_link, '$profile_link' => $profile_link,
'$photo' => $rr[$photo], '$photo' => $rr[$photo],
'$alt_text' => $rr['name'], '$alt_text' => $rr['name'],
'$name' => $rr['name'], '$name' => $rr['name'],
'$details' => $pdesc . $details, '$details' => $pdesc . $details,
'$page_type' => $page_type, '$page_type' => $page_type,
'$profile' => $profile, '$profile' => $profile,
'$location' => $location, '$location' => $location,
'$gender' => $gender, '$gender' => $gender,
'$pdesc' => $pdesc, '$pdesc' => $pdesc,
'$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 {
info(t("No entries \x28some entries may be hidden\x29.") . EOL);
} }
else
info( t("No entries \x28some entries may be hidden\x29.") . EOL);
return $o; return $o;
} }