index.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. if (cfr('PERMISSIONS')) {
  3. if (!ubRouting::checkPost('registernewadministrator') AND ! ubRouting::checkGet('editadministrator')) {
  4. show_window('', wf_BackLink('?module=permissions'));
  5. show_window(__('Administrator registration'), web_AdministratorRegForm());
  6. }
  7. //deletion of administrator account
  8. if (ubRouting::checkGet('deleteadministrator')) {
  9. $adminForDeletion = ubRouting::get('deleteadministrator');
  10. user_delete($adminForDeletion);
  11. log_register('UBADMIN DELETE {' . $adminForDeletion . '}');
  12. ubRouting::nav('?module=permissions');
  13. }
  14. //new administrator registration
  15. if (ubRouting::checkPost('registernewadministrator')) {
  16. if (ubRouting::checkPost(array('newadmusername', 'newadmpass', 'newadmconf', 'email'))) {
  17. $newAdmLogin = ubRouting::post('newadmusername');
  18. $newAdmNick = ubRouting::post('newadmusername'); //just similar with username
  19. $newAdmPass = ubRouting::post('newadmpass');
  20. $newAdmConfirm = ubRouting::post('newadmconf');
  21. $newAdmEmail = ubRouting::post('email');
  22. $newAdmUserData = ubRouting::post('userdata');
  23. $admRegResult = $system->registerUser($newAdmLogin, $newAdmNick, $newAdmPass, $newAdmConfirm, $newAdmEmail, $newAdmUserData);
  24. if ($admRegResult) {
  25. log_register('UBADMIN CREATE {' . $newAdmLogin . '} SUCCESS');
  26. show_success(__('Administrator registered'));
  27. $permControlLabel = web_edit_icon() . ' ' . __('His permissions you can setup via corresponding module');
  28. $permControl = wf_link('?module=permissions&edit=' . $newAdmLogin, $permControlLabel, false, 'ubButton');
  29. show_window('', $permControl);
  30. } else {
  31. show_error(__('Something went wrong') . ': ' . $system->results['registration']);
  32. log_register('UBADMIN CREATE {' . $newAdmLogin . '} FAILED');
  33. show_window('', wf_BackLink('?module=adminreg'));
  34. }
  35. } else {
  36. show_error(__('No all of required fields is filled'));
  37. show_window('', wf_BackLink('?module=adminreg'));
  38. }
  39. }
  40. //editing admins password or other data
  41. if (ubRouting::checkGet('editadministrator')) {
  42. $edAdmLogin = ubRouting::get('editadministrator');
  43. if (ubRouting::checkPost(array('save', 'edadmusername'))) {
  44. $updUsername = ubRouting::post('edadmusername');
  45. $updNickname = ubRouting::post('edadmusername'); //same as username at this moment
  46. $updPassword = ubRouting::post('edadmpass');
  47. $updConfirmation = ubRouting::post('edadmconf');
  48. $updEmail = ubRouting::post('email');
  49. $updUserData = ubRouting::post('userdata');
  50. $updateResult = $system->updateUser($updUsername, $updNickname, $updPassword, $updConfirmation, $updEmail, $updUserData, true);
  51. if ($updateResult) {
  52. log_register('UBADMIN CHANGE {' . $updUsername . '} DATA SUCCESS');
  53. ubRouting::nav('?module=adminreg&editadministrator=' . $edAdmLogin);
  54. } else {
  55. log_register('UBADMIN CHANGE {' . $updUsername . '} DATA FAIL');
  56. show_error($system->results['profileupdate']);
  57. }
  58. }
  59. show_window('', wf_BackLink('?module=permissions'));
  60. show_window(__('Edit') . ': ' . $edAdmLogin, web_AdministratorEditForm($edAdmLogin));
  61. }
  62. } else {
  63. show_error(__('Access denied'));
  64. }