index.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. if ($system->getAuthEnabled()) {
  3. if (cfr('ROOT')) {
  4. $userManager = new UserManager();
  5. //User deletion
  6. if (ubRouting::checkGet($userManager::ROUTE_DELETE)) {
  7. $userManager->deleteUser(ubRouting::get($userManager::ROUTE_DELETE));
  8. ubRouting::nav($userManager::URL_ME);
  9. }
  10. //User creation
  11. if (ubRouting::checkPost($userManager::PROUTE_DOREGISTER)) {
  12. //all of this props are required for normal registration
  13. $requiredParams = array(
  14. $userManager::PROUTE_USERNAME,
  15. $userManager::PROUTE_PASSWORD,
  16. $userManager::PROUTE_PASSWORDCONFIRM,
  17. $userManager::PROUTE_USERROLE,
  18. );
  19. if (ubRouting::checkPost($requiredParams)) {
  20. $registerResult = $userManager->createUser(ubRouting::post($userManager::PROUTE_USERNAME), ubRouting::post($userManager::PROUTE_PASSWORD), ubRouting::post($userManager::PROUTE_PASSWORDCONFIRM), ubRouting::post($userManager::PROUTE_USERROLE));
  21. if (empty($registerResult)) {
  22. ubRouting::nav($userManager::URL_ME);
  23. } else {
  24. show_error($registerResult);
  25. }
  26. }
  27. }
  28. //User profile editing
  29. if (ubRouting::checkPost($userManager::PROUTE_DOEDIT)) {
  30. $saveResult = $userManager->saveUser(ubRouting::post($userManager::PROUTE_DOEDIT), ubRouting::post($userManager::PROUTE_PASSWORD), ubRouting::post($userManager::PROUTE_PASSWORDCONFIRM));
  31. if (empty($saveResult)) {
  32. ubRouting::nav($userManager::URL_ME . '&' . $userManager::ROUTE_EDIT . '=' . ubRouting::post($userManager::PROUTE_DOEDIT));
  33. } else {
  34. show_error($saveResult);
  35. }
  36. }
  37. //User permissions/rights editing
  38. if (ubRouting::checkPost($userManager::PROUTE_DOPERMS)) {
  39. $permEditResult = $userManager->savePermissions();
  40. if (empty($permEditResult)) {
  41. ubRouting::nav($userManager::URL_ME . '&' . $userManager::ROUTE_PERMISSIONS . '=' . ubRouting::post($userManager::PROUTE_DOPERMS));
  42. } else {
  43. show_error($permEditResult);
  44. }
  45. }
  46. if (!ubRouting::checkGet($userManager::ROUTE_EDIT) AND ! ubRouting::checkGet($userManager::ROUTE_PERMISSIONS) AND ! ubRouting::checkGet($userManager::ROUTE_NEWUSER)) {
  47. //rendering existing users list
  48. show_window(__('Available users'), $userManager->renderUsersList());
  49. } else {
  50. //rendering user data edit interface
  51. if (ubRouting::checkGet($userManager::ROUTE_EDIT)) {
  52. show_window(__('Edit user') . ' ' . ubRouting::get($userManager::ROUTE_EDIT), $userManager->renderEditForm(ubRouting::get($userManager::ROUTE_EDIT)));
  53. show_window('', wf_BackLink($userManager::URL_ME));
  54. }
  55. //rendering user permissions edit interface
  56. if (ubRouting::checkGet($userManager::ROUTE_PERMISSIONS)) {
  57. show_window(__('Edit user permissions') . ' ' . ubRouting::get($userManager::ROUTE_PERMISSIONS), $userManager->renderPermissionsForm(ubRouting::get($userManager::ROUTE_PERMISSIONS)));
  58. show_window('', wf_BackLink($userManager::URL_ME));
  59. }
  60. //rendering new user creation form
  61. if (ubRouting::checkGet($userManager::ROUTE_NEWUSER)) {
  62. show_window(__('Register new user'), $userManager->renderRegisterForm());
  63. show_window('', wf_BackLink($userManager::URL_ME));
  64. }
  65. }
  66. } else {
  67. show_error(__('Access denied'));
  68. }
  69. } else {
  70. show_error(__('Authorization engine disabled'));
  71. }