X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FGroup.php;h=889f8269d1a2646820c2d5c32d03f2ce904a2330;hb=87673fd0c52b40d1100fd46c648c786bab3750cf;hp=3d075f12e92a59d4e8669500bd0186a3c2e428af;hpb=af88c2daa34e39cb6430abf64d0648665bfeb9cd;p=friendica.git diff --git a/src/Model/Group.php b/src/Model/Group.php index 3d075f12e9..889f8269d1 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -1,16 +1,32 @@ . + * */ namespace Friendica\Model; use Friendica\BaseModule; -use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; /** * functions for interacting with the group database table @@ -73,7 +89,7 @@ class Group $group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]); if (DBA::isResult($group) && $group['deleted']) { DBA::update('group', ['deleted' => 0], ['id' => $gid]); - notice(L10n::t('A deleted group with this name was revived. Existing item permissions may apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL); + notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions may apply to this group and any future members. If this is not what you intended, please create another group with a different name.')); } return true; } @@ -117,6 +133,16 @@ class Group } DBA::close($stmt); + // Meta-groups + $contact = Contact::getById($cid, ['rel']); + if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) { + $return[] = self::FOLLOWERS; + } + + if ($contact['rel'] == Contact::FRIEND) { + $return[] = self::MUTUALS; + } + return $return; } @@ -134,7 +160,7 @@ class Group public static function countUnseen() { $stmt = DBA::p("SELECT `group`.`id`, `group`.`name`, - (SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`) + (SELECT COUNT(*) FROM `post-user` WHERE `uid` = ? AND `unseen` AND `contact-id` IN @@ -422,7 +448,7 @@ class Group Logger::info('Got groups', $display_groups); if ($label == '') { - $label = L10n::t('Default privacy group for new contacts'); + $label = DI::l10n()->t('Default privacy group for new contacts'); } $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('group_selection.tpl'), [ @@ -454,7 +480,7 @@ class Group $display_groups = [ [ - 'text' => L10n::t('Everybody'), + 'text' => DI::l10n()->t('Everybody'), 'id' => 0, 'selected' => (($group_id === 'everyone') ? 'group-selected' : ''), 'href' => $every, @@ -473,16 +499,23 @@ class Group if ($editmode == 'full') { $groupedit = [ 'href' => 'group/' . $group['id'], - 'title' => L10n::t('edit'), + 'title' => DI::l10n()->t('edit'), ]; } else { $groupedit = null; } + if ($each == 'group') { + $count = DBA::count('group_member', ['gid' => $group['id']]); + $group_name = sprintf('%s (%d)', $group['name'], $count); + } else { + $group_name = $group['name']; + } + $display_groups[] = [ 'id' => $group['id'], 'cid' => $cid, - 'text' => $group['name'], + 'text' => $group_name, 'href' => $each . '/' . $group['id'], 'edit' => $groupedit, 'selected' => $selected, @@ -498,17 +531,17 @@ class Group $tpl = Renderer::getMarkupTemplate('group_side.tpl'); $o = Renderer::replaceMacros($tpl, [ - '$add' => L10n::t('add'), - '$title' => L10n::t('Groups'), + '$add' => DI::l10n()->t('add'), + '$title' => DI::l10n()->t('Groups'), '$groups' => $display_groups, 'newgroup' => $editmode == 'extended' || $editmode == 'full' ? 1 : '', 'grouppage' => 'group/', - '$edittext' => L10n::t('Edit group'), - '$ungrouped' => $every === 'contact' ? L10n::t('Contacts not in any group') : '', + '$edittext' => DI::l10n()->t('Edit group'), + '$ungrouped' => $every === 'contact' ? DI::l10n()->t('Contacts not in any group') : '', '$ungrouped_selected' => (($group_id === 'none') ? 'group-selected' : ''), - '$createtext' => L10n::t('Create a new group'), - '$creategroup' => L10n::t('Group Name: '), - '$editgroupstext' => L10n::t('Edit groups'), + '$createtext' => DI::l10n()->t('Create a new group'), + '$creategroup' => DI::l10n()->t('Group Name: '), + '$editgroupstext' => DI::l10n()->t('Edit groups'), '$form_security_token' => BaseModule::getFormSecurityToken('group_edit'), ]);