mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-15 04:46:49 +01:00
* [MOD] Improved account's history view
This commit is contained in:
@@ -109,7 +109,6 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
} catch (\Exception $e) {
|
||||
debugLog($e->getMessage(), true);
|
||||
|
||||
// FIXME
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
@@ -129,14 +128,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
->withTagsById($accountDetailsResponse);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccount(
|
||||
|
||||
if (!$AccountHelper->setAccount(
|
||||
$accountDetailsResponse,
|
||||
$this->accountService,
|
||||
ActionsInterface::ACCOUNT_VIEW
|
||||
);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,14 +332,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
->withTagsById($accountDetailsResponse);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccount(
|
||||
|
||||
if (!$AccountHelper->setAccount(
|
||||
$accountDetailsResponse,
|
||||
$this->accountService,
|
||||
ActionsInterface::ACCOUNT_COPY
|
||||
);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,14 +378,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
->withTagsById($accountDetailsResponse);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccount(
|
||||
|
||||
if (!$AccountHelper->setAccount(
|
||||
$accountDetailsResponse,
|
||||
$this->accountService,
|
||||
ActionsInterface::ACCOUNT_EDIT
|
||||
);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -432,14 +425,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
->withUserGroupsById($accountDetailsResponse);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccount(
|
||||
|
||||
if (!$AccountHelper->setAccount(
|
||||
$accountDetailsResponse,
|
||||
$this->accountService,
|
||||
ActionsInterface::ACCOUNT_DELETE
|
||||
);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -479,14 +470,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
->withUserGroupsById($accountDetailsResponse);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccount(
|
||||
|
||||
if (!$AccountHelper->setAccount(
|
||||
$accountDetailsResponse,
|
||||
$this->accountService,
|
||||
ActionsInterface::ACCOUNT_EDIT_PASS
|
||||
);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -520,16 +509,21 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
public function viewHistoryAction($id)
|
||||
{
|
||||
try {
|
||||
$accountHistoryService = new AccountHistoryService();
|
||||
$accountHistoryData = $accountHistoryService->getById($id);
|
||||
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
|
||||
$AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_VIEW_HISTORY);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess()) {
|
||||
if (!$AccountHelper->setAccountHistory(
|
||||
$accountHistoryService,
|
||||
$accountHistoryData,
|
||||
ActionsInterface::ACCOUNT_VIEW_HISTORY)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->addTemplate('account-history');
|
||||
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleNormal',
|
||||
@@ -537,11 +531,10 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
'icon' => 'access_time'
|
||||
]
|
||||
);
|
||||
|
||||
$this->view->assign('formRoute', 'account/saveRestore');
|
||||
$this->view->assign('isView', true);
|
||||
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.history', $this);
|
||||
} catch (\Exception $e) {
|
||||
debugLog($e->getMessage(), true);
|
||||
@@ -639,6 +632,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
|
||||
/**
|
||||
* Saves copy action
|
||||
*
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveCopyAction()
|
||||
{
|
||||
@@ -647,6 +642,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
|
||||
/**
|
||||
* Saves create action
|
||||
*
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveCreateAction()
|
||||
{
|
||||
@@ -682,6 +679,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
* Saves edit action
|
||||
*
|
||||
* @param $id Account's ID
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveEditAction($id)
|
||||
{
|
||||
@@ -716,6 +714,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
* Saves edit action
|
||||
*
|
||||
* @param $id Account's ID
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveEditPassAction($id)
|
||||
{
|
||||
@@ -749,6 +748,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
*
|
||||
* @param int $historyId Account's history ID
|
||||
* @param int $id Account's ID
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveEditRestoreAction($historyId, $id)
|
||||
{
|
||||
@@ -783,9 +783,6 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
if ($this->accountService->delete($id)) {
|
||||
$this->deleteCustomFieldsForItem(ActionsInterface::ACCOUNT, $id);
|
||||
|
||||
// FIXME: obtener cuenta antes de eliminar
|
||||
// $accountRepository->logAccountAction($id, ActionsInterface::ACCOUNT_DELETE);
|
||||
|
||||
$this->eventDispatcher->notifyEvent('delete.account', $this);
|
||||
|
||||
$this->returnJsonResponseData(
|
||||
@@ -803,6 +800,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
|
||||
|
||||
/**
|
||||
* Initialize class
|
||||
*
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
|
||||
@@ -28,13 +28,13 @@ use SP\Account\AccountAcl;
|
||||
use SP\Core\Acl\Acl;
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\DataModel\AccountHistoryData;
|
||||
use SP\DataModel\Dto\AccountAclDto;
|
||||
use SP\DataModel\Dto\AccountDetailsResponse;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Mgmt\Users\UserPass;
|
||||
use SP\Modules\Web\Controllers\Traits\ItemTrait;
|
||||
use SP\Mvc\View\Components\SelectItemAdapter;
|
||||
use SP\Repositories\Account\AccountHistoryRepository;
|
||||
use SP\Repositories\PublicLink\PublicLinkRepository;
|
||||
use SP\Services\Account\AccountHistoryService;
|
||||
use SP\Services\Account\AccountService;
|
||||
use SP\Services\Category\CategoryService;
|
||||
@@ -63,6 +63,10 @@ class AccountHelper extends HelperBase
|
||||
* @var AccountService
|
||||
*/
|
||||
protected $accountService;
|
||||
/**
|
||||
* @var AccountHistoryService
|
||||
*/
|
||||
protected $accountHistoryService;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -99,148 +103,94 @@ class AccountHelper extends HelperBase
|
||||
/**
|
||||
* Establecer las variables que contienen la información de la cuenta en una fecha concreta.
|
||||
*
|
||||
* @param $accountHistoryId
|
||||
* @param $actionId
|
||||
* @param AccountHistoryService $accountHistoryService
|
||||
* @param AccountHistoryData $accountHistoryData
|
||||
* @param int $actionId
|
||||
* @return bool
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function setAccountDataHistory($accountHistoryId, $actionId)
|
||||
public function setAccountHistory(AccountHistoryService $accountHistoryService, AccountHistoryData $accountHistoryData, $actionId)
|
||||
{
|
||||
$this->accountHistoryId = $accountHistoryId;
|
||||
|
||||
$this->actionId = $actionId;
|
||||
$this->isHistory = true;
|
||||
$this->accountHistoryId = $accountHistoryData->getId();
|
||||
$this->accountId = $accountHistoryData->getAccountId();
|
||||
$this->accountHistoryService = $accountHistoryService;
|
||||
|
||||
// FIXME
|
||||
$this->accountService = new AccountHistoryService();
|
||||
$this->accountDetailsResponse = $this->accountService->getById($accountHistoryId);
|
||||
$this->accountId = $this->accountDetailsResponse->getId();
|
||||
if (!$this->checkAccessHistory($accountHistoryData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->view->assign('accountData', $accountHistoryData);
|
||||
$this->view->assign('accountAcl', $this->accountAcl);
|
||||
$this->view->assign('actionId', $this->actionId);
|
||||
$this->view->assign('accountId', $this->accountId);
|
||||
$this->view->assign('accountData', $this->accountDetailsResponse);
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
$this->view->assign('accountHistoryId', $accountHistoryId);
|
||||
$this->view->assign('accountHistoryId', $this->accountHistoryId);
|
||||
$this->view->assign('historyData', $this->accountHistoryService->getHistoryForAccount($this->accountId));
|
||||
$this->view->assign('accountIsHistory', true);
|
||||
$this->view->assign('accountPassDate', date('Y-m-d H:i:s', $accountHistoryData->getPassDate()));
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', $accountHistoryData->getPassDateChange() ?: 0));
|
||||
$this->view->assign('categories', (new SelectItemAdapter(CategoryService::getItemsBasic()))->getItemsFromModelSelected([$accountHistoryData->getCategoryId()]));
|
||||
$this->view->assign('clients', (new SelectItemAdapter(ClientService::getItemsBasic()))->getItemsFromModelSelected([$accountHistoryData->getClientId()]));
|
||||
$this->view->assign('isModified', strtotime($accountHistoryData->getDateEdit()) !== false);
|
||||
$this->view->assign('actions', $this->getActions($accountHistoryData->getParentId()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private function isGotData()
|
||||
{
|
||||
return $this->accountDetailsResponse !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountAcl
|
||||
*/
|
||||
public function getAccountAcl()
|
||||
{
|
||||
return $this->accountAcl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAccountId()
|
||||
{
|
||||
return $this->accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer variables comunes del formulario para todos los interfaces
|
||||
* Comprobar si el usuario dispone de acceso al módulo
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @param AccountHistoryData $accountHistoryData
|
||||
* @return bool
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function setCommonData()
|
||||
public function checkAccessHistory(AccountHistoryData $accountHistoryData)
|
||||
{
|
||||
if ($this->accountService === null) {
|
||||
$this->accountService = new AccountService();
|
||||
$this->view->assign('showLogo', false);
|
||||
|
||||
if (!$this->acl->checkUserAccess($this->actionId)) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$userProfileData = $this->session->getUserProfile();
|
||||
if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getId())) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_UPDATE_MPASS);
|
||||
|
||||
if ($this->isGotData()) {
|
||||
$accountData = $this->accountDetailsResponse->getAccountVData();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->view->assign('accountIsHistory', $this->isHistory);
|
||||
$this->view->assign('accountOtherUsers', $this->accountDetailsResponse->getUsers());
|
||||
$this->view->assign('accountOtherGroups', $this->accountDetailsResponse->getUserGroups());
|
||||
$this->view->assign('accountTags', $this->accountDetailsResponse->getTags());
|
||||
$this->view->assign('accountTagsJson', Json::getJson(array_keys($this->accountDetailsResponse->getTags())));
|
||||
if ($this->accountId > 0) {
|
||||
$acccountAclDto = new AccountAclDto();
|
||||
$acccountAclDto->setAccountId($accountHistoryData->getAccountId());
|
||||
$acccountAclDto->setDateEdit(strtotime($accountHistoryData->getDateEdit()));
|
||||
$acccountAclDto->setUserId($accountHistoryData->getUserId());
|
||||
$acccountAclDto->setUserGroupId($accountHistoryData->getUserGroupId());
|
||||
$acccountAclDto->setUsersId($this->accountHistoryService->getUsersByAccountId($this->accountId));
|
||||
$acccountAclDto->setUserGroupsId($this->accountHistoryService->getUserGroupsByAccountId($this->accountId));
|
||||
|
||||
$accountHistoryService = new AccountHistoryRepository();
|
||||
$this->view->assign('historyData', $accountHistoryService->getHistoryForAccount($this->accountId));
|
||||
$this->accountAcl = (new AccountAcl($this->actionId, true))->getAcl($acccountAclDto);
|
||||
|
||||
$this->view->assign('isModified', strtotime($accountData->getDateEdit()) !== false);
|
||||
$this->view->assign('maxFileSize', round($this->configData->getFilesAllowedSize() / 1024, 1));
|
||||
$this->view->assign('filesAllowedExts', implode(',', $this->configData->getFilesAllowedExts()));
|
||||
if (!$this->accountAcl->checkAccountAccess()) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_ACCOUNT_NO_PERMISSION);
|
||||
|
||||
if ($this->configData->isPublinksEnabled() && $this->accountAcl->isShowLink()) {
|
||||
$publicLinkService = new PublicLinkRepository();
|
||||
$publicLinkData = $publicLinkService->getHashForItem($this->accountId);
|
||||
|
||||
$publicLinkUrl = $publicLinkData ? PublicLinkService::getLinkForHash($publicLinkData->getHash()) : null;
|
||||
$this->view->assign('publicLinkUrl', $publicLinkUrl);
|
||||
$this->view->assign('publicLinkId', $publicLinkData ? $publicLinkData->getId() : 0);
|
||||
$this->view->assign('publicLinkShow', true);
|
||||
} else {
|
||||
$this->view->assign('publicLinkShow', false);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->view->assign('accountPassDate', date('Y-m-d H:i:s', $accountData->getPassDate()));
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', $accountData->getPassDateChange() ?: 0));
|
||||
} else {
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', time() + 7776000));
|
||||
}
|
||||
|
||||
|
||||
$this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::ACCOUNT, $this->accountId));
|
||||
$this->view->assign('actionId', Acl::getActionRoute($this->actionId));
|
||||
|
||||
$this->view->assign('categories', (new SelectItemAdapter(CategoryService::getItemsBasic()))->getItemsFromModel());
|
||||
|
||||
$this->view->assign('clients', (new SelectItemAdapter(ClientService::getItemsBasic()))->getItemsFromModel());
|
||||
|
||||
$userItemAdapter = new SelectItemAdapter(UserService::getItemsBasic());
|
||||
|
||||
$this->view->assign('otherUsers', $userItemAdapter->getItemsFromModel());
|
||||
$this->view->assign('otherUsersJson', $userItemAdapter->getJsonItemsFromModel());
|
||||
|
||||
$userGroupItemAdapter = new SelectItemAdapter(UserGroupService::getItemsBasic());
|
||||
|
||||
$this->view->assign('otherGroups', $userGroupItemAdapter->getItemsFromModel());
|
||||
$this->view->assign('otherGroupsJson', $userGroupItemAdapter->getJsonItemsFromModel());
|
||||
|
||||
$tagItemAdapter = new SelectItemAdapter(TagService::getItemsBasic());
|
||||
|
||||
$this->view->assign('tagsJson', $tagItemAdapter->getJsonItemsFromModel());
|
||||
$this->view->assign('allowPrivate', $userProfileData->isAccPrivate());
|
||||
$this->view->assign('allowPrivateGroup', $userProfileData->isAccPrivateGroup());
|
||||
$this->view->assign('mailRequestEnabled', $this->configData->isMailRequestsEnabled());
|
||||
$this->view->assign('passToImageEnabled', $this->configData->isAccountPassToImage());
|
||||
|
||||
$this->view->assign('otherAccounts', $this->accountService->getForUser($this->accountId));
|
||||
$this->view->assign('linkedAccounts', $this->accountService->getLinked($this->accountId));
|
||||
|
||||
$this->view->assign('addClientEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CLIENT));
|
||||
$this->view->assign('addClientRoute', Acl::getActionRoute(ActionsInterface::CLIENT_CREATE));
|
||||
|
||||
$this->view->assign('addCategoryEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CATEGORY));
|
||||
$this->view->assign('addCategoryRoute', Acl::getActionRoute(ActionsInterface::CATEGORY_CREATE));
|
||||
|
||||
$this->view->assign('disabled', $this->view->isView ? 'disabled' : '');
|
||||
$this->view->assign('readonly', $this->view->isView ? 'readonly' : '');
|
||||
|
||||
$this->view->assign('showViewCustomPass', $this->accountAcl->isShowViewPass());
|
||||
$this->view->assign('AccountAcl', $this->accountAcl);
|
||||
$this->view->assign('actions', $this->getActions());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icons for view
|
||||
*
|
||||
* @param int $parentId
|
||||
* @return DataGridAction[]
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
protected function getActions()
|
||||
protected function getActions($parentId = 0)
|
||||
{
|
||||
$actionsEnabled = [];
|
||||
|
||||
@@ -264,9 +214,9 @@ class AccountHelper extends HelperBase
|
||||
}
|
||||
|
||||
if ($this->isHistory === false
|
||||
&& $parentId === 0
|
||||
&& $this->accountAcl->isShowLink()
|
||||
&& $this->accountAcl->isShowViewPass()
|
||||
&& $this->accountDetailsResponse->getAccountVData()->getParentId() === 0
|
||||
) {
|
||||
if (null === $this->view->publicLinkUrl) {
|
||||
$actionsEnabled[] = $actions->getPublicLinkAction();
|
||||
@@ -279,8 +229,8 @@ class AccountHelper extends HelperBase
|
||||
$actionViewPass = $actions->getViewPassAction();
|
||||
$actionCopy = $actions->getCopyPassAction();
|
||||
|
||||
$actionViewPass->addData('parent-id', $this->accountDetailsResponse->getAccountVData()->getParentId());
|
||||
$actionCopy->addData('parent-id', $this->accountDetailsResponse->getAccountVData()->getParentId());
|
||||
$actionViewPass->addData('parent-id', $parentId);
|
||||
$actionCopy->addData('parent-id', $parentId);
|
||||
|
||||
$actionViewPass->addData('history', (int)$this->isHistory);
|
||||
$actionCopy->addData('history', (int)$this->isHistory);
|
||||
@@ -332,51 +282,111 @@ class AccountHelper extends HelperBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si el usuario dispone de acceso al módulo
|
||||
* @return AccountAcl
|
||||
*/
|
||||
public function getAccountAcl()
|
||||
{
|
||||
return $this->accountAcl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAccountId()
|
||||
{
|
||||
return $this->accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer variables comunes del formulario para todos los interfaces
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function checkAccess()
|
||||
public function setCommonData()
|
||||
{
|
||||
$this->view->assign('showLogo', false);
|
||||
$userProfileData = $this->session->getUserProfile();
|
||||
|
||||
$acl = new AccountAcl($this->actionId, $this->isHistory);
|
||||
$this->accountAcl = $acl;
|
||||
|
||||
if (!$this->acl->checkUserAccess($this->actionId)) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getId())) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_UPDATE_MPASS);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->accountId > 0) {
|
||||
if ($this->isGotData()) {
|
||||
$accountData = $this->accountDetailsResponse->getAccountVData();
|
||||
|
||||
$acccountAclDto = new AccountAclDto();
|
||||
$acccountAclDto->setAccountId($accountData->getId());
|
||||
$acccountAclDto->setDateEdit($accountData->getDateEdit());
|
||||
$acccountAclDto->setUserId($accountData->getUserId());
|
||||
$acccountAclDto->setUserGroupId($accountData->getUserGroupId());
|
||||
$acccountAclDto->setUsersId($this->accountDetailsResponse->getUsers());
|
||||
$acccountAclDto->setUserGroupsId($this->accountDetailsResponse->getUserGroups());
|
||||
$this->view->assign('accountIsHistory', $this->isHistory);
|
||||
$this->view->assign('accountOtherUsers', $this->accountDetailsResponse->getUsers());
|
||||
$this->view->assign('accountOtherGroups', $this->accountDetailsResponse->getUserGroups());
|
||||
$this->view->assign('accountTags', $this->accountDetailsResponse->getTags());
|
||||
$this->view->assign('accountTagsJson', Json::getJson(array_keys($this->accountDetailsResponse->getTags())));
|
||||
|
||||
$this->accountAcl = $acl->getAcl($acccountAclDto);
|
||||
$accountHistoryService = new AccountHistoryService();
|
||||
$this->view->assign('historyData', $accountHistoryService->getHistoryForAccount($this->accountId));
|
||||
|
||||
if (!$this->accountAcl->checkAccountAccess()) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_ACCOUNT_NO_PERMISSION);
|
||||
$this->view->assign('isModified', strtotime($accountData->getDateEdit()) !== false);
|
||||
$this->view->assign('maxFileSize', round($this->configData->getFilesAllowedSize() / 1024, 1));
|
||||
$this->view->assign('filesAllowedExts', implode(',', $this->configData->getFilesAllowedExts()));
|
||||
|
||||
return false;
|
||||
if ($this->configData->isPublinksEnabled() && $this->accountAcl->isShowLink()) {
|
||||
$publicLinkService = new PublicLinkService();
|
||||
$publicLinkData = $publicLinkService->getHashForItem($this->accountId);
|
||||
|
||||
$publicLinkUrl = $publicLinkData ? PublicLinkService::getLinkForHash($publicLinkData->getHash()) : null;
|
||||
$this->view->assign('publicLinkUrl', $publicLinkUrl);
|
||||
$this->view->assign('publicLinkId', $publicLinkData ? $publicLinkData->getId() : 0);
|
||||
$this->view->assign('publicLinkShow', true);
|
||||
} else {
|
||||
$this->view->assign('publicLinkShow', false);
|
||||
}
|
||||
|
||||
$this->view->assign('accountPassDate', date('Y-m-d H:i:s', $accountData->getPassDate()));
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', $accountData->getPassDateChange() ?: 0));
|
||||
} else {
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', time() + 7776000));
|
||||
}
|
||||
|
||||
return true;
|
||||
$this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::ACCOUNT, $this->accountId));
|
||||
$this->view->assign('categories', (new SelectItemAdapter(CategoryService::getItemsBasic()))->getItemsFromModel());
|
||||
$this->view->assign('clients', (new SelectItemAdapter(ClientService::getItemsBasic()))->getItemsFromModel());
|
||||
|
||||
$userItemAdapter = new SelectItemAdapter(UserService::getItemsBasic());
|
||||
|
||||
$this->view->assign('otherUsers', $userItemAdapter->getItemsFromModel());
|
||||
$this->view->assign('otherUsersJson', $userItemAdapter->getJsonItemsFromModel());
|
||||
|
||||
$userGroupItemAdapter = new SelectItemAdapter(UserGroupService::getItemsBasic());
|
||||
|
||||
$this->view->assign('otherGroups', $userGroupItemAdapter->getItemsFromModel());
|
||||
$this->view->assign('otherGroupsJson', $userGroupItemAdapter->getJsonItemsFromModel());
|
||||
|
||||
$tagItemAdapter = new SelectItemAdapter(TagService::getItemsBasic());
|
||||
|
||||
$this->view->assign('tagsJson', $tagItemAdapter->getJsonItemsFromModel());
|
||||
$this->view->assign('allowPrivate', $userProfileData->isAccPrivate());
|
||||
$this->view->assign('allowPrivateGroup', $userProfileData->isAccPrivateGroup());
|
||||
$this->view->assign('mailRequestEnabled', $this->configData->isMailRequestsEnabled());
|
||||
$this->view->assign('passToImageEnabled', $this->configData->isAccountPassToImage());
|
||||
|
||||
$this->view->assign('otherAccounts', $this->accountService->getForUser($this->accountId));
|
||||
$this->view->assign('linkedAccounts', $this->accountService->getLinked($this->accountId));
|
||||
|
||||
$this->view->assign('addClientEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CLIENT));
|
||||
$this->view->assign('addClientRoute', Acl::getActionRoute(ActionsInterface::CLIENT_CREATE));
|
||||
|
||||
$this->view->assign('addCategoryEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CATEGORY));
|
||||
$this->view->assign('addCategoryRoute', Acl::getActionRoute(ActionsInterface::CATEGORY_CREATE));
|
||||
|
||||
$this->view->assign('disabled', $this->view->isView ? 'disabled' : '');
|
||||
$this->view->assign('readonly', $this->view->isView ? 'readonly' : '');
|
||||
|
||||
$this->view->assign('showViewCustomPass', $this->accountAcl->isShowViewPass());
|
||||
$this->view->assign('accountAcl', $this->accountAcl);
|
||||
|
||||
$this->view->assign('actions', $this->getActions($this->isGotData() ? $this->accountDetailsResponse->getAccountVData()->getParentId() : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private function isGotData()
|
||||
{
|
||||
return $this->accountDetailsResponse !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,10 +411,11 @@ class AccountHelper extends HelperBase
|
||||
* @param AccountDetailsResponse $accountDetailsResponse
|
||||
* @param AccountService $accountService
|
||||
* @param int $actionId
|
||||
* @return bool
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function setAccount(AccountDetailsResponse $accountDetailsResponse, AccountService $accountService, $actionId)
|
||||
{
|
||||
|
||||
$this->accountDetailsResponse = $accountDetailsResponse;
|
||||
$this->accountService = $accountService;
|
||||
|
||||
@@ -412,9 +423,62 @@ class AccountHelper extends HelperBase
|
||||
$this->actionId = $actionId;
|
||||
$this->isHistory = false;
|
||||
|
||||
if (!$this->checkAccess($accountDetailsResponse)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->view->assign('actionId', $actionId);
|
||||
$this->view->assign('accountId', $this->accountId);
|
||||
$this->view->assign('accountData', $accountDetailsResponse->getAccountVData());
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si el usuario dispone de acceso al módulo
|
||||
*
|
||||
* @param AccountDetailsResponse $accountDetailsResponse
|
||||
* @return bool
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function checkAccess(AccountDetailsResponse $accountDetailsResponse = null)
|
||||
{
|
||||
$this->view->assign('showLogo', false);
|
||||
|
||||
if (!$this->acl->checkUserAccess($this->actionId)) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getId())) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_UPDATE_MPASS);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->accountId > 0 && $accountDetailsResponse !== null) {
|
||||
$accountData = $accountDetailsResponse->getAccountVData();
|
||||
|
||||
$acccountAclDto = new AccountAclDto();
|
||||
$acccountAclDto->setAccountId($accountData->getId());
|
||||
$acccountAclDto->setDateEdit(strtotime($accountData->getDateEdit()));
|
||||
$acccountAclDto->setUserId($accountData->getUserId());
|
||||
$acccountAclDto->setUserGroupId($accountData->getUserGroupId());
|
||||
$acccountAclDto->setUsersId($accountDetailsResponse->getUsers());
|
||||
$acccountAclDto->setUserGroupsId($accountDetailsResponse->getUserGroups());
|
||||
|
||||
$this->accountAcl = (new AccountAcl($this->actionId, $this->isHistory))->getAcl($acccountAclDto);
|
||||
|
||||
if (!$this->accountAcl->checkAccountAccess()) {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_ACCOUNT_NO_PERMISSION);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +499,6 @@ class AccountHelper extends HelperBase
|
||||
$this->view->assign('changesHash');
|
||||
$this->view->assign('chkUserEdit');
|
||||
$this->view->assign('chkGroupEdit');
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
$this->view->assign('isView', false);
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/** @var \SP\Account\AccountAcl $accountAcl */
|
||||
/** @var \SP\DataModel\AccountHistoryData $accountData */
|
||||
/** @var \SP\Mvc\View\Template $this */
|
||||
?>
|
||||
|
||||
<div class="data-container">
|
||||
<div id="title" class="midroundup titleNormal">
|
||||
<?php echo $title['name']; ?>
|
||||
<i id="history-icon" class="material-icons"
|
||||
title="<?php echo __('Histórico'); ?>"><?php echo $title['icon']; ?></i>
|
||||
</div>
|
||||
|
||||
<form method="post" name="frmaccount" id="frmAccount" class="form-action"
|
||||
data-onsubmit="account/save"
|
||||
data-action-route="<?php echo isset($formRoute) ? $formRoute : ''; ?>"
|
||||
data-item-id="<?php echo isset($accountId) ? $accountId : ''; ?>"
|
||||
data-hash="">
|
||||
<input type="hidden" name="sk" value="">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
|
||||
<table class="data round">
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Nombre'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="name" name="name" type="text" required
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
maxlength="50"
|
||||
value="<?php echo $accountData->getName() ?>"
|
||||
tabindex="1" readonly>
|
||||
<label class="mdl-textfield__label" for="name"><?php echo __('Nombre de cuenta'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Cliente'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="lowres-title"><?php echo __('Cliente'); ?></div>
|
||||
|
||||
<select id="selClient" name="clientId" class="select-box sel-chosen-client"
|
||||
tabindex="2" required disabled>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $clients */
|
||||
foreach ($clients as $client): ?>
|
||||
<option
|
||||
value="<?php echo $client->getId(); ?>" <?php echo $client->isSelected() ? 'selected' : ''; ?>><?php echo $client->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Categoría'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="lowres-title"><?php echo __('Categoría'); ?></div>
|
||||
|
||||
<select id="selCategory" name="categoryId" class="select-box sel-chosen-category"
|
||||
tabindex="3" required disabled>
|
||||
<option value=""><?php echo __('Seleccionar Categoría'); ?></option>
|
||||
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $categories */
|
||||
foreach ($categories as $category): ?>
|
||||
<option
|
||||
value="<?php echo $category->getId(); ?>" <?php echo $category->isSelected() ? 'selected' : ''; ?>><?php echo $category->getName(); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('URL / IP'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="url" name="url" type="text" class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
maxlength="255" tabindex="4"
|
||||
value="<?php echo $accountData->getUrl(); ?>" readonly>
|
||||
<label class="mdl-textfield__label" for="name"><?php echo __('URL o IP de acceso'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Usuario'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="login" name="login" type="text"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
maxlength="50" tabindex="5"
|
||||
value="<?php echo $accountData->getLogin(); ?>" readonly>
|
||||
<label class="mdl-textfield__label" for="name"><?php echo __('Usuario de acceso'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Fecha Caducidad Clave'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="accountpassdatechange" name="accountpassdatechange" type="date"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400 password-datefield__input"
|
||||
tabindex="8"
|
||||
value="<?php echo $accountPassDateChange; ?>" readonly>
|
||||
<label class="mdl-textfield__label"
|
||||
for="accountpassdatechange"><?php echo __('Fecha'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Notas'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<textarea class="mdl-textfield__input mdl-color-text--indigo-400" rows="3" id="notes"
|
||||
name="notes" tabindex="9"
|
||||
maxlength="5000" readonly><?php echo $accountData->getNotes(); ?></textarea>
|
||||
<label class="mdl-textfield__label"
|
||||
for="notes"><?php echo __('Notas sobre la cuenta'); ?></label>
|
||||
</div>
|
||||
</tr>
|
||||
<?php if ($accountAcl->isShowHistory() && count($historyData) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Historial'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="lowres-title"><?php echo __('Historial'); ?></div>
|
||||
|
||||
<select id="historyId" name="historyId" class="select-box" tabindex="12"
|
||||
data-action-route="account/viewHistory"
|
||||
data-onchange="account/viewHistory">
|
||||
<option value=""><?php echo __('Seleccionar fecha'); ?></option>
|
||||
<?php foreach ($historyData as $historyId => $historyData): ?>
|
||||
<option
|
||||
value="<?php echo $historyId; ?>" <?php echo ($accountIsHistory && $historyId === $accountHistoryId) ? 'selected' : ''; ?>><?php echo $historyData; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Última Modificación'); ?></td>
|
||||
<td class="valField"><?php printf('%s (%s)', $accountData->getDateEdit(), $accountData->getUserEditName() ?: $accountData->getUserEditLogin()); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<!--More info about account details -->
|
||||
<?php if ($accountAcl->isShowDetails()): ?>
|
||||
<?php include $this->includeTemplate('details'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php include $this->includeTemplate('actions'); ?>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
sysPassApp.sk.set("<?php echo $sk; ?>");
|
||||
})();
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/** @var \SP\Account\AccountAcl $AccountAcl */
|
||||
/** @var \SP\Account\AccountAcl $accountAcl */
|
||||
/** @var \SP\DataModel\AccountExtData $accountData */
|
||||
/** @var $icons \SP\Core\UI\ThemeIconsBase */
|
||||
?>
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<div id="data-accesses">
|
||||
<table>
|
||||
<?php if ($AccountAcl->isShowPermission()): ?>
|
||||
<?php if ($accountAcl->isShowPermission()): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Permisos'); ?></td>
|
||||
<td class="valField">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/** @var \SP\Account\AccountAcl $AccountAcl */
|
||||
/** @var \SP\Account\AccountAcl $accountAcl */
|
||||
/** @var \SP\DataModel\AccountExtData $accountData */
|
||||
?>
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
data-action-route="<?php echo isset($formRoute) ? $formRoute : ''; ?>"
|
||||
data-item-id="<?php echo isset($accountId) ? $accountId : ''; ?>"
|
||||
data-hash="">
|
||||
<input type="hidden" name="actionId" value="<?php echo $actionId; ?>">
|
||||
<?php if ($gotData): ?>
|
||||
<input type="hidden" name="itemId" value="<?php echo $accountId; ?>"/>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="sk" value="">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
|
||||
@@ -111,7 +107,7 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($AccountAcl->isShowPass()): ?>
|
||||
<?php if ($accountAcl->isShowPass()): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Clave'); ?></td>
|
||||
<td class="valField">
|
||||
@@ -199,7 +195,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($AccountAcl->isShowHistory() && count($historyData) > 0): ?>
|
||||
<?php if ($accountAcl->isShowHistory() && count($historyData) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Historial'); ?></td>
|
||||
<td class="valField">
|
||||
@@ -240,7 +236,7 @@
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
|
||||
<?php if (!$isView && $AccountAcl->isShowPermission()): ?>
|
||||
<?php if (!$isView && $accountAcl->isShowPermission()): ?>
|
||||
<?php include $this->includeTemplate('account-permissions'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -265,7 +261,7 @@
|
||||
</form>
|
||||
|
||||
<!--Files box -->
|
||||
<?php if ($gotData && $AccountAcl->isShowFiles()): ?>
|
||||
<?php if ($gotData && $accountAcl->isShowFiles()): ?>
|
||||
<?php include $this->includeTemplate('files'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -274,7 +270,7 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<!--More info about account details -->
|
||||
<?php if ($gotData && $AccountAcl->isShowDetails()): ?>
|
||||
<?php if ($gotData && $accountAcl->isShowDetails()): ?>
|
||||
<?php include $this->includeTemplate('details'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** @var $icons \Theme\Icons */
|
||||
/** @var \SP\Account\AccountAcl $AccountAcl */
|
||||
?>
|
||||
<div class="item-actions">
|
||||
<ul>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<?php echo $accountData->getUserGroupName(); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (is_array($accountOtherUsers) && count($accountOtherUsers) > 0): ?>
|
||||
<?php if (isset($accountOtherUsers) && is_array($accountOtherUsers) && count($accountOtherUsers) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Usuarios Secundarios'); ?></td>
|
||||
<td class="valField">
|
||||
@@ -78,7 +78,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if (is_array($accountOtherGroups) && count($accountOtherGroups) > 0): ?>
|
||||
<?php if (isset($accountOtherGroups) && is_array($accountOtherGroups) && count($accountOtherGroups) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Grupos Secundarios'); ?></td>
|
||||
<td class="valField">
|
||||
@@ -101,7 +101,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($AccountAcl->isModified()): ?>
|
||||
<?php if ($accountAcl->isModified()): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo __('Fecha Edición'); ?></td>
|
||||
<td class="valField">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
/** @var $icons \Theme\Icons */
|
||||
/** @var $files \SP\DataModel\FileData[] */
|
||||
/** @var $AccountAcl \SP\Account\AccountAcl */
|
||||
?>
|
||||
|
||||
<div id="files-wrap" class="list-wrap round">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \SP\Account\AccountAcl $AccountAcl
|
||||
* @var \SP\Account\AccountAcl $accountAcl
|
||||
* @var \SP\Core\UI\ThemeIconsBase $icons
|
||||
*/
|
||||
?>
|
||||
@@ -22,7 +22,7 @@
|
||||
<div id="list-account-files"
|
||||
data-item-id="<?php echo $accountId; ?>"
|
||||
data-history="<?php $accountIsHistory; ?>"
|
||||
data-delete="<?php echo (int)$AccountAcl->isShowDelete(); ?>"
|
||||
data-delete="<?php echo (int)$accountAcl->isShowDelete(); ?>"
|
||||
data-sk="<?php echo $sk; ?>">
|
||||
</div>
|
||||
<?php if (isset($editAction)): ?>
|
||||
@@ -31,7 +31,7 @@
|
||||
data-item-id="<?php echo $accountId; ?>"
|
||||
data-sk="<?php echo $sk; ?>"
|
||||
data-action-route="<?php echo $fileUploadRoute; ?>"
|
||||
data-delete="<?php echo (int)$AccountAcl->isShowDelete(); ?>">
|
||||
data-delete="<?php echo (int)$accountAcl->isShowDelete(); ?>">
|
||||
<i class="material-icons md-60 mdl-color-text--teal-500">cloud_upload</i>
|
||||
</div>
|
||||
<form method="post" enctype="multipart/form-data" name="upload_form" class="file-upload"
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -39,6 +39,10 @@ class AccountHistoryData extends AccountExtData
|
||||
* @var bool
|
||||
*/
|
||||
public $isDeleted = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $accountId;
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
@@ -71,4 +75,20 @@ class AccountHistoryData extends AccountExtData
|
||||
{
|
||||
$this->isDeleted = (int)$isDeleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAccountId()
|
||||
{
|
||||
return $this->accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
*/
|
||||
public function setAccountId($accountId)
|
||||
{
|
||||
$this->accountId = $accountId;
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ class Template
|
||||
/**
|
||||
* @param null $file Archivo de plantilla a añadir
|
||||
* @param array $vars Variables a inicializar
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function __construct($file = null, array $vars = [])
|
||||
{
|
||||
@@ -163,7 +164,7 @@ class Template
|
||||
private function setVars(&$vars)
|
||||
{
|
||||
foreach ($vars as $name => $value) {
|
||||
$this->$name = $value;
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@ class AccountHistoryRepository extends Repository implements RepositoryItemInter
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT AH.id,
|
||||
AH.accountId,
|
||||
AH.clientId,
|
||||
AH.categoryId,
|
||||
AH.name,
|
||||
@@ -267,7 +268,7 @@ class AccountHistoryRepository extends Repository implements RepositoryItemInter
|
||||
U1.name AS userName,
|
||||
U1.login AS userLogin,
|
||||
UG.name AS userGroupName,
|
||||
U2.name AS useEditName,
|
||||
U2.name AS userEditName,
|
||||
U2.login AS userEditLogin
|
||||
FROM AccountHistory AH
|
||||
INNER JOIN Category C ON AH.categoryId = C.id
|
||||
|
||||
@@ -44,7 +44,7 @@ class AccountToUserGroupRepository extends Repository
|
||||
* Obtiene el listado con el nombre de los grupos de una cuenta.
|
||||
*
|
||||
* @param int $id con el Id de la cuenta
|
||||
* @return UserGroupData[]
|
||||
* @return array
|
||||
*/
|
||||
public function getUserGroupsByAccountId($id)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,8 @@ use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\DataModel\AccountHistoryData;
|
||||
use SP\Repositories\Account\AccountHistoryRepository;
|
||||
use SP\Repositories\Account\AccountToUserGroupRepository;
|
||||
use SP\Repositories\Account\AccountToUserRepository;
|
||||
|
||||
/**
|
||||
* Class AccountHistoryService
|
||||
@@ -42,6 +44,14 @@ class AccountHistoryService
|
||||
* @var AccountHistoryRepository
|
||||
*/
|
||||
protected $accountHistoryRepository;
|
||||
/**
|
||||
* @var AccountToUserGroupRepository
|
||||
*/
|
||||
protected $accountToUserGroupRepository;
|
||||
/**
|
||||
* @var AccountToUserRepository
|
||||
*/
|
||||
protected $accountToUserRepository;
|
||||
|
||||
/**
|
||||
* AccountHistoryService constructor.
|
||||
@@ -54,11 +64,17 @@ class AccountHistoryService
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountHistoryRepository $accountHistoryRepository
|
||||
* @param AccountHistoryRepository $accountHistoryRepository
|
||||
* @param AccountToUserGroupRepository $accountToUserGroupRepository
|
||||
* @param AccountToUserRepository $accountToUserRepository
|
||||
*/
|
||||
public function inject(AccountHistoryRepository $accountHistoryRepository)
|
||||
public function inject(AccountHistoryRepository $accountHistoryRepository,
|
||||
AccountToUserGroupRepository $accountToUserGroupRepository,
|
||||
AccountToUserRepository $accountToUserRepository)
|
||||
{
|
||||
$this->accountHistoryRepository = $accountHistoryRepository;
|
||||
$this->accountToUserGroupRepository = $accountToUserGroupRepository;
|
||||
$this->accountToUserRepository = $accountToUserRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,4 +90,32 @@ class AccountHistoryService
|
||||
return $this->accountHistoryRepository->getById($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el listado del histórico de una cuenta.
|
||||
*
|
||||
* @param $id
|
||||
* @return array|false Con los registros con id como clave y fecha - usuario como valor
|
||||
*/
|
||||
public function getHistoryForAccount($id)
|
||||
{
|
||||
return $this->accountHistoryRepository->getHistoryForAccount($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function getUsersByAccountId($id)
|
||||
{
|
||||
return $this->accountToUserRepository->getUsersByAccountId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function getUserGroupsByAccountId($id)
|
||||
{
|
||||
return $this->accountToUserGroupRepository->getUserGroupsByAccountId($id);
|
||||
}
|
||||
}
|
||||
@@ -319,4 +319,16 @@ class PublicLinkService
|
||||
{
|
||||
return $this->publicLinkRepository->getByHash($hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el hash asociado a un elemento
|
||||
*
|
||||
* @param int $itemId
|
||||
* @return PublicLinkData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getHashForItem($itemId)
|
||||
{
|
||||
return $this->publicLinkRepository->getHashForItem($itemId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user