aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-08 17:21:32 -0800
committerzotlabs <mike@macgirvin.com>2017-02-08 17:21:32 -0800
commit91819bfc2d475e1b16d3f5e9ca685ca2531a9084 (patch)
tree0a139ef141996efc1dedae5476b4f6fb8ddde981
parent6ee691e0190a7d6488888d2fd5009324e3a88f74 (diff)
downloadvolse-hubzilla-91819bfc2d475e1b16d3f5e9ca685ca2531a9084.tar.gz
volse-hubzilla-91819bfc2d475e1b16d3f5e9ca685ca2531a9084.tar.bz2
volse-hubzilla-91819bfc2d475e1b16d3f5e9ca685ca2531a9084.zip
bringer - all basic functionality is implemented
-rw-r--r--Zotlabs/Lib/Permcat.php22
-rw-r--r--Zotlabs/Module/Connedit.php2
-rw-r--r--Zotlabs/Module/Settings/Permcats.php42
-rw-r--r--include/features.php9
-rw-r--r--include/widgets.php8
-rw-r--r--view/js/mod_settings.js32
-rwxr-xr-xview/tpl/abook_edit.tpl3
-rw-r--r--view/tpl/settings_permcats.tpl13
8 files changed, 107 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'],
diff --git a/include/features.php b/include/features.php
index 8ff0d2d21..0fc6fbc1d 100644
--- a/include/features.php
+++ b/include/features.php
@@ -149,6 +149,15 @@ function get_features($filtered = true) {
],
[
+ 'permcats',
+ t('Permission Groups'),
+ t('Provide alternate connection permission roles.'),
+ false,
+ get_config('feature_lock','permcats'),
+ feature_level('permcats',2),
+ ],
+
+ [
'smart_birthdays',
t('Smart Birthdays'),
t('Make birthday events timezone aware in case your friends are scattered across the planet.'),
diff --git a/include/widgets.php b/include/widgets.php
index 408ba5d24..52f8fd655 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -661,6 +661,14 @@ function widget_settings_menu($arr) {
);
}
+ if(feature_enabled(local_channel(),'permcats')) {
+ $tabs[] = array(
+ 'label' => t('Permission Categories'),
+ 'url' => z_root() . '/settings/permcats',
+ 'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
+ );
+ }
+
if($role === false || $role === 'custom') {
$tabs[] = array(
diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js
index db321ae70..5c729fa48 100644
--- a/view/js/mod_settings.js
+++ b/view/js/mod_settings.js
@@ -17,6 +17,16 @@ $(document).ready(function() {
else
$('#advanced-perm').hide();
});
+
+ $('#id_permcat_list').change(function() {
+ $('.loading-role-rotator').spin(true);
+ var permName = $('#id_permcat').val();
+ loadPermcat(permName);
+ });
+
+
+
+
});
@@ -137,3 +147,25 @@ function channel_privacy_macro(n) {
$('#id_profile_in_directory').val(1);
}
}
+
+
+
+function loadPermcat(name) {
+
+ if(! name)
+ name = 'default';
+
+ $('.abook-edit-me').each(function() {
+ if(! $(this).is(':disabled'))
+ $(this).removeAttr('checked');
+ });
+
+ $.get('permcat/' + name, function(data) {
+ $(data.perms).each(function() {
+ if(this.value)
+ $('#me_id_perms_' + this.name).attr('checked','checked');
+ });
+ $('.loading-role-rotator').spin(false);
+ });
+}
+
diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index 231841659..ebc69c5f8 100755
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -473,8 +473,11 @@
{{if $self}}{{$permnote_self}}{{/if}}
</div>
+ {{if $permcat_enable}}
<div class="loading-role-rotator"></div>
+ <a href="settings/permcats" class="pull-right"><i class="fa fa-plus"></i>&nbsp;{{$permcat_new}}</a>
{{include file="field_select.tpl" field=$permcat}}
+ {{/if}}
<table id="perms-tool-table" class=form-group>
<tr>
diff --git a/view/tpl/settings_permcats.tpl b/view/tpl/settings_permcats.tpl
index 597002815..f6bb9b036 100644
--- a/view/tpl/settings_permcats.tpl
+++ b/view/tpl/settings_permcats.tpl
@@ -45,6 +45,19 @@
</div>
</div>
</div>
+ {{if $permcats}}
+ <div class="section-content-wrapper-np">
+ <table id="permcat-index">
+ {{foreach $permcats as $k => $v}}
+ <tr class="permcat-row-{{$k}}">
+ <td width="99%"><a href="settings/permcats/{{$k}}">{{$k}}</a></td>
+ <td width="1%"><i class="fa fa-trash-o drop-icons" onClick="dropItem('/settings/permcats/{{$k}}/drop', '.permcat-row-{{$k}}')"></i></td>
+ </tr>
+ {{/foreach}}
+ </table>
+ </div>
+ {{/if}}
+
</div>
</form>