added permissionroles
This commit is contained in:
parent
85d2ad4aea
commit
17e161006a
70
Zotlabs/Access/PermissionRoles.php
Normal file
70
Zotlabs/Access/PermissionRoles.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Zotlabs\Access;
|
||||||
|
|
||||||
|
use Zotlabs\Lib as Zlib;
|
||||||
|
|
||||||
|
class PermissionRoles {
|
||||||
|
|
||||||
|
static private role_limits = array();
|
||||||
|
static private role_perms = array();
|
||||||
|
|
||||||
|
static public function roles() {
|
||||||
|
$roles = [
|
||||||
|
t('Social Networking') => [
|
||||||
|
'social' => t('Social - Mostly Public'),
|
||||||
|
'social_restricted' => t('Social - Restricted'),
|
||||||
|
'social_private' => t('Social - Private')
|
||||||
|
],
|
||||||
|
|
||||||
|
t('Community Forum') => [
|
||||||
|
'forum' => t('Forum - Mostly Public'),
|
||||||
|
'forum_restricted' => t('Forum - Restricted'),
|
||||||
|
'forum_private' => t('Forum - Private')
|
||||||
|
],
|
||||||
|
|
||||||
|
t('Feed Republish') => [
|
||||||
|
'feed' => t('Feed - Mostly Public'),
|
||||||
|
'feed_restricted' => t('Feed - Restricted')
|
||||||
|
],
|
||||||
|
|
||||||
|
t('Special Purpose') => [
|
||||||
|
'soapbox' => t('Special - Celebrity/Soapbox'),
|
||||||
|
'repository' => t('Special - Group Repository')
|
||||||
|
],
|
||||||
|
|
||||||
|
t('Other') => [
|
||||||
|
'custom' => t('Custom/Expert Mode')
|
||||||
|
]
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return $roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public function LimitSet($permission,$limit,$roles) {
|
||||||
|
if(is_array($roles)) {
|
||||||
|
foreach($roles as $role) {
|
||||||
|
self::$role_limits[$role][$permission] = $limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self::$role_limits[$role][$permission] = $limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function PermSet($permission,$roles) {
|
||||||
|
if(is_array($roles)) {
|
||||||
|
foreach($roles as $role) {
|
||||||
|
self::$role_perms[$role][] = $permission;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self::$role_perms[$role][] = $permission;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -7,7 +7,6 @@ use Zotlabs\Lib as Zlib;
|
|||||||
|
|
||||||
class Permissions {
|
class Permissions {
|
||||||
|
|
||||||
|
|
||||||
static public function Perms($filter) {
|
static public function Perms($filter) {
|
||||||
|
|
||||||
$perms = [
|
$perms = [
|
||||||
@ -43,39 +42,12 @@ class Permissions {
|
|||||||
return Zlib\PConfig::Get($channel_id,'perms',$permission);
|
return Zlib\PConfig::Get($channel_id,'perms',$permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public function Set($channel_id,$xchan_hash,$permission,$value) {
|
static public function Set($channel_id,$xchan_hash,$permission,$value) {
|
||||||
$channel = channelx_by_n($channel_id);
|
return Zlib\AbConfig::Set($channel_id,$xchan_hash,'perms',$permission,$value);
|
||||||
if($channel) {
|
|
||||||
return Zlib\AbConfig::Set($channel['channel_hash'],$xchan_hash,'perms',$permission,$value);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function Get($channel_id,$xchan_hash,$permission) {
|
static public function Get($channel_id,$xchan_hash,$permission) {
|
||||||
$channel = channelx_by_n($channel_id);
|
return Zlib\AbConfig::Get($channel_id,$xchan_hash,'perms',$permission);
|
||||||
if($channel) {
|
|
||||||
return Zlib\AbConfig::Get($channel['channel_hash'],$xchan_hash,'perms',$permission);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function SetHash($channel_hash,$xchan_hash,$permission,$value) {
|
|
||||||
return Zlib\AbConfig::Set($channel_hash,$xchan_hash,'perms',$permission,$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function GetHash($channel_hash,$xchan_hash,$permission) {
|
|
||||||
return Zlib\AbConfig::Get($channel_hash,$xchan_hash,'perms',$permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user