mirror of
https://github.com/friendica/friendica
synced 2025-03-12 22:28:26 +00:00
Merge pull request #14720 from MrPetovan/bug/14099-create-new-group
Show Create new Group link in widget even if there's no group membership to display
This commit is contained in:
commit
4fa82f4c73
2 changed files with 91 additions and 88 deletions
|
@ -45,11 +45,11 @@ class GroupManager
|
||||||
|
|
||||||
$condition = [
|
$condition = [
|
||||||
'contact-type' => Contact::TYPE_COMMUNITY,
|
'contact-type' => Contact::TYPE_COMMUNITY,
|
||||||
'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB],
|
'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB],
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'blocked' => false,
|
'blocked' => false,
|
||||||
'pending' => false,
|
'pending' => false,
|
||||||
'archive' => false,
|
'archive' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$condition = DBA::mergeConditions($condition, ["`platform` NOT IN (?, ?)", 'peertube', 'wordpress']);
|
$condition = DBA::mergeConditions($condition, ["`platform` NOT IN (?, ?)", 'peertube', 'wordpress']);
|
||||||
|
@ -64,7 +64,7 @@ class GroupManager
|
||||||
|
|
||||||
$groupList = [];
|
$groupList = [];
|
||||||
|
|
||||||
$fields = ['id', 'url', 'alias', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
|
$fields = ['id', 'url', 'alias', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
|
||||||
$contacts = DBA::select('account-user-view', $fields, $condition, $params);
|
$contacts = DBA::select('account-user-view', $fields, $condition, $params);
|
||||||
if (!$contacts) {
|
if (!$contacts) {
|
||||||
return $groupList;
|
return $groupList;
|
||||||
|
@ -72,10 +72,10 @@ class GroupManager
|
||||||
|
|
||||||
while ($contact = DBA::fetch($contacts)) {
|
while ($contact = DBA::fetch($contacts)) {
|
||||||
$groupList[] = [
|
$groupList[] = [
|
||||||
'url' => $contact['url'],
|
'url' => $contact['url'],
|
||||||
'alias' => $contact['alias'],
|
'alias' => $contact['alias'],
|
||||||
'name' => $contact['name'],
|
'name' => $contact['name'],
|
||||||
'id' => $contact['id'],
|
'id' => $contact['id'],
|
||||||
'micro' => $contact['micro'],
|
'micro' => $contact['micro'],
|
||||||
'thumb' => $contact['thumb'],
|
'thumb' => $contact['thumb'],
|
||||||
];
|
];
|
||||||
|
@ -97,52 +97,47 @@ class GroupManager
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function widget(int $uid)
|
public static function widget(int $uid): string
|
||||||
{
|
{
|
||||||
$o = '';
|
|
||||||
|
|
||||||
//sort by last updated item
|
//sort by last updated item
|
||||||
$lastitem = true;
|
$contacts = self::getList($uid, true, true, true);
|
||||||
|
$total = count($contacts);
|
||||||
$contacts = self::getList($uid, $lastitem, true, true);
|
|
||||||
$total = count($contacts);
|
|
||||||
$visibleGroups = 10;
|
$visibleGroups = 10;
|
||||||
|
|
||||||
if (DBA::isResult($contacts)) {
|
$id = 0;
|
||||||
$id = 0;
|
|
||||||
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
foreach ($contacts as $contact) {
|
$contacts = [];
|
||||||
$entry = [
|
|
||||||
'url' => 'contact/' . $contact['id'] . '/conversations',
|
|
||||||
'external_url' => Contact::magicLinkByContact($contact),
|
|
||||||
'name' => $contact['name'],
|
|
||||||
'cid' => $contact['id'],
|
|
||||||
'micro' => DI::baseUrl()->remove(Contact::getMicro($contact)),
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('widget/group_list.tpl');
|
foreach ($contacts as $contact) {
|
||||||
|
$entry = [
|
||||||
$o .= Renderer::replaceMacros(
|
'url' => 'contact/' . $contact['id'] . '/conversations',
|
||||||
$tpl,
|
'external_url' => Contact::magicLinkByContact($contact),
|
||||||
[
|
'name' => $contact['name'],
|
||||||
'$title' => DI::l10n()->t('Groups'),
|
'cid' => $contact['id'],
|
||||||
'$groups' => $entries,
|
'micro' => DI::baseUrl()->remove(Contact::getMicro($contact)),
|
||||||
'$link_desc' => DI::l10n()->t('External link to group'),
|
'id' => ++$id,
|
||||||
'$new_group_page' => 'register/',
|
];
|
||||||
'$total' => $total,
|
$entries[] = $entry;
|
||||||
'$visible_groups' => $visibleGroups,
|
|
||||||
'$showless' => DI::l10n()->t('show less'),
|
|
||||||
'$showmore' => DI::l10n()->t('show more'),
|
|
||||||
'$create_new_group' => DI::l10n()->t('Create new group')]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
$tpl = Renderer::getMarkupTemplate('widget/group_list.tpl');
|
||||||
|
|
||||||
|
return Renderer::replaceMacros(
|
||||||
|
$tpl,
|
||||||
|
[
|
||||||
|
'$title' => DI::l10n()->t('Groups'),
|
||||||
|
'$groups' => $entries,
|
||||||
|
'$link_desc' => DI::l10n()->t('External link to group'),
|
||||||
|
'$new_group_page' => 'register/',
|
||||||
|
'$total' => $total,
|
||||||
|
'$visible_groups' => $visibleGroups,
|
||||||
|
'$showless' => DI::l10n()->t('show less'),
|
||||||
|
'$showmore' => DI::l10n()->t('show more'),
|
||||||
|
'$create_new_group' => DI::l10n()->t('Create new group')
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,7 +201,11 @@ class GroupManager
|
||||||
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
|
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
|
||||||
AND `contact`.`uid` = ?
|
AND `contact`.`uid` = ?
|
||||||
GROUP BY `contact`.`id`",
|
GROUP BY `contact`.`id`",
|
||||||
DI::userSession()->getLocalUserId(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, DI::userSession()->getLocalUserId()
|
DI::userSession()->getLocalUserId(),
|
||||||
|
Protocol::DFRN,
|
||||||
|
Protocol::ACTIVITYPUB,
|
||||||
|
Contact::TYPE_COMMUNITY,
|
||||||
|
DI::userSession()->getLocalUserId()
|
||||||
);
|
);
|
||||||
|
|
||||||
return DBA::toArray($stmtContacts);
|
return DBA::toArray($stmtContacts);
|
||||||
|
|
|
@ -18,49 +18,53 @@ function showHideGroupList() {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<span id="group-list-sidebar-frame">
|
<span id="group-list-sidebar-frame">
|
||||||
<span id="group-list-sidebar-inflated" class="widget inflated fakelink" onclick="openCloseWidget('group-list-sidebar', 'group-list-sidebar-inflated');">
|
<span id="group-list-sidebar-inflated" class="widget inflated fakelink" onclick="openCloseWidget('group-list-sidebar', 'group-list-sidebar-inflated');">
|
||||||
<h3>{{$title}}</h3>
|
|
||||||
</span>
|
|
||||||
<div id="group-list-sidebar" class="widget">
|
|
||||||
<div id="sidebar-group-header" class="sidebar-widget-header">
|
|
||||||
<span class="fakelink" onclick="openCloseWidget('group-list-sidebar', 'group-list-sidebar-inflated');">
|
|
||||||
<h3>{{$title}}</h3>
|
<h3>{{$title}}</h3>
|
||||||
</span>
|
</span>
|
||||||
<a class="group-new-tool pull-right widget-action faded-icon" id="sidebar-new-group" href="{{$new_group_page}}" data-toggle="tooltip" title="{{$create_new_group}}">
|
<div id="group-list-sidebar" class="widget">
|
||||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
<div id="sidebar-group-header" class="sidebar-widget-header">
|
||||||
</a>
|
<span class="fakelink" onclick="openCloseWidget('group-list-sidebar', 'group-list-sidebar-inflated');">
|
||||||
|
<h3>{{$title}}</h3>
|
||||||
|
</span>
|
||||||
|
{{if $groups}}
|
||||||
|
<a class="group-new-tool pull-right widget-action faded-icon" id="sidebar-new-group" href="{{$new_group_page}}" data-toggle="tooltip" title="{{$create_new_group}}">
|
||||||
|
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
<div id="sidebar-group-list" class="sidebar-widget-list">
|
||||||
|
{{* The list of available groups *}}
|
||||||
|
<ul id="group-list-sidebar-ul" role="menu">
|
||||||
|
{{foreach $groups as $group}}
|
||||||
|
{{if $group.id <= $visible_groups}}
|
||||||
|
<li class="group-widget-entry group-{{$group.cid}}" id="group-widget-entry-{{$group.id}}" role="menuitem">
|
||||||
|
<span class="notify badge pull-right"></span>
|
||||||
|
<a href="{{$group.external_url}}" title="{{$group.link_desc}}" class="label sparkle" target="_blank" rel="noopener noreferrer">
|
||||||
|
<img class="group-list-img" src="{{$group.micro}}" alt="{{$group.link_desc}}" />
|
||||||
|
</a>
|
||||||
|
<a class="group-widget-link" id="group-widget-link-{{$group.id}}" href="{{$group.url}}">{{$group.name}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $group.id > $visible_groups}}
|
||||||
|
<li class="group-widget-entry group-{{$group.cid}}" id="group-widget-entry-extended-{{$group.id}}" role="menuitem" style="display: none;">
|
||||||
|
<span class="notify badge pull-right"></span>
|
||||||
|
<a href="{{$group.external_url}}" title="{{$group.link_desc}}" class="label sparkle" target="_blank" rel="noopener noreferrer">
|
||||||
|
<img class="group-list-img" src="{{$group.micro}}" alt="{{$group.link_desc}}" />
|
||||||
|
</a>
|
||||||
|
<a class="group-widget-link" id="group-widget-link-{{$group.id}}" href="{{$group.url}}">{{$group.name}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{foreachelse}}
|
||||||
|
<li><a href="{{$new_group_page}}"><i class="fa fa-plus" aria-hidden="true"></i> {{$create_new_group}}</a></li>
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
|
{{if $total > $visible_groups }}
|
||||||
|
<li onclick="showHideGroupList(); return false;" id="group-widget-collapse" class="group-widget-link fakelink tool">{{$showmore}}</li>
|
||||||
|
{{/if}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="sidebar-group-list" class="sidebar-widget-list">
|
|
||||||
{{* The list of available groups *}}
|
|
||||||
<ul id="group-list-sidebar-ul" role="menu">
|
|
||||||
{{foreach $groups as $group}}
|
|
||||||
{{if $group.id <= $visible_groups}}
|
|
||||||
<li class="group-widget-entry group-{{$group.cid}}" id="group-widget-entry-{{$group.id}}" role="menuitem">
|
|
||||||
<span class="notify badge pull-right"></span>
|
|
||||||
<a href="{{$group.external_url}}" title="{{$group.link_desc}}" class="label sparkle" target="_blank" rel="noopener noreferrer">
|
|
||||||
<img class="group-list-img" src="{{$group.micro}}" alt="{{$group.link_desc}}" />
|
|
||||||
</a>
|
|
||||||
<a class="group-widget-link" id="group-widget-link-{{$group.id}}" href="{{$group.url}}">{{$group.name}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $group.id > $visible_groups}}
|
|
||||||
<li class="group-widget-entry group-{{$group.cid}}" id="group-widget-entry-extended-{{$group.id}}" role="menuitem" style="display: none;">
|
|
||||||
<span class="notify badge pull-right"></span>
|
|
||||||
<a href="{{$group.external_url}}" title="{{$group.link_desc}}" class="label sparkle" target="_blank" rel="noopener noreferrer">
|
|
||||||
<img class="group-list-img" src="{{$group.micro}}" alt="{{$group.link_desc}}" />
|
|
||||||
</a>
|
|
||||||
<a class="group-widget-link" id="group-widget-link-{{$group.id}}" href="{{$group.url}}">{{$group.name}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{if $total > $visible_groups }}
|
|
||||||
<li onclick="showHideGroupList(); return false;" id="group-widget-collapse" class="group-widget-link fakelink tool">{{$showmore}}</li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</span>
|
</span>
|
||||||
<script>
|
<script>
|
||||||
initWidget('group-list-sidebar', 'group-list-sidebar-inflated');
|
initWidget('group-list-sidebar', 'group-list-sidebar-inflated');
|
||||||
|
|
Loading…
Add table
Reference in a new issue