aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Access
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-12-15 12:17:19 +0000
committerMario <mario@mariovavti.com>2021-12-15 12:17:19 +0000
commit2968bf8241d2969c4d51f1651fc3f8c7688b2fca (patch)
treedb015d27098c546c32f41682e3b7dac2480b890e /Zotlabs/Access
parentb37165c62b1037e504d4b68a507241acf97ede5e (diff)
downloadvolse-hubzilla-2968bf8241d2969c4d51f1651fc3f8c7688b2fca.tar.gz
volse-hubzilla-2968bf8241d2969c4d51f1651fc3f8c7688b2fca.tar.bz2
volse-hubzilla-2968bf8241d2969c4d51f1651fc3f8c7688b2fca.zip
merge branch perms_ng into dev
Diffstat (limited to 'Zotlabs/Access')
-rw-r--r--Zotlabs/Access/PermissionLimits.php2
-rw-r--r--Zotlabs/Access/PermissionRoles.php79
-rw-r--r--Zotlabs/Access/Permissions.php37
3 files changed, 97 insertions, 21 deletions
diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php
index fb5fe6133..7a574ba6a 100644
--- a/Zotlabs/Access/PermissionLimits.php
+++ b/Zotlabs/Access/PermissionLimits.php
@@ -89,4 +89,4 @@ class PermissionLimits {
return false;
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php
index 998b6d8d2..2078b52a8 100644
--- a/Zotlabs/Access/PermissionRoles.php
+++ b/Zotlabs/Access/PermissionRoles.php
@@ -17,7 +17,7 @@ class PermissionRoles {
* @return number
*/
static public function version() {
- return 2;
+ return 3;
}
static function role_perms($role) {
@@ -27,6 +27,54 @@ class PermissionRoles {
$ret['role'] = $role;
switch($role) {
+
+ case 'public':
+ $ret['default_collection'] = false;
+ $ret['perms_connect'] = [
+ 'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'view_pages', 'view_wiki',
+ 'send_stream', 'post_comments', 'post_mail', 'post_wall', 'chat', 'post_like', 'republish'
+ ];
+ $ret['limits'] = PermissionLimits::Std_Limits();
+ $ret['limits']['post_comments'] = PERMS_AUTHED;
+ $ret['limits']['post_mail'] = PERMS_AUTHED;
+ $ret['limits']['post_like'] = PERMS_AUTHED;
+ $ret['limits']['chat'] = PERMS_AUTHED;
+ break;
+
+ // Hubzilla default role
+ case 'personal':
+ $ret['default_collection'] = true;
+ $ret['perms_connect'] = [
+ 'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'view_pages', 'view_wiki',
+ 'send_stream', 'post_comments', 'post_mail', 'chat', 'post_like'
+ ];
+ $ret['limits'] = PermissionLimits::Std_Limits();
+ $ret['limits']['view_contacts'] = PERMS_SPECIFIC;
+ break;
+
+ case 'group':
+ $ret['default_collection'] = false;
+ $ret['perms_connect'] = [
+ 'view_stream', 'view_profile', 'view_contacts', 'view_storage',
+ 'view_pages', 'view_wiki', 'post_wall', 'post_comments',
+ 'post_mail', 'post_like', 'chat'
+ ];
+ $ret['limits'] = PermissionLimits::Std_Limits();
+ $ret['channel_type'] = 'group';
+ break;
+
+ // Provide some defaults for the custom role so that we do not start
+ // with no permissions at all if we create a new channel with this role
+ case 'custom':
+ $ret['default_collection'] = true;
+ $ret['perms_connect'] = [
+ 'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'view_pages', 'view_wiki',
+ 'send_stream', 'post_comments', 'post_mail', 'chat', 'post_like'
+ ];
+ $ret['limits'] = PermissionLimits::Std_Limits();
+ break;
+
+/*
case 'social':
$ret['perms_auto'] = false;
$ret['default_collection'] = false;
@@ -193,13 +241,14 @@ class PermissionRoles {
$ret['channel_type'] = 'group';
break;
+*/
- case 'custom':
default:
break;
}
$x = get_config('system','role_perms');
+
// let system settings over-ride any or all
if($x && is_array($x) && array_key_exists($role,$x))
$ret = array_merge($ret,$x[$role]);
@@ -284,6 +333,7 @@ class PermissionRoles {
*/
static public function roles() {
$roles = [
+
t('Social Networking') => [
'social_federation' => t('Social - Federation'),
'social' => t('Social - Mostly Public'),
@@ -317,4 +367,29 @@ class PermissionRoles {
return $roles;
}
+ /**
+ * @brief Array with translated role names and grouping.
+ *
+ * Return an associative array with role names that can be used
+ * to create select groups like in \e field_select_grouped.tpl.
+ *
+ * @return array
+ */
+ static public function channel_roles() {
+ $channel_roles = [
+ //'public' => [t('Public'), t('A very permissive role suited for participation in the fediverse')],
+ //'personal' => [t('Personal'), t('The $Projectname default role suited for a personal channel')],
+ //'forum' => [t('Community forum'), t('This role configures your channel to act as an community forum')],
+ //'custom' => [t('Custom'), t('This role comes with the presets of the personal role but allows you to configure it to your needs')]
+ 'public' => t('Public'),
+ 'personal' => t('Personal'),
+ 'group' => t('Community forum'),
+ 'custom' => t('Custom')
+ ];
+
+ call_hooks('list_channel_roles', $channel_roles);
+
+ return $channel_roles;
+ }
+
}
diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php
index 45dd30d69..09f4c9678 100644
--- a/Zotlabs/Access/Permissions.php
+++ b/Zotlabs/Access/Permissions.php
@@ -41,7 +41,7 @@ class Permissions {
* @return number
*/
static public function version() {
- return 2;
+ return 3;
}
/**
@@ -67,9 +67,9 @@ class Permissions {
'post_comments' => t('Can comment on or like my posts'),
'post_mail' => t('Can send me direct messages'),
'post_like' => t('Can like/dislike profiles and profile things'),
- 'tag_deliver' => t('Can forward direct messages to all my channel connections (forum)'),
'chat' => t('Can chat with me'),
- 'republish' => t('Can source my public posts in derived channels'),
+ 'republish' => t('Can source/mirror my public posts in derived channels'),
+ //'tag_deliver' => t('Can forward to my contacts via direct messages (forum)'),
'delegate' => t('Can administer my channel')
];
@@ -217,25 +217,23 @@ class Permissions {
$my_perms = [];
$permcat = null;
- $automatic = 0;
+ $automatic = get_pconfig($channel_id, 'system', 'autoperms');
// If a default permcat exists, use that
- $pc = ((feature_enabled($channel_id, 'permcats')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default');
- if (!in_array($pc, ['', 'default'])) {
- $pcp = new Zlib\Permcat($channel_id);
- $permcat = $pcp->fetch($pc);
- if ($permcat && $permcat['perms']) {
- foreach ($permcat['perms'] as $p) {
- $my_perms[$p['name']] = $p['value'];
- }
+ $pc = get_pconfig($channel_id, 'system', 'default_permcat', 'default');
+ $pcp = new Zlib\Permcat($channel_id);
+ $permcat = $pcp->fetch($pc);
+ if ($permcat && $permcat['perms']) {
+ foreach ($permcat['perms'] as $p) {
+ $my_perms[$p['name']] = $p['value'];
}
}
// look up the permission role to see if it specified auto-connect
// and if there was no permcat or a default permcat, set the perms
// from the role
-
+/*
$role = get_pconfig($channel_id, 'system', 'permissions_role');
if ($role) {
$xx = PermissionRoles::role_perms($role);
@@ -247,11 +245,12 @@ class Permissions {
$my_perms = Permissions::FilledPerms($default_perms);
}
}
+*/
// If we reached this point without having any permission information,
// it is likely a custom permissions role. First see if there are any
// automatic permissions.
-
+/*
if (!$my_perms) {
$m = Permissions::FilledAutoperms($channel_id);
if ($m) {
@@ -259,11 +258,12 @@ class Permissions {
$my_perms = $m;
}
}
-
+*/
// If we reached this point with no permissions, the channel is using
// custom perms but they are not automatic. They will be stored in abconfig with
// the channel's channel_hash (the 'self' connection).
+/*
if (!$my_perms) {
$r = q("select channel_hash from channel where channel_id = %d",
intval($channel_id)
@@ -280,10 +280,10 @@ class Permissions {
}
}
}
-
- return (['perms' => $my_perms, 'automatic' => $automatic]);
+*/
+ return (['perms' => $my_perms, 'automatic' => $automatic, 'role' => $pc]);
}
-
+/*
static public function serialise($p) {
$n = [];
if ($p) {
@@ -295,4 +295,5 @@ class Permissions {
}
return implode(',', $n);
}
+*/
}