user.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. $permissions = json_decode($row['Permissions']);
  3. $available = array("edit.Page", "edit.Users", "edit.Section", "edit.Menu", "edit.CSS",
  4. "new.Page", "new.Users", "new.Section", "new.Menu",
  5. "delete.Page", "delete.Users", "delete.Section", "delete.Menu",
  6. "list.Page", "list.Users", "list.Section", "list.Menu", "rsps");
  7. $forbidden = array_diff($available, $permissions->custom_permissions);
  8. ?>
  9. Permission level: <input id="level" value="<?php echo $permissions->permission_level ?>">
  10. <br />
  11. <div class="sort permlist" id="forbid">
  12. <h3>Forbidden</h3>
  13. <ul class="permlist">
  14. <?php
  15. foreach ($forbidden as $permission) {
  16. echo "<li id='$permission'>$permission</li>";
  17. }
  18. ?>
  19. </ul>
  20. </div>
  21. <div class="sort" id="allow">
  22. <h3>Allowed</h3>
  23. <ul class="permlist">
  24. <?php
  25. foreach ($permissions->custom_permissions as $permission) {
  26. echo "<li id='$permission'>$permission</li>";
  27. }
  28. ?>
  29. </ul>
  30. </div>
  31. <script>
  32. function updatePermissions() {
  33. var allowed = $('#allow ul').sortable("toArray");
  34. console.log($("#level").val());
  35. $.post("actions/updatePermissions.php?uid=<?php echo $uid ?>", {level: $("#level").val(), custom: JSON.stringify(allowed)}, function(theResponse){
  36. display_message(theResponse);
  37. });
  38. }
  39. $(document).ready(function() {
  40. $('div.sort li').disableSelection();
  41. $('#forbid ul').sortable({
  42. revert: 'invalid',
  43. connectWith: "#allow ul",
  44. cursor: 'move'
  45. });
  46. $('#allow ul').sortable({
  47. revert: 'invalid',
  48. connectWith: "#forbid ul",
  49. cursor: 'move',
  50. update: updatePermissions
  51. });
  52. $('#level').spinner().change(updatePermissions);
  53. });
  54. </script>