index.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. //flushing IM cache
  13. $ubCache = new UbillingCache();
  14. $ubCache->delete('UBIM_ADM_LIST');
  15. $ubCache->delete('EMPLOYEE_LOGINS');
  16. $ubCache->delete('ADM_ONLINE');
  17. ubRouting::nav('?module=permissions');
  18. }
  19. //new administrator registration
  20. if (ubRouting::checkPost('registernewadministrator')) {
  21. if (ubRouting::checkPost(array('newadmusername', 'newadmpass', 'newadmconf', 'email'))) {
  22. $newAdmLogin = ubRouting::post('newadmusername');
  23. $newAdmNick = ubRouting::post('newadmusername'); //just similar with username
  24. $newAdmPass = ubRouting::post('newadmpass');
  25. $newAdmConfirm = ubRouting::post('newadmconf');
  26. $newAdmEmail = ubRouting::post('email');
  27. $newAdmUserData = ubRouting::post('userdata');
  28. $admRegResult = $system->registerUser($newAdmLogin, $newAdmNick, $newAdmPass, $newAdmConfirm, $newAdmEmail, $newAdmUserData);
  29. if ($admRegResult) {
  30. log_register('UBADMIN CREATE {' . $newAdmLogin . '} SUCCESS');
  31. show_success(__('Administrator registered'));
  32. $permControlLabel = web_edit_icon() . ' ' . __('His permissions you can setup via corresponding module');
  33. $permControl = wf_link('?module=permissions&edit=' . $newAdmLogin, $permControlLabel, false, 'ubButton');
  34. show_window('', $permControl);
  35. //flushing IM cache
  36. $ubCache = new UbillingCache();
  37. $ubCache->delete('UBIM_ADM_LIST');
  38. $ubCache->delete('EMPLOYEE_LOGINS');
  39. $ubCache->delete('ADM_ONLINE');
  40. } else {
  41. show_error(__('Something went wrong') . ': ' . $system->results['registration']);
  42. log_register('UBADMIN CREATE {' . $newAdmLogin . '} FAILED');
  43. show_window('', wf_BackLink('?module=adminreg'));
  44. }
  45. } else {
  46. show_error(__('No all of required fields is filled'));
  47. show_window('', wf_BackLink('?module=adminreg'));
  48. }
  49. }
  50. //editing admins password or other data
  51. if (ubRouting::checkGet('editadministrator')) {
  52. $edAdmLogin = ubRouting::get('editadministrator');
  53. if (ubRouting::checkPost(array('save', 'edadmusername'))) {
  54. $updUsername = ubRouting::post('edadmusername');
  55. $updNickname = ubRouting::post('edadmusername'); //same as username at this moment
  56. $updPassword = ubRouting::post('edadmpass');
  57. $updConfirmation = ubRouting::post('edadmconf');
  58. $updEmail = ubRouting::post('email');
  59. $updUserData = ubRouting::post('userdata');
  60. $updateResult = $system->updateUser($updUsername, $updNickname, $updPassword, $updConfirmation, $updEmail, $updUserData, true);
  61. if ($updateResult) {
  62. log_register('UBADMIN CHANGE {' . $updUsername . '} DATA SUCCESS');
  63. ubRouting::nav('?module=adminreg&editadministrator=' . $edAdmLogin);
  64. } else {
  65. log_register('UBADMIN CHANGE {' . $updUsername . '} DATA FAIL');
  66. show_error($system->results['profileupdate']);
  67. }
  68. }
  69. show_window('', wf_BackLink('?module=permissions'));
  70. show_window(__('Edit') . ': ' . $edAdmLogin, web_AdministratorEditForm($edAdmLogin));
  71. }
  72. } else {
  73. show_error(__('Access denied'));
  74. }