From 5635c38ed034c0a64caa18e20db5035587aefc2a Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Thu, 4 Dec 2014 14:30:43 +0000 Subject: [PATCH] Users and Settings --- PHPCI/Controller/SettingsController.php | 41 ++++++++--------- PHPCI/Controller/UserController.php | 34 ++++++++------- PHPCI/Languages/lang.en-gb.php | 58 +++++++++++++++++++++++++ PHPCI/View/Settings/index.phtml | 32 ++++++++------ PHPCI/View/User/index.phtml | 17 ++++---- PHPCI/View/User/profile.phtml | 5 ++- 6 files changed, 127 insertions(+), 60 deletions(-) diff --git a/PHPCI/Controller/SettingsController.php b/PHPCI/Controller/SettingsController.php index 09dd6bf3..97b232ee 100644 --- a/PHPCI/Controller/SettingsController.php +++ b/PHPCI/Controller/SettingsController.php @@ -13,6 +13,7 @@ use b8; use b8\Form; use b8\HttpClient; use PHPCI\Controller; +use PHPCI\Helper\Lang; use PHPCI\Model\Build; use Symfony\Component\Yaml\Dumper; use Symfony\Component\Yaml\Parser; @@ -40,7 +41,7 @@ class SettingsController extends Controller { $this->requireAdmin(); - $this->layout->title = 'Settings'; + $this->layout->title = Lang::get('settings'); $this->view->settings = $this->settings; $emailSettings = array(); @@ -173,7 +174,7 @@ class SettingsController extends Controller $field = new Form\Element\Text('githubid'); $field->setRequired(true); $field->setPattern('[a-zA-Z0-9]+'); - $field->setLabel('Application ID'); + $field->setLabel(Lang::get('application_id')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); @@ -185,7 +186,7 @@ class SettingsController extends Controller $field = new Form\Element\Text('githubsecret'); $field->setRequired(true); $field->setPattern('[a-zA-Z0-9]+'); - $field->setLabel('Application Secret'); + $field->setLabel(Lang::get('application_secret')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); @@ -195,7 +196,7 @@ class SettingsController extends Controller } $field = new Form\Element\Submit(); - $field->setValue('Save »'); + $field->setValue(Lang::get('save')); $field->setClass('btn btn-success pull-right'); $form->addField($field); @@ -211,7 +212,7 @@ class SettingsController extends Controller $field = new Form\Element\Text('smtp_address'); $field->setRequired(false); - $field->setLabel('SMTP Server'); + $field->setLabel(Lang::get('smtp_server')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $field->setValue('localhost'); @@ -220,7 +221,7 @@ class SettingsController extends Controller $field = new Form\Element\Text('smtp_port'); $field->setRequired(false); $field->setPattern('[0-9]+'); - $field->setLabel('SMTP Port'); + $field->setLabel(Lang::get('smtp_port')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $field->setValue(25); @@ -228,42 +229,42 @@ class SettingsController extends Controller $field = new Form\Element\Text('smtp_username'); $field->setRequired(false); - $field->setLabel('SMTP Username'); + $field->setLabel(Lang::get('smtp_username')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Text('smtp_password'); $field->setRequired(false); - $field->setLabel('SMTP Password'); + $field->setLabel(Lang::get('smtp_password')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Email('from_address'); $field->setRequired(false); - $field->setLabel('From Email Address'); + $field->setLabel(Lang::get('from_email_address')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Email('default_mailto_address'); $field->setRequired(false); - $field->setLabel('Default Notification Address'); + $field->setLabel(Lang::get('default_notification_address')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Select('smtp_encryption'); - $field->setOptions(['' => 'None', 'tls' => 'TLS', 'ssl' => 'SSL']); + $field->setOptions(['' => Lang::get('none'), 'tls' => Lang::get('tls'), 'ssl' => Lang::get('ssl')]); $field->setRequired(false); - $field->setLabel('Use SMTP encryption?'); + $field->setLabel(Lang::get('use_smtp_encryption')); $field->setContainerClass('form-group'); $field->setValue(1); $form->addField($field); $field = new Form\Element\Submit(); - $field->setValue('Save »'); + $field->setValue(Lang::get('save')); $field->setClass('btn btn-success pull-right'); $form->addField($field); @@ -293,22 +294,22 @@ class SettingsController extends Controller $field = new Form\Element\Select('failed_after'); $field->setRequired(false); - $field->setLabel('Consider a build failed after'); + $field->setLabel(Lang::get('failed_after')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $field->setOptions([ - 300 => '5 Minutes', - 900 => '15 Minutes', - 1800 => '30 Minutes', - 3600 => '1 Hour', - 10800 => '3 Hours', + 300 => Lang::get('5_mins'), + 900 => Lang::get('15_mins'), + 1800 => Lang::get('30_mins'), + 3600 => Lang::get('1_hour'), + 10800 => Lang::get('3_hours'), ]); $field->setValue(1800); $form->addField($field); $field = new Form\Element\Submit(); - $field->setValue('Save »'); + $field->setValue(Lang::get('save')); $field->setClass('btn btn-success pull-right'); $form->addField($field); diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index 583381f6..5781d61a 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -14,6 +14,7 @@ use b8\Exception\HttpException\ForbiddenException; use b8\Exception\HttpException\NotFoundException; use b8\Form; use PHPCI\Controller; +use PHPCI\Helper\Lang; use PHPCI\Model\User; use PHPCI\Service\UserService; @@ -49,7 +50,7 @@ class UserController extends Controller $users = $this->userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC')); $this->view->users = $users; - $this->layout->title = 'Users'; + $this->layout->title = Lang::get('manage_users'); return $this->view->render(); } @@ -58,7 +59,8 @@ class UserController extends Controller { $user = $_SESSION['phpci_user']; - $this->layout->title = 'Edit Profile'; + $this->layout->title = $user->getName(); + $this->layout->subtitle = Lang::get('edit_profile'); if ($this->request->getMethod() == 'POST') { $name = $this->getParam('name', null); @@ -80,27 +82,27 @@ class UserController extends Controller $name = new Form\Element\Text('name'); $name->setClass('form-control'); $name->setContainerClass('form-group'); - $name->setLabel('Name'); + $name->setLabel(Lang::get('name')); $name->setRequired(true); $form->addField($name); $email = new Form\Element\Email('email'); $email->setClass('form-control'); $email->setContainerClass('form-group'); - $email->setLabel('Email Address'); + $email->setLabel(Lang::get('email_address')); $email->setRequired(true); $form->addField($email); $password = new Form\Element\Password('password'); $password->setClass('form-control'); $password->setContainerClass('form-group'); - $password->setLabel('Password (leave blank if you don\'t want to change it)'); + $password->setLabel(Lang::get('password_change')); $password->setRequired(false); $form->addField($password); $submit = new Form\Element\Submit(); $submit->setClass('btn btn-success'); - $submit->setValue('Save »'); + $submit->setValue(Lang::get('save')); $form->addField($submit); $form->setValues($values); @@ -117,7 +119,7 @@ class UserController extends Controller { $this->requireAdmin(); - $this->layout->title = 'Add User'; + $this->layout->title = Lang::get('add_user'); $method = $this->request->getMethod(); @@ -161,11 +163,11 @@ class UserController extends Controller $user = $this->userStore->getById($userId); if (empty($user)) { - throw new NotFoundException('User with ID: ' . $userId . ' does not exist.'); + throw new NotFoundException(Lang::get('user_n_not_found', $userId)); } $this->layout->title = $user->getName(); - $this->layout->subtitle = 'Edit User'; + $this->layout->subtitle = Lang::get('edit_user'); $values = array_merge($user->getDataArray(), $this->getParams()); $form = $this->userForm($values, 'edit/' . $userId); @@ -202,14 +204,14 @@ class UserController extends Controller $field = new Form\Element\Email('email'); $field->setRequired(true); - $field->setLabel('Email Address'); + $field->setLabel(Lang::get('email_address')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Text('name'); $field->setRequired(true); - $field->setLabel('Name'); + $field->setLabel(Lang::get('name')); $field->setClass('form-control'); $field->setContainerClass('form-group'); $form->addField($field); @@ -218,10 +220,10 @@ class UserController extends Controller if ($type == 'add') { $field->setRequired(true); - $field->setLabel('Password'); + $field->setLabel(Lang::get('password')); } else { $field->setRequired(false); - $field->setLabel('Password (leave blank to keep current password)'); + $field->setLabel(Lang::get('password_change')); } $field->setClass('form-control'); @@ -231,12 +233,12 @@ class UserController extends Controller $field = new Form\Element\Checkbox('is_admin'); $field->setRequired(false); $field->setCheckedValue(1); - $field->setLabel('Is this user an administrator?'); + $field->setLabel(Lang::get('is_user_admin')); $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Submit(); - $field->setValue('Save User'); + $field->setValue(Lang::get('save_user')); $field->setClass('btn-success'); $form->addField($field); @@ -254,7 +256,7 @@ class UserController extends Controller $user = $this->userStore->getById($userId); if (empty($user)) { - throw new NotFoundException('User with ID: ' . $userId . ' does not exist.'); + throw new NotFoundException(Lang::get('user_n_not_found', $userId)); } $this->userService->deleteUser($user); diff --git a/PHPCI/Languages/lang.en-gb.php b/PHPCI/Languages/lang.en-gb.php index 16059451..dc1f9578 100644 --- a/PHPCI/Languages/lang.en-gb.php +++ b/PHPCI/Languages/lang.en-gb.php @@ -198,4 +198,62 @@ PHPCI', 'build_created' => 'Build Created', 'build_started' => 'Build Started', 'build_finished' => 'Build Finished', + + // Users + 'name' => 'Name', + 'password_change' => 'Password (leave blank if you don\'t want to change)', + 'save' => 'Save »', + 'update_your_details' => 'Update your details', + 'your_details_updated' => 'Your details have been updated.', + 'add_user' => 'Add User', + 'is_admin' => 'Is Admin?', + 'yes' => 'Yes', + 'no' => 'No', + 'edit' => 'Edit', + 'edit_user' => 'Edit User', + 'delete_user' => 'Delete User', + 'user_n_not_found' => 'User with ID %d does not exist.', + 'is_user_admin' => 'Is this user an administrator?', + 'save_user' => 'Save User', + + // Settings: + 'settings_saved' => 'Your settings have been saved.', + 'settings_check_perms' => 'Your settings could not be saved, check the permissions of your config.yml file.', + 'settings_cannot_write' => 'PHPCI cannot write to your config.yml file, settings may not be saved properly + until this is rectified.', + 'settings_github_linked' => 'Your Github account has been linked.', + 'settings_github_not_linked' => 'Your Github account could not be linked.', + 'build_settings' => 'Build Settings', + 'github_application' => 'Github Application', + 'github_sign_in' => 'Before you can start using Github, you need to sign in and grant + PHPCI access to your account.', + 'github_phpci_linked' => 'PHPCI is successfully linked to Github account.', + 'github_where_to_find' => 'Where to find these...', + 'github_where_help' => 'If you own the application you would like to use, you can find this information within your + applications settings area.', + + 'email_settings' => 'Email Settings', + 'email_settings_help' => 'Before PHPCI can send build status emails, + you need to configure your SMTP settings below.', + + 'application_id' => 'Application ID', + 'application_secret' => 'Application Secret', + + 'smtp_server' => 'SMTP Server', + 'smtp_port' => 'SMTP Port', + 'smtp_username' => 'SMTP Username', + 'smtp_password' => 'SMTP Password', + 'from_email_address' => 'From Email Address', + 'default_notification_address' => 'Default Notification Email Address', + 'use_smtp_encryption' => 'Use SMTP Encryption?', + 'none' => 'None', + 'ssl' => 'SSL', + 'tls' => 'TLS', + + 'failed_after' => 'Consider a build failed after', + '5_mins' => '5 Minutes', + '15_mins' => '15 Minutes', + '30_mins' => '30 Minutes', + '1_hour' => '1 Hour', + '3_hours' => '3 Hours', ); diff --git a/PHPCI/View/Settings/index.phtml b/PHPCI/View/Settings/index.phtml index ddd49d89..7e74abff 100644 --- a/PHPCI/View/Settings/index.phtml +++ b/PHPCI/View/Settings/index.phtml @@ -1,42 +1,44 @@ + +

- Your settings have been saved. +

- Your settings could not be saved, maybe check the permissions of config.yml? +

- PHPCI cannot write to your config.yml file, settings may not be saved properly until this is rectified. +

- Your Github account has been linked. +

- Your Github account could not be linked. +

-

Build Settings

+

-

Github Application

+

@@ -53,13 +55,14 @@ ?>

- Before you can start using Github, you need to sign in and grant PHPCI access to your account. +

- PHPCI is successfully linked to Github account + + @@ -74,12 +77,13 @@

-

Where to find these...

+

-

If you own the application you would like to use, you can find this information within your - applications settings area.

+

+ +

@@ -91,13 +95,13 @@
-

Email Settings

+

- Before PHPCI can send build status emails, you need to configure your SMTP settings below. +

diff --git a/PHPCI/View/User/index.phtml b/PHPCI/View/User/index.phtml index 742e1794..15208667 100644 --- a/PHPCI/View/User/index.phtml +++ b/PHPCI/View/User/index.phtml @@ -1,6 +1,7 @@ +
- Add User +
@@ -11,9 +12,9 @@ - - - + + + @@ -24,12 +25,12 @@ { case 0: $cls = ''; - $status = 'No'; + $status = Lang::get('no'); break; case 1: $cls = 'warning'; - $status = 'Yes'; + $status = Lang::get('yes'); break; } ?> @@ -40,12 +41,12 @@
Email AddressNameAdministrator
User()->getIsAdmin()): ?>
- Edit +
diff --git a/PHPCI/View/User/profile.phtml b/PHPCI/View/User/profile.phtml index 51ff3b76..5c8b5f68 100644 --- a/PHPCI/View/User/profile.phtml +++ b/PHPCI/View/User/profile.phtml @@ -1,10 +1,11 @@ + -

Your details have been updated.

+

-

Update your details

+