Commit b2bae867 authored by Zot's avatar Zot

more background work for permcat support

parent 1cef3f15
......@@ -281,22 +281,22 @@ class PermissionRoles {
$permcats = [
[ 'follower', t('follower','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki',
'post_like' ]
],
[ 'contributor', t('contributor','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
'post_wall','post_comments','post_like','tag_deliver','chat' ]
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki',
'post_wall','post_comments','write_wiki','post_like','tag_deliver','chat' ]
],
[ 'trusted', t('trusted','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
'write_storage','post_wall','post_comments','post_like','tag_deliver',
'write_storage','post_wall','write_pages','write_wiki','post_comments','post_like','tag_deliver',
'chat', 'republish' ]
],
[ 'moderator', t('moderator','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
'write_storage','post_wall','post_comments','post_like','tag_deliver',
'write_storage','post_wall','wite_pages','write_wiki','post_comments','post_like','tag_deliver',
'chat', 'republish' ]
]
];
......
......@@ -106,6 +106,18 @@ class Permissions {
}
static public function OPerms($arr) {
$ret = [];
if($arr) {
foreach($arr as $k => $v) {
$ret[] = [ 'name' => $k, 'value' => $v ];
}
}
return $ret;
}
static public function FilledAutoperms($channel_id) {
if(! intval(get_pconfig($channel_id,'system','autoperms')))
return false;
......
<?php
namespace Zotlabs\Module;
use \Zotlabs\Access as Zaccess;
class Permcat extends \Zotlabs\Web\Controller {
private $permcats = [];
public function init() {
if(! local_channel())
return;
$name = 'default';
$localname = t('default','permcat');
$perms = Zaccess\Permissions::FilledAutoPerms(local_channel());
if(! $perms) {
$role = get_pconfig(local_channel(),'system','permissions_role');
if($role) {
$x = Zaccess\PermissionRoles::role_perms($role);
$perms = Zaccess\Permissions::FilledPerms($x['perms_connect']);
}
if(! $perms) {
$perms = Zaccess\Permissions::FilledPerms([]);
}
}
$this->permcats[] = [
'name' => $name,
'localname' => $localname,
'perms' => Zaccess\Permissions::Operms($perms)
];
$p = Zaccess\PermissionRoles::permcats(local_channel());
if($p) {
for($x = 0; $x < count($p); $x++) {
$this->permcats[] = [
'name' => $p[$x][0],
'localname' => $p[$x][1],
'perms' => Zaccess\Permissions::Operms(Zaccess\Permissions::FilledPerms($p[$x][2]))
];
}
}
if(argc() > 1 && $this->permcats) {
foreach($this->permcats as $permcat) {
if(strcasecmp($permcat['name'],argv(1)) === 0) {
json_return_and_die($permcat);
}
}
json_return_and_die(['error' => true]);
}
json_return_and_die($this->permcats);
}
}
\ No newline at end of file
......@@ -450,7 +450,6 @@ return array(
'Zotlabs\\Module\\Events' => $baseDir . '/Zotlabs/Module/Events.php',
'Zotlabs\\Module\\Fbrowser' => $baseDir . '/Zotlabs/Module/Fbrowser.php',
'Zotlabs\\Module\\Feed' => $baseDir . '/Zotlabs/Module/Feed.php',
'Zotlabs\\Module\\Ffsapi' => $baseDir . '/Zotlabs/Module/Ffsapi.php',
'Zotlabs\\Module\\Fhublocs' => $baseDir . '/Zotlabs/Module/Fhublocs.php',
'Zotlabs\\Module\\File_upload' => $baseDir . '/Zotlabs/Module/File_upload.php',
'Zotlabs\\Module\\Filer' => $baseDir . '/Zotlabs/Module/Filer.php',
......@@ -494,7 +493,6 @@ return array(
'Zotlabs\\Module\\Oep' => $baseDir . '/Zotlabs/Module/Oep.php',
'Zotlabs\\Module\\Oexchange' => $baseDir . '/Zotlabs/Module/Oexchange.php',
'Zotlabs\\Module\\Online' => $baseDir . '/Zotlabs/Module/Online.php',
'Zotlabs\\Module\\Opensearch' => $baseDir . '/Zotlabs/Module/Opensearch.php',
'Zotlabs\\Module\\Page' => $baseDir . '/Zotlabs/Module/Page.php',
'Zotlabs\\Module\\Pconfig' => $baseDir . '/Zotlabs/Module/Pconfig.php',
'Zotlabs\\Module\\Pdledit' => $baseDir . '/Zotlabs/Module/Pdledit.php',
......
$(document).ready(function() {
$('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); // Warn user about unsaved settings
// Warn member about unsaved settings
$('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] });
if(typeof(after_following) !== 'undefined' && after_following) {
if(typeof(connectDefaultShare) !== 'undefined')
......@@ -102,3 +103,23 @@ function connectFullShare() {
$('#me_id_perms_republish').attr('checked','checked');
$('#me_id_perms_post_like').attr('checked','checked');
}
function loadAbookRole(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');
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment