unsubscribe_account.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once '../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('UnsubscribeFromPlatform'), 'warning');
  9. $form = new FormValidator('user_add');
  10. $form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm")))."')) return false;"));
  11. $content = $form->return_form();
  12. if ($form->validate()) {
  13. $user_info = api_get_user_info();
  14. $result = UserManager::delete_user($user_info['user_id']);
  15. if ($result) {
  16. $message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username'])));
  17. $content = null;
  18. online_logout($user_info['user_id'], false);
  19. api_not_allowed(true, $message);
  20. }
  21. }
  22. $tpl = new Template($tool_name);
  23. $tpl->assign('actions', $actions);
  24. $tpl->assign('message', $message);
  25. $tpl->assign('content', $content);
  26. $tpl->display_one_col_template();