diff --git a/Code/Lib/AccessList.php b/Code/Lib/AccessList.php
index d56c449d0..88d34d5e8 100644
--- a/Code/Lib/AccessList.php
+++ b/Code/Lib/AccessList.php
@@ -139,6 +139,24 @@ class AccessList
return false;
}
+ public static function hashbyname($uid, $name): mixed
+ {
+ if (!($uid && $name)) {
+ return false;
+ }
+ $r = q(
+ "SELECT hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($name)
+ );
+ if ($r) {
+ return $r[0]['hash'];
+ }
+ return false;
+ }
+
+
+
public static function by_id($uid, $id): mixed
{
if (!($uid && $id)) {
diff --git a/Code/Lib/Libacl.php b/Code/Lib/Libacl.php
index 9b7a90062..a28dc6158 100644
--- a/Code/Lib/Libacl.php
+++ b/Code/Lib/Libacl.php
@@ -82,6 +82,10 @@ class Libacl
$groups = EMPTY_STR;
+ $selection = (($single_group && !$selected && 'connections:' . $channel['channel_hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
+ $selected = $selection ?: $selected;
+ $groups .= '' . "\r\n";
+
$r = q(
"SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel())
@@ -89,25 +93,24 @@ class Libacl
if ($r) {
foreach ($r as $rr) {
- $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
- $groups .= '' . "\r\n";
+ $selection = (($single_group && !$selected && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
+ $selected = $selection ?: $selected;
+ $groups .= '' . "\r\n";
}
}
- $selected = (($single_group && 'connections:' . $channel['channel_hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
- $groups .= '' . "\r\n";
$forums = get_forum_channels(local_channel(), 1);
- $selected = false;
if ($forums) {
foreach ($forums as $f) {
- $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : '');
- $groups .= '' . "\r\n";
+ $selection = (($single_group && !$selected && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : '');
+ $selected = $selection ?: $selected;
+ $groups .= '' . "\r\n";
}
}
// preset acl with DM to a single xchan (not a group)
- if ($selected === false && count($allow_cid) === 1 && $channel && $allow_cid[0] !== $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
+ if (!$selected && count($allow_cid) === 1 && $channel && $allow_cid[0] !== $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
$f = q(
"select * from xchan where xchan_hash = '%s'",
dbesc($allow_cid[0])
diff --git a/Code/Module/Settings/Channel.php b/Code/Module/Settings/Channel.php
index 88b5a02ab..bd969a2a9 100644
--- a/Code/Module/Settings/Channel.php
+++ b/Code/Module/Settings/Channel.php
@@ -83,7 +83,6 @@ class Channel
$preview_outbox = ((x($_POST, 'preview_outbox')) ? intval($_POST['preview_outbox']) : 0);
$allow_location = (((x($_POST, 'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1 : 0);
$blocktags = (((x($_POST, 'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0 : 1); // this setting is inverted!
- $suggestme = ((x($_POST, 'suggestme')) ? intval($_POST['suggestme']) : 0);
$hyperdrive = ((x($_POST, 'hyperdrive')) ? intval($_POST['hyperdrive']) : 0);
$activitypub = ((x($_POST, 'activitypub')) ? intval($_POST['activitypub']) : 0);
$tag_username = ((x($_POST, 'tag_username')) ? intval($_POST['tag_username']) : 0);
@@ -160,7 +159,6 @@ class Channel
set_pconfig(local_channel(), 'system', 'followed_tags', ($ntags) ?: EMPTY_STR);
set_pconfig(local_channel(), 'system', 'use_browser_location', $allow_location);
- set_pconfig(local_channel(), 'system', 'suggestme', $suggestme);
set_pconfig(local_channel(), 'system', 'post_newfriend', $post_newfriend);
set_pconfig(local_channel(), 'system', 'post_joingroup', $post_joingroup);
set_pconfig(local_channel(), 'system', 'post_profilechange', $post_profilechange);
@@ -308,9 +306,6 @@ class Channel
$hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status'));
- $suggestme = get_pconfig(local_channel(), 'system', 'suggestme');
- $suggestme = (($suggestme === false) ? '0' : $suggestme); // default if not set: 0
-
$post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend');
$post_newfriend = (($post_newfriend === false) ? '0' : $post_newfriend); // default if not set: 0
@@ -332,11 +327,6 @@ class Channel
]);
}
- $suggestme = replace_macros($opt_tpl, [
- '$field' => ['suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no],
-
- ]);
-
$subdir = ((strlen(App::get_path())) ? '
' . t('or') . ' ' . z_root() . '/channel/' . $nickname : '');
$webbie = $nickname . '@' . App::get_hostname();
@@ -372,9 +362,6 @@ class Channel
$acl = new AccessControl($channel);
$perm_defaults = $acl->get();
- $group_select = AccessList::select(local_channel(), $channel['channel_default_group']);
-
-
$m1 = Menu::list(local_channel());
$menu = false;
if ($m1) {
@@ -484,8 +471,6 @@ class Channel
'$allow_gid' => acl2json($perm_defaults['allow_gid']),
'$deny_cid' => acl2json($perm_defaults['deny_cid']),
'$deny_gid' => acl2json($perm_defaults['deny_gid']),
- '$suggestme' => $suggestme,
- '$group_select' => $group_select,
'$can_change_role' => !in_array($permissions_role, ['collection', 'collection_restricted']),
'$permissions_role' => $permissions_role,
'$role' => ['permissions_role', t('Channel type and privacy'), $permissions_role, '', $perm_roles, ' onchange="update_role_text(); return false;"'],
@@ -599,13 +584,6 @@ class Channel
protected function set_custom_role($channel)
{
$hide_presence = (((x($_POST, 'hide_presence')) && (intval($_POST['hide_presence']) == 1)) ? 1 : 0);
- $def_group = ((x($_POST, 'group-selection')) ? notags(trim($_POST['group-selection'])) : '');
- q(
- "update channel set channel_default_group = '%s' where channel_id = %d",
- dbesc($def_group),
- intval(local_channel())
- );
-
$global_perms = Permissions::Perms();
foreach ($global_perms as $k => $v) {
@@ -634,49 +612,29 @@ class Channel
return;
}
$hide_presence = 1 - (intval($role_permissions['online']));
- if ($role_permissions['default_collection']) {
- $default_list = q("select channel_default_group from channel where channel_id = %d",
- (int)local_channel(),
- );
- if (!empty($default_list[0]['channel_default_group'])) {
- $r = q("select hash from pgrp where uid = %d and hash = '%s' limit 1",
- (int)local_channel(),
- dbesc($default_list[0]['channel_default_group'])
- );
- }
- else {
- $r = q(
- "select hash from pgrp where uid = %d and gname = '%s' limit 1",
- intval(local_channel()),
- dbesc(t('Friends'))
- );
- }
- if (!$r) {
- AccessList::add(local_channel(), t('Friends'));
- AccessList::member_add(local_channel(), t('Friends'), $channel['channel_hash']);
- $r = q(
- "select hash from pgrp where uid = %d and gname = '%s' limit 1",
- intval(local_channel()),
- dbesc(t('Friends'))
- );
- }
- if ($r) {
- q(
- "update channel set channel_default_group = '%s', channel_allow_gid = '%s', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d",
- dbesc($r[0]['hash']),
- dbesc('<' . $r[0]['hash'] . '>'),
- intval(local_channel())
- );
- } else {
- notice(sprintf('Default access list \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
- return;
- }
- } // no default permissions
- else {
- q("update channel set channel_allow_gid = '', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d",
- intval(local_channel())
- );
+
+ $defquery = q("select channel_default_group from channel where channel_id = %d",
+ (int)local_channel(),
+ );
+ $default_list = $defquery ? $defquery[0]['channel_default_group'] : null;
+ if (!$default_list) {
+ $default_list = AccessList::hashbyname(local_channel(), t('Friends'));
}
+ if (!$default_list) {
+ $default_list = AccessList::add(local_channel(), t('Friends'));
+ AccessList::member_add(local_channel(), t('Friends'), $channel['channel_hash']);
+ }
+
+ q("update channel set channel_default_group = '%s', channel_allow_gid = '%s',
+ channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = ''
+ where channel_id = %d",
+ dbesc((string)$default_list),
+ dbesc(($role_permissions['default_collection'])
+ ? ('<' . 'connections:' . $channel['channel_hash'] . '>')
+ :
+ ''),
+ intval(local_channel())
+ );
if ($role_permissions['perms_connect']) {
$x = Permissions::FilledPerms($role_permissions['perms_connect']);
diff --git a/include/security.php b/include/security.php
index 92367c32c..a1292c97d 100644
--- a/include/security.php
+++ b/include/security.php
@@ -731,13 +731,16 @@ function get_security_ids($channel_id, $ob_hash)
}
}
- // virtual groups this identity is a member of
+ // virtual groups this identity is a member of
$r = q("select channel_hash from channel left join abook on channel_id = abook_channel where abook_xchan in ( " . protect_sprintf($hashes) . " ) and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ");
if ($r) {
foreach ($r as $rv) {
$groups[] = 'connections:' . $rv['channel_hash'];
- if (in_array($xchans[0]['xchan_network'],['nomad','zot6'])) {
+ if ($xchans[0]['xchan_network'] === 'nomad') {
+ $groups[] = 'nomad:' . $rv['channel_hash'];
+ }
+ if ($xchans[0]['xchan_network'] === 'zot6') {
$groups[] = 'zot:' . $rv['channel_hash'];
}
if ($xchans[0]['xchan_network'] === 'activitypub') {
diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl
index 3d68c317a..05293f390 100755
--- a/view/tpl/settings.tpl
+++ b/view/tpl/settings.tpl
@@ -65,7 +65,6 @@
{{include file="field_input.tpl" field=$unless_tag_count}}
{{include file="field_checkbox.tpl" field=$preview_outbox}}
{{include file="field_checkbox.tpl" field=$nomadic_ids_in_profile}}
- {{$group_select}}