unsubscribe_account.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. if (api_get_setting('platform_unsubscribe_allowed') != 'true') {
  5. api_not_allowed();
  6. }
  7. $tool_name = get_lang('Unsubscribe');
  8. $message = Display::return_message(get_lang('If you want to unsubscribe completely from this campus and have all your information removed from our database, please click the button below and confirm.'), 'warning');
  9. $form = new FormValidator('user_add');
  10. $form->addElement(
  11. 'button',
  12. 'submit',
  13. get_lang('Unsubscribe'),
  14. [
  15. 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("If you want to unsubscribe completely from this campus and have all your information removed from our database, please click the button below and confirm.Confirm")))."')) return false;",
  16. ]
  17. );
  18. $content = $form->returnForm();
  19. if ($form->validate()) {
  20. $user_info = api_get_user_info();
  21. $result = UserManager::delete_user($user_info['user_id']);
  22. if ($result) {
  23. $message = Display::return_message(
  24. sprintf(
  25. get_lang('If you want to unsubscribe completely from this campus and have all your information removed from our database, please click the button below and confirm.Success'),
  26. $user_info['username']
  27. )
  28. );
  29. $content = null;
  30. online_logout($user_info['user_id'], false);
  31. api_not_allowed(true, $message);
  32. }
  33. }
  34. $tpl = new Template($tool_name);
  35. $tpl->assign('message', $message);
  36. $tpl->assign('content', $content);
  37. $tpl->display_one_col_template();