$errors[] = lang("SQL_ERROR"); } } //Add access to pages if (!empty($_POST['addPage'])) { $add = $_POST['addPage']; if ($addition_count = addPage($add, $permissionId)) { $successes[] = lang("PERMISSION_ADD_PAGES", array($addition_count)); } else { $errors[] = lang("SQL_ERROR"); } } $permissionDetails = fetchPermissionDetails($permissionId); } } $pagePermissions = fetchPermissionPages($permissionId); //Retrieve list of accessible pages $permissionUsers = fetchPermissionUsers($permissionId); //Retrieve list of users with membership $userData = fetchAllUsers(); //Fetch all users $pageData = fetchAllPages(); //Fetch all pages require_once "models/header.php"; echo "\n<body>\n<div id='wrapper'>\n<div id='top'><div id='logo'></div></div>\n<div id='content'>\n<h1> </h1>\n<h2>Admin Permissions</h2>\n<div id='left-nav'>"; include "left-nav.php"; echo "\n</div>\n<div id='main'>"; echo resultBlock($errors, $successes); echo "\n<form name='adminPermission' action='" . $_SERVER['PHP_SELF'] . "?id=" . $permissionId . "' method='post'>\n<table class='admin'>\n<tr><td>\n<h3>Permission Information</h3>\n<div id='regbox'>\n<p>\n<label>ID:</label>\n" . $permissionDetails['id'] . "\n</p>\n<p>\n<label>Name:</label>\n<input type='text' name='name' value='" . $permissionDetails['name'] . "' />\n</p>\n<label>Delete:</label>\n<input type='checkbox' name='delete[" . $permissionDetails['id'] . "]' id='delete[" . $permissionDetails['id'] . "]' value='" . $permissionDetails['id'] . "'>\n</p>\n</div></td><td>\n<h3>Permission Membership</h3>\n<div id='regbox'>\n<p>\nRemove Members:"; //List users with permission level foreach ($userData as $v1) {
public function index() { /* UserCake (Via CupCake) Version: 2.0.2 http://usercake.com */ global $baseURL; require_once "{$baseURL}/application/third_party/user_cake/models/config.php"; if (!securePage($_SERVER['PHP_SELF'])) { die; } $permissionId = $_GET['id']; //Check if selected permission level exists if (!permissionIdExists($permissionId)) { header("Location: " . site_url('admin_permissions')); die; } $permissionDetails = fetchPermissionDetails($permissionId); //Fetch information specific to permission level //Forms posted if (!empty($_POST)) { //Delete selected permission level if (!empty($_POST['delete'])) { $deletions = $_POST['delete']; if ($deletion_count = deletePermission($deletions)) { $successes[] = lang("PERMISSION_DELETIONS_SUCCESSFUL", array($deletion_count)); header("Location: " . site_url('admin_permissions')); } else { $errors[] = lang("SQL_ERROR"); } } else { //Update permission level name if ($permissionDetails[0]['name'] != $_POST['name']) { $permission = trim($_POST['name']); //Validate new name if (permissionNameExists($permission)) { $errors[] = lang("ACCOUNT_PERMISSIONNAME_IN_USE", array($permission)); } elseif (minMaxRange(1, 50, $permission)) { $errors[] = lang("ACCOUNT_PERMISSION_CHAR_LIMIT", array(1, 50)); } else { if (updatePermissionName($permissionId, $permission)) { $successes[] = lang("PERMISSION_NAME_UPDATE", array($permission)); } else { $errors[] = lang("SQL_ERROR"); } } } //Remove access to pages if (!empty($_POST['removePermission'])) { $remove = $_POST['removePermission']; if ($deletion_count = removePermission($permissionId, $remove)) { $successes[] = lang("PERMISSION_REMOVE_USERS", array($deletion_count)); } else { $errors[] = lang("SQL_ERROR"); } } //Add access to pages if (!empty($_POST['addPermission'])) { $add = $_POST['addPermission']; if ($addition_count = addPermission($permissionId, $add)) { $successes[] = lang("PERMISSION_ADD_USERS", array($addition_count)); } else { $errors[] = lang("SQL_ERROR"); } } //Remove access to pages if (!empty($_POST['removePage'])) { $remove = $_POST['removePage']; if ($deletion_count = removePage($remove, $permissionId)) { $successes[] = lang("PERMISSION_REMOVE_PAGES", array($deletion_count)); } else { $errors[] = lang("SQL_ERROR"); } } //Add access to pages if (!empty($_POST['addPage'])) { $add = $_POST['addPage']; if ($addition_count = addPage($add, $permissionId)) { $successes[] = lang("PERMISSION_ADD_PAGES", array($addition_count)); } else { $errors[] = lang("SQL_ERROR"); } } $permissionDetails = fetchPermissionDetails($permissionId); } } $pagePermissions = fetchPermissionPages($permissionId); //Retrieve list of accessible pages $permissionUsers = fetchPermissionUsers($permissionId); //Retrieve list of users with membership $userData = fetchAllUsers(); //Fetch all users $pageData = fetchAllPages(); //Fetch all pages require_once "{$baseURL}/application/third_party/user_cake/models/header.php"; echo "\r\n<body>\r\n<div id='wrapper'>\r\n<div id='top'><div id='logo'></div></div>\r\n<div id='content'>\r\n<h1>UserCake (Via CupCake)</h1>\r\n<h2>Admin Permissions</h2>\r\n<div id='left-nav'>"; include "{$baseURL}/application/third_party/user_cake/left-nav.php"; echo "\r\n</div>\r\n<div id='main'>"; echo resultBlock($errors, $successes); echo "\r\n<form name='adminPermission' action='" . $_SERVER['PHP_SELF'] . "?id=" . $permissionId . "' method='post'>\r\n<table class='admin'>\r\n<tr><td>\r\n<h3>Permission Information</h3>\r\n<div id='regbox'>\r\n<p>\r\n<label>ID:</label>\r\n" . $permissionDetails[0]['id'] . "\r\n</p>\r\n<p>\r\n<label>Name:</label>\r\n<input type='text' name='name' value='" . $permissionDetails[0]['name'] . "' />\r\n</p>\r\n<label>Delete:</label>\r\n<input type='checkbox' name='delete[" . $permissionDetails[0]['id'] . "]' id='delete[" . $permissionDetails[0]['id'] . "]' value='" . $permissionDetails[0]['id'] . "'>\r\n</p>\r\n</div></td><td>\r\n<h3>Permission Membership</h3>\r\n<div id='regbox'>\r\n<p>\r\nRemove Members:"; //List users with permission level foreach ($userData as $v1) { if (isset($permissionUsers[$v1['id']])) { echo "<br><input type='checkbox' name='removePermission[" . $v1['id'] . "]' id='removePermission[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['display_name']; } } echo "\r\n</p><p>Add Members:"; //List users without permission level foreach ($userData as $v1) { if (!isset($permissionUsers[$v1['id']])) { echo "<br><input type='checkbox' name='addPermission[" . $v1['id'] . "]' id='addPermission[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['display_name']; } } echo "\r\n</p>\r\n</div>\r\n</td>\r\n<td>\r\n<h3>Permission Access</h3>\r\n<div id='regbox'>\r\n<p>\r\nPublic Access:"; //List public pages foreach ($pageData as $v1) { if ($v1['private'] != 1) { echo "<br>" . $v1['page']; } } echo "\r\n</p>\r\n<p>\r\nRemove Access:"; //List pages accessible to permission level foreach ($pageData as $v1) { if (isset($pagePermissions[$v1['id']]) and $v1['private'] == 1) { echo "<br><input type='checkbox' name='removePage[" . $v1['id'] . "]' id='removePage[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['page']; } } echo "\r\n</p><p>Add Access:"; //List pages inaccessible to permission level foreach ($pageData as $v1) { if (!isset($pagePermissions[$v1['id']]) and $v1['private'] == 1) { echo "<br><input type='checkbox' name='addPage[" . $v1['id'] . "]' id='addPage[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['page']; } } echo "\r\n</p>\r\n</div>\r\n</td>\r\n</tr>\r\n</table>\r\n<p>\r\n<label> </label>\r\n<input type='submit' value='Update' class='submit' />\r\n</p>\r\n</form>\r\n</div>\r\n<div id='bottom'></div>\r\n</div>\r\n</body>\r\n</html>"; }