diff --git a/plugins/box/users/users.admin.php b/plugins/box/users/users.admin.php
index 4c3b63b..964b54a 100644
--- a/plugins/box/users/users.admin.php
+++ b/plugins/box/users/users.admin.php
@@ -67,17 +67,22 @@
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
+ // Errors
$errors = array();
+
if (Request::post('register')) {
if (Security::check(Request::post('csrf'))) {
- $user_login = trim(Request::post('login'));
+ $user_login = trim(Request::post('login'));
$user_password = trim(Request::post('password'));
+ $user_email = trim(Request::post('email'));
+
if ($user_login == '') $errors['users_empty_login'] = __('Required field', 'users');
if ($user_password == '') $errors['users_empty_password'] = __('Required field', 'users');
- $user = $users->select("[login='".$user_login."']");
- if ($user != null) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
+ if ($user_email == '') $errors['users_empty_email'] = __('Required field', 'users');
+ if ($users->select("[login='".$user_login."']")) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
+ if ($users->select("[email='".$user_email."']")) $errors['users_this_email_alredy_exists'] = __('This email alredy exist', 'users');
if (count($errors) == 0) {
$users->insert(array('login' => Security::safeName($user_login),
diff --git a/plugins/box/users/views/backend/add.view.php b/plugins/box/users/views/backend/add.view.php
index 057111c..20955f2 100644
--- a/plugins/box/users/views/backend/add.view.php
+++ b/plugins/box/users/views/backend/add.view.php
@@ -10,7 +10,7 @@
Form::input('login', null, array('class' => (isset($errors['users_this_user_alredy_exists']) || isset($errors['users_empty_login'])) ? 'span3 error-field' : 'span3'))
);
- if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).''.$errors['users_this_user_alredy_exists'].'';
+ if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).''.$errors['users_this_user_alredy_exists'].'';
if (isset($errors['users_empty_login'])) echo Html::nbsp(3).''.$errors['users_empty_login'].'';
echo (
@@ -22,7 +22,13 @@
echo (
Form::label('email', __('Email', 'users')).
- Form::input('email', null, array('class' => 'span3')). Html::br().
+ Form::input('email', null, array('class' => (isset($errors['users_this_email_alredy_exists']) || isset($errors['users_empty_email'])) ? 'span3 error-field' : 'span3'))
+ );
+
+ if (isset($errors['users_this_email_alredy_exists'])) echo Html::nbsp(3).''.$errors['users_this_email_alredy_exists'].'';
+ if (isset($errors['users_empty_email'])) echo Html::nbsp(3).''.$errors['users_empty_email'].'';
+
+ echo(
Form::label('role', __('Role', 'users')).
Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), null, array('class' => 'span3')). Html::br(2).
Form::submit('register', __('Register', 'users'), array('class' => 'btn default')).