Consolidate role settings

This commit is contained in:
DM42.Net (Matt Dent) 2019-07-12 11:13:42 -04:00
parent cf040dea61
commit 07f86afa43
6 changed files with 20 additions and 15 deletions

View file

@ -17,7 +17,7 @@ class PermissionRoles {
* @return number
*/
static public function version() {
return 2;
return 3;
}
static function role_perms($role) {
@ -62,6 +62,7 @@ class PermissionRoles {
'view_pages', 'post_wall', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();
$ret['channel_type'] = 'group';
break;
@ -76,6 +77,7 @@ class PermissionRoles {
'view_pages', 'post_wall', 'post_comments', 'moderated'
];
$ret['limits'] = PermissionLimits::Std_Limits();
$ret['channel_type'] = 'group';
break;
@ -90,6 +92,7 @@ class PermissionRoles {
];
$ret['limits'] = PermissionLimits::Std_Limits();
$ret['limits']['view_contacts'] = PERMS_SPECIFIC;
$ret['channel_type'] = 'group';
break;
case 'collection':
@ -102,6 +105,7 @@ class PermissionRoles {
'view_pages', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();
$ret['channel_type'] = 'collection';
break;
@ -116,6 +120,7 @@ class PermissionRoles {
];
$ret['limits'] = PermissionLimits::Std_Limits();
$ret['limits']['view_contacts'] = PERMS_SPECIFIC;
$ret['channel_type'] = 'collection';
break;
case 'feed':
@ -132,6 +137,10 @@ class PermissionRoles {
break;
case 'repository':
//Legacy settings to cover all channel_types previously in Libzot.php
$ret['channel_type'] = 'group';
default:
break;
}
@ -190,4 +199,4 @@ class PermissionRoles {
return $roles;
}
}
}

View file

@ -41,7 +41,7 @@ class Permissions {
* @return number
*/
static public function version() {
return 2;
return 3;
}
/**
@ -279,4 +279,4 @@ class Permissions {
return implode(',',$n);
}
}
}

View file

@ -11,6 +11,7 @@ use App;
use Zotlabs\Web\HTTPSig;
use Zotlabs\Access\Permissions;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Access\PermissionRoles;
use Zotlabs\Daemon\Master;
@ -2952,15 +2953,10 @@ class Libzot {
// now all forums (public, restricted, and private) set the public_forum flag. So it really means "is a group"
// and has nothing to do with accessibility.
$channel_type = 'normal';
$role = get_pconfig($e['channel_id'],'system','permissions_role');
if (in_array($role, ['forum','forum_restricted','repository'])) {
$channel_type = 'group';
}
if (in_array($role, ['collection','collection_restricted'])) {
$channel_type = 'collection';
}
$rolesettings = PermissionRoles::role_perms($role);
$channel_type = isset($rolesettings['channel_type']) ? $rolesettings['channel_type'] : 'normal';
// This is for birthdays and keywords, but must check access permissions
$p = q("select * from profile where uid = %d and is_default = 1",

View file

@ -246,7 +246,7 @@ function create_identity($arr) {
if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) {
$role_permissions = PermissionRoles::role_perms($arr['permissions_role']);
if(strpos($arr['permissions_role'],'collection') !== false) {
if(isset($role_permissions['channel_type']) && $role_permissions['channel_type'] == 'collection') {
$parent_channel_hash = $arr['parent_hash'];
}
}

View file

@ -39,7 +39,7 @@ class PermissionRolesTest extends UnitTestCase {
use PHPMock;
public function testVersion() {
$expectedVersion = 2;
$expectedVersion = 3;
$this->assertEquals($expectedVersion, PermissionRoles::version());

View file

@ -37,7 +37,7 @@ class PermissionsTest extends UnitTestCase {
use PHPMock;
public function testVersion() {
$expectedVersion = 2;
$expectedVersion = 3;
// static call
$this->assertEquals($expectedVersion, Permissions::version());