Exemple #1
0
<?php

use Enpowi\Modules\Module;
Module::is();
$perms = [];
$groupNames = Enpowi\App::param('groupNames');
foreach ($groupNames as $groupName) {
    (new \Enpowi\Users\Group($groupName))->removePerms();
}
foreach (Enpowi\App::param('perm') as $permUnparsed) {
    $parsed = Enpowi\Users\Perm::parse($permUnparsed);
    $group = new \Enpowi\Users\Group($parsed['group']);
    \Enpowi\Users\Perm::create($parsed['module'], $parsed['component'], $group);
}
Module::successRespond('success', true);
Exemple #2
0
$everyoneGroup = Group::create('Everyone', false, false, true);
$anonymousGroup = Group::create('Anonymous', false, true);
$registeredGroup = Group::create('Registered', true);
$administratorGroup = Group::create('Administrator', false, false, false, true);
//create first user & put him in admin group
$administratorUser = User::create('admin', 'admin', true);
$administratorGroup->addUser($administratorUser);
//give Anonymous abilities
Perm::create('user', 'login', $anonymousGroup);
Perm::create('user', 'register', $anonymousGroup);
Perm::create('user', 'forgot', $anonymousGroup);
Perm::create('user', 'confirm', $anonymousGroup);
//give registered abilities
Perm::create('gallery', '*', $registeredGroup);
Perm::create('user', 'view', $registeredGroup);
Perm::create('user', 'logout', $registeredGroup);
Perm::create('user', 'confirm', $registeredGroup);
Perm::create('page', 'edit', $registeredGroup);
//give Administrator group access to everything
Perm::create('*', '*', $administratorGroup);
//give everyone the ability to see modules with no security
Perm::create('app', '*', $everyoneGroup);
Perm::create('default', '*', $everyoneGroup);
Perm::create('setup', '*', $everyoneGroup);
Perm::create('page', 'index', $everyoneGroup);
if (is_writable($dir)) {
    echo 'cannot write lock file. ';
} else {
    file_put_contents($dir . '/config.lock', '');
}
echo 'setup complete';