<?php // load all contacts $permissions = list_permissions_for_user($user_name); $sitePermissions = array(); foreach ($permissions as $per) { $a = explode("Site", $per); // permissions should be structured as "Site<site name>" if (count($a) > 1 && $a[1] != "") { // this permission contains a site name $a $sitePermissions[] = $a[1]; // append the site name to the list of sites } } if (count($sitePermissions) == 0) { echo json_encode(array("message" => "Error: no site assigned to this user")); return; } $sites = $sitePermissions; $output = array("info" => "Summary"); function cmp($a, $b) { $ad = new DateTime($a); $bd = new DateTime($b); if ($ad == $bd) { return 0; } if ($ad < $bd) { return -1; } return 1;
} if (isset($_GET['value'])) { $value = $_GET['value']; } else { $value = null; } if ($action == "create") { $id = addPermission($value); echo json_encode(array("id" => $id)); return; } else { if ($action == "remove") { if ($role == "") { removePermission($value); } else { removePermissionFromRole($role, $value); } echo json_encode(array("message" => "done")); return; } else { if ($action == "user") { echo json_encode(list_permissions_for_user($value)); return; } else { echo json_encode(list_permissions($role)); return; } } } ?>