mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:35:12 +00:00
roles app
This commit is contained in:
parent
491d037c56
commit
445dad7601
13 changed files with 91 additions and 53 deletions
|
@ -228,7 +228,7 @@ class Permissions
|
|||
|
||||
// If a default permcat exists, use that
|
||||
|
||||
$pc = ((feature_enabled($channel_id, 'permcats')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default');
|
||||
$pc = ((Zlib\Apps::system_app_installed($channel_id, 'Roles')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default');
|
||||
if (! in_array($pc, [ '','default' ])) {
|
||||
$pcp = new Zlib\Permcat($channel_id);
|
||||
$permcat = $pcp->fetch($pc);
|
||||
|
|
|
@ -395,6 +395,7 @@ class Apps
|
|||
'Random Channel' => t('Random Channel'),
|
||||
'Remote Diagnostics' => t('Remote Diagnostics'),
|
||||
'Report Bug' => t('Report Bug'),
|
||||
'Roles' => t('Roles'),
|
||||
'Search' => t('Search'),
|
||||
'Secrets' => t('Secrets'),
|
||||
'Settings' => t('Settings'),
|
||||
|
|
|
@ -52,7 +52,7 @@ class Permcat
|
|||
// if no role perms it may be a custom role, see if there any autoperms
|
||||
|
||||
if (! $perms) {
|
||||
$perms = Permissions::FilledAutoPerms($channel_id);
|
||||
$perms = Permissions::FilledAutoperms($channel_id);
|
||||
}
|
||||
|
||||
// if no autoperms it may be a custom role with manual perms
|
||||
|
@ -60,7 +60,7 @@ class Permcat
|
|||
if (! $perms) {
|
||||
$c = channelx_by_n($channel_id);
|
||||
if ($c) {
|
||||
$perms = Permissions::FilledPerms(get_abconfig($channel_id, $c['channel_hash'], 'system', 'my_perms', EMPTY_STR));
|
||||
$perms = Permissions::FilledPerms(explode(',',get_abconfig($channel_id, $c['channel_hash'], 'system', 'my_perms', EMPTY_STR)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ class Permcat
|
|||
);
|
||||
if ($x) {
|
||||
foreach ($x as $xv) {
|
||||
$value = ((preg_match('|^a:[0-9]+:{.*}$|s', $xv['v'])) ? unserialize($xv['v']) : $xv['v']);
|
||||
$value = unserialise($xv['v']);
|
||||
$permcats[] = [ $xv['k'], $xv['k'], $value, 0 ];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -768,7 +768,7 @@ class Connedit extends Controller
|
|||
$thisperm = "1";
|
||||
}
|
||||
|
||||
$perms[] = array('perms_' . $k, $v, ((array_key_exists($k, $their_perms)) ? intval($their_perms[$k]) : ''), $thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
|
||||
$perms[] = array('perms_' . $k, $v, ((array_key_exists($k, $their_perms)) ? intval($their_perms[$k]) : ''), $thisperm, $yes_no, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
|
||||
}
|
||||
|
||||
$pcat = new Permcat(local_channel());
|
||||
|
@ -806,7 +806,7 @@ class Connedit extends Controller
|
|||
'$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'), '', '<span class="loading invisible">' . t('Loading') . '<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span></span>', $permcats],
|
||||
'$permcat_new' => t('Add permission role'),
|
||||
'$permcat_enable' => feature_enabled(local_channel(), 'permcats'),
|
||||
'$permcat_enable' => Apps::system_app_installed(local_channel(),'Roles'),
|
||||
'$addr' => unpunify($contact['xchan_addr']),
|
||||
'$primeurl' => unpunify($contact['xchan_url']),
|
||||
'$block_announce' => ['block_announce', t('Ignore shares and repeats this connection posts'), get_abconfig(local_channel(), $contact['xchan_hash'], 'system', 'block_announce', false), t('Note: This is not recommended for Groups.'), [t('No'), t('Yes')]],
|
||||
|
@ -840,7 +840,7 @@ class Connedit extends Controller
|
|||
'$pending_label' => t('Connection Pending Approval'),
|
||||
'$is_pending' => (intval($contact['abook_pending']) ? 1 : ''),
|
||||
'$unapproved' => $unapproved,
|
||||
'$inherited' => t('inherited'),
|
||||
'$inherited' => '', // t('inherited'),
|
||||
'$submit' => t('Submit'),
|
||||
'$lbl_vis2' => sprintf(t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
|
||||
'$close' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 80),
|
||||
|
@ -848,8 +848,8 @@ class Connedit extends Controller
|
|||
'$me' => t('My Settings'),
|
||||
'$perms' => $perms,
|
||||
'$permlbl' => t('Individual Permissions'),
|
||||
'$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'),
|
||||
'$permnote_self' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.'),
|
||||
'$permnote' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'),
|
||||
'$permnote_self' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'),
|
||||
'$lastupdtext' => t('Last update:'),
|
||||
'$last_update' => relative_date($contact['abook_connected']),
|
||||
'$profile_select' => contact_profile_assign($contact['abook_profile']),
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module;
|
|||
use App;
|
||||
use Zotlabs\Lib\Permcat;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Access\Permissions;
|
||||
use Zotlabs\Access\PermissionLimits;
|
||||
|
@ -248,7 +249,7 @@ class Defperms extends Controller
|
|||
'$autoperms' => array('autoperms', t('Apply these permissions automatically'), ((get_pconfig(local_channel(), 'system', 'autoperms')) ? 1 : 0), t('If enabled, connection requests will be approved without your interaction'), $yes_no),
|
||||
'$permcat' => ['permcat', t('Permission role'), '', '<span class="loading invisible">' . t('Loading') . '<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span></span>', $permcats],
|
||||
'$permcat_new' => t('Add permission role'),
|
||||
'$permcat_enable' => feature_enabled(local_channel(), 'permcats'),
|
||||
'$permcat_enable' => Apps::system_app_installed($channel_id, 'Roles'),
|
||||
'$section' => $section,
|
||||
'$sections' => $sections,
|
||||
'$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'),
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Module\Settings;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\AccessList;
|
||||
use Zotlabs\Access\Permissions;
|
||||
|
@ -670,7 +671,7 @@ class Channel
|
|||
'$permissions_role' => $permissions_role,
|
||||
'$role' => array('permissions_role', t('Channel type and privacy'), $permissions_role, '', $perm_roles, ' onchange="update_role_text(); return false;"'),
|
||||
'$defpermcat' => ['defpermcat', t('Default Permissions Group'), $default_permcat, '', $permcats],
|
||||
'$permcat_enable' => feature_enabled(local_channel(), 'permcats'),
|
||||
'$permcat_enable' => Apps::system_app_installed(local_channel(), 'Roles'),
|
||||
'$profile_in_dir' => $profile_in_dir,
|
||||
'$hide_friends' => $hide_friends,
|
||||
'$hide_wall' => $hide_wall,
|
||||
|
|
|
@ -13,7 +13,8 @@ class Permcats
|
|||
|
||||
public function post()
|
||||
{
|
||||
|
||||
//logger('$_REQUEST: ' . print_r($_REQUEST,true));
|
||||
|
||||
if (!local_channel()) {
|
||||
return;
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ class Permcats
|
|||
|
||||
Libsync::build_sync_packet();
|
||||
|
||||
info(t('Permission category saved.') . EOL);
|
||||
info(t('Permission role saved.') . EOL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -91,24 +92,39 @@ class Permcats
|
|||
}
|
||||
}
|
||||
|
||||
$hidden_perms = [];
|
||||
$global_perms = Permissions::Perms();
|
||||
|
||||
foreach ($global_perms as $k => $v) {
|
||||
$thisperm = Permcat::find_permcat($existing, $k);
|
||||
|
||||
$checkinherited = PermissionLimits::Get(local_channel(), $k);
|
||||
|
||||
if ($existing[$k]) {
|
||||
$thisperm = "1";
|
||||
$inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true);
|
||||
|
||||
$thisperm = 0;
|
||||
if ($existing) {
|
||||
foreach ($existing as $ex) {
|
||||
if ($ex['name'] === $k) {
|
||||
$thisperm = $ex['value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$perms[] = [ 'perms_' . $k, $v, $inherited ? 1 : intval($thisperm), '', [ t('No'), t('Yes') ], (($inherited) ? ' disabled="disabled" ' : '' )];
|
||||
|
||||
if ($inherited) {
|
||||
$hidden_perms[] = ['perms_' . $k, 1 ];
|
||||
}
|
||||
|
||||
$perms[] = array('perms_' . $k, $v, '', $thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tpl = get_markup_template("settings_permcats.tpl");
|
||||
$o .= replace_macros($tpl, array(
|
||||
'$form_security_token' => get_form_security_token("settings_permcats"),
|
||||
'$title' => t('Permission Categories'),
|
||||
'$title' => t('Permission Roles'),
|
||||
'$desc' => $desc,
|
||||
'$desc2' => $desc2,
|
||||
'$tokens' => $t,
|
||||
|
@ -116,14 +132,15 @@ class Permcats
|
|||
'$atoken' => $atoken,
|
||||
'$url1' => z_root() . '/channel/' . $channel['channel_address'],
|
||||
'$url2' => z_root() . '/photos/' . $channel['channel_address'],
|
||||
'$name' => array('name', t('Permission Name') . ' <span class="required">*</span>', (($name) ? $name : ''), ''),
|
||||
'$name' => array('name', t('Role name') . ' <span class="required">*</span>', (($name) ? $name : ''), ''),
|
||||
'$me' => t('My Settings'),
|
||||
'$perms' => $perms,
|
||||
'$hidden_perms' => $hidden_perms,
|
||||
'$inherited' => t('inherited'),
|
||||
'$notself' => 0,
|
||||
'$self' => 1,
|
||||
'$permlbl' => t('Individual Permissions'),
|
||||
'$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'),
|
||||
'$permnote' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'),
|
||||
'$submit' => t('Submit')
|
||||
));
|
||||
return $o;
|
||||
|
|
|
@ -105,13 +105,13 @@ class Settings_menu
|
|||
// );
|
||||
// }
|
||||
|
||||
// if(feature_enabled(local_channel(),'permcats')) {
|
||||
// $tabs[] = array(
|
||||
// 'label' => t('Permission Categories'),
|
||||
// 'url' => z_root() . '/settings/permcats',
|
||||
// 'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
|
||||
// );
|
||||
// }
|
||||
if(Apps::system_app_installed(local_channel(),'Roles')) {
|
||||
$tabs[] = array(
|
||||
'label' => t('Permission Roles'),
|
||||
'url' => z_root() . '/settings/permcats',
|
||||
'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// if($role === false || $role === 'custom') {
|
||||
|
|
6
app/roles.apd
Normal file
6
app/roles.apd
Normal file
|
@ -0,0 +1,6 @@
|
|||
version: 1
|
||||
url: $baseurl/settings/permcats
|
||||
requires: local_channel
|
||||
name: Roles
|
||||
photo: icon:users
|
||||
categories: Networking
|
|
@ -247,14 +247,14 @@ function get_features($filtered = true, $level = (-1))
|
|||
// ],
|
||||
|
||||
|
||||
// [
|
||||
// 'permcats',
|
||||
// t('Permission Categories'),
|
||||
// t('Create custom connection permission limits'),
|
||||
// false,
|
||||
// get_config('feature_lock','permcats'),
|
||||
// feature_level('permcats',2),
|
||||
// ],
|
||||
[
|
||||
'permcats',
|
||||
t('Permission Categories'),
|
||||
t('Create custom connection permission limits'),
|
||||
true,
|
||||
get_config('feature_lock','permcats'),
|
||||
feature_level('permcats',2),
|
||||
],
|
||||
|
||||
// [
|
||||
// 'oauth_clients',
|
||||
|
|
|
@ -238,7 +238,7 @@
|
|||
{{include file="field_select.tpl" field=$permcat}}
|
||||
{{/if}}
|
||||
|
||||
<table id="perms-tool-table" class=form-group>
|
||||
<table id="perms-tool-table" class="form-group">
|
||||
<tr>
|
||||
<td></td>
|
||||
{{if $notself}}
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
<tr class="highlight">
|
||||
<tr class="highlight" style="line-height: 2";>
|
||||
<td>
|
||||
<label class="mainlabel" for='me_id_{{$field.0}}'>{{$field.1}}</label><br>
|
||||
<span class='field_abook_help'>{{$field.6}}</span>
|
||||
</td>
|
||||
{{if $notself}}
|
||||
<td class="abook-them">
|
||||
{{if $field.2 === 1}}<i class="fa fa-check-square-o"></i>{{/if}}
|
||||
{{if $field.2 === 0}}<i class="fa fa-square-o"></i>{{/if}}
|
||||
<td class="abook-them form-group checkbox">
|
||||
<div>
|
||||
<input type="checkbox" name='them-id-{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} disabled="disabled" /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span>
|
||||
</div>
|
||||
</td>
|
||||
{{/if}}
|
||||
<td class="abook-me">
|
||||
<td class="abook-me form-group checkbox" >
|
||||
{{if $self || !$field.5 }}
|
||||
<input type="checkbox" name='{{$field.0}}' class='abook-edit-me' id='me_id_{{$field.0}}' value="{{$field.4}}" {{if $field.3}}checked="checked"{{/if}} />
|
||||
<div>
|
||||
<input type="checkbox" class="abook-edit-me" name='{{$field.0}}' id='me_id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
<!--input type="checkbox" name='{{$field.0}}' class='abook-edit-me' id='me_id_{{$field.0}}' value="{{$field.4}}" {{if $field.3}}checked="checked"{{/if}} /-->
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if $notself && $field.5}}
|
||||
<div>
|
||||
<input type="hidden" name='{{$field.0}}' value="{{if $field.7}}1{{else}}0{{/if}}" />
|
||||
{{if $field.3}}<i class="fa fa-check-square-o"></i>{{else}}<i class="fa fa-square-o"></i>{{/if}}
|
||||
<input type="checkbox" name='{{$field.0}}' id='me_id_{{$field.0}}' value="{{if $field.7}}1{{else}}0{{/if}}" {{if $field.2}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
</div>
|
||||
|
||||
{{*if $field.3}}<i class="fa fa-check-square-o" style="color:#800;"></i>{{else}}<i class="fa fa-square-o"></i>{{/if*}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -20,25 +20,29 @@
|
|||
<div class="panel">
|
||||
<div class="section-subtitle-wrapper" role="tab" id="perms-tool">
|
||||
<h3>
|
||||
<a data-toggle="collapse" data-parent="#contact-edit-tools" href="#perms-tool-collapse" aria-expanded="true" aria-controls="perms-tool-collapse">
|
||||
<a data-toggle="collapse" data-target="#perms-tool-collapse" href="#perms-tool-collapse" aria-expanded="true" aria-controls="perms-tool-collapse">
|
||||
{{$permlbl}}
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div id="perms-tool-collapse" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="perms-tool">
|
||||
<div id="perms-tool-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="perms-tool" style="display:block;">
|
||||
<div class="section-content-tools-wrapper">
|
||||
<div class="section-content-warning-wrapper">
|
||||
{{$permnote}}
|
||||
</div>
|
||||
|
||||
<table id="perms-tool-table" class=form-group>
|
||||
<tr>
|
||||
<td></td><td colspan="2" class="abook-me">{{$me}}</td>
|
||||
</tr>
|
||||
{{foreach $perms as $prm}}
|
||||
{{include file="field_acheckbox.tpl" field=$prm}}
|
||||
{{/foreach}}
|
||||
</table>
|
||||
|
||||
<div class="defperms-edit">
|
||||
{{foreach $perms as $prm}}
|
||||
{{include file="field_checkbox.tpl" field=$prm}}
|
||||
{{/foreach}}
|
||||
</div>
|
||||
|
||||
{{if $hidden_perms}}
|
||||
{{foreach $hidden_perms as $prm}}
|
||||
<input type="hidden" name="{{$prm.0}}" value="{{$prm.1}}" >
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<div class="settings-submit-wrapper" >
|
||||
<button type="submit" name="submit" class="btn btn-primary">{{$submit}}</button>
|
||||
|
|
Loading…
Reference in a new issue