19declare(strict_types=1);
32 private readonly \
ilCtrl $ctrl,
35 private readonly UIFactory $ui_factory,
36 private readonly UIRenderer $ui_renderer,
48 $this->tpl->setTitle($this->
lng->txt(
'user_delete_own_account'));
49 $cmd = $this->
ctrl->getCmd(
'showGeneralSettings');
50 $this->$cmd() .
'Cmd';
55 if (!(
bool) $this->
settings->get(
'user_delete_own_account') ||
57 $this->
ctrl->redirectByClass(
58 [\ilDashboardGUI::class, PersonalSettingsGUI::class],
64 $this->current_user->removeDeletionFlag();
66 $modal = $this->ui_factory->modal()->interruptive(
67 $this->
lng->txt(
'user_delete_own_account'),
68 $this->lng->txt(
'user_delete_own_account_logout_confirmation'),
69 $this->ctrl->getFormActionByClass(self::class,
'deleteOwnAccountLogout')
70 )->withActionButtonLabel($this->
lng->txt(
'user_delete_own_account_logout_button'));
72 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'user_delete_own_account_info'));
74 $this->ui_factory->button()->standard(
75 $this->lng->txt(
'btn_next'),
76 $modal->getShowSignal()
80 $this->tpl->setContent($this->ui_renderer->render($modal));
82 $this->tpl->printToStdout();
87 $this->current_user->removeDeletionFlag();
89 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'user_delete_own_account_aborted'),
true);
90 $this->
ctrl->redirect($this,
'showGeneralSettings');
95 $this->current_user->activateDeletionFlag();
98 $this->auth_session->logout();
100 $this->
ctrl->redirectToURL(
101 'login.php?cmd=force_login&target=usr_'
109 !(
bool) $this->
settings->get(
'user_delete_own_account') ||
111 !$this->current_user->hasDeletionFlag()
113 $this->
ctrl->redirect($this,
'showGeneralSettings');
116 $this->tpl->setOnScreenMessage(
118 $this->
lng->txt(
'user_delete_own_account_final_confirmation')
122 $this->ui_factory->button()->standard(
123 $this->lng->txt(
'confirm'),
124 $this->ctrl->getLinkTargetByClass(self::class,
'deleteOwnAccountStep3')
129 $this->ui_factory->button()->standard(
130 $this->lng->txt(
'cancel'),
131 $this->ctrl->getLinkTargetByClass(self::class,
'abortDeleteOwnAccount')
134 $this->tpl->printToStdout();
140 !(
bool) $this->
settings->get(
'user_delete_own_account') ||
142 !$this->current_user->hasDeletionFlag()
144 $this->
ctrl->redirect($this,
'showGeneralSettings');
149 $ntf = new \ilSystemNotification();
150 $ntf->setLangModules([
'user']);
151 $ntf->addAdditionalInfo(
'profile', $this->current_user->getProfileAsString($this->lng),
true);
155 $ntf->setIntroductionDirect(
157 $this->
lng->txt(
'user_delete_own_account_email_body'),
158 $this->current_user->getLogin(),
164 $message = $ntf->composeAndGetMessage($this->current_user->getId(),
null,
'read',
true);
165 $subject = $this->
lng->txt(
'user_delete_own_account_email_subject');
168 $user_email = $this->current_user->getEmail();
169 $admin_mail = $this->
settings->get(
'user_delete_own_account_email');
171 $mmail = new \ilMimeMail();
172 $mmail->From($this->mail_sender_factory->system());
174 if ($user_email !==
'') {
175 $mmail->To($user_email);
176 $mmail->Bcc($admin_mail);
177 $mmail->Subject($subject,
true);
178 $mmail->Body($message);
180 } elseif ($admin_mail !==
null || $admin_mail !==
'') {
181 $mmail->To($admin_mail);
182 $mmail->Subject($subject,
true);
183 $mmail->Body($message);
187 $this->log->root()->log(
'Account deleted: ' . $this->current_user->getLogin() .
' (' . $this->current_user->getId() .
')');
189 $this->current_user->delete();
192 $this->auth_session->logout();
193 $this->
ctrl->redirectToURL(
'login.php?accdel=1');
Provides fluid interface to LoggingServices.
Builds a Color from either hex- or rgb values.
__construct(private readonly \ilCtrl $ctrl, private readonly Language $lng, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly \ilToolbarGUI $toolbar, private readonly LoggingServices $log, private readonly \ilMailMimeSenderFactory $mail_sender_factory, private readonly \ilSetting $settings, private readonly \ilAuthSession $auth_session, private readonly \ilObjUser $current_user)
const DEL_OWN_ACCOUNT_OPERATION
Class ilCtrl provides processing control methods.
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static setClosingContext(int $a_context)
set closing context (for statistics)
const int SESSION_CLOSE_USER
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
An entity that renders components to a string output.