aboutsummaryrefslogtreecommitdiffstats
path: root/include/channel.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-03 13:09:17 +0000
committerMario <mario@mariovavti.com>2021-03-03 14:12:42 +0100
commitc2dc3e8dec7acf1f1750f7379e641ae8c7a2ed81 (patch)
tree492b03da20305c46e5754ca8197a284999a210e8 /include/channel.php
parent7d1599f9b0bd8ead7a0652ceca494fc38a28fd82 (diff)
downloadvolse-hubzilla-c2dc3e8dec7acf1f1750f7379e641ae8c7a2ed81.tar.gz
volse-hubzilla-c2dc3e8dec7acf1f1750f7379e641ae8c7a2ed81.tar.bz2
volse-hubzilla-c2dc3e8dec7acf1f1750f7379e641ae8c7a2ed81.zip
set the default collection acl if indicated so by the role permissions but always set the created friends group as channel_default_group when creating a new channel
(cherry picked from commit 9389abdb757d5cb5b4b4322260e86c47d11ff043)
Diffstat (limited to 'include/channel.php')
-rw-r--r--include/channel.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/include/channel.php b/include/channel.php
index d1095115d..4f48402d2 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -503,23 +503,22 @@ function create_identity($arr) {
// right away as a default group for new contacts.
require_once('include/group.php');
- group_add($newuid, t('Friends'));
- group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']);
+ $group_hash = group_add($newuid, t('Friends'));
- // if our role_permissions indicate that we're using a default collection ACL, add it.
+ if($group_hash) {
+ group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']);
- if(is_array($role_permissions) && $role_permissions['default_collection']) {
- $r = q("select hash from pgrp where uid = %d and gname = '%s' limit 1",
- intval($newuid),
- dbesc( t('Friends') )
- );
- if($r) {
- q("update channel set channel_default_group = '%s', channel_allow_gid = '%s' where channel_id = %d",
- dbesc($r[0]['hash']),
- dbesc('<' . $r[0]['hash'] . '>'),
- intval($newuid)
- );
+ $default_collection = '';
+ // if our role_permissions indicate that we're using a default collection ACL, add it.
+ if(is_array($role_permissions) && $role_permissions['default_collection']) {
+ $default_collection_str = '<' . $group_hash . '>';
}
+
+ q("update channel set channel_default_group = '%s', channel_allow_gid = '%s' where channel_id = %d",
+ dbesc($group_hash),
+ dbesc($default_collection_str),
+ intval($newuid)
+ );
}
if(! $system) {