mirror of
https://github.com/friendica/friendica
synced 2025-01-03 20:42:19 +00:00
Merge pull request #14016 from annando/issue-13787
Issue 13787: Filter in circles editor by contact relation
This commit is contained in:
commit
987e6c5ea6
1 changed files with 24 additions and 1 deletions
|
@ -142,12 +142,14 @@ class Circle extends BaseModule
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
$change = false;
|
$change = false;
|
||||||
|
$relation = $request['rel'] ?? '';
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::page()['aside'] = Model\Circle::sidebarWidget('contact', 'circle', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
|
DI::page()['aside'] = Model\Circle::sidebarWidget('contact', 'circle', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
|
||||||
|
DI::page()['aside'] .= Widget::contactRels($this->server['REQUEST_URI'], $relation);
|
||||||
|
|
||||||
// With no circle number provided we jump to the unassigned contacts as a starting point
|
// With no circle number provided we jump to the unassigned contacts as a starting point
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
|
@ -298,6 +300,9 @@ class Circle extends BaseModule
|
||||||
|
|
||||||
// Format the data of the circle members
|
// Format the data of the circle members
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
|
if (!self::matchRelation($relation, $member['rel'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($member['url']) {
|
if ($member['url']) {
|
||||||
$entry = Contact::getContactTemplateVars($member);
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
$entry['label'] = 'members';
|
$entry['label'] = 'members';
|
||||||
|
@ -332,6 +337,9 @@ class Circle extends BaseModule
|
||||||
if (DBA::isResult($contacts)) {
|
if (DBA::isResult($contacts)) {
|
||||||
// Format the data of the contacts who aren't in the contact circle
|
// Format the data of the contacts who aren't in the contact circle
|
||||||
foreach ($contacts as $member) {
|
foreach ($contacts as $member) {
|
||||||
|
if (!self::matchRelation($relation, $member['rel'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!in_array($member['id'], $preselected)) {
|
if (!in_array($member['id'], $preselected)) {
|
||||||
$entry = Contact::getContactTemplateVars($member);
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
$entry['label'] = 'contacts';
|
$entry['label'] = 'contacts';
|
||||||
|
@ -366,4 +374,19 @@ class Circle extends BaseModule
|
||||||
|
|
||||||
return Renderer::replaceMacros($tpl, $context);
|
return Renderer::replaceMacros($tpl, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function matchRelation(string $relation, int $rel)
|
||||||
|
{
|
||||||
|
switch ($relation) {
|
||||||
|
case 'followers':
|
||||||
|
return($rel == Model\Contact::FOLLOWER);
|
||||||
|
case 'following':
|
||||||
|
return($rel == Model\Contact::SHARING);
|
||||||
|
case 'mutuals':
|
||||||
|
return($rel == Model\Contact::FRIEND);
|
||||||
|
case 'nothing':
|
||||||
|
return($rel == Model\Contact::NOTHING);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue