The notice and info have been moved

This commit is contained in:
Michael 2022-10-17 18:55:22 +00:00
parent 20291ddc2b
commit fdfa1f8630
73 changed files with 273 additions and 284 deletions

View file

@ -74,20 +74,20 @@ class Register extends BaseModule
$block = DI::config()->get('system', 'block_extended_register');
if (local_user() && $block) {
notice(DI::l10n()->t('Permission denied.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
if (local_user()) {
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => local_user()]);
if (!empty($user['parent-uid'])) {
notice(DI::l10n()->t('Only parent users can create additional accounts.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
return '';
}
}
if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
notice(DI::l10n()->t('Permission denied.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
@ -96,7 +96,7 @@ class Register extends BaseModule
$count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
if ($count >= $max_dailies) {
Logger::notice('max daily registrations exceeded.');
notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
return '';
}
}
@ -203,19 +203,19 @@ class Register extends BaseModule
$additional_account = false;
if (!local_user() && !empty($arr['post']['parent_password'])) {
notice(DI::l10n()->t('Permission denied.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
} elseif (local_user() && !empty($arr['post']['parent_password'])) {
try {
Model\User::getIdFromPasswordAuthentication(local_user(), $arr['post']['parent_password']);
} catch (\Exception $ex) {
notice(DI::l10n()->t("Password doesn't match."));
DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match."));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
$additional_account = true;
} elseif (local_user()) {
notice(DI::l10n()->t('Please enter your password.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.'));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
@ -242,7 +242,7 @@ class Register extends BaseModule
case self::CLOSED:
default:
if (empty($_SESSION['authenticated']) && empty($_SESSION['administrator'])) {
notice(DI::l10n()->t('Permission denied.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
}
$blocked = 1;
@ -257,14 +257,14 @@ class Register extends BaseModule
// Is there text in the tar pit?
if (!empty($arr['email'])) {
Logger::info('Tar pit', $arr);
notice(DI::l10n()->t('You have entered too much information.'));
DI::sysmsg()->addNotice(DI::l10n()->t('You have entered too much information.'));
DI::baseUrl()->redirect('register/');
}
if ($additional_account) {
$user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]);
if (!DBA::isResult($user)) {
notice(DI::l10n()->t('User not found.'));
DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
DI::baseUrl()->redirect('register');
}
@ -280,7 +280,7 @@ class Register extends BaseModule
if ($arr['email'] != $arr['repeat']) {
Logger::info('Mail mismatch', $arr);
notice(DI::l10n()->t('Please enter the identical mail address in the second field.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter the identical mail address in the second field.'));
$regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
@ -292,7 +292,7 @@ class Register extends BaseModule
try {
$result = Model\User::create($arr);
} catch (\Exception $e) {
notice($e->getMessage());
DI::sysmsg()->addNotice($e->getMessage());
return;
}
@ -307,7 +307,7 @@ class Register extends BaseModule
if ($additional_account) {
DBA::update('user', ['parent-uid' => local_user()], ['uid' => $user['uid']]);
info(DI::l10n()->t('The additional account was created.'));
DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
DI::baseUrl()->redirect('delegation');
}
@ -332,28 +332,28 @@ class Register extends BaseModule
);
if ($res) {
info(DI::l10n()->t('Registration successful. Please check your email for further instructions.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful. Please check your email for further instructions.'));
DI::baseUrl()->redirect();
} else {
notice(
DI::sysmsg()->addNotice(
DI::l10n()->t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
$user['email'],
$result['password'])
);
}
} else {
info(DI::l10n()->t('Registration successful.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful.'));
DI::baseUrl()->redirect();
}
} elseif (intval(DI::config()->get('config', 'register_policy')) === self::APPROVE) {
if (!strlen(DI::config()->get('config', 'admin_email'))) {
notice(DI::l10n()->t('Your registration can not be processed.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Your registration can not be processed.'));
DI::baseUrl()->redirect();
}
// Check if the note to the admin is actually filled out
if (empty($_POST['permonlybox'])) {
notice(DI::l10n()->t('You have to leave a request note for the admin.')
DI::sysmsg()->addNotice(DI::l10n()->t('You have to leave a request note for the admin.')
. DI::l10n()->t('Your registration can not be processed.'));
DI::baseUrl()->redirect('register/');
@ -399,7 +399,7 @@ class Register extends BaseModule
$result['password']
);
info(DI::l10n()->t('Your registration is pending approval by the site owner.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Your registration is pending approval by the site owner.'));
DI::baseUrl()->redirect();
}