<?php require_once 'acl_class.php'; if (isset($_POST['role_id'])) { $acl = new data_manipulation(); $role_id = $_POST['role_id']; $length = strlen($role_id); $x = strpos($role_id, 'role'); $role_id = (int) substr($role_id, $x + 4, $length - $x - 4); if (isset($_POST['id'])) { $acl->delete_data('manage_privilege', 'role_id', $role_id); foreach ($_POST['id'] as $key => $value) { $a['val'] = $value; $length = strlen($a['val']); $x = strpos($a['val'], 'action'); // substr(string,starting position,length of substing to be extracted) $resource_id = (int) substr($a['val'], 8, $x - 8); $action_id = (int) substr($a['val'], $x + 6, $length - $x - 6); $acl->assign_privilege($role_id, $resource_id, $action_id); } } } echo json_encode($a); ?>
<?php error_reporting(-1); ini_set('display_errors', 'On'); $acl = new data_manipulation(); // for role if (isset($_POST['add_role'])) { $text = $_POST['role_type']; $acl->add_data('role', 'role', $text); } if (isset($_POST['delete_role'])) { $text = $_POST['role']; $acl->delete_data('role', 'role', $text); } // for action if (isset($_POST['add_action'])) { $text = $_POST['action_type']; $acl->add_data('action', 'operation', $text); } if (isset($_POST['delete_action'])) { $text = $_POST['action']; $acl->delete_data('action', 'operation', $text); } //for resource if (isset($_POST['add_resource'])) { $text = $_POST['resource_type']; $acl->add_data('resource', 'resource', $text); } if (isset($_POST['delete_resource'])) { $text = $_POST['resource']; $acl->delete_data('resource', 'resource', $text);