From 5369c74ec0df35aa072a6067837c1d748836b96e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 18 Jul 2015 10:02:29 -0400 Subject: Add form to create remote user --- app/Controller/User.php | 4 ++- app/Locale/da_DK/translations.php | 2 ++ app/Locale/de_DE/translations.php | 2 ++ app/Locale/es_ES/translations.php | 2 ++ app/Locale/fi_FI/translations.php | 2 ++ app/Locale/fr_FR/translations.php | 2 ++ app/Locale/hu_HU/translations.php | 2 ++ app/Locale/it_IT/translations.php | 2 ++ app/Locale/ja_JP/translations.php | 2 ++ app/Locale/nl_NL/translations.php | 2 ++ app/Locale/pl_PL/translations.php | 2 ++ app/Locale/pt_BR/translations.php | 2 ++ app/Locale/ru_RU/translations.php | 2 ++ app/Locale/sr_Latn_RS/translations.php | 2 ++ app/Locale/sv_SE/translations.php | 2 ++ app/Locale/th_TH/translations.php | 2 ++ app/Locale/tr_TR/translations.php | 2 ++ app/Locale/zh_CN/translations.php | 2 ++ app/Model/User.php | 8 ++++- app/Template/user/create_local.php | 51 ++++++++++++++++++++++++++++++ app/Template/user/create_remote.php | 57 ++++++++++++++++++++++++++++++++++ app/Template/user/index.php | 3 +- app/Template/user/layout.php | 3 +- app/Template/user/new.php | 50 ----------------------------- 24 files changed, 156 insertions(+), 54 deletions(-) create mode 100644 app/Template/user/create_local.php create mode 100644 app/Template/user/create_remote.php delete mode 100644 app/Template/user/new.php (limited to 'app') diff --git a/app/Controller/User.php b/app/Controller/User.php index 189d068d..10a3a931 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -60,7 +60,9 @@ class User extends Base */ public function create(array $values = array(), array $errors = array()) { - $this->response->html($this->template->layout('user/new', array( + $is_remote = $this->request->getIntegerParam('remote') == 1 || (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1); + + $this->response->html($this->template->layout($is_remote ? 'user/create_remote' : 'user/create_local', array( 'timezones' => $this->config->getTimezones(true), 'languages' => $this->config->getLanguages(true), 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()), diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index c40574d9..5f55f3e8 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 37f759b2..90c029ba 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 7d5a3c56..ecaf8a23 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 4093947f..ddbb26c3 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 558c4f4d..1c4c76ee 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -998,4 +998,6 @@ return array( 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => 'Si vous cochez la case « Interdir le formulaire d\'authentification », les identifiants entrés dans le formulaire d\'authentification seront ignorés.', 'By @%s on Gitlab' => 'Par @%s sur Gitlab', 'Gitlab issue comment created' => 'Commentaire créé sur un ticket Gitlab', + 'New remote user' => 'Créer un utilisateur distant', + 'New local user' => 'Créer un utilisateur local', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 5d82f3e1..f1bd1453 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 5493d218..6dd60c18 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 3ced5ea1..e52f82b6 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 688f988d..ed8be05b 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index c61ec77c..9f8641a0 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index b5f4d0e0..68de0368 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 40e49952..3b7d678c 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 7a731c15..f3369341 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 73c94287..db552359 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index ae81e16a..c4d608bd 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 61210ddd..afb88744 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 37bbda95..cd2518fd 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -996,4 +996,6 @@ return array( // 'If you check the box "Disallow login form", credentials entered in the login form will be ignored.' => '', // 'By @%s on Gitlab' => '', // 'Gitlab issue comment created' => '', + // 'New remote user' => '', + // 'New local user' => '', ); diff --git a/app/Model/User.php b/app/Model/User.php index 36b7194c..b6804abc 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -377,6 +377,7 @@ class User extends Base new Validators\Unique('username', t('The username must be unique'), $this->db->getConnection(), self::TABLE, 'id'), new Validators\Email('email', t('Email address invalid')), new Validators\Integer('is_admin', t('This value must be an integer')), + new Validators\Integer('is_ldap_user', t('This value must be an integer')), ); } @@ -409,7 +410,12 @@ class User extends Base new Validators\Required('username', t('The username is required')), ); - $v = new Validator($values, array_merge($rules, $this->commonValidationRules(), $this->commonPasswordValidationRules())); + if (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1) { + $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); + } + else { + $v = new Validator($values, array_merge($rules, $this->commonValidationRules(), $this->commonPasswordValidationRules())); + } return array( $v->execute(), diff --git a/app/Template/user/create_local.php b/app/Template/user/create_local.php new file mode 100644 index 00000000..aeec300f --- /dev/null +++ b/app/Template/user/create_local.php @@ -0,0 +1,51 @@ +
+ +
+
+ + form->csrf() ?> + +
+ form->label(t('Username'), 'username') ?> + form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
+ + form->label(t('Name'), 'name') ?> + form->text('name', $values, $errors) ?>
+ + form->label(t('Email'), 'email') ?> + form->email('email', $values, $errors) ?>
+ + form->label(t('Password'), 'password') ?> + form->password('password', $values, $errors, array('required')) ?>
+ + form->label(t('Confirmation'), 'confirmation') ?> + form->password('confirmation', $values, $errors, array('required')) ?>
+
+ +
+ form->label(t('Add project member'), 'project_id') ?> + form->select('project_id', $projects, $values, $errors) ?>
+ + form->label(t('Timezone'), 'timezone') ?> + form->select('timezone', $timezones, $values, $errors) ?>
+ + form->label(t('Language'), 'language') ?> + form->select('language', $languages, $values, $errors) ?>
+ + form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> + form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> +
+ +
+ + + url->link(t('cancel'), 'user', 'index') ?> +
+
+
+
\ No newline at end of file diff --git a/app/Template/user/create_remote.php b/app/Template/user/create_remote.php new file mode 100644 index 00000000..52661585 --- /dev/null +++ b/app/Template/user/create_remote.php @@ -0,0 +1,57 @@ +
+ +
+ + form->csrf() ?> + form->hidden('is_ldap_user', array('is_ldap_user' => 1)) ?> + +
+ form->label(t('Username'), 'username') ?> + form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
+ + form->label(t('Name'), 'name') ?> + form->text('name', $values, $errors) ?>
+ + form->label(t('Email'), 'email') ?> + form->email('email', $values, $errors) ?>
+ + form->label(t('Google Id'), 'google_id') ?> + form->password('google_id', $values, $errors) ?>
+ + form->label(t('Github Id'), 'github_id') ?> + form->password('github_id', $values, $errors) ?>
+
+ +
+ form->label(t('Add project member'), 'project_id') ?> + form->select('project_id', $projects, $values, $errors) ?>
+ + form->label(t('Timezone'), 'timezone') ?> + form->select('timezone', $timezones, $values, $errors) ?>
+ + form->label(t('Language'), 'language') ?> + form->select('language', $languages, $values, $errors) ?>
+ + form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> + form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> + form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?> +
+ +
+ + + url->link(t('cancel'), 'user', 'index') ?> +
+
+
+
    +
  • +
  • +
+
+
\ No newline at end of file diff --git a/app/Template/user/index.php b/app/Template/user/index.php index fc575466..edf043a6 100644 --- a/app/Template/user/index.php +++ b/app/Template/user/index.php @@ -2,7 +2,8 @@ diff --git a/app/Template/user/layout.php b/app/Template/user/layout.php index e60ab77d..a27f359b 100644 --- a/app/Template/user/layout.php +++ b/app/Template/user/layout.php @@ -3,7 +3,8 @@ user->isAdmin()): ?> diff --git a/app/Template/user/new.php b/app/Template/user/new.php deleted file mode 100644 index 0db1e824..00000000 --- a/app/Template/user/new.php +++ /dev/null @@ -1,50 +0,0 @@ -
- -
-
- - form->csrf() ?> - -
- form->label(t('Username'), 'username') ?> - form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
- - form->label(t('Name'), 'name') ?> - form->text('name', $values, $errors) ?>
- - form->label(t('Email'), 'email') ?> - form->email('email', $values, $errors) ?>
- - form->label(t('Password'), 'password') ?> - form->password('password', $values, $errors, array('required')) ?>
- - form->label(t('Confirmation'), 'confirmation') ?> - form->password('confirmation', $values, $errors, array('required')) ?>
-
- -
- form->label(t('Add project member'), 'project_id') ?> - form->select('project_id', $projects, $values, $errors) ?>
- - form->label(t('Timezone'), 'timezone') ?> - form->select('timezone', $timezones, $values, $errors) ?>
- - form->label(t('Language'), 'language') ?> - form->select('language', $languages, $values, $errors) ?>
- - form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> - form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> -
- -
- - - url->link(t('cancel'), 'user', 'index') ?> -
-
-
-
\ No newline at end of file -- cgit v1.2.3