Users and Settings
This commit is contained in:
parent
cfe4566af2
commit
5635c38ed0
6 changed files with 127 additions and 60 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue