mirror of
https://github.com/friendica/friendica
synced 2025-04-23 20:30:10 +00:00
Filter for account type for contacts
This commit is contained in:
parent
ae6b380362
commit
4b9cbac23e
7 changed files with 78 additions and 53 deletions
|
@ -37,6 +37,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
@ -260,6 +261,9 @@ class Contact extends BaseModule
|
|||
$rel = Strings::escapeTags(trim($_GET['rel'] ?? ''));
|
||||
$group = Strings::escapeTags(trim($_GET['group'] ?? ''));
|
||||
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttypeid = User::getAccountTypeByString($accounttype);
|
||||
|
||||
$page = DI::page();
|
||||
|
||||
$page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
|
||||
|
@ -339,6 +343,7 @@ class Contact extends BaseModule
|
|||
|
||||
$findpeople_widget = '';
|
||||
$follow_widget = '';
|
||||
$account_widget = '';
|
||||
$networks_widget = '';
|
||||
$rel_widget = '';
|
||||
|
||||
|
@ -356,12 +361,13 @@ class Contact extends BaseModule
|
|||
$follow_widget = Widget::follow();
|
||||
}
|
||||
|
||||
$account_widget = Widget::accounttypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
$networks_widget = Widget::networks($_SERVER['REQUEST_URI'], $nets);
|
||||
$rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
|
||||
$groups_widget = Widget::groups($_SERVER['REQUEST_URI'], $group);
|
||||
}
|
||||
|
||||
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget;
|
||||
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $account_widget . $groups_widget . $networks_widget . $rel_widget;
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
|
@ -664,6 +670,11 @@ class Contact extends BaseModule
|
|||
break;
|
||||
}
|
||||
|
||||
if (isset($accounttypeid)) {
|
||||
$sql_extra .= " AND `contact-type` = ?";
|
||||
$sql_values[] = $accounttypeid;
|
||||
}
|
||||
|
||||
$searching = false;
|
||||
$search_hdr = null;
|
||||
if ($search) {
|
||||
|
|
|
@ -4,10 +4,11 @@ namespace Friendica\Module\Contact;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
|
@ -23,6 +24,8 @@ class Contacts extends BaseModule
|
|||
|
||||
$cid = $parameters['id'];
|
||||
$type = $parameters['type'] ?? 'all';
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttypeid = User::getAccountTypeByString($accounttype);
|
||||
|
||||
if (!$cid) {
|
||||
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
|
||||
|
@ -44,6 +47,10 @@ class Contacts extends BaseModule
|
|||
'failed' => false,
|
||||
];
|
||||
|
||||
if (isset($accounttypeid)) {
|
||||
$condition['contact-type'] = $accounttypeid;
|
||||
}
|
||||
|
||||
$noresult_label = DI::l10n()->t('No known contacts.');
|
||||
|
||||
switch ($type) {
|
||||
|
@ -57,10 +64,6 @@ class Contacts extends BaseModule
|
|||
$total = Model\Contact\Relation::countMutuals($cid, $condition);
|
||||
break;
|
||||
case 'common':
|
||||
$condition = [
|
||||
'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
|
||||
$localContactId,
|
||||
];
|
||||
$total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
|
||||
$noresult_label = DI::l10n()->t('No common contacts.');
|
||||
break;
|
||||
|
@ -119,6 +122,8 @@ class Contacts extends BaseModule
|
|||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
DI::page()['aside'] .= Widget::accounttypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,23 +192,7 @@ class Community extends BaseModule
|
|||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
|
||||
}
|
||||
|
||||
switch ($parameters['accounttype'] ?? '') {
|
||||
case 'person':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_PERSON;
|
||||
break;
|
||||
case 'organisation':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_ORGANISATION;
|
||||
break;
|
||||
case 'news':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_NEWS;
|
||||
break;
|
||||
case 'community':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_COMMUNITY;
|
||||
break;
|
||||
default:
|
||||
self::$accounttype = null;
|
||||
break;
|
||||
}
|
||||
self::$accounttype = User::getAccountTypeByString($parameters['accounttype'] ?? '');
|
||||
|
||||
self::$content = $parameters['content'] ?? '';
|
||||
if (!self::$content) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue