48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Controller\ControllerBase,
|
|
App\Form\UserSettings as UserSettingsForm,
|
|
App\Model\Data\ActivityLog;
|
|
|
|
class UserController extends ControllerBase
|
|
{
|
|
public function settingsAction()
|
|
{
|
|
$user = $this->_getAuth()->getUser();
|
|
|
|
$form = new UserSettingsForm($user);
|
|
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->getPost();
|
|
|
|
if ($form->isValid($data)) {
|
|
|
|
$new_pw = $form->getValue('passwordNew');
|
|
if (strlen($new_pw) > 0) {
|
|
$hash = password_hash($new_pw, PASSWORD_BCRYPT);
|
|
$user->setPassword($hash);
|
|
}
|
|
$user->save();
|
|
$form->initialize();
|
|
|
|
$this->flash->message('success', 'Settings saved!');
|
|
} else {
|
|
$this->flash->message('error', 'Could not save settings');
|
|
}
|
|
}
|
|
|
|
$this->view->form = $form;
|
|
}
|
|
|
|
public function activityAction($page = 1)
|
|
{
|
|
$user = $this->_getAuth()->getUser();
|
|
|
|
$paginator = ActivityLog::getPaginationList($user->getId(), $page);
|
|
|
|
$this->view->page = $paginator->getPaginate();
|
|
$this->view->pagination_url = '/user/activity/';
|
|
}
|
|
}
|