<?php

use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\HttpRequests;
require '../../vendor/autoload.php';
require '../tools.php';
if (!isset($_GET['id'])) {
    die('Http request id is missing from request URL.');
}
$http_request_id_to_edit_for_relations = $_GET['id'];
if (!hasOnlyDigits($http_request_id_to_edit_for_relations)) {
    die('Wrong Http request id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$http_request_to_edit_for_relations = $pm->getHttpRequests()->getHttpRequestById($http_request_id_to_edit_for_relations);
if (count($http_request_to_edit_for_relations) < 1) {
    die('No Http request exists having the requested id.');
}
$assigned_groups = $pm->getHttpRequests()->getAssignedGroups($http_request_to_edit_for_relations['id']);
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    if (!isset($_POST['groups'])) {
        $errors[] = 'No groups to assign, in post request.';
    }
    try {
        $groups_to_assign = json_decode($_POST['groups']);
    } catch (Exception $exc) {
        $errors[] = 'Invalid groups format.';
예제 #2
0
<?php

$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
if ($method !== 'post') {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: Request method is not supported.']]);
    die;
}
if (!isset($_POST['groupsToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No groups to delete.']]);
    die;
}
if (!is_array($_POST['groupsToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No groups to delete.']]);
    die;
}
require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$g = $pm->getGroups();
foreach ($_POST['groupsToDelete'] as $group_id) {
    if (is_scalar($group_id) && hasOnlyDigits($group_id)) {
        $g->deleteGroupById($group_id);
    }
}
header('Content-Type: application/json');
echo json_encode(['redirect' => BASE_URL . '/groups/']);
예제 #3
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\HttpRequests;
if (!isset($_GET['id'])) {
    die('Http request id to edit is missing from request URL.');
}
$http_request_id_to_edit = $_GET['id'];
if (!hasOnlyDigits($http_request_id_to_edit)) {
    die('Wrong Http request id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$http_request_to_edit = $pm->getHttpRequests()->getHttpRequestById($http_request_id_to_edit);
if (count($http_request_to_edit) < 1) {
    die('No Http request exists having the requested menu id.');
}
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    $method = isset($_POST['http_request_method']) ? $_POST['http_request_method'] : '';
    $method_regex = isset($_POST['http_request_method_regex']) && $_POST['http_request_method_regex'] == 'on' ? HttpRequests::HTTP_REQUEST_METHOD_REGEX : HttpRequests::HTTP_REQUEST_METHOD_NOT_REGEX;
    $value = isset($_POST['http_request_value']) ? $_POST['http_request_value'] : '';
    $value_regex = isset($_POST['http_request_value_regex']) && $_POST['http_request_value_regex'] == 'on' ? HttpRequests::HTTP_REQUEST_VALUE_REGEX : HttpRequests::HTTP_REQUEST_VALUE_NOT_REGEX;
    $description = isset($_POST['http_request_description']) ? $_POST['http_request_description'] : '';
    $status = isset($_POST['http_request_status']) ? $_POST['http_request_status'] : '';
    if (strlen($method) < 1 || strlen($method) > 255) {
        $errors[] = 'Method length must be 1..255.';
예제 #4
0
     $errors[] = 'Username length must be 1..128.';
 }
 if (strlen($password) < 1 || strlen($password) > 512) {
     $errors[] = 'Password length must be 1..512.';
 }
 if (strlen($email_address) < 1 || strlen($email_address) > 128) {
     $errors[] = 'Email address length must be 1..128.';
 }
 if (filter_var($email_address, FILTER_VALIDATE_EMAIL) == FALSE) {
     $errors[] = 'Email address is not valid.';
 }
 if ($status !== 'active' && $status !== 'inactive') {
     $errors[] = 'You must select status.';
 }
 if (count($errors) < 1) {
     $pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
     $re = $pm->getUsers()->addUser(['first_name' => $first_name, 'last_name' => $last_name, 'username' => $username, 'email_address' => $email_address, 'password' => md5($password), 'status' => $status == 'active' ? Users::USER_STATUS_ACTIVE : Users::USER_STATUS_INACTIVE]);
     if ($re < 1) {
         if ($re === Users::USERNAME_ALREADY_EXISTS) {
             $errors[] = 'Username exists, please choose another one.';
         } else {
             if ($re === Users::EMAILADDRESS_ALREADY_EXISTS) {
                 $errors[] = 'Email address exists, please choose another one.';
             } else {
                 $errors[] = 'Unknown error, please contact administrator.';
             }
         }
     } else {
         redirect(BASE_URL . '/users/');
     }
 }
예제 #5
0
<?php

$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
if ($method !== 'post') {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: Request method is not supported.']]);
    die;
}
if (!isset($_POST['httpRequestsToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No Http requests to delete']]);
    die;
}
if (!is_array($_POST['httpRequestsToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No Http requests to delete.']]);
    die;
}
require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$hr = $pm->getHttpRequests();
foreach ($_POST['httpRequestsToDelete'] as $http_request_id) {
    $hr->deleteHttpRequestById($http_request_id);
}
header('Content-Type: application/json');
echo json_encode(['redirect' => BASE_URL . '/http_requests/']);
예제 #6
0
    $description = isset($_POST['http_request_description']) ? $_POST['http_request_description'] : '';
    $status = isset($_POST['http_request_status']) ? $_POST['http_request_status'] : '';
    if (strlen($method) < 1 || strlen($method) > 255) {
        $errors[] = 'Method length must be 1..255.';
    }
    if (strlen($value) < 1 || strlen($value) > 2047) {
        $errors[] = 'Value length must be 1..2047.';
    }
    if (strlen($description) > 255) {
        $errors[] = 'Description must be no more than 255 characters.';
    }
    if ($status !== 'active' && $status !== 'inactive') {
        $errors[] = 'You must select status.';
    }
    if (count($errors) < 1) {
        $pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
        $re = $pm->getHttpRequests()->addHttpRequest(['method' => $method, 'method_regex' => $method_regex, 'value' => $value, 'value_regex' => $value_regex, 'description' => $description, 'status' => $status == 'active' ? HttpRequests::HTTP_REQUEST_STATUS_ACTIVE : HttpRequests::HTTP_REQUEST_STATUS_INACTIVE]);
        redirect(BASE_URL . '/http_requests/');
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="add.css" type="text/css">
        <script src="../jquery-1.11.3.min.js"></script>
        <script src="add.js"></script>
        <title>Add new Http request</title>
    </head>
    <body>
<?php

use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Users;
require '../../vendor/autoload.php';
require '../tools.php';
if (!isset($_GET['id'])) {
    die('User id is missing from request URL.');
}
$user_id_to_edit_for_relations = $_GET['id'];
if (!hasOnlyDigits($user_id_to_edit_for_relations)) {
    die('Wrong User id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$user_to_edit_for_relations = $pm->getUsers()->getUserById($user_id_to_edit_for_relations);
if (count($user_to_edit_for_relations) < 1) {
    die('No User exists having the requested id.');
}
$assigned_groups = $pm->getUsers()->getAssignedGroups($user_to_edit_for_relations['id']);
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    if (!isset($_POST['groups'])) {
        $errors[] = 'No groups to assign, in post request.';
    }
    try {
        $groups_to_assign = json_decode($_POST['groups']);
    } catch (Exception $exc) {
        $errors[] = 'Invalid groups format.';
예제 #8
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Users;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$users = $pm->getUsers()->getAllUsers();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="index.css" type="text/css">
        <script src="../jquery-1.11.3.min.js"></script>
        <script src="index.js"></script>
        <title>Users</title>
    </head>
    <body>
        <p><a href="<?php 
echo BASE_URL;
?>
/">Home</a></p>
        <div id="messages"></div>
        <div id="users">
            <h2>Users</h2>
            <div id="menubar">
                <a href="add.php" id="add">Add</a>
                <?php 
if (count($users) > 0) {
    ?>
예제 #9
0
<?php

use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Menus;
require '../../vendor/autoload.php';
require '../tools.php';
if (!isset($_GET['id'])) {
    die('Menu id to edit is missing from request URL.');
}
$menu_id_to_edit = $_GET['id'];
if (!hasOnlyDigits($menu_id_to_edit)) {
    die('Wrong menu id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$menu_to_edit = $pm->getMenus()->getMenuById($menu_id_to_edit);
if (count($menu_to_edit) < 1) {
    die('No menu exists having the requested menu id.');
}
if ($menu_to_edit['id'] == $pm->getMenus()->getRootMenuId()) {
    die('Cannot edit root menu (RootMenu)');
}
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    $name = isset($_POST['menu_name']) ? $_POST['menu_name'] : '';
    $href = isset($_POST['menu_href']) ? $_POST['menu_href'] : '';
    $display_order = isset($_POST['menu_display_order']) ? (int) $_POST['menu_display_order'] : 0;
    $class = isset($_POST['menu_class']) ? $_POST['menu_class'] : NULL;
    $image = isset($_POST['menu_image']) ? $_POST['menu_image'] : NULL;
예제 #10
0
<?php

use PermissionsManager\PermissionsManager;
$toReturn = [];
if (isset($_GET['id'])) {
    require '../../vendor/autoload.php';
    require '../tools.php';
    $group_id = $_GET['id'];
    if (!hasOnlyDigits($group_id)) {
        die('Wrong group id format, only digits are allowed.');
    }
    $pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
    $group = $pm->getGroups()->getGroupById($group_id);
    if (count($group) < 1) {
        $toReturn = ['error' => 'There was an error, the requested group id was not found.'];
    } else {
        $toReturn = ['groupDetails' => $group];
    }
} else {
    $toReturn = ['error' => 'No group id was provided. Please check the request URL.'];
}
header('Content-Type: application/json');
echo json_encode($toReturn);
예제 #11
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Menus;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    $name = isset($_POST['menu_name']) ? $_POST['menu_name'] : '';
    $href = isset($_POST['menu_href']) ? $_POST['menu_href'] : '';
    $display_order = isset($_POST['menu_display_order']) ? (int) $_POST['menu_display_order'] : 0;
    $class = isset($_POST['menu_class']) ? $_POST['menu_class'] : NULL;
    $image = isset($_POST['menu_image']) ? $_POST['menu_image'] : NULL;
    $description = isset($_POST['menu_description']) ? $_POST['menu_description'] : '';
    $status = isset($_POST['menu_status']) ? $_POST['menu_status'] : '';
    $menu_parent = isset($_POST['menu_parent']) ? $_POST['menu_parent'] : '';
    if (strlen($name) < 1 || strlen($name) > 255) {
        $errors[] = 'Name length must be 1..255.';
    }
    if (strlen($href) < 1 || strlen($href) > 2047) {
        $errors[] = 'Href length must be 1..2047.';
    }
    //    $href = filter_var($href, FILTER_VALIDATE_URL);
    //
    //    if ($href === false) {
    //        $errors[] = 'Href must be a valid URL.';
    //    }
예제 #12
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\HttpRequests;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$http_requests = $pm->getHttpRequests()->getAllHttpRequests();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="index.css" type="text/css">
        <script src="../jquery-1.11.3.min.js"></script>
        <script src="index.js"></script>
        <title>Http Requests</title>
    </head>
    <body>
        <p><a href="<?php 
echo BASE_URL;
?>
/">Home</a></p>
        <div id="messages"></div>
        <div id="http_requests">
            <h2>Http Requests</h2>
            <div id="menubar">
                <a href="add.php" id="add">Add</a>
                <?php 
if (count($http_requests) > 0) {
    ?>
예제 #13
0
<?php

use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Groups;
require '../../vendor/autoload.php';
require '../tools.php';
if (!isset($_GET['id'])) {
    die('Group id to edit is missing from request URL.');
}
$group_id_to_edit = $_GET['id'];
if (!hasOnlyDigits($group_id_to_edit)) {
    die('Wrong group id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$group_to_edit = $pm->getGroups()->getGroupById($group_id_to_edit);
if (count($group_to_edit) < 1) {
    die('No group exists having the requested group id.');
}
if ($group_to_edit['id'] == $pm->getGroups()->getRootGroupId()) {
    die('Cannot edit root group (public)');
}
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    $name = isset($_POST['group_name']) ? $_POST['group_name'] : '';
    $description = isset($_POST['group_description']) ? $_POST['group_description'] : '';
    $details = isset($_POST['group_details']) ? $_POST['group_details'] : NULL;
    $status = isset($_POST['group_status']) ? $_POST['group_status'] : '';
    $group_parent = isset($_POST['group_parent']) ? $_POST['group_parent'] : '';
예제 #14
0
<?php

$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
if ($method !== 'post') {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: Request method is not supported.']]);
    die;
}
if (!isset($_POST['usersToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No Users to delete']]);
    die;
}
if (!is_array($_POST['usersToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No Users to delete.']]);
    die;
}
require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$u = $pm->getUsers();
foreach ($_POST['usersToDelete'] as $user_id) {
    $u->deleteUserById($user_id);
}
header('Content-Type: application/json');
echo json_encode(['redirect' => BASE_URL . '/users/']);
예제 #15
0
            <a href="<?php 
echo BASE_URL;
?>
/groups/">Groups</a> | 
            <a href="<?php 
echo BASE_URL;
?>
/menus/">Menus</a> | 
            <a href="<?php 
echo BASE_URL;
?>
/http_requests/">Http Requests</a>
        </p>
        <hr>
        <?php 
$pm = new PermissionsManager(include '../src/PermissionsManager/config.php');
echo "<pre>";
echo "GROUPS:" . "<br>\n";
print_r($pm->getUserGroups(1));
echo "<br>\n";
echo "HTTP REQUESTS:" . "<br>\n";
$user_http_requests = $pm->getUserHttpRequests(1);
print_r($user_http_requests);
echo "<br>\n";
echo "MENUS:" . "<br>\n";
print_r($pm->getUserMenus(1));
echo "<br>\n";
$test_requests = [0 => ['get', '/contact'], 1 => ['get', '/'], 2 => ['get', '/login'], 3 => ['post', '/login'], 4 => ['post', '/'], 5 => ['delete', '/contact'], 6 => ['get', '/logout'], 7 => ['put', '/user']];
foreach ($test_requests as $req) {
    echo "Request method: {$req['0']}<br>\n";
    echo "Request value: {$req['1']}<br>\n";
예제 #16
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Users;
if (!isset($_GET['id'])) {
    die('User id to edit is missing from request URL.');
}
$user_id_to_edit = $_GET['id'];
if (!hasOnlyDigits($user_id_to_edit)) {
    die('Wrong User id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$user_to_edit = $pm->getUsers()->getUserById($user_id_to_edit);
if (count($user_to_edit) < 1) {
    die('No User exists having the requested id.');
}
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    $first_name = isset($_POST['user_first_name']) && $_POST['user_first_name'] != '' ? $_POST['user_first_name'] : NULL;
    $last_name = isset($_POST['user_last_name']) && $_POST['user_last_name'] != '' ? $_POST['user_last_name'] : NULL;
    $username = isset($_POST['user_username']) ? $_POST['user_username'] : '';
    $password = isset($_POST['user_password']) ? $_POST['user_password'] : '';
    $email_address = isset($_POST['user_email_address']) ? $_POST['user_email_address'] : '';
    $status = isset($_POST['user_status']) ? $_POST['user_status'] : '';
    if (strlen($username) < 1 || strlen($username) > 128) {
        $errors[] = 'Username length must be 1..128.';
예제 #17
0
<?php

$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
if ($method !== 'post') {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: Request method is not supported.']]);
    die;
}
if (!isset($_POST['menusToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No menus to delete.']]);
    die;
}
if (!is_array($_POST['menusToDelete'])) {
    header('Content-Type: application/json');
    echo json_encode(['messages' => ['Error: No menus to delete.']]);
    die;
}
require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$m = $pm->getMenus();
foreach ($_POST['menusToDelete'] as $menu_id) {
    $m->deleteMenuById($menu_id);
}
header('Content-Type: application/json');
echo json_encode(['redirect' => BASE_URL . '/menus/']);
예제 #18
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$groups = turnResources2ATree_V2($pm->getGroups()->getAllGroups());
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="index.css" type="text/css">
        <script src="../jquery-1.11.3.min.js"></script>
        <script src="index.js"></script>
        <title>Groups</title>
    </head>
    <body>
        <p><a href="<?php 
echo BASE_URL;
?>
/">Home</a></p>
        <div id="messages"></div>
        <div id="groups">
            <h2>Groups</h2>
            <div id="menubar">
                <a href="add.php" id="add">Add</a>
                <a href="edit.php" id="edit">Edit</a>
                <a href="#" id="delete">Delete</a>
            </div><br>
            <div id="tree">
<?php

use PermissionsManager\PermissionsManager;
use PermissionsManager\Models\Menus;
require '../../vendor/autoload.php';
require '../tools.php';
if (!isset($_GET['id'])) {
    die('Menu id is missing from request URL.');
}
$menu_id_to_edit_for_relations = $_GET['id'];
if (!hasOnlyDigits($menu_id_to_edit_for_relations)) {
    die('Wrong menu id format, only digits are allowed.');
}
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$menu_to_edit_for_relations = $pm->getMenus()->getMenuById($menu_id_to_edit_for_relations);
if (count($menu_to_edit_for_relations) < 1) {
    die('No menu exists having the requested menu id.');
}
if ($menu_to_edit_for_relations['id'] == $pm->getMenus()->getRootMenuId()) {
    die('Cannot relate root menu (RootMenu) to any group.');
}
$menu_parent = $pm->getMenus()->getMenuById($menu_to_edit_for_relations['parent_id']);
$menu_parent_name = isset($menu_parent['name']) ? $menu_parent['name'] : 'unknown';
$menu_parent_name .= ' (' . (isset($menu_parent['id']) ? $menu_parent['id'] : '?') . ')';
$assigned_groups = $pm->getMenus()->getAssignedGroups($menu_to_edit_for_relations['id']);
$method = isset($_SERVER['REQUEST_METHOD']) ? mb_strtolower($_SERVER['REQUEST_METHOD']) : '';
$errors = [];
$is_post = false;
if ($method == 'post') {
    $is_post = true;
    if (!isset($_POST['groups'])) {
예제 #20
0
<?php

use PermissionsManager\PermissionsManager;
$toReturn = [];
if (isset($_GET['id'])) {
    require '../../vendor/autoload.php';
    require '../tools.php';
    $menu_id = $_GET['id'];
    if (!hasOnlyDigits($menu_id)) {
        die('Wrong menu id format, only digits are allowed.');
    }
    $pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
    $menu = $pm->getMenus()->getMenuById($menu_id);
    if (count($menu) < 1) {
        $toReturn = ['error' => 'There was an error, the requested menu id was not found.'];
    } else {
        $toReturn = ['menuDetails' => $menu];
    }
} else {
    $toReturn = ['error' => 'No menu id was provided. Please check the request URL.'];
}
header('Content-Type: application/json');
echo json_encode($toReturn);
예제 #21
0
<?php

require '../../vendor/autoload.php';
require '../tools.php';
use PermissionsManager\PermissionsManager;
$pm = new PermissionsManager(include '../../src/PermissionsManager/config.php');
$menus = turnResources2ATree_V2($pm->getMenus()->getAllMenus());
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="index.css" type="text/css">
        <script src="../jquery-1.11.3.min.js"></script>
        <script src="index.js"></script>
        <title>Menus</title>
    </head>
    <body>
        <p><a href="<?php 
echo BASE_URL;
?>
/">Home</a></p>
        <div id="messages"></div>
        <div id="menus">
            <h2>Menus</h2>
            <div id="menubar">
                <a href="add.php" id="add">Add</a>
                <a href="edit.php" id="edit">Edit</a>
                <a href="#" id="delete">Delete</a>
                | 
                <a href="groupRelations.php" id="groupRelations">Add/Remove to/from groups</a>