aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Permcat.php22
-rw-r--r--Zotlabs/Module/Connedit.php2
-rw-r--r--Zotlabs/Module/Settings/Permcats.php42
3 files changed, 42 insertions, 24 deletions
diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php
index c697984f1..7988aff97 100644
--- a/Zotlabs/Lib/Permcat.php
+++ b/Zotlabs/Lib/Permcat.php
@@ -28,7 +28,8 @@ class Permcat {
$this->permcats[] = [
'name' => $name,
'localname' => $localname,
- 'perms' => Zaccess\Permissions::Operms($perms)
+ 'perms' => Zaccess\Permissions::Operms($perms),
+ 'system' => 1
];
@@ -38,7 +39,8 @@ class Permcat {
$this->permcats[] = [
'name' => $p[$x][0],
'localname' => $p[$x][1],
- 'perms' => Zaccess\Permissions::Operms(Zaccess\Permissions::FilledPerms($p[$x][2]))
+ 'perms' => Zaccess\Permissions::Operms(Zaccess\Permissions::FilledPerms($p[$x][2])),
+ 'system' => intval($p[$x][3])
];
}
}
@@ -65,16 +67,16 @@ class Permcat {
$permcats = [
[ 'follower', t('follower','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki',
- 'post_like' ]
+ 'post_like' ], 1
],
[ 'contributor', t('contributor','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki',
- 'post_wall','post_comments','write_wiki','post_like','tag_deliver','chat' ]
+ 'post_wall','post_comments','write_wiki','post_like','tag_deliver','chat' ], 1
],
[ 'publisher', t('publisher','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
'write_storage','post_wall','write_pages','write_wiki','post_comments','post_like','tag_deliver',
- 'chat', 'republish' ]
+ 'chat', 'republish' ], 1
]
];
@@ -85,7 +87,7 @@ class Permcat {
if($x) {
foreach($x as $xv) {
$value = ((preg_match('|^a:[0-9]+:{.*}$|s', $xv['v'])) ? unserialize($xv['v']) : $xv['v']);
- $permcats[] = [ $xv['k'], $xv['k'], $value ];
+ $permcats[] = [ $xv['k'], $xv['k'], $value, 0 ];
}
}
}
@@ -96,6 +98,14 @@ class Permcat {
}
+ static public function find_permcat($arr,$name) {
+ if((! $arr) || (! $name))
+ return false;
+ foreach($arr as $p)
+ if($p['name'] == $name)
+ return $p['value'];
+ }
+
static public function update($channel_id, $name,$permarr) {
PConfig::Set($channel_id,'permcat',$name,$permarr);
}
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index 8f382246a..ccaf5cd5b 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -827,6 +827,8 @@ class Connedit extends \Zotlabs\Web\Controller {
'$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
'$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
'$permcat' => [ 'permcat', t('Permission role'), '', '',$permcats ],
+ '$permcat_new' => t('Add permission role'),
+ '$permcat_enable' => feature_enabled(local_channel(),'permcats'),
'$addr' => $contact['xchan_addr'],
'$section' => $section,
'$sections' => $sections,
diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php
index 82ee45bf7..35d533196 100644
--- a/Zotlabs/Module/Settings/Permcats.php
+++ b/Zotlabs/Module/Settings/Permcats.php
@@ -42,6 +42,8 @@ class Permcats {
function get() {
+logger('cmd: ' . \App::$cmd);
+
if(! local_channel())
return;
@@ -51,30 +53,33 @@ class Permcats {
if(argc() > 2)
$name = argv(2);
+ if(argc() > 3 && argv(3) === 'drop') {
+ \Zotlabs\Lib\Permcat::delete(local_channel(),$name);
+ build_sync_packet();
+ json_return_and_die([ 'success' => true ]);
+ }
- $desc = t('Use this form to create permission rules for various classes of people or connections.');
-
- $global_perms = \Zotlabs\Access\Permissions::Perms();
-
- $their_perms = [];
- $existing = get_all_perms(local_channel(),(($atoken_xchan) ? $atoken_xchan : ''));
+ $desc = t('Use this form to create permission rules for various classes of people or connections.');
- if($atoken_xchan) {
- $theirs = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'their_perms'",
- intval(local_channel()),
- dbesc($atoken_xchan)
- );
- if($theirs) {
- foreach($theirs as $t) {
- $their_perms[$t['k']] = $t['v'];
- }
+ $existing = [];
+
+ $pcat = new \Zotlabs\Lib\Permcat(local_channel());
+ $pcatlist = $pcat->listing();
+ $permcats = [];
+ if($pcatlist) {
+ foreach($pcatlist as $pc) {
+ if(($pc['name']) && ($name) && ($pc['name'] == $name))
+ $existing = $pc['perms'];
+ if(! $pc['system'])
+ $permcats[$pc['name']] = $pc['localname'];
}
}
- foreach($global_perms as $k => $v) {
- $thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
-//fixme
+ $global_perms = \Zotlabs\Access\Permissions::Perms();
+
+ foreach($global_perms as $k => $v) {
+ $thisperm = \Zotlabs\Lib\Permcat::find_permcat($existing,$k);
$checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k);
if($existing[$k])
@@ -92,6 +97,7 @@ class Permcats {
'$desc' => $desc,
'$desc2' => $desc2,
'$tokens' => $t,
+ '$permcats' => $permcats,
'$atoken' => $atoken,
'$url1' => z_root() . '/channel/' . $channel['channel_address'],
'$url2' => z_root() . '/photos/' . $channel['channel_address'],