permcats app

This commit is contained in:
Mario Vavti
2018-09-26 22:02:50 +02:00
parent 505782f224
commit a7948d7bfe
9 changed files with 41 additions and 35 deletions

View File

@@ -7,6 +7,7 @@ namespace Zotlabs\Module;
*
*/
use Zotlabs\Lib\Apps;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@@ -851,7 +852,7 @@ class Connedit extends \Zotlabs\Web\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(), 'Permission Categories'),
'$addr' => unpunify($contact['xchan_addr']),
'$primeurl' => unpunify($contact['xchan_url']),
'$section' => $section,

View File

@@ -1,6 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Apps;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@@ -238,7 +239,7 @@ class Defperms extends \Zotlabs\Web\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(local_channel(), 'Permission Categories'),
'$section' => $section,
'$sections' => $sections,
'$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'),

View File

@@ -1,19 +1,25 @@
<?php
namespace Zotlabs\Module\Settings;
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
class Permcats {
class Permcats extends Controller {
function post() {
if(! local_channel())
return;
$channel = \App::get_channel();
if(! Apps::system_app_installed(local_channel(), 'Permission Categories'))
return
check_form_security_token_redirectOnErr('/settings/permcats', 'settings_permcats');
$channel = App::get_channel();
check_form_security_token_redirectOnErr('/permcats', 'permcats');
$all_perms = \Zotlabs\Access\Permissions::Perms();
@@ -50,13 +56,22 @@ class Permcats {
if(! local_channel())
return;
$channel = \App::get_channel();
if(! Apps::system_app_installed(local_channel(), 'Permission Categories')) {
//Do not display any associated widgets at this point
App::$pdl = '';
$o = '<b>Permission Categories App (Not Installed):</b><br>';
$o .= t('Create custom connection permission limits');
return $o;
}
$channel = App::get_channel();
if(argc() > 2)
$name = hex2bin(argv(2));
if(argc() > 1)
$name = hex2bin(argv(1));
if(argc() > 3 && argv(3) === 'drop') {
if(argc() > 2 && argv(2) === 'drop') {
\Zotlabs\Lib\Permcat::delete(local_channel(),$name);
build_sync_packet();
json_return_and_die([ 'success' => true ]);
@@ -93,9 +108,9 @@ class Permcats {
$tpl = get_markup_template("settings_permcats.tpl");
$tpl = get_markup_template("permcats.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_permcats"),
'$form_security_token' => get_form_security_token("permcats"),
'$title' => t('Permission Categories'),
'$desc' => $desc,
'$desc2' => $desc2,