Alerts: replace 'error' class with 'danger'

This commit is contained in:
Aaron van Geffen 2023-03-11 13:30:02 +01:00
parent f9eefe7b41
commit 0366df9b5f
6 changed files with 14 additions and 14 deletions

View File

@ -123,7 +123,7 @@ class EditAlbum extends HTMLController
// Anything missing?
if (!empty($form->getMissing()))
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'error'));
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'danger'));
$data = $form->getData();
@ -140,7 +140,7 @@ class EditAlbum extends HTMLController
$data['kind'] = 'Album';
$newTag = Tag::createNew($data);
if ($newTag === false)
return $formview->adopt(new Alert('Cannot create this album', 'Something went wrong while creating the album...', 'error'));
return $formview->adopt(new Alert('Cannot create this album', 'Something went wrong while creating the album...', 'danger'));
if (isset($_POST['submit_and_new']))
{

View File

@ -115,7 +115,7 @@ class EditTag extends HTMLController
// Anything missing?
if (!empty($form->getMissing()))
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'error'));
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'danger'));
$data = $form->getData();
@ -127,7 +127,7 @@ class EditTag extends HTMLController
{
$return = Tag::createNew($data);
if ($return === false)
return $formview->adopt(new Alert('Cannot create this tag', 'Something went wrong while creating the tag...', 'error'));
return $formview->adopt(new Alert('Cannot create this tag', 'Something went wrong while creating the tag...', 'danger'));
if (isset($_POST['submit_and_new']))
{

View File

@ -129,7 +129,7 @@ class EditUser extends HTMLController
// Anything missing?
if (!empty($form->getMissing()))
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'error'));
return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'danger'));
$data = $form->getData();
@ -150,18 +150,18 @@ class EditUser extends HTMLController
// If it looks like an e-mail address...
if (!empty($data['emailaddress']) && !preg_match('~^[^ ]+@[^ ]+\.[a-z]+$~', $data['emailaddress']))
return $formview->adopt(new Alert('Email addresses invalid', 'The email address you entered is not a valid email address.', 'error'));
return $formview->adopt(new Alert('Email addresses invalid', 'The email address you entered is not a valid email address.', 'danger'));
// Check whether email address is already linked to an account in the database -- just not to the account we happen to be editing, of course.
elseif (!empty($data['emailaddress']) && Member::exists($data['emailaddress']) && !($id_user && $user->getEmailAddress() == $data['emailaddress']))
return $formview->adopt(new Alert('Email address already in use', 'Another account is already using the e-mail address you entered.', 'error'));
return $formview->adopt(new Alert('Email address already in use', 'Another account is already using the e-mail address you entered.', 'danger'));
// Setting passwords? We'll need two!
if (!$id_user || !empty($data['password1']) && !empty($data['password2']))
{
if (strlen($data['password1']) < 6 || !preg_match('~[^A-z]~', $data['password1']))
return $formview->adopt(new Alert('Password not acceptable', 'Please fill in a password that is at least six characters long and contains at least one non-alphabetic character (e.g. a number or symbol).', 'error'));
return $formview->adopt(new Alert('Password not acceptable', 'Please fill in a password that is at least six characters long and contains at least one non-alphabetic character (e.g. a number or symbol).', 'danger'));
elseif ($data['password1'] !== $data['password2'])
return $formview->adopt(new Alert('Passwords do not match', 'The passwords you entered do not match. Please try again.', 'error'));
return $formview->adopt(new Alert('Passwords do not match', 'The passwords you entered do not match. Please try again.', 'danger'));
else
$data['password'] = $data['password1'];
@ -173,7 +173,7 @@ class EditUser extends HTMLController
{
$return = Member::createNew($data);
if ($return === false)
return $formview->adopt(new Alert('Cannot create this user', 'Something went wrong while creating the user...', 'error'));
return $formview->adopt(new Alert('Cannot create this user', 'Something went wrong while creating the user...', 'danger'));
if (isset($_POST['submit_and_new']))
{

View File

@ -44,7 +44,7 @@ class Login extends HTMLController
parent::__construct('Log in - ' . SITE_TITLE);
$form = new LogInForm('Log in');
if ($login_error)
$form->adopt(new Alert('', 'Invalid email address or password.', 'error'));
$form->adopt(new Alert('', 'Invalid email address or password.', 'danger'));
// Tried anything? Be helpful, at least.
if (isset($_POST['emailaddress']))

View File

@ -48,7 +48,7 @@ class ResetPassword extends HTMLController
exit;
}
else
$form->adopt(new Alert('Some fields require your attention', '<ul><li>' . implode('</li><li>', $missing) . '</li></ul>', 'error'));
$form->adopt(new Alert('Some fields require your attention', '<ul><li>' . implode('</li><li>', $missing) . '</li></ul>', 'danger'));
}
}
else
@ -63,7 +63,7 @@ class ResetPassword extends HTMLController
$id_user = Authentication::getUserid(trim($_POST['emailaddress']));
if ($id_user === false)
{
$form->adopt(new Alert('Invalid email address', 'The email address you provided could not be found in our system. Please try again.', 'error'));
$form->adopt(new Alert('Invalid email address', 'The email address you provided could not be found in our system. Please try again.', 'danger'));
return;
}

View File

@ -50,7 +50,7 @@ class Dispatcher
public static function kickGuest($title = null, $message = null)
{
$form = new LogInForm('Log in');
$form->adopt(new Alert($title ?? '', $message ?? 'You need to be logged in to view this page.', 'error'));
$form->adopt(new Alert($title ?? '', $message ?? 'You need to be logged in to view this page.', 'danger'));
$form->setRedirectUrl($_SERVER['REQUEST_URI']);
$page = new MainTemplate('Login required');