From 5fd678fddd25153735dc625c32637fe93e4c2284 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 25 Dec 2017 23:17:10 +0100 Subject: [PATCH] * [ADD] Finished access manager refactoring. Work in progress. --- .../Controllers/AccessManagerController.php | 47 +- .../web/Controllers/AccountController.php | 243 ++++++-- .../web/Controllers/ApiTokenController.php | 307 ++++++++++ .../Helpers/AccountActionsHelper.php | 58 +- .../web/Controllers/Helpers/AccountHelper.php | 275 +++++---- .../Helpers/AccountPasswordHelper.php | 21 +- .../Helpers/AccountSearchHelper.php | 5 +- .../Controllers/Helpers/ItemsGridHelper.php | 197 ++++--- .../web/Controllers/Helpers/LayoutHelper.php | 141 +++-- .../web/Controllers/IndexController.php | 13 +- .../web/Controllers/ItemsController.php | 1 + .../web/Controllers/LoginController.php | 14 +- .../web/Controllers/MainController.php | 62 +- .../web/Controllers/PassresetController.php | 13 +- .../web/Controllers/PublicLinkController.php | 296 ++++++++++ .../web/Controllers/Traits/ItemTrait.php | 29 +- .../web/Controllers/Traits/JsonTrait.php | 32 +- .../web/Controllers/UserController.php | 148 +++-- .../web/Controllers/UserGroupController.php | 299 ++++++++++ .../web/Controllers/UserProfileController.php | 290 +++++++++ .../views/_partials/body-footer.inc | 2 +- .../views/_partials/body-header.inc | 1 - .../views/_partials/error-full.inc | 6 + .../views/account/account-editpass.inc | 2 +- .../views/account/account-link.inc | 17 +- .../{request.inc => account-request.inc} | 11 +- .../material-blue/views/account/account.inc | 8 +- .../material-blue/views/account/actions.inc | 34 +- .../material-blue/views/account/details.inc | 3 +- .../views/account/files-list.inc | 8 +- .../material-blue/views/account/files.inc | 11 +- .../views/account/linkedAccounts.inc | 6 +- .../views/grid/datatabs-grid.inc | 6 +- .../itemshow/{tokens.inc => apitoken.inc} | 17 +- .../views/itemshow/publiclink.inc | 131 +++++ .../views/itemshow/publiclinks.inc | 90 --- .../views/itemshow/{users.inc => user.inc} | 0 .../itemshow/{groups.inc => usergroup.inc} | 26 +- .../itemshow/{userspass.inc => userpass.inc} | 0 .../{profiles.inc => userprofile.inc} | 69 ++- lib/BaseFunctions.php | 2 +- lib/SP/Account/AccountAcl.php | 70 +-- lib/SP/Account/AccountSearch.php | 86 +-- lib/SP/Api/SyspassApi.php | 4 +- lib/SP/Bootstrap.php | 55 +- lib/SP/Controller/AccountController.php | 5 +- lib/SP/Controller/ControllerBase.php | 48 +- lib/SP/Controller/ItemActionController.php | 39 +- lib/SP/Controller/ItemShowController.php | 4 +- lib/SP/Controller/RequestControllerTrait.php | 3 - lib/SP/Core/Acl/Acl.php | 3 + lib/SP/Core/Acl/Action.php | 2 + lib/SP/Core/Acl/ActionsInterface.php | 1 + lib/SP/Core/Crypt/Hash.php | 2 +- lib/SP/Core/SessionUtil.php | 22 +- lib/SP/Core/Template.php | 115 ++-- lib/SP/DataModel/AccountHistoryData.php | 2 +- lib/SP/DataModel/PublicLinkData.php | 29 +- lib/SP/Forms/ApiTokenForm.php | 8 +- lib/SP/Forms/CategoryForm.php | 2 +- lib/SP/Forms/PublicLinkForm.php | 56 +- .../{GroupForm.php => UserGroupForm.php} | 6 +- .../{ProfileForm.php => UserProfileForm.php} | 8 +- lib/SP/Html/DataGrid/DataGridActionBase.php | 48 +- .../Html/DataGrid/DataGridActionInterface.php | 29 + lib/SP/Html/DataGrid/DataGridBase.php | 2 + lib/SP/Http/JsonResponse.php | 8 + lib/SP/Mgmt/CustomFields/CustomField.php | 4 +- lib/SP/Mgmt/CustomFields/CustomFieldDef.php | 4 +- .../CustomFields/CustomFieldDefSearch.php | 2 +- lib/SP/Mgmt/CustomFields/CustomFieldsUtil.php | 2 +- lib/SP/Mgmt/Profiles/Profile.php | 3 +- lib/SP/Mgmt/PublicLinks/PublicLink.php | 9 +- lib/SP/Mgmt/PublicLinks/PublicLinkSearch.php | 2 +- lib/SP/Mgmt/Users/UserPreferences.php | 4 +- lib/SP/Mgmt/Users/UserPreferencesUtil.php | 4 +- .../Account/AccountHistoryService.php | 404 +++++++++++++ .../Services/{ => Account}/AccountService.php | 465 +++++++++++---- lib/SP/Services/ApiToken/ApiTokenService.php | 363 +++++++++++- .../CustomField/CustomFieldService.php | 14 +- lib/SP/Services/LoginService.php | 110 ++-- .../Services/PublicLink/PublicLinkService.php | 552 ++++++++++++++++-- lib/SP/Services/Service.php | 19 +- lib/SP/Services/ServiceItemTrait.php | 11 + lib/SP/Services/User/UserService.php | 146 ++++- .../Services/UserGroup/UserGroupService.php | 244 ++++++-- .../Services/UserGroup/UserToGroupService.php | 167 ++++++ .../UserProfile/UserProfileService.php | 276 +++++++-- lib/SP/Storage/Database.php | 74 ++- lib/SP/Storage/DatabaseInterface.php | 79 +++ lib/SP/Storage/DbWrapper.php | 87 +-- lib/SP/Util/DateUtil.php | 45 ++ lib/SP/Util/ErrorUtil.php | 138 +++++ lib/SP/Util/Util.php | 56 +- public/js/app-actions.js | 63 +- public/js/app-actions.min.js | 93 +-- public/js/app-main.js | 12 +- public/js/app-main.min.js | 46 +- public/js/app-requests.js | 16 + public/js/app-requests.min.js | 7 +- public/js/app-triggers.js | 2 +- public/js/app-triggers.min.js | 8 +- schemas/22017050101.sql | 271 ++++----- schemas/dbstructure.sql | 260 ++++----- 104 files changed, 5880 insertions(+), 1780 deletions(-) create mode 100644 app/modules/web/Controllers/ApiTokenController.php create mode 100644 app/modules/web/Controllers/PublicLinkController.php create mode 100644 app/modules/web/Controllers/UserGroupController.php create mode 100644 app/modules/web/Controllers/UserProfileController.php create mode 100644 app/modules/web/themes/material-blue/views/_partials/error-full.inc rename app/modules/web/themes/material-blue/views/account/{request.inc => account-request.inc} (93%) rename app/modules/web/themes/material-blue/views/itemshow/{tokens.inc => apitoken.inc} (86%) create mode 100644 app/modules/web/themes/material-blue/views/itemshow/publiclink.inc delete mode 100644 app/modules/web/themes/material-blue/views/itemshow/publiclinks.inc rename app/modules/web/themes/material-blue/views/itemshow/{users.inc => user.inc} (100%) rename app/modules/web/themes/material-blue/views/itemshow/{groups.inc => usergroup.inc} (80%) rename app/modules/web/themes/material-blue/views/itemshow/{userspass.inc => userpass.inc} (100%) rename app/modules/web/themes/material-blue/views/itemshow/{profiles.inc => userprofile.inc} (93%) rename lib/SP/Forms/{GroupForm.php => UserGroupForm.php} (93%) rename lib/SP/Forms/{ProfileForm.php => UserProfileForm.php} (95%) create mode 100644 lib/SP/Services/Account/AccountHistoryService.php rename lib/SP/Services/{ => Account}/AccountService.php (59%) create mode 100644 lib/SP/Services/UserGroup/UserToGroupService.php create mode 100644 lib/SP/Storage/DatabaseInterface.php create mode 100644 lib/SP/Util/DateUtil.php create mode 100644 lib/SP/Util/ErrorUtil.php diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php index c35b2ab3..8f189e59 100644 --- a/app/modules/web/Controllers/AccessManagerController.php +++ b/app/modules/web/Controllers/AccessManagerController.php @@ -59,6 +59,7 @@ class AccessManagerController extends ControllerBase /** * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws \SP\Core\Exceptions\InvalidClassException */ public function indexAction() { @@ -69,6 +70,7 @@ class AccessManagerController extends ControllerBase * Returns a tabbed grid with items * * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws \SP\Core\Exceptions\InvalidClassException */ protected function getGridTabs() { @@ -108,87 +110,54 @@ class AccessManagerController extends ControllerBase /** * Returns users' data tab - * - * @throws \SP\Core\Exceptions\InvalidArgumentException */ protected function getUsersList() { $service = new UserService(); - $service->search($this->itemSearchData); - $grid = $this->itemsGridHelper->getUsersGrid(); - $grid->getData()->setData($service->search($this->itemSearchData)); - $grid->updatePager(); - - return $grid; + return $this->itemsGridHelper->getUsersGrid($service->search($this->itemSearchData))->updatePager(); } /** * Returns users group data tab - * - * @throws \SP\Core\Exceptions\InvalidArgumentException */ protected function getUsersGroupList() { $service = new UserGroupService(); - $service->search($this->itemSearchData); - $grid = $this->itemsGridHelper->getGroupsGrid(); - $grid->getData()->setData($service->search($this->itemSearchData)); - $grid->updatePager(); - - return $grid; + return $this->itemsGridHelper->getUserGroupsGrid($service->search($this->itemSearchData))->updatePager(); } /** * Returns users profile data tab - * - * @throws \SP\Core\Exceptions\InvalidArgumentException */ protected function getUsersProfileList() { $service = new UserProfileService(); - $service->search($this->itemSearchData); - $grid = $this->itemsGridHelper->getProfilesGrid(); - $grid->getData()->setData($service->search($this->itemSearchData)); - $grid->updatePager(); - - return $grid; + return $this->itemsGridHelper->getUserProfilesGrid($service->search($this->itemSearchData))->updatePager(); } /** * Returns API tokens data tab - * - * @throws \SP\Core\Exceptions\InvalidArgumentException */ protected function getApiTokensList() { $service = new ApiTokenService(); - $service->search($this->itemSearchData); - $grid = $this->itemsGridHelper->getApiTokensGrid(); - $grid->getData()->setData($service->search($this->itemSearchData)); - $grid->updatePager(); - - return $grid; + return $this->itemsGridHelper->getApiTokensGrid($service->search($this->itemSearchData))->updatePager(); } /** * Returns public links data tab * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws \SP\Core\Exceptions\InvalidClassException */ protected function getPublicLinksList() { $service = new PublicLinkService(); - $service->search($this->itemSearchData); - $grid = $this->itemsGridHelper->getPublicLinksGrid(); - $grid->getData()->setData($service->search($this->itemSearchData)); - $grid->updatePager(); - - return $grid; + return $this->itemsGridHelper->getPublicLinksGrid($service->search($this->itemSearchData))->updatePager(); } /** diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php index 6bdb81fb..403abeaf 100644 --- a/app/modules/web/Controllers/AccountController.php +++ b/app/modules/web/Controllers/AccountController.php @@ -24,24 +24,30 @@ namespace SP\Modules\Web\Controllers; -use SP\Core\Acl\Acl; -use SP\Core\Exceptions\ValidationException; -use SP\Forms\AccountForm; -use SP\Modules\Web\Controllers\Helpers\AccountPasswordHelper; -use SP\Modules\Web\Controllers\Traits\ItemTrait; -use SP\Modules\Web\Controllers\Traits\JsonTrait; -use SP\Services\AccountService; use SP\Controller\ControllerBase; +use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; +use SP\Core\Crypt\Crypt; use SP\Core\Exceptions\SPException; +use SP\Core\Exceptions\ValidationException; use SP\Core\SessionUtil; +use SP\DataModel\AccountExtData; +use SP\Forms\AccountForm; +use SP\Http\JsonResponse; use SP\Http\Request; -use SP\Http\Response; use SP\Mgmt\Files\FileUtil; use SP\Modules\Web\Controllers\Helpers\AccountHelper; +use SP\Modules\Web\Controllers\Helpers\AccountPasswordHelper; use SP\Modules\Web\Controllers\Helpers\AccountSearchHelper; +use SP\Modules\Web\Controllers\Helpers\LayoutHelper; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Mvc\Controller\CrudControllerInterface; -use SP\Services\CustomField\CustomFieldService; +use SP\Services\Account\AccountService; +use SP\Services\PublicLink\PublicLinkService; +use SP\Util\ErrorUtil; +use SP\Util\ImageUtil; +use SP\Util\Util; /** * Class AccountController @@ -69,7 +75,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -93,12 +99,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'html' => $this->render() ]; - Response::printJson($data, 0); + $this->returnJsonResponseData($data); } catch (\Exception $e) { debugLog($e->getMessage(), true); // FIXME - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } } @@ -129,14 +135,93 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->view->assign('isView', true); - $AccountHelper->getAccount()->incrementViewCounter(); + $AccountHelper->getAccountService()->incrementViewCounter(); $AccountHelper->setCommonData(); - $this->eventDispatcher->notifyEvent('show.account.view', $this); + $this->eventDispatcher->notifyEvent('show.account', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); + } + + $this->view(); + } + + /** + * View public link action + * + * @param string $hash Link's hash + */ + public function viewLinkAction($hash) + { + $LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $LayoutHelper->getPublicLayout('account-link', 'account'); + + try { + $publicLinkService = new PublicLinkService(); + $publicLinkData = $publicLinkService->getByHash($hash); + + if (time() < $publicLinkData->getDateExpire() + && $publicLinkData->getCountViews() < $publicLinkData->getMaxCountViews() + ) { + $publicLinkService->addLinkView($publicLinkData); + +// if ($publicLinkData->isNotify()) { +// $Message = new NoticeMessage(); +// $Message->setTitle(__('Enlace visualizado')); +// $Message->addDescription(sprintf('%s : %s', __('Cuenta'), $PublicLink->getItemId())); +// $Message->addDescription(sprintf('%s : %s', __('Origen'), $this->configData->isDemoEnabled() ? '*.*.*.*' : HttpUtil::getClientAddress(true))); +// $Message->addDescription(sprintf('%s : %s', __('Agente'), Request::getRequestHeaders('HTTP_USER_AGENT'))); +// $Message->addDescription(sprintf('HTTPS : %s', Checks::httpsEnabled() ? 'ON' : 'OFF')); +// +// +// $NoticeData = new NoticeData(); +// $NoticeData->setNoticeComponent(__('Cuentas')); +// $NoticeData->setNoticeDescription($Message); +// $NoticeData->setNoticeType(__('Información')); +// $NoticeData->setNoticeUserId($PublicLink->getUserId()); +// +// Notice::getItem($NoticeData)->add(); +// } + + $accountService = new AccountService(); + $accountService->incrementViewCounter($publicLinkData->getItemId()); + $accountService->incrementDecryptCounter($publicLinkData->getItemId()); + + $key = $this->configData->getPasswordSalt() . $publicLinkData->getLinkHash(); + $securedKey = Crypt::unlockSecuredKey($publicLinkData->getPassIV(), $key); + + /** @var AccountExtData $accountData */ + $accountData = Util::unserialize(AccountExtData::class, Crypt::decrypt($publicLinkData->getData(), $securedKey, $key)); + + $this->view->assign('title', + [ + 'class' => 'titleNormal', + 'name' => __('Detalles de Cuenta'), + 'icon' => $this->icons->getIconView()->getIcon() + ] + ); + + $this->view->assign('isView', true); + $this->view->assign('useImage', $this->configData->isPublinksImageEnabled() || $this->configData->isAccountPassToImage()); + + if ($this->view->useImage) { + $this->view->assign('accountPassImage', ImageUtil::convertText($accountData->getAccountPass())); + } else { + $this->view->assign('copyPassRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); + } + + $this->view->assign('accountData', $accountData); + + $this->eventDispatcher->notifyEvent('show.account.link', $this); + } else { + ErrorUtil::showErrorFull($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, 'account-link'); + } + } catch (\Exception $e) { + debugLog($e->getMessage(), true); + + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -162,7 +247,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->view->assign('accountId', $id); $this->view->assign('deleteEnabled', Request::analyze('del', 0)); $this->view->assign('files', FileUtil::getAccountFiles($id)); - $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('sk', SessionUtil::getSessionKey()); + $this->view->assign('fileViewRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_VIEW)); + $this->view->assign('fileDownloadRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_DOWNLOAD)); + $this->view->assign('fileDeleteRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_DELETE)); + $this->view->assign('fileUploadRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_UPLOAD)); if (!is_array($this->view->files) || count($this->view->files) === 0) { return; @@ -172,7 +261,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -200,15 +289,15 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => $this->icons->getIconAdd()->getIcon() ] ); - $this->view->assign('formAction', 'account/saveCreate'); + $this->view->assign('formRoute', 'account/saveCreate'); $AccountHelper->setCommonData(); - $this->eventDispatcher->notifyEvent('show.account.new', $this); + $this->eventDispatcher->notifyEvent('show.account.create', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -238,7 +327,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => $this->icons->getIconAdd()->getIcon() ] ); - $this->view->assign('formAction', 'account/saveCopy'); + $this->view->assign('formRoute', 'account/saveCopy'); $AccountHelper->setCommonData(); @@ -246,7 +335,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -276,16 +365,16 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => $this->icons->getIconEdit()->getIcon() ] ); - $this->view->assign('formAction', 'account/saveEdit'); + $this->view->assign('formRoute', 'account/saveEdit'); - $AccountHelper->getAccount()->incrementViewCounter(); + $AccountHelper->getAccountService()->incrementViewCounter(); $AccountHelper->setCommonData(); $this->eventDispatcher->notifyEvent('show.account.edit', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -315,7 +404,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => $this->icons->getIconDelete()->getIcon() ] ); - $this->view->assign('formAction', 'account/saveDelete'); + $this->view->assign('formRoute', 'account/saveDelete'); $AccountHelper->setCommonData(); @@ -323,7 +412,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -353,15 +442,15 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => $this->icons->getIconEditPass()->getIcon() ] ); - $this->view->assign('formAction', 'account/saveEditPass'); + $this->view->assign('formRoute', 'account/saveEditPass'); - $this->view->assign('accountPassDateChange', gmdate('Y-m-d', $AccountHelper->getAccount()->getAccountData()->getAccountPassDateChange())); + $this->view->assign('accountPassDateChange', gmdate('Y-m-d', $AccountHelper->getAccountData()->getAccountPassDateChange())); $this->eventDispatcher->notifyEvent('show.account.editpass', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -391,18 +480,17 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'icon' => 'access_time' ] ); - $this->view->assign('formAction', 'account/saveRestore'); + $this->view->assign('formRoute', 'account/saveRestore'); $this->view->assign('isView', true); - $AccountHelper->getAccount()->setAccountIsHistory(1); $AccountHelper->setCommonData(); - $this->eventDispatcher->notifyEvent('show.account.viewhistory', $this); + $this->eventDispatcher->notifyEvent('show.account.history', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -419,14 +507,14 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_REQUEST); - $this->view->addTemplate('request'); - $this->view->assign('formAction', 'account/saveRequest'); + $this->view->addTemplate('account-request'); + $this->view->assign('formRoute', 'account/saveRequest'); $this->eventDispatcher->notifyEvent('show.account.request', $this); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->showError(self::ERR_EXCEPTION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION); } $this->view(); @@ -437,6 +525,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac * * @param int $id Account's ID * @param int $isHistory The account's ID refers to history + * @throws \Psr\Container\ContainerExceptionInterface */ public function viewPassAction($id, $isHistory) { @@ -455,11 +544,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->eventDispatcher->notifyEvent('show.account.pass', $this); - $this->returnJsonResponse(0, '', $data); + $this->returnJsonResponseData($data); } catch (\Exception $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(0, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, $e->getMessage()); } } @@ -468,6 +557,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac * * @param int $id Account's ID * @param int $isHistory The account's ID refers to history + * @throws Helpers\HelperException + * @throws SPException + * @throws \Defuse\Crypto\Exception\BadFormatException + * @throws \Defuse\Crypto\Exception\CryptoException + * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws \Psr\Container\ContainerExceptionInterface */ public function copyPassAction($id, $isHistory) { @@ -480,7 +575,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac 'accpass' => $accountPassHelper->getPassword($account, $this->acl, AccountPasswordHelper::TYPE_NORMAL), ]; - $this->returnJsonResponse(0, '', $data); + $this->eventDispatcher->notifyEvent('copy.account.pass', $this); + + $this->returnJsonResponseData($data); } /** @@ -508,15 +605,22 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $accountService->logAction($account->getId(), ActionsInterface::ACCOUNT_CREATE); - $this->eventDispatcher->notifyEvent('add.account', $this); + $this->eventDispatcher->notifyEvent('create.account', $this); - $this->returnJsonResponse(0, __('Cuenta creada', false), ['itemId' => $account->getId(), 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)]); + $this->returnJsonResponseData( + [ + 'itemId' => $account->getId(), + 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT) + ], + JsonResponse::JSON_SUCCESS, + __u('Cuenta creada') + ); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -532,7 +636,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $form->validate(ActionsInterface::ACCOUNT_EDIT); $accountService = new AccountService(); - $accountService->edit($form->getItemData()); + $accountService->update($form->getItemData()); $this->updateCustomFieldsForItem(ActionsInterface::ACCOUNT, $id); @@ -540,13 +644,20 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->eventDispatcher->notifyEvent('edit.account', $this); - $this->returnJsonResponse(0, __('Cuenta actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); + $this->returnJsonResponseData( + [ + 'itemId' => $id, + 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW) + ], + JsonResponse::JSON_SUCCESS, + __u('Cuenta actualizada') + ); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -568,13 +679,20 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->eventDispatcher->notifyEvent('edit.account.pass', $this); - $this->returnJsonResponse(0, __('Clave actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); + $this->returnJsonResponseData( + [ + 'itemId' => $id, + 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW) + ], + JsonResponse::JSON_SUCCESS, + __u('Clave actualizada') + ); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -594,11 +712,18 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->eventDispatcher->notifyEvent('edit.account.restore', $this); - $this->returnJsonResponse(0, __('Cuenta restaurada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); + $this->returnJsonResponseData( + [ + 'itemId' => $id, + 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW) + ], + JsonResponse::JSON_SUCCESS, + __u('Cuenta restaurada') + ); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -620,12 +745,16 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->eventDispatcher->notifyEvent('delete.account', $this); - $this->returnJsonResponse(0, __('Cuenta eliminada', false), ['nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_SEARCH)]); + $this->returnJsonResponseData( + ['nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_SEARCH)], + JsonResponse::JSON_SUCCESS, + __u('Cuenta eliminada') + ); } } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -634,6 +763,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac */ protected function initialize() { - $this->checkLoggedIn(); + if ($this->actionName !== 'viewLinkAction') { + $this->checkLoggedIn(); + } } } \ No newline at end of file diff --git a/app/modules/web/Controllers/ApiTokenController.php b/app/modules/web/Controllers/ApiTokenController.php new file mode 100644 index 00000000..a2322244 --- /dev/null +++ b/app/modules/web/Controllers/ApiTokenController.php @@ -0,0 +1,307 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use SP\Controller\ControllerBase; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\SPException; +use SP\Core\Exceptions\ValidationException; +use SP\Core\SessionUtil; +use SP\DataModel\ApiTokenData; +use SP\Forms\ApiTokenForm; +use SP\Http\JsonResponse; +use SP\Http\Request; +use SP\Mgmt\ApiTokens\ApiTokensUtil; +use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Mvc\Controller\CrudControllerInterface; +use SP\Services\ApiToken\ApiTokenService; +use SP\Services\User\UserService; + +/** + * Class ApiTokenController + * + * @package SP\Modules\Web\Controllers + */ +class ApiTokenController extends ControllerBase implements CrudControllerInterface +{ + use JsonTrait; + use ItemTrait; + + /** + * @var ApiTokenService + */ + protected $apiTokenService; + + /** + * Search action + */ + public function searchAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_SEARCH)) { + return; + } + + $itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $grid = $itemsGridHelper->getApiTokensGrid($this->apiTokenService->search($this->getSearchData($this->configData)))->updatePager(); + + $this->view->addTemplate('datagrid-table', 'grid'); + $this->view->assign('index', Request::analyze('activetab', 0)); + $this->view->assign('data', $grid); + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Create action + * + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function createAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_CREATE)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); + $this->view->assign('header', __('Nueva Autorización')); + $this->view->assign('isView', false); + $this->view->assign('route', 'apiToken/saveCreate'); + + try { + $this->setViewData(); + + $this->eventDispatcher->notifyEvent('show.apiToken.create', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Sets view data for displaying user's data + * + * @param $apiTokenId + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Defuse\Crypto\Exception\CryptoException + */ + protected function setViewData($apiTokenId = null) + { + $this->view->addTemplate('apitoken', 'itemshow'); + + $apiToken = $apiTokenId ? $this->apiTokenService->getById($apiTokenId) : new ApiTokenData(); + + $this->view->assign('apiToken', $apiToken); + + $this->view->assign('users', UserService::getServiceItems()); + $this->view->assign('actions', ApiTokensUtil::getTokenActions()); + + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); + + if ($this->view->isView === true) { + $this->view->assign('disabled', 'disabled'); + $this->view->assign('readonly', 'readonly'); + } else { + $this->view->assign('disabled'); + $this->view->assign('readonly'); + } + + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::APITOKEN, $apiTokenId)); + } + + /** + * Edit action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function editAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_EDIT)) { + return; + } + + $this->view->assign('header', __('Editar Autorización')); + $this->view->assign('isView', false); + $this->view->assign('route', 'apiToken/saveEdit/' . $id); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.apiToken.edit', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Delete action + * + * @param $id + */ + public function deleteAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_DELETE)) { + return; + } + + try { +// $this->apiTokenService->logAction($id, ActionsInterface::APITOKEN_DELETE); + $this->apiTokenService->delete($id); + + $this->deleteCustomFieldsForItem(ActionsInterface::APITOKEN, $id); + + $this->eventDispatcher->notifyEvent('delete.apiToken', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización eliminada')); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves create action + */ + public function saveCreateAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_CREATE)) { + return; + } + + try { + $form = new ApiTokenForm(); + $form->validate(ActionsInterface::APITOKEN_CREATE); + + $apiTokenData = $form->getItemData(); + + $id = $this->apiTokenService->create($apiTokenData); +// $this->apiTokenService->logAction($id, ActionsInterface::APITOKEN_CREATE); + + $this->addCustomFieldsForItem(ActionsInterface::APITOKEN, $id); + + $this->eventDispatcher->notifyEvent('create.apiToken', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización creada')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (EnvironmentIsBrokenException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (CryptoException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves edit action + * + * @param $id + */ + public function saveEditAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_EDIT)) { + return; + } + + try { + $form = new ApiTokenForm($id); + $form->validate(ActionsInterface::APITOKEN_EDIT); + + $apiTokenData = $form->getItemData(); + + $this->apiTokenService->update($apiTokenData); +// $this->apiTokenService->logAction($id, ActionsInterface::APITOKEN_EDIT); + + $this->updateCustomFieldsForItem(ActionsInterface::APITOKEN, $id); + + $this->eventDispatcher->notifyEvent('edit.apiToken', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización actualizada')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (CryptoException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * View action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function viewAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::APITOKEN_VIEW)) { + return; + } + + $this->view->assign('header', __('Ver Autorización')); + $this->view->assign('isView', true); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.apiToken', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Initialize class + */ + protected function initialize() + { + $this->checkLoggedIn(); + + $this->apiTokenService = new ApiTokenService(); + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/Helpers/AccountActionsHelper.php b/app/modules/web/Controllers/Helpers/AccountActionsHelper.php index 29fe6bf2..ee79a882 100644 --- a/app/modules/web/Controllers/Helpers/AccountActionsHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountActionsHelper.php @@ -31,9 +31,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Detalles de Cuenta')); $action->setTitle(__('Detalles de Cuenta')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconView()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowView'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); @@ -51,9 +52,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Ver Clave')); $action->setTitle(__('Ver Clave')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconViewPass()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowViewPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); $action->addData('action-full', 1); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); @@ -72,9 +74,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Modificar Clave de Cuenta')); $action->setTitle(__('Modificar Clave de Cuenta')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconEditPass()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowViewPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS)); $action->addAttribute('type', 'button'); @@ -92,8 +95,9 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Restaurar cuenta desde este punto')); $action->setTitle(__('Restaurar cuenta desde este punto')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconRestore()); - $action->addData('action-id', 'account/saveEditRestore'); + $action->addData('action-route', 'account/saveEditRestore'); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'account/saveEditRestore'); $action->addAttribute('type', 'button'); @@ -111,8 +115,9 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Guardar')); $action->setTitle(__('Guardar')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconSave()); - $action->addData('action-id', 'account/save'); + $action->addData('action-route', 'account/save'); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'account/save'); $action->addAttribute('type', 'submit'); @@ -133,9 +138,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Copiar Clave en Portapapeles')); $action->setTitle(__('Copiar Clave en Portapapeles')); + $action->addClass('btn-action'); $action->setIcon($ClipboardIcon); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowCopyPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY_PASS)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY_PASS)); $action->addData('action-full', 0); $action->addData('action-sk', $this->view->sk); $action->addData('useclipboard', '1'); @@ -154,9 +160,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::EDIT_ITEM); $action->setName(__('Editar Cuenta')); $action->setTitle(__('Editar Cuenta')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconEdit()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowEdit'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)); $action->addAttribute('type', 'button'); @@ -173,11 +180,12 @@ class AccountActionsHelper extends HelperBase $action->setId(ActionsInterface::PUBLICLINK_CREATE); $action->setName(__('Crear Enlace Público')); $action->setTitle(__('Crear Enlace Público')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconPublicLink()); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::PUBLICLINK_CREATE)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_CREATE)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'link/save'); - $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); + $action->addData('action-next', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); return $action; @@ -193,10 +201,10 @@ class AccountActionsHelper extends HelperBase $action->setName(__('Actualizar Enlace Público')); $action->setTitle(__('Actualizar Enlace Público')); $action->setIcon($this->icons->getIconPublicLink()); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'link/refresh'); - $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); + $action->addData('action-next', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); return $action; @@ -212,9 +220,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::NEW_ITEM); $action->setName(__('Copiar Cuenta')); $action->setTitle(__('Copiar Cuenta')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconCopy()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowCopy'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY)); $action->addAttribute('type', 'button'); @@ -232,9 +241,10 @@ class AccountActionsHelper extends HelperBase $action->setType(DataGridActionType::DELETE_ITEM); $action->setName(__('Eliminar Cuenta')); $action->setTitle(__('Eliminar Cuenta')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconDelete()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowDelete'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_DELETE)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_DELETE)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_DELETE)); $action->addAttribute('type', 'button'); @@ -251,9 +261,10 @@ class AccountActionsHelper extends HelperBase $action->setId(ActionsInterface::ACCOUNT_REQUEST); $action->setName(__('Solicitar Modificación')); $action->setTitle(__('Solicitar Modificación')); + $action->addClass('btn-action'); $action->setIcon($this->icons->getIconEmail()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowRequest'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_REQUEST)); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_REQUEST)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'submit'); @@ -261,6 +272,25 @@ class AccountActionsHelper extends HelperBase return $action; } + /** + * @return DataGridAction + */ + public function getBackAction() + { + $action = new DataGridAction(); + $action->setId('btnBack'); + $action->setName(__('Atrás')); + $action->setTitle(__('Atrás')); + $action->addClass('btn-action'); + $action->setIcon($this->icons->getIconBack()); + $action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); + $action->addData('action-sk', $this->view->sk); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); + $action->addAttribute('type', 'button'); + + return $action; + } + /** * Initialize class */ diff --git a/app/modules/web/Controllers/Helpers/AccountHelper.php b/app/modules/web/Controllers/Helpers/AccountHelper.php index 2b439319..205df418 100644 --- a/app/modules/web/Controllers/Helpers/AccountHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountHelper.php @@ -24,15 +24,12 @@ namespace SP\Modules\Web\Controllers\Helpers; -use SP\Account\Account; use SP\Account\AccountAcl; -use SP\Account\AccountHistory; use SP\Account\AccountUtil; use SP\Account\UserAccounts; use SP\Controller\ControllerBase; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; -use SP\Core\Init; use SP\Core\SessionUtil; use SP\DataModel\AccountExtData; use SP\DataModel\CustomFieldData; @@ -41,10 +38,13 @@ use SP\Mgmt\Customers\Customer; use SP\Mgmt\CustomFields\CustomField; use SP\Mgmt\Groups\Group; use SP\Mgmt\Groups\GroupAccountsUtil; -use SP\Mgmt\PublicLinks\PublicLink; use SP\Mgmt\Tags\Tag; use SP\Mgmt\Users\UserPass; use SP\Mgmt\Users\UserUtil; +use SP\Services\Account\AccountHistoryService; +use SP\Services\Account\AccountService; +use SP\Services\PublicLink\PublicLinkService; +use SP\Util\ErrorUtil; use SP\Util\Json; /** @@ -63,19 +63,27 @@ class AccountHelper extends HelperBase /** * @var AccountAcl */ - private $AccountAcl; + private $accountAcl; /** - * @var Account|AccountHistory instancia para el manejo de datos de una cuenta + * @var AccountService */ - private $Account; + private $accountService; /** - * @var int con el id de la cuenta + * @var int con el Id de la cuenta */ - private $id; + private $accountId; + /** + * @var int el Id de la cuenta en el histórico + */ + private $accountHistoryId; /** * @var AccountExtData */ - private $AccountData; + private $accountData; + /** + * @var bool + */ + private $isHistory; /** * @param Acl $acl @@ -86,24 +94,25 @@ class AccountHelper extends HelperBase } /** - * Establecer las variables que contienen la información de la cuenta. + * Establecer las variables que contienen la información de la cuenta en una fecha concreta. * - * @param $accountId + * @param $accountHistoryId * @param $actionId - * @throws \SP\Core\Exceptions\SPException */ - public function setAccountData($accountId, $actionId) + public function setAccountDataHistory($accountHistoryId, $actionId) { - $this->id = $accountId; + $this->accountHistoryId = $accountHistoryId; $this->actionId = $actionId; + $this->isHistory = true; - $Account = new Account(new AccountExtData($accountId)); - $this->Account = $Account; - $this->AccountData = $Account->getData(); + $this->accountService = new AccountHistoryService(); + $this->accountData = $this->accountService->getById($accountHistoryId); + $this->accountId = $this->accountData->getAccountId(); - $this->view->assign('accountId', $accountId); - $this->view->assign('accountData', $this->AccountData); + $this->view->assign('accountId', $this->accountId); + $this->view->assign('accountData', $this->accountData); $this->view->assign('gotData', $this->isGotData()); + $this->view->assign('accountHistoryId', $accountHistoryId); } /** @@ -111,30 +120,7 @@ class AccountHelper extends HelperBase */ private function isGotData() { - return $this->AccountData !== null; - } - - /** - * Establecer las variables que contienen la información de la cuenta en una fecha concreta. - * - * @param $accountId - * @param $actionId - * @throws \SP\Core\Exceptions\SPException - */ - public function setAccountDataHistory($accountId, $actionId) - { - $this->id = $accountId; - $this->actionId = $actionId; - - $Account = new AccountHistory(new AccountExtData()); - $Account->setId($accountId); - $this->Account = $Account; - $this->AccountData = $Account->getData(); - - $this->view->assign('accountId', $this->AccountData->getAccountId()); - $this->view->assign('accountData', $this->AccountData); - $this->view->assign('gotData', $this->isGotData()); - $this->view->assign('accountHistoryId', $accountId); + return $this->accountData !== null; } /** @@ -142,15 +128,15 @@ class AccountHelper extends HelperBase */ public function getAccountAcl() { - return $this->AccountAcl; + return $this->accountAcl; } /** * @return int */ - public function getId() + public function getAccountId() { - return $this->id; + return $this->accountId; } /** @@ -165,23 +151,31 @@ class AccountHelper extends HelperBase $this->getCustomFieldsForItem(); if ($this->isGotData()) { - $this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory()); - $this->view->assign('accountOtherUsers', UserAccounts::getUsersInfoForAccount($this->id)); - $this->view->assign('accountOtherGroups', GroupAccountsUtil::getGroupsInfoForAccount($this->id)); - $this->view->assign('accountTagsJson', Json::getJson(array_keys($this->getAccount()->getAccountData()->getTags()))); - $this->view->assign('historyData', AccountHistory::getAccountList($this->AccountData->getAccountId())); - $this->view->assign('isModified', strtotime($this->AccountData->getAccountDateEdit()) !== false); + $accountHistoryService = new AccountHistoryService(); + + $this->view->assign('accountIsHistory', $this->isHistory); + $this->view->assign('accountOtherUsers', UserAccounts::getUsersInfoForAccount($this->accountId)); + $this->view->assign('accountOtherGroups', GroupAccountsUtil::getGroupsInfoForAccount($this->accountId)); + $this->view->assign('accountTagsJson', Json::getJson(array_keys($this->accountData->getTags()))); + $this->view->assign('historyData', $accountHistoryService->getHistoryForAccount($this->accountId)); + $this->view->assign('isModified', strtotime($this->accountData->getAccountDateEdit()) !== false); $this->view->assign('maxFileSize', round($this->configData->getFilesAllowedSize() / 1024, 1)); $this->view->assign('filesAllowedExts', implode(',', $this->configData->getFilesAllowedExts())); - $PublicLinkData = PublicLink::getItem()->getHashForItem($this->id); + if ($this->configData->isPublinksEnabled() && $this->accountAcl->isShowLink()) { + $publicLinkService = new PublicLinkService(); + $publicLinkData = $publicLinkService->getHashForItem($this->accountId); - $publicLinkUrl = ($this->configData->isPublinksEnabled() && $PublicLinkData ? Init::$WEBURI . '/index.php?h=' . $PublicLinkData->getPublicLinkHash() . '&a=link' : null); - $this->view->assign('publicLinkUrl', $publicLinkUrl); - $this->view->assign('publicLinkId', $PublicLinkData ? $PublicLinkData->getPublicLinkId() : 0); + $publicLinkUrl = $publicLinkData ? PublicLinkService::getLinkForHash($publicLinkData->getPublicLinkHash()) : null; + $this->view->assign('publicLinkUrl', $publicLinkUrl); + $this->view->assign('publicLinkId', $publicLinkData ? $publicLinkData->getPublicLinkId() : 0); + $this->view->assign('publicLinkShow', true); + } else { + $this->view->assign('publicLinkShow', false); + } - $this->view->assign('accountPassDate', date('Y-m-d H:i:s', $this->AccountData->getAccountPassDate())); - $this->view->assign('accountPassDateChange', date('Y-m-d', $this->AccountData->getAccountPassDateChange() ?: 0)); + $this->view->assign('accountPassDate', date('Y-m-d H:i:s', $this->accountData->getAccountPassDate())); + $this->view->assign('accountPassDateChange', date('Y-m-d', $this->accountData->getAccountPassDateChange() ?: 0)); } else { $this->view->assign('accountPassDateChange', date('Y-m-d', time() + 7776000)); } @@ -200,8 +194,8 @@ class AccountHelper extends HelperBase $this->view->assign('mailRequestEnabled', $this->configData->isMailRequestsEnabled()); $this->view->assign('passToImageEnabled', $this->configData->isAccountPassToImage()); - $this->view->assign('otherAccounts', AccountUtil::getAccountsForUser($this->session, $this->id)); - $this->view->assign('linkedAccounts', AccountUtil::getLinkedAccounts($this->id, $this->session)); + $this->view->assign('otherAccounts', AccountUtil::getAccountsForUser($this->session, $this->accountId)); + $this->view->assign('linkedAccounts', AccountUtil::getLinkedAccounts($this->accountId, $this->session)); $this->view->assign('addCustomerEnabled', $this->acl->checkUserAccess(ActionsInterface::CLIENT)); $this->view->assign('addCategoryEnabled', $this->acl->checkUserAccess(ActionsInterface::CATEGORY)); @@ -209,8 +203,8 @@ class AccountHelper extends HelperBase $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('showViewCustomPass', $this->accountAcl->isShowViewPass()); + $this->view->assign('AccountAcl', $this->accountAcl); $this->view->assign('actions', $this->getActions()); } @@ -219,15 +213,7 @@ class AccountHelper extends HelperBase */ private function getCustomFieldsForItem() { - $this->view->assign('customFields', CustomField::getItem(new CustomFieldData(ActionsInterface::ACCOUNT))->getById($this->id)); - } - - /** - * @return Account|AccountHistory - */ - public function getAccount() - { - return $this->Account ?: new Account(new AccountExtData()); + $this->view->assign('customFields', CustomField::getItem(new CustomFieldData(ActionsInterface::ACCOUNT))->getById($this->accountId)); } /** @@ -238,19 +224,28 @@ class AccountHelper extends HelperBase $actionsEnabled = []; $actions = new AccountActionsHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $account = $this->getAccount(); - /** @var AccountExtData $accountData */ - $accountData = $account->getAccountData(); + $actionBack = $actions->getBackAction(); - if ($this->AccountAcl->isShowDelete()) { - $actionsEnabled[] = $actions->getDeleteAction()->addData('item-id', $accountData->getAccountId()); + if ($this->isHistory) { + $actionBack->addData('item-id', $this->accountId); + $actionBack->setName(__('Ver Actual')); + $actionBack->setTitle(__('Ver Actual')); + } else { + $actionBack->setData([]); + $actionBack->setClasses(['btn-back']); } - if ($this->AccountAcl->isShowLink() - && $this->AccountAcl->isShowViewPass() - && $account->getAccountParentId() === 0 - && $account->getAccountIsHistory() !== 1 + $actionsEnabled[] = $actionBack; + + if ($this->accountAcl->isShowDelete()) { + $actionsEnabled[] = $actions->getDeleteAction()->addData('item-id', $this->accountId); + } + + if ($this->isHistory === false + && $this->accountAcl->isShowLink() + && $this->accountAcl->isShowViewPass() + && $this->accountData->getAccountParentId() === 0 ) { if (null === $this->view->publicLinkUrl) { $actionsEnabled[] = $actions->getPublicLinkAction(); @@ -259,56 +254,56 @@ class AccountHelper extends HelperBase } } - if ($this->AccountAcl->isShowViewPass()) { - $action = $actions->getViewPassAction(); + if ($this->accountAcl->isShowViewPass()) { + $actionViewPass = $actions->getViewPassAction(); $actionCopy = $actions->getCopyPassAction(); - $action->addData('parent-id', $accountData->getAccountParentId()); - $actionCopy->addData('parent-id', $accountData->getAccountParentId()); + $actionViewPass->addData('parent-id', $this->accountData->getAccountParentId()); + $actionCopy->addData('parent-id', $this->accountData->getAccountParentId()); - $action->addData('history', $account->getAccountIsHistory()); - $actionCopy->addData('history', $account->getAccountIsHistory()); + $actionViewPass->addData('history', (int)$this->isHistory); + $actionCopy->addData('history', (int)$this->isHistory); - if ($account->getAccountIsHistory()) { - $action->addData('item-id', $this->id); - $actionCopy->addData('item-id', $this->id); + if ($this->isHistory) { + $actionViewPass->addData('item-id', $this->accountHistoryId); + $actionCopy->addData('item-id', $this->accountHistoryId); } else { - $action->addData('item-id', $accountData->getAccountId()); - $actionCopy->addData('item-id', $accountData->getAccountId()); + $actionViewPass->addData('item-id', $this->accountId); + $actionCopy->addData('item-id', $this->accountId); } - $actionsEnabled[] = $action; + $actionsEnabled[] = $actionViewPass; $actionsEnabled[] = $actionCopy; } - if ($this->AccountAcl->isShowCopy()) { - $actionsEnabled[] = $actions->getCopyAction()->addData('item-id', $accountData->getAccountId()); + if ($this->accountAcl->isShowCopy()) { + $actionsEnabled[] = $actions->getCopyAction()->addData('item-id', $this->accountId); } - if ($this->AccountAcl->isShowEditPass()) { - $actionsEnabled[] = $actions->getEditPassAction()->addData('item-id', $accountData->getAccountId()); + if ($this->accountAcl->isShowEditPass()) { + $actionsEnabled[] = $actions->getEditPassAction()->addData('item-id', $this->accountId); } - if ($this->AccountAcl->isShowEdit()) { - $actionsEnabled[] = $actions->getEditAction()->addData('item-id', $accountData->getAccountId()); + if ($this->accountAcl->isShowEdit()) { + $actionsEnabled[] = $actions->getEditAction()->addData('item-id', $this->accountId); } if ($this->actionId === ActionsInterface::ACCOUNT_VIEW - && !$this->AccountAcl->isShowEdit() + && !$this->accountAcl->isShowEdit() && $this->configData->isMailRequestsEnabled() ) { - $actionsEnabled[] = $actions->getRequestAction()->addData('item-id', $accountData->getAccountId()); + $actionsEnabled[] = $actions->getRequestAction()->addData('item-id', $this->accountId); } - if ($this->AccountAcl->isShowRestore()) { - $action = $actions->getRestoreAction(); - $action->addData('item-id', $accountData->getAccountId()); - $action->addData('history-id', $this->id); + if ($this->accountAcl->isShowRestore()) { + $actionRestore = $actions->getRestoreAction(); + $actionRestore->addData('item-id', $this->accountId); + $actionRestore->addData('history-id', $this->accountHistoryId); - $actionsEnabled[] = $action; + $actionsEnabled[] = $actionRestore; } - if ($this->AccountAcl->isShowSave()) { + if ($this->accountAcl->isShowSave()) { $actionsEnabled[] = $actions->getSaveAction()->addAttribute('form', 'frmAccount'); } @@ -325,24 +320,27 @@ class AccountHelper extends HelperBase { $this->view->assign('showLogo', false); - $Acl = new AccountAcl($this->Account, $this->actionId); - $this->AccountAcl = $Acl; + $acl = new AccountAcl($this->actionId, $this->accountData, $this->isHistory); + $this->accountAcl = $acl; if (!$this->acl->checkUserAccess($this->actionId)) { - $controller->showError(ControllerBase::ERR_PAGE_NO_PERMISSION); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION); + return false; } if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getUserId())) { - $controller->showError(ControllerBase::ERR_UPDATE_MPASS); + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_UPDATE_MPASS); + return false; } - if ($this->id > 0) { - $this->AccountAcl = $Acl->getAcl(); + if ($this->accountId > 0) { + $this->accountAcl = $acl->getAcl(); + + if (!$this->accountAcl->checkAccountAccess()) { + ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_ACCOUNT_NO_PERMISSION); - if (!$this->AccountAcl->checkAccountAccess()) { - $controller->showError(ControllerBase::ERR_ACCOUNT_NO_PERMISSION); return false; } } @@ -358,8 +356,55 @@ class AccountHelper extends HelperBase $this->actionId = $actionId; } + /** + * @return AccountService + */ + public function getAccountService() + { + return $this->accountService; + } + + /** + * @return AccountExtData + */ + public function getAccountData() + { + return $this->accountData; + } + + /** + * Establecer las variables que contienen la información de la cuenta. + * + * @param $accountId + * @param $actionId + * @throws \SP\Core\Exceptions\SPException + */ + public function setAccountData($accountId, $actionId) + { + $this->accountId = $accountId; + $this->actionId = $actionId; + $this->isHistory = false; + + $this->accountService = new AccountService(); + $this->accountData = $this->accountService->getById($accountId); + + $this->view->assign('accountId', $accountId); + $this->view->assign('accountData', $this->accountData); + $this->view->assign('gotData', $this->isGotData()); + } + + /** + * @return int + */ + public function getAccountHistoryId() + { + return $this->accountHistoryId; + } + /** * Initialize + * + * @throws \Psr\Container\ContainerExceptionInterface */ protected function initialize() { diff --git a/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php b/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php index fa0dacfc..8f678b08 100644 --- a/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php @@ -5,10 +5,10 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\Crypt\Crypt; +use SP\Core\Crypt\Session as CryptSession; use SP\Core\SessionUtil; use SP\DataModel\AccountPassData; use SP\Mgmt\Users\UserPass; -use SP\Core\Crypt\Session as CryptSession; use SP\Util\ImageUtil; /** @@ -27,8 +27,14 @@ class AccountPasswordHelper extends HelperBase /** * @param AccountPassData $account * @param \SP\Core\Acl\Acl $acl - * @param $type + * @param $type * @return string + * @throws HelperException + * @throws \Defuse\Crypto\Exception\BadFormatException + * @throws \Defuse\Crypto\Exception\CryptoException + * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \SP\Core\Exceptions\SPException */ public function getPassword(AccountPassData $account, Acl $acl, $type) { @@ -50,13 +56,16 @@ class AccountPasswordHelper extends HelperBase * @param AccountPassData $accountData * @return string * @throws HelperException + * @throws \Defuse\Crypto\Exception\BadFormatException + * @throws \Defuse\Crypto\Exception\CryptoException + * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException */ protected function getPasswordClear(AccountPassData $accountData) { if (!$this->acl->checkUserAccess(ActionsInterface::ACCOUNT_VIEW_PASS) || $accountData->getAccountId() === 0 ) { - throw new HelperException(__('No tiene permisos para acceder a esta cuenta', false)); + throw new HelperException(__u('No tiene permisos para acceder a esta cuenta')); } if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getUserId())) { @@ -71,6 +80,12 @@ class AccountPasswordHelper extends HelperBase /** * @param AccountPassData $accountData + * @throws HelperException + * @throws \Defuse\Crypto\Exception\BadFormatException + * @throws \Defuse\Crypto\Exception\CryptoException + * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \SP\Core\Exceptions\SPException */ protected function setTemplateVars(AccountPassData $accountData) { diff --git a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php index 85e03645..9a7a9a7b 100644 --- a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php @@ -26,13 +26,11 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Account\AccountSearch; use SP\Account\AccountsSearchItem; -use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\SessionUtil; use SP\Html\DataGrid\DataGrid; use SP\Html\DataGrid\DataGridAction; use SP\Html\DataGrid\DataGridActionSearch; -use SP\Html\DataGrid\DataGridActionType; use SP\Html\DataGrid\DataGridData; use SP\Html\DataGrid\DataGridHeaderSort; use SP\Html\DataGrid\DataGridPager; @@ -84,8 +82,8 @@ class AccountSearchHelper extends HelperBase * Obtener los resultados de una búsqueda * * @throws \InvalidArgumentException - * @throws \ReflectionException * @throws \Psr\Container\ContainerExceptionInterface + * @throws \SP\Core\Exceptions\SPException */ public function getSearch() { @@ -136,7 +134,6 @@ class AccountSearchHelper extends HelperBase * * @return DataGrid * @throws \Psr\Container\ContainerExceptionInterface - * @throws \ReflectionException */ private function getGrid() { diff --git a/app/modules/web/Controllers/Helpers/ItemsGridHelper.php b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php index 2549e9fd..4092046e 100644 --- a/app/modules/web/Controllers/Helpers/ItemsGridHelper.php +++ b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php @@ -28,7 +28,6 @@ defined('APP_ROOT') || die(); use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; -use SP\Core\Exceptions\InvalidArgumentException; use SP\Core\UI\ThemeIconsBase; use SP\Html\Assets\FontIcon; use SP\Html\DataGrid\DataGridAction; @@ -65,10 +64,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getCategoriesGrid() + public function getCategoriesGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -80,6 +79,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('category_id'); $GridData->addDataRowSource('category_name'); $GridData->addDataRowSource('category_description'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -98,7 +98,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchCategory'); $GridActionSearch->setTitle(__('Buscar Categoría')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::CATEGORY_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -112,7 +112,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::CATEGORY_CREATE)); $Grid->setDataActions($GridActionNew); @@ -123,7 +123,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Categoría')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::CATEGORY_VIEW)); $Grid->setDataActions($GridActionEdit); @@ -135,7 +135,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Categoría')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::CATEGORY_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -165,10 +165,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getClientsGrid() + public function getClientsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -180,6 +180,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('customer_id'); $GridData->addDataRowSource('customer_name'); $GridData->addDataRowSource('customer_description'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -198,7 +199,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchCustomer'); $GridActionSearch->setTitle(__('Buscar Cliente')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::CLIENT_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -212,7 +213,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::CLIENT_CREATE)); $Grid->setDataActions($GridActionNew); @@ -223,7 +224,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Cliente')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::CLIENT_VIEW)); $Grid->setDataActions($GridActionEdit); @@ -234,7 +235,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Cliente')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::CLIENT_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -243,10 +244,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getCustomFieldsGrid() + public function getCustomFieldsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -260,6 +261,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSource('moduleName'); $GridData->addDataRowSource('name'); $GridData->addDataRowSource('typeName'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -278,7 +280,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchCustomField'); $GridActionSearch->setTitle(__('Buscar Campo')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -292,7 +294,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_CREATE)); $Grid->setDataActions($GridActionNew); @@ -303,7 +305,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Campo')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_VIEW)); $Grid->setDataActions($GridActionEdit); @@ -314,7 +316,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Campo')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -323,10 +325,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getFilesGrid() + public function getFilesGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -344,6 +346,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSource('accfile_name'); $GridData->addDataRowSource('accfile_type'); $GridData->addDataRowSource('accfile_size'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -362,7 +365,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchFile'); $GridActionSearch->setTitle(__('Buscar Archivo')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::FILE_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::FILE_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -375,7 +378,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setTitle(__('Ver Archivo')); $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('file/view'); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::FILE_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::FILE_VIEW)); $Grid->setDataActions($GridActionView); @@ -386,7 +389,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Archivo')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::FILE_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::FILE_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -395,10 +398,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getAccountsGrid() + public function getAccountsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -410,6 +413,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('account_id'); $GridData->addDataRowSource('account_name'); $GridData->addDataRowSource('customer_name'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -428,7 +432,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchAccount'); $GridActionSearch->setTitle(__('Buscar Cuenta')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -441,7 +445,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Cuenta')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -450,10 +454,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getAccountsHistoryGrid() + public function getAccountsHistoryGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -473,6 +477,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSource('acchistory_date'); $GridData->addDataRowSourceWithIcon('acchistory_isModify', $iconEdit->setTitle(__('Modificada'))->setClass('opacity50')); $GridData->addDataRowSourceWithIcon('acchistory_isDeleted', $iconDelete->setTitle(__('Eliminada'))->setClass('opacity50')); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -491,7 +496,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchAccountHistory'); $GridActionSearch->setTitle(__('Buscar Cuenta')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH_HISTORY)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH_HISTORY)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -503,7 +508,7 @@ class ItemsGridHelper extends HelperBase $GridActionRestore->setName(__('Restaurar Cuenta')); $GridActionRestore->setTitle(__('Restaurar Cuenta')); $GridActionRestore->setIcon($this->icons->getIconRestore()); - $GridActionRestore->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_RESTORE)); + $GridActionRestore->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_RESTORE)); // $Grid->setDataActions($GridActionRestore); @@ -514,7 +519,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Cuenta')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE_HISTORY)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE_HISTORY)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -523,10 +528,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getUsersGrid() + public function getUsersGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -547,6 +552,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSourceWithIcon('user_isAdminAcc', $this->icons->getIconAccAdmin()); $GridData->addDataRowSourceWithIcon('user_isLdap', $this->icons->getIconLdapUser()); $GridData->addDataRowSourceWithIcon('user_isDisabled', $this->icons->getIconDisabled()); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -565,7 +571,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchUser'); $GridActionSearch->setTitle(__('Buscar Usuario')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::USER_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -578,7 +584,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::USER_CREATE)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_CREATE)); $Grid->setDataActions($GridActionNew); @@ -593,7 +599,7 @@ class ItemsGridHelper extends HelperBase $GridActionLdapSync->setIcon(new FontIcon('get_app')); $GridActionLdapSync->setSkip(true); $GridActionLdapSync->setOnClickFunction('appMgmt/ldapSync'); - $GridActionLdapSync->addData('route', Acl::getActionRoute(ActionsInterface::LDAP_SYNC)); + $GridActionLdapSync->addData('action-route', Acl::getActionRoute(ActionsInterface::LDAP_SYNC)); $Grid->setDataActions($GridActionLdapSync); } @@ -606,7 +612,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setTitle(__('Ver Detalles de Usuario')); $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('appMgmt/show'); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::USER_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_VIEW)); $Grid->setDataActions($GridActionView); @@ -617,7 +623,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Usuario')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::USER_EDIT)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_EDIT)); $Grid->setDataActions($GridActionEdit); @@ -629,7 +635,7 @@ class ItemsGridHelper extends HelperBase $GridActionEditPass->setIcon($this->icons->getIconEditPass()); $GridActionEditPass->setOnClickFunction('appMgmt/show'); $GridActionEditPass->setFilterRowSource('user_isLdap'); - $GridActionEditPass->addData('route', Acl::getActionRoute(ActionsInterface::USER_EDIT_PASS)); + $GridActionEditPass->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_EDIT_PASS)); $Grid->setDataActions($GridActionEditPass); @@ -640,7 +646,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Usuario')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::USER_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -649,10 +655,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getGroupsGrid() + public function getUserGroupsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -664,6 +670,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('usergroup_id'); $GridData->addDataRowSource('usergroup_name'); $GridData->addDataRowSource('usergroup_description'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -682,7 +689,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchGroup'); $GridActionSearch->setTitle(__('Buscar Grupo')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::GROUP_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -696,10 +703,21 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::GROUP_CREATE)); $Grid->setDataActions($GridActionNew); + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::GROUP_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Grupo')); + $GridActionView->setTitle(__('Ver Grupo')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::GROUP_VIEW)); + + $Grid->setDataActions($GridActionView); + $GridActionEdit = new DataGridAction(); $GridActionEdit->setId(ActionsInterface::GROUP_EDIT); $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); @@ -707,7 +725,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Grupo')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::GROUP_EDIT)); $Grid->setDataActions($GridActionEdit); @@ -718,7 +736,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Grupo')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::GROUP_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -727,10 +745,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getProfilesGrid() + public function getUserProfilesGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -740,6 +758,7 @@ class ItemsGridHelper extends HelperBase $GridData = new DataGridData(); $GridData->setDataRowSourceId('userprofile_id'); $GridData->addDataRowSource('userprofile_name'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -758,7 +777,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchProfile'); $GridActionSearch->setTitle(__('Buscar Perfil')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::PROFILE_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -772,7 +791,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::PROFILE_CREATE)); $Grid->setDataActions($GridActionNew); @@ -783,7 +802,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setTitle(__('Ver Detalles de Perfil')); $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('appMgmt/show'); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); $Grid->setDataActions($GridActionView); @@ -794,7 +813,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Perfil')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::PROFILE_EDIT)); $Grid->setDataActions($GridActionEdit); @@ -805,7 +824,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Perfil')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::PROFILE_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -814,10 +833,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getApiTokensGrid() + public function getApiTokensGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -829,6 +848,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('authtoken_id'); $GridData->addDataRowSource('user_login'); $GridData->addDataRowSource('authtoken_actionId'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -847,7 +867,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchToken'); $GridActionSearch->setTitle(__('Buscar Token')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::APITOKEN_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -861,7 +881,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::APITOKEN_CREATE)); $Grid->setDataActions($GridActionNew); @@ -872,7 +892,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setTitle(__('Ver token de Autorización')); $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('appMgmt/show'); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); $Grid->setDataActions($GridActionView); @@ -883,7 +903,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setTitle(__('Editar Autorización')); $GridActionEdit->setIcon($this->icons->getIconEdit()); $GridActionEdit->setOnClickFunction('appMgmt/show'); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::APITOKEN_EDIT)); $Grid->setDataActions($GridActionEdit); @@ -894,7 +914,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Autorización')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::APITOKEN_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -903,10 +923,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getPublicLinksGrid() + public function getPublicLinksGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -926,6 +946,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSource('userLogin'); $GridData->addDataRowSource('notify'); $GridData->addDataRowSource('countViews'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -944,12 +965,24 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchLink'); $GridActionSearch->setTitle(__('Buscar Enlace')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::PUBLICLINK_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Enlace')); + $GridActionNew->setTitle(__('Nuevo Enlace')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_CREATE)); + + $Grid->setDataActions($GridActionNew); + $GridActionView = new DataGridAction(); $GridActionView->setId(ActionsInterface::PUBLICLINK_VIEW); $GridActionView->setType(DataGridActionType::VIEW_ITEM); @@ -957,7 +990,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setTitle(__('Ver Enlace')); $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('appMgmt/show'); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_VIEW)); $Grid->setDataActions($GridActionView); @@ -967,7 +1000,7 @@ class ItemsGridHelper extends HelperBase $GridActionRefresh->setTitle(__('Renovar Enlace')); $GridActionRefresh->setIcon($this->icons->getIconRefresh()); $GridActionRefresh->setOnClickFunction('link/refresh'); - $GridActionRefresh->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); + $GridActionRefresh->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); $Grid->setDataActions($GridActionRefresh); @@ -978,7 +1011,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Enlace')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -987,10 +1020,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getTagsGrid() + public function getTagsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -1000,6 +1033,7 @@ class ItemsGridHelper extends HelperBase $GridData = new DataGridData(); $GridData->setDataRowSourceId('tag_id'); $GridData->addDataRowSource('tag_name'); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -1018,7 +1052,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchTag'); $GridActionSearch->setTitle(__('Buscar Etiqueta')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::TAG_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::TAG_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -1032,7 +1066,7 @@ class ItemsGridHelper extends HelperBase $GridActionNew->setIcon($this->icons->getIconAdd()); $GridActionNew->setSkip(true); $GridActionNew->setOnClickFunction('appMgmt/show'); - $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::TAG_VIEW)); + $GridActionNew->addData('action-route', Acl::getActionRoute(ActionsInterface::TAG_CREATE)); $Grid->setDataActions($GridActionNew); @@ -1042,7 +1076,7 @@ class ItemsGridHelper extends HelperBase $GridActionEdit->setName(__('Editar Etiqueta')); $GridActionEdit->setTitle(__('Editar Etiqueta')); $GridActionEdit->setIcon($this->icons->getIconEdit()); - $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::TAG_VIEW)); + $GridActionEdit->addData('action-route', Acl::getActionRoute(ActionsInterface::TAG_VIEW)); $Grid->setDataActions($GridActionEdit); @@ -1053,7 +1087,7 @@ class ItemsGridHelper extends HelperBase $GridActionDel->setTitle(__('Eliminar Etiqueta')); $GridActionDel->setIcon($this->icons->getIconDelete()); $GridActionDel->setOnClickFunction('appMgmt/delete'); - $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::TAG_DELETE)); + $GridActionDel->addData('action-route', Acl::getActionRoute(ActionsInterface::TAG_DELETE)); $Grid->setDataActions($GridActionDel); $Grid->setDataActions($GridActionDel, true); @@ -1062,10 +1096,10 @@ class ItemsGridHelper extends HelperBase } /** + * @param array $data * @return DataGridTab - * @throws InvalidArgumentException */ - public function getPluginsGrid() + public function getPluginsGrid(array $data) { // Grid Header $GridHeaders = new DataGridHeader(); @@ -1079,6 +1113,7 @@ class ItemsGridHelper extends HelperBase $GridData->addDataRowSourceWithIcon('plugin_enabled', $this->icons->getIconEnabled()); $GridData->addDataRowSourceWithIcon('plugin_enabled', $this->icons->getIconDisabled(), 0); $GridData->addDataRowSourceWithIcon('plugin_available', $this->icons->getIconDelete()->setTitle(__('No disponible')), 0); + $GridData->setData($data); // Grid $Grid = new DataGridTab(); @@ -1097,7 +1132,7 @@ class ItemsGridHelper extends HelperBase $GridActionSearch->setName('frmSearchPlugin'); $GridActionSearch->setTitle(__('Buscar Plugin')); $GridActionSearch->setOnSubmitFunction('appMgmt/search'); - $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_SEARCH)); + $GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_SEARCH)); $Grid->setDataActions($GridActionSearch); $Grid->setPager($this->getPager($GridActionSearch)); @@ -1111,7 +1146,7 @@ class ItemsGridHelper extends HelperBase $GridActionView->setIcon($this->icons->getIconView()); $GridActionView->setOnClickFunction('appMgmt/show'); $GridActionView->setFilterRowSource('plugin_available', 0); - $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_VIEW)); + $GridActionView->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_VIEW)); $Grid->setDataActions($GridActionView); @@ -1123,7 +1158,7 @@ class ItemsGridHelper extends HelperBase $GridActionEnable->setOnClickFunction('plugin/toggle'); $GridActionEnable->setFilterRowSource('plugin_enabled'); $GridActionEnable->setFilterRowSource('plugin_available', 0); - $GridActionEnable->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_ENABLE)); + $GridActionEnable->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_ENABLE)); $Grid->setDataActions($GridActionEnable); @@ -1135,7 +1170,7 @@ class ItemsGridHelper extends HelperBase $GridActionDisable->setOnClickFunction('plugin/toggle'); $GridActionDisable->setFilterRowSource('plugin_enabled', 0); $GridActionDisable->setFilterRowSource('plugin_available', 0); - $GridActionDisable->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_DISABLE)); + $GridActionDisable->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_DISABLE)); $Grid->setDataActions($GridActionDisable); @@ -1146,7 +1181,7 @@ class ItemsGridHelper extends HelperBase $GridActionReset->setIcon($this->icons->getIconRefresh()); $GridActionReset->setOnClickFunction('plugin/reset'); $GridActionReset->setFilterRowSource('plugin_available', 0); - $GridActionReset->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_RESET)); + $GridActionReset->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_RESET)); $Grid->setDataActions($GridActionReset); diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php index ded30f4d..a426309d 100644 --- a/app/modules/web/Controllers/Helpers/LayoutHelper.php +++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php @@ -58,6 +58,37 @@ class LayoutHelper extends HelperBase $this->theme = $theme; } + /** + * Sets a full layout page + * + * @param Acl $acl + * @param string $page Page/view name + * @return LayoutHelper + */ + public function getFullLayout(Acl $acl, $page = '') + { + $this->setPage($page); + $this->initBody(); + $this->getSessionBar(); + $this->getMenu($acl); + + $this->view->addPartial('body-content'); + $this->view->addPartial('body-footer'); + $this->view->addPartial('body-end'); + + return $this; + } + + /** + * Establecer la variable de página de la vista + * + * @param $page + */ + public function setPage($page) + { + $this->view->assign('page', $page); + } + /** * Inicializar las variables para la vista principal de la aplicación */ @@ -70,7 +101,7 @@ class LayoutHelper extends HelperBase $this->view->assign('useLayout', true); $this->view->assign('isInstalled', $this->configData->isInstalled()); - $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('sk', SessionUtil::getSessionKey(true, $this->configData)); $this->view->assign('appInfo', Util::getAppInfo()); $this->view->assign('appVersion', Util::getVersionString()); $this->view->assign('isDemoMode', $this->configData->isDemoEnabled()); @@ -119,8 +150,10 @@ class LayoutHelper extends HelperBase $this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash); } - if ($this->loggedIn && $this->session->getUserPreferences()->getUserId() > 0) { - $resultsAsCards = $this->session->getUserPreferences()->isResultsAsCards(); + $userPreferences = $this->session->getUserPreferences(); + + if ($this->loggedIn && $userPreferences->getUserId() > 0) { + $resultsAsCards = $userPreferences->isResultsAsCards(); } else { $resultsAsCards = $this->configData->isResultsAsCards(); } @@ -174,16 +207,6 @@ class LayoutHelper extends HelperBase header('Pragma: public; max-age=0'); } - /** - * Establecer la variable de página de la vista - * - * @param $page - */ - public function setPage($page) - { - $this->view->assign('page', $page); - } - /** * Obtener los datos para la mostrar la barra de sesión */ @@ -222,89 +245,109 @@ class LayoutHelper extends HelperBase $icons = $this->theme->getIcons(); - $ActionSearch = new DataGridAction(); - $ActionSearch->setId(ActionsInterface::ACCOUNT); - $ActionSearch->setTitle(__('Buscar')); - $ActionSearch->setIcon($icons->getIconSearch()); - $ActionSearch->setData([ + $actionSearch = new DataGridAction(); + $actionSearch->setId(ActionsInterface::ACCOUNT); + $actionSearch->setTitle(__('Buscar')); + $actionSearch->setIcon($icons->getIconSearch()); + $actionSearch->setData([ 'historyReset' => 1, 'view' => 'search', 'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT) ]); - $this->view->append('actions', $ActionSearch); + $this->view->append('actions', $actionSearch); if ($acl->checkUserAccess(ActionsInterface::ACCOUNT_CREATE)) { - $ActionNew = new DataGridAction(); - $ActionNew->setId(ActionsInterface::ACCOUNT_CREATE); - $ActionNew->setTitle(__('Nueva Cuenta')); - $ActionNew->setIcon($icons->getIconAdd()); - $ActionNew->setData([ + $actionNewAccount = new DataGridAction(); + $actionNewAccount->setId(ActionsInterface::ACCOUNT_CREATE); + $actionNewAccount->setTitle(__('Nueva Cuenta')); + $actionNewAccount->setIcon($icons->getIconAdd()); + $actionNewAccount->setData([ 'historyReset' => 0, 'view' => 'account', 'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT_CREATE) ]); - $this->view->append('actions', $ActionNew); + $this->view->append('actions', $actionNewAccount); } if ($acl->checkUserAccess(ActionsInterface::ACCESS_MANAGE)) { - $ActionUsr = new DataGridAction(); - $ActionUsr->setId(ActionsInterface::ACCESS_MANAGE); - $ActionUsr->setTitle(__('Usuarios y Accesos')); - $ActionUsr->setIcon($icons->getIconAccount()); - $ActionUsr->setData([ + $actionAccessManager = new DataGridAction(); + $actionAccessManager->setId(ActionsInterface::ACCESS_MANAGE); + $actionAccessManager->setTitle(__('Usuarios y Accesos')); + $actionAccessManager->setIcon($icons->getIconAccount()); + $actionAccessManager->setData([ 'historyReset' => 0, 'view' => 'datatabs', 'route' => Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE) ]); - $this->view->append('actions', $ActionUsr); + $this->view->append('actions', $actionAccessManager); } if ($acl->checkUserAccess(ActionsInterface::ITEMS_MANAGE)) { - $ActionMgm = new DataGridAction(); - $ActionMgm->setId(ActionsInterface::ITEMS_MANAGE); - $ActionMgm->setTitle(__('Elementos y Personalización')); - $ActionMgm->setIcon($icons->getIconGroup()); - $ActionMgm->setData([ + $actionItemManager = new DataGridAction(); + $actionItemManager->setId(ActionsInterface::ITEMS_MANAGE); + $actionItemManager->setTitle(__('Elementos y Personalización')); + $actionItemManager->setIcon($icons->getIconGroup()); + $actionItemManager->setData([ 'historyReset' => 0, 'view' => 'datatabs', 'route' => Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE) ]); - $this->view->append('actions', $ActionMgm); + $this->view->append('actions', $actionItemManager); } if ($acl->checkUserAccess(ActionsInterface::CONFIG)) { - $ActionConfig = new DataGridAction(); - $ActionConfig->setId('config'); - $ActionConfig->setTitle(__('Configuración')); - $ActionConfig->setIcon($icons->getIconSettings()); - $ActionConfig->setData([ + $actionConfigManager = new DataGridAction(); + $actionConfigManager->setId('config'); + $actionConfigManager->setTitle(__('Configuración')); + $actionConfigManager->setIcon($icons->getIconSettings()); + $actionConfigManager->setData([ 'historyReset' => 1, 'view' => 'config', 'route' => Acl::getActionRoute(ActionsInterface::CONFIG) ]); - $this->view->append('actions', $ActionConfig); + $this->view->append('actions', $actionConfigManager); } if ($acl->checkUserAccess(ActionsInterface::EVENTLOG) && $this->configData->isLogEnabled()) { - $ActionEventlog = new DataGridAction(); - $ActionEventlog->setId(ActionsInterface::EVENTLOG); - $ActionEventlog->setTitle(__('Registro de Eventos')); - $ActionEventlog->setIcon($icons->getIconHeadline()); - $ActionEventlog->setData([ + $actionEventlog = new DataGridAction(); + $actionEventlog->setId(ActionsInterface::EVENTLOG); + $actionEventlog->setTitle(__('Registro de Eventos')); + $actionEventlog->setIcon($icons->getIconHeadline()); + $actionEventlog->setData([ 'historyReset' => 1, 'view' => 'eventlog', 'route' => Acl::getActionRoute(ActionsInterface::EVENTLOG) ]); - $this->view->append('actions', $ActionEventlog); + $this->view->append('actions', $actionEventlog); } } + /** + * Sets a full layout page + * + * @param string $template + * @param string $page Page/view name + * @return LayoutHelper + */ + public function getPublicLayout($template, $page = '') + { + $this->setPage($page); + $this->initBody(); + + $this->view->addPartial('body-header'); + $this->view->addTemplate($template); + $this->view->addPartial('body-footer'); + $this->view->addPartial('body-end'); + + return $this; + } + /** * @param bool $loggedIn */ diff --git a/app/modules/web/Controllers/IndexController.php b/app/modules/web/Controllers/IndexController.php index 9b5fa2ef..cfe8ed0f 100644 --- a/app/modules/web/Controllers/IndexController.php +++ b/app/modules/web/Controllers/IndexController.php @@ -38,8 +38,6 @@ class IndexController extends ControllerBase { /** * Index action - * - * @throws \SP\Core\Exceptions\SPException */ public function indexAction() { @@ -47,14 +45,7 @@ class IndexController extends ControllerBase Response::redirect('index.php?r=login'); } else { $LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $LayoutHelper->setPage('main'); - $LayoutHelper->initBody(); - $LayoutHelper->getSessionBar(); - $LayoutHelper->getMenu($this->acl); - - $this->view->addPartial('body-content'); - $this->view->addPartial('body-footer'); - $this->view->addPartial('body-end'); + $LayoutHelper->getFullLayout($this->acl, 'main'); $this->view(); } @@ -62,6 +53,8 @@ class IndexController extends ControllerBase /** * Updates checking action + * + * @throws \Psr\Container\ContainerExceptionInterface */ public function checkUpdatesAction() { diff --git a/app/modules/web/Controllers/ItemsController.php b/app/modules/web/Controllers/ItemsController.php index 66b3f5bc..c8323ed4 100644 --- a/app/modules/web/Controllers/ItemsController.php +++ b/app/modules/web/Controllers/ItemsController.php @@ -51,6 +51,7 @@ class ItemsController * Devolver las cuentas visibles por el usuario * * @param int $accountId + * @throws \Psr\Container\ContainerExceptionInterface */ public function accountsUserAction($accountId = null) { diff --git a/app/modules/web/Controllers/LoginController.php b/app/modules/web/Controllers/LoginController.php index 30171cde..6ba5dc4c 100644 --- a/app/modules/web/Controllers/LoginController.php +++ b/app/modules/web/Controllers/LoginController.php @@ -44,12 +44,14 @@ class LoginController extends ControllerBase /** * Login action * - * @throws \InvalidArgumentException + * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ public function loginAction() { $LoginService = new LoginService($this->config, $this->session, $this->theme, $this->eventDispatcher); - return Json::returnJson($LoginService->doLogin()); + Json::returnJson($LoginService->doLogin()); } /** @@ -63,10 +65,10 @@ class LoginController extends ControllerBase $Log = new Log(); $LogMessage = $Log->getLogMessage(); - $LogMessage->setAction(__('Finalizar sesión', false)); - $LogMessage->addDetails(__('Usuario', false), SessionFactory::getUserData()->getUserLogin()); - $LogMessage->addDetails(__('Tiempo inactivo', false), $inactiveTime . ' min.'); - $LogMessage->addDetails(__('Tiempo total', false), $totalTime . ' min.'); + $LogMessage->setAction(__u('Finalizar sesión')); + $LogMessage->addDetails(__u('Usuario'), SessionFactory::getUserData()->getUserLogin()); + $LogMessage->addDetails(__u('Tiempo inactivo'), $inactiveTime . ' min.'); + $LogMessage->addDetails(__u('Tiempo total'), $totalTime . ' min.'); $Log->writeLog(); SessionUtil::cleanSession(); diff --git a/app/modules/web/Controllers/MainController.php b/app/modules/web/Controllers/MainController.php index 91135b65..ac1f1b6e 100644 --- a/app/modules/web/Controllers/MainController.php +++ b/app/modules/web/Controllers/MainController.php @@ -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. @@ -29,7 +29,6 @@ defined('APP_ROOT') || die(); use SP\Account\AccountUtil; use SP\Controller\AccountController; use SP\Controller\ControllerBase; -use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\DiFactory; use SP\Core\Exceptions\SPException; @@ -63,9 +62,10 @@ class MainController extends ControllerBase implements ActionsInterface /** * Constructor * - * @param $template Template con instancia de plantilla - * @param string $page El nombre de página para la clase del body - * @param bool $initialize Si es una inicialización completa + * @param Template $template Template con instancia de plantilla + * @param string $page El nombre de página para la clase del body + * @param bool $initialize Si es una inicialización completa + * @throws \Psr\Container\ContainerExceptionInterface */ public function __construct(Template $template = null, $page = '', $initialize = true) { @@ -90,6 +90,8 @@ class MainController extends ControllerBase implements ActionsInterface /** * Inicializar las variables para la vista principal de la aplicación + * + * @throws \Psr\Container\ContainerExceptionInterface */ protected function initialize() { @@ -114,7 +116,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->setLoggedIn(Util::isLoggedIn($this->session)); $this->view->assign('lang', $this->loggedIn ? Language::$userLang : Language::$globalLang); - $this->view->assign('loadApp', SessionFactory::getAuthCompleted()); + $this->view->assign('loadApp', $this->session->getAuthCompleted()); try { @@ -148,8 +150,10 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('jsLinks', Init::$WEBROOT . '/public/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash); } - if ($this->loggedIn && SessionFactory::getUserPreferences()->getUserId() > 0) { - $resultsAsCards = SessionFactory::getUserPreferences()->isResultsAsCards(); + $userPreferences = $this->session->getUserPreferences(); + + if ($this->loggedIn && $userPreferences->getUserId() > 0) { + $resultsAsCards = $userPreferences->isResultsAsCards(); } else { $resultsAsCards = $this->configData->isResultsAsCards(); } @@ -203,6 +207,16 @@ class MainController extends ControllerBase implements ActionsInterface header('Pragma: public; max-age=0'); } + /** + * @throws SPException + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function indexAction() + { + $this->initialize(); + $this->getMain(); + } + /** * Obtener los datos para el interface principal de sysPass * @@ -220,12 +234,6 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->addTemplate('body-end'); } - public function indexAction() - { - $this->initialize(); - $this->getMain(); - } - /** * Obtener los datos para la mostrar la barra de sesión * @@ -267,7 +275,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionSearch); - if (Acl::checkUserAccess(self::ACCOUNT_CREATE)) { + if ($this->acl->checkUserAccess(self::ACCOUNT_CREATE)) { $ActionNew = new DataGridAction(); $ActionNew->setId(self::ACCOUNT_CREATE); $ActionNew->setTitle(__('Nueva Cuenta')); @@ -277,7 +285,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionNew); } - if (Acl::checkUserAccess(self::ACCESS_MANAGE)) { + if ($this->acl->checkUserAccess(self::ACCESS_MANAGE)) { $ActionUsr = new DataGridAction(); $ActionUsr->setId(self::ACCESS_MANAGE); $ActionUsr->setTitle(__('Usuarios y Accesos')); @@ -287,7 +295,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionUsr); } - if (Acl::checkUserAccess(self::ITEMS_MANAGE)) { + if ($this->acl->checkUserAccess(self::ITEMS_MANAGE)) { $ActionMgm = new DataGridAction(); $ActionMgm->setId(self::ITEMS_MANAGE); $ActionMgm->setTitle(__('Elementos y Personalización')); @@ -297,7 +305,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionMgm); } - if (Acl::checkUserAccess(self::CONFIG)) { + if ($this->acl->checkUserAccess(self::CONFIG)) { $ActionConfig = new DataGridAction(); $ActionConfig->setId(self::CONFIG); $ActionConfig->setTitle(__('Configuración')); @@ -307,7 +315,7 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionConfig); } - if (Acl::checkUserAccess(self::EVENTLOG) && $this->configData->isLogEnabled()) { + if ($this->acl->checkUserAccess(self::EVENTLOG) && $this->configData->isLogEnabled()) { $ActionEventlog = new DataGridAction(); $ActionEventlog->setId(self::EVENTLOG); $ActionEventlog->setTitle(__('Registro de Eventos')); @@ -492,6 +500,8 @@ class MainController extends ControllerBase implements ActionsInterface /** * Obtener los datos para el interface de comprobación de actualizaciones + * + * @throws \Psr\Container\ContainerExceptionInterface */ public function getCheckUpdates() { @@ -538,6 +548,7 @@ class MainController extends ControllerBase implements ActionsInterface * Realizar las acciones del controlador * * @param mixed $type Tipo de acción + * @throws \phpmailer\phpmailerException */ public function doAction($type = null) { @@ -561,8 +572,6 @@ class MainController extends ControllerBase implements ActionsInterface /** * Obtener los datos para el interface de restablecimiento de clave de usuario - * - * @throws \SP\Core\Exceptions\FileNotFoundException */ public function getPassReset() { @@ -595,12 +604,9 @@ class MainController extends ControllerBase implements ActionsInterface /** * Obtener la vista para mostrar un enlace publicado * - * @return bool - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\FileNotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException - * @throws \SP\Core\Exceptions\SPException + * @return void + * @throws SPException + * @throws \phpmailer\phpmailerException */ public function getPublicLink() { diff --git a/app/modules/web/Controllers/PassresetController.php b/app/modules/web/Controllers/PassresetController.php index 6bdce0eb..0915e230 100644 --- a/app/modules/web/Controllers/PassresetController.php +++ b/app/modules/web/Controllers/PassresetController.php @@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers; use SP\Controller\ControllerBase; use SP\Http\Request; use SP\Modules\Web\Controllers\Helpers\LayoutHelper; +use SP\Util\ErrorUtil; /** * Class PassresetController @@ -41,14 +42,9 @@ class PassresetController extends ControllerBase public function indexAction() { $LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $LayoutHelper->initBody(); - $LayoutHelper->setPage('passreset'); - - $this->view->addPartial('body-header'); + $LayoutHelper->getPublicLayout('passreset', 'passreset'); if ($this->configData->isMailEnabled() || Request::analyze('f', 0) === 1) { - $this->view->addTemplate('passreset'); - $this->view->assign('login', Request::analyze('login')); $this->view->assign('email', Request::analyze('email')); @@ -58,12 +54,9 @@ class PassresetController extends ControllerBase $this->view->assign('passReset', $this->view->action === 'passreset' && !empty($this->view->hash) && !empty($this->view->time)); } else { - $this->showError(self::ERR_UNAVAILABLE, false); + ErrorUtil::showErrorFull($this->view, self::ERR_UNAVAILABLE, 'passreset'); } - $this->view->addPartial('body-footer'); - $this->view->addPartial('body-end'); - $this->view(); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/PublicLinkController.php b/app/modules/web/Controllers/PublicLinkController.php new file mode 100644 index 00000000..68362c4c --- /dev/null +++ b/app/modules/web/Controllers/PublicLinkController.php @@ -0,0 +1,296 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use Defuse\Crypto\Exception\CryptoException; +use SP\Account\AccountUtil; +use SP\Controller\ControllerBase; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\SPException; +use SP\Core\Exceptions\ValidationException; +use SP\Core\SessionUtil; +use SP\DataModel\PublicLinkListData; +use SP\Forms\PublicLinkForm; +use SP\Http\JsonResponse; +use SP\Http\Request; +use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Mvc\Controller\CrudControllerInterface; +use SP\Services\PublicLink\PublicLinkService; + +/** + * Class PublicLinkController + * + * @package SP\Modules\Web\Controllers + */ +class PublicLinkController extends ControllerBase implements CrudControllerInterface +{ + use JsonTrait; + use ItemTrait; + + /** + * @var PublicLinkService + */ + protected $publicLinkService; + + /** + * Search action + * + * @throws \SP\Core\Exceptions\InvalidClassException + */ + public function searchAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_SEARCH)) { + return; + } + + $itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $grid = $itemsGridHelper->getPublicLinksGrid($this->publicLinkService->search($this->getSearchData($this->configData)))->updatePager(); + + $this->view->addTemplate('datagrid-table', 'grid'); + $this->view->assign('index', Request::analyze('activetab', 0)); + $this->view->assign('data', $grid); + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Create action + * + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function createAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_CREATE)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); + $this->view->assign('header', __('Nuevo Enlace Público')); + $this->view->assign('isView', false); + $this->view->assign('route', 'publicLink/saveCreate'); + + try { + $this->setViewData(); + + $this->eventDispatcher->notifyEvent('show.publicLink.create', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Sets view data for displaying user's data + * + * @param $publicLinkId + * @throws SPException + * @throws \Psr\Container\ContainerExceptionInterface + */ + protected function setViewData($publicLinkId = null) + { + $this->view->addTemplate('publiclink', 'itemshow'); + + $publicLink = $publicLinkId ? PublicLinkService::mapItemsForList([$this->publicLinkService->getById($publicLinkId)]) : new PublicLinkListData(); + + $this->view->assign('publicLink', is_array($publicLink) ? $publicLink[0] : $publicLink); + $this->view->assign('accounts', AccountUtil::getAccountsForUser($this->session)); + + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); + + if ($this->view->isView === true) { + $this->view->assign('publicLinkURL', PublicLinkService::getLinkForHash($publicLink[0]->getPublicLinkHash())); + $this->view->assign('disabled', 'disabled'); + $this->view->assign('readonly', 'readonly'); + } else { + $this->view->assign('disabled'); + $this->view->assign('readonly'); + } + } + + /** + * Create action + * + * @param int $id + */ + public function refreshAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_REFRESH)) { + return; + } + + try { + $this->publicLinkService->refresh($id); + + $this->eventDispatcher->notifyEvent('edit.publicLink.refresh', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace actualizado')); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (CryptoException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Edit action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function editAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_EDIT)) { + return; + } + + $this->view->assign('header', __('Editar Enlace Público')); + $this->view->assign('isView', false); + $this->view->assign('route', 'publicLink/saveEdit/' . $id); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.publicLink.edit', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Delete action + * + * @param $id + */ + public function deleteAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_DELETE)) { + return; + } + + try { +// $this->publicLinkService->logAction($id, ActionsInterface::PROFILE_DELETE); + $this->publicLinkService->delete($id); + + $this->deleteCustomFieldsForItem(ActionsInterface::PUBLICLINK, $id); + + $this->eventDispatcher->notifyEvent('delete.publicLink', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace eliminado')); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves create action + */ + public function saveCreateAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_CREATE)) { + return; + } + + try { + $form = new PublicLinkForm(); + $form->validate(ActionsInterface::PUBLICLINK_CREATE); + + $this->publicLinkService->create($form->getItemData()); +// $this->publicLinkService->logAction($id, ActionsInterface::PUBLICLINK_CREATE); + + $this->eventDispatcher->notifyEvent('create.publicLink', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (CryptoException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves edit action + * + * @param $id + */ + public function saveEditAction($id) + { + + } + + /** + * View action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function viewAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_VIEW)) { + return; + } + + $this->view->assign('header', __('Ver Enlace')); + $this->view->assign('isView', true); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.publicLink', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Initialize class + */ + protected function initialize() + { + $this->checkLoggedIn(); + + $this->publicLinkService = new PublicLinkService(); + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/Traits/ItemTrait.php b/app/modules/web/Controllers/Traits/ItemTrait.php index fd7472fd..c45850b0 100644 --- a/app/modules/web/Controllers/Traits/ItemTrait.php +++ b/app/modules/web/Controllers/Traits/ItemTrait.php @@ -24,11 +24,11 @@ namespace SP\Modules\Web\Controllers\Traits; +use SP\Config\ConfigData; use SP\Core\Exceptions\SPException; +use SP\DataModel\ItemSearchData; use SP\Http\Request; use SP\Services\CustomField\CustomFieldService; -use SP\Services\UserGroup\UserGroupService; -use SP\Services\UserProfile\UserProfileService; /** * Trait ItemTrait @@ -91,24 +91,19 @@ trait ItemTrait } /** - * Return user groups list + * Returns search data object for the current request * - * @return array + * @param ConfigData $configData + * @return ItemSearchData */ - protected function getUserGroups() + protected function getSearchData(ConfigData $configData) { - $userGroupService = new UserGroupService(); - return $userGroupService->getItemsForSelect(); - } + $itemSearchData = new ItemSearchData(); + $itemSearchData->setLimitCount($configData->getAccountCount()); + $itemSearchData->setSeachString(Request::analyze('search')); + $itemSearchData->setLimitStart(Request::analyze('start', 0)); + $itemSearchData->setLimitCount(Request::analyze('count', $configData->getAccountCount())); - /** - * Return user profiles list - * - * @return array - */ - protected function getUserProfiles() - { - $userProfile = new UserProfileService(); - return $userProfile->getItemsForSelect(); + return $itemSearchData; } } \ No newline at end of file diff --git a/app/modules/web/Controllers/Traits/JsonTrait.php b/app/modules/web/Controllers/Traits/JsonTrait.php index 2805a005..d3e98847 100644 --- a/app/modules/web/Controllers/Traits/JsonTrait.php +++ b/app/modules/web/Controllers/Traits/JsonTrait.php @@ -37,17 +37,41 @@ trait JsonTrait /** * Returns JSON response * - * @param $status - * @param $description - * @param array|null $data + * @param int $status Status code + * @param string $description Untranslated description string + * @param array|null $messages Untranslated massages array of strings */ - protected function returnJsonResponse($status, $description, array $data = null) + protected function returnJsonResponse($status, $description, array $messages = null) { $jsonResponse = new JsonResponse(); $jsonResponse->setStatus($status); $jsonResponse->setDescription($description); + + if (null !== $messages) { + $jsonResponse->setMessages($messages); + } + + Json::returnJson($jsonResponse); + } + + /** + * Returns JSON response + * + * @param mixed $data + * @param int $status Status code + * @param null $description Untranslated description string + */ + protected function returnJsonResponseData($data, $status = 0, $description = null) + { + $jsonResponse = new JsonResponse(); + $jsonResponse->setStatus($status); $jsonResponse->setData($data); + if (null !== $description) { + $jsonResponse->setDescription($description); + } + + Json::returnJson($jsonResponse); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php index 66c771a8..3f26304b 100644 --- a/app/modules/web/Controllers/UserController.php +++ b/app/modules/web/Controllers/UserController.php @@ -33,11 +33,15 @@ use SP\Core\Exceptions\ValidationException; use SP\Core\SessionUtil; use SP\DataModel\UserData; use SP\Forms\UserForm; +use SP\Http\JsonResponse; use SP\Http\Request; +use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Mvc\Controller\CrudControllerInterface; use SP\Services\User\UserService; +use SP\Services\UserGroup\UserGroupService; +use SP\Services\UserProfile\UserProfileService; /** * Class UserController @@ -59,7 +63,18 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function searchAction() { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_SEARCH)) { + return; + } + $itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $grid = $itemsGridHelper->getUsersGrid($this->userService->search($this->getSearchData($this->configData)))->updatePager(); + + $this->view->addTemplate('datagrid-table', 'grid'); + $this->view->assign('index', Request::analyze('activetab', 0)); + $this->view->assign('data', $grid); + + $this->returnJsonResponseData(['html' => $this->render()]); } /** @@ -69,6 +84,10 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function createAction() { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_CREATE)) { + return; + } + $this->view->assign(__FUNCTION__, 1); $this->view->assign('header', __('Nuevo Usuario')); $this->view->assign('isView', false); @@ -76,11 +95,13 @@ class UserController extends ControllerBase implements CrudControllerInterface try { $this->setViewData(); + + $this->eventDispatcher->notifyEvent('show.user.create', $this); } catch (\Exception $e) { $this->returnJsonResponse(1, $e->getMessage()); } - $this->returnJsonResponse(0, '', ['html' => $this->render()]); + $this->returnJsonResponseData(['html' => $this->render()]); } /** @@ -93,13 +114,13 @@ class UserController extends ControllerBase implements CrudControllerInterface */ protected function setViewData($userId = null) { - $this->view->addTemplate('users', 'itemshow'); + $this->view->addTemplate('user', 'itemshow'); $user = $userId ? $this->userService->getById($userId) : new UserData(); $this->view->assign('user', $user); - $this->view->assign('groups', $this->getUserGroups()); - $this->view->assign('profiles', $this->getUserProfiles()); + $this->view->assign('groups', UserGroupService::getServiceItems()); + $this->view->assign('profiles', UserProfileService::getServiceItems()); $this->view->assign('isUseSSO', $this->configData->isAuthBasicAutoLoginEnabled()); $this->view->assign('sk', SessionUtil::getSessionKey(true)); $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); @@ -123,17 +144,24 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function editAction($id) { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_EDIT)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); $this->view->assign('header', __('Editar Usuario')); $this->view->assign('isView', false); $this->view->assign('route', 'user/saveEdit/' . $id); try { $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.user.edit', $this); } catch (\Exception $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } - $this->returnJsonResponse(0, '', ['html' => $this->render()]); + $this->returnJsonResponseData(['html' => $this->render()]); } /** @@ -145,12 +173,13 @@ class UserController extends ControllerBase implements CrudControllerInterface public function editPassAction($id) { // Comprobar si el usuario a modificar es distinto al de la sesión - if ($id !== $this->userData->getUserId() && !$this->checkAccess()) { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_EDIT_PASS, $this->userData->getUserId())) { return; } - $this->view->addTemplate('userspass', 'itemshow'); + $this->view->addTemplate('userpass', 'itemshow'); + $this->view->assign(__FUNCTION__, 1); $this->view->assign('header', __('Cambio de Clave')); $this->view->assign('isView', false); $this->view->assign('route', 'user/saveEditPass/' . $id); @@ -160,11 +189,13 @@ class UserController extends ControllerBase implements CrudControllerInterface $user = $id ? $this->userService->getById($id) : new UserData(); $this->view->assign('user', $user); + + $this->eventDispatcher->notifyEvent('show.user.editPass', $this); } catch (\Exception $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } - $this->returnJsonResponse(0, '', ['html' => $this->render()]); + $this->returnJsonResponseData(['html' => $this->render()]); } /** @@ -174,20 +205,25 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function deleteAction($id) { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_DELETE)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); + try { - $userService = new UserService(); - $userService->logAction($id, ActionsInterface::USER_DELETE); - $userService->delete($id); + $this->userService->logAction($id, ActionsInterface::USER_DELETE); + $this->userService->delete($id); $this->deleteCustomFieldsForItem(ActionsInterface::USER, $id); $this->eventDispatcher->notifyEvent('delete.user', $this); - $this->returnJsonResponse(0, __('Usuario eliminado')); + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario eliminado')); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -196,32 +232,38 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function saveCreateAction() { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_CREATE)) { + return; + } + try { $form = new UserForm(); $form->validate(ActionsInterface::USER_CREATE); - $userService = new UserService(); - - $id = $userService->create($form->getItemData()); - $userService->logAction($id, ActionsInterface::USER_CREATE); + $id = $this->userService->create($form->getItemData()); + $this->userService->logAction($id, ActionsInterface::USER_CREATE); $this->addCustomFieldsForItem(ActionsInterface::USER, $id); - $this->eventDispatcher->notifyEvent('edit.user', $this); + $this->eventDispatcher->notifyEvent('create.user', $this); if ($form->getItemData()->isUserIsChangePass() && !AuthUtil::mailPassRecover($form->getItemData()) ) { - $this->returnJsonResponse(2, __('Usuario creado'), __('No se pudo realizar la petición de cambio de clave.')); + $this->returnJsonResponse( + JsonResponse::JSON_WARNING, + __u('Usuario creado'), + [__('No se pudo realizar la petición de cambio de clave.')] + ); } - $this->returnJsonResponse(0, __('Usuario creado')); + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario creado')); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -232,34 +274,39 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function saveEditAction($id) { - try { - $isLdap = Request::analyze('isLdap', 0); + if (!$this->acl->checkUserAccess(ActionsInterface::USER_EDIT)) { + return; + } + try { $form = new UserForm($id); - $form->setIsLdap($isLdap); + $form->setIsLdap(Request::analyze('isLdap', 0)); $form->validate(ActionsInterface::USER_EDIT); - if ($isLdap) { - // FIXME: LDAP Service - $userService = new UserService(); - } else { - $userService = new UserService(); - } - - $userService->update($form->getItemData()); - $userService->logAction($id, ActionsInterface::USER_EDIT); + $this->userService->update($form->getItemData()); + $this->userService->logAction($id, ActionsInterface::USER_EDIT); $this->updateCustomFieldsForItem(ActionsInterface::USER, $id); $this->eventDispatcher->notifyEvent('edit.user', $this); - $this->returnJsonResponse(0, __('Usuario actualizado')); + if ($form->getItemData()->isUserIsChangePass() + && !AuthUtil::mailPassRecover($form->getItemData()) + ) { + $this->returnJsonResponse( + JsonResponse::JSON_WARNING, + __u('Usuario actualizado'), + [__('No se pudo realizar la petición de cambio de clave.')] + ); + } + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario actualizado')); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -270,6 +317,10 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function saveEditPassAction($id) { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_EDIT_PASS)) { + return; + } + try { $form = new UserForm($id); $form->validate(ActionsInterface::USER_EDIT_PASS); @@ -278,15 +329,15 @@ class UserController extends ControllerBase implements CrudControllerInterface $userService->updatePass($form->getItemData()); $userService->logAction($id, ActionsInterface::USER_EDIT_PASS); - $this->eventDispatcher->notifyEvent('editPass.user', $this); + $this->eventDispatcher->notifyEvent('edit.user.pass', $this); - $this->returnJsonResponse(0, __('Clave actualizada')); + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada')); } catch (ValidationException $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } catch (SPException $e) { debugLog($e->getMessage(), true); - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } } @@ -298,16 +349,23 @@ class UserController extends ControllerBase implements CrudControllerInterface */ public function viewAction($id) { + if (!$this->acl->checkUserAccess(ActionsInterface::USER_VIEW)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); $this->view->assign('header', __('Ver Usuario')); $this->view->assign('isView', true); try { $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.user', $this); } catch (\Exception $e) { - $this->returnJsonResponse(1, $e->getMessage()); + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); } - $this->returnJsonResponse(0, '', ['html' => $this->render()]); + $this->returnJsonResponseData(['html' => $this->render()]); } /** diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php new file mode 100644 index 00000000..98584d09 --- /dev/null +++ b/app/modules/web/Controllers/UserGroupController.php @@ -0,0 +1,299 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use SP\Controller\ControllerBase; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\SPException; +use SP\Core\Exceptions\ValidationException; +use SP\Core\SessionUtil; +use SP\DataModel\GroupData; +use SP\Forms\UserGroupForm; +use SP\Http\JsonResponse; +use SP\Http\Request; +use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Mvc\Controller\CrudControllerInterface; +use SP\Services\User\UserService; +use SP\Services\UserGroup\UserGroupService; +use SP\Services\UserGroup\UserToGroupService; + +/** + * Class GroupController + * + * @package SP\Modules\Web\Controllers + */ +class UserGroupController extends ControllerBase implements CrudControllerInterface +{ + use JsonTrait; + use ItemTrait; + + /** + * @var UserGroupService + */ + protected $userGroupService; + /** + * @var UserToGroupService + */ + protected $userToGroupService; + + /** + * Search action + */ + public function searchAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_SEARCH)) { + return; + } + + $itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $grid = $itemsGridHelper->getUserGroupsGrid($this->userGroupService->search($this->getSearchData($this->configData)))->updatePager(); + + $this->view->addTemplate('datagrid-table', 'grid'); + $this->view->assign('index', Request::analyze('activetab', 0)); + $this->view->assign('data', $grid); + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Create action + * + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function createAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_CREATE)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); + $this->view->assign('header', __('Nuevo Grupo')); + $this->view->assign('isView', false); + $this->view->assign('route', 'userGroup/saveCreate'); + + try { + $this->setViewData(); + + $this->eventDispatcher->notifyEvent('show.userGroup.create', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Sets view data for displaying user's data + * + * @param $groupId + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Defuse\Crypto\Exception\CryptoException + */ + protected function setViewData($groupId = null) + { + $this->view->addTemplate('usergroup', 'itemshow'); + + $group = $groupId ? $this->userGroupService->getById($groupId) : new GroupData(); + + $this->view->assign('group', $group); + $this->view->assign('users', UserService::getServiceItems()); + $this->view->assign('groupUsers', $this->userToGroupService->getById($groupId)); + + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); + + if ($this->view->isView === true) { + $this->view->assign('disabled', 'disabled'); + $this->view->assign('readonly', 'readonly'); + } else { + $this->view->assign('disabled'); + $this->view->assign('readonly'); + } + + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::GROUP, $groupId)); + } + + /** + * Edit action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function editAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_EDIT)) { + return; + } + + $this->view->assign('header', __('Editar Grupo')); + $this->view->assign('isView', false); + $this->view->assign('route', 'userGroup/saveEdit/' . $id); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.userGroup.edit', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Delete action + * + * @param $id + */ + public function deleteAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_DELETE)) { + return; + } + + try { + $this->userGroupService->logAction($id, ActionsInterface::GROUP_DELETE); + $this->userGroupService->delete($id); + + $this->deleteCustomFieldsForItem(ActionsInterface::GROUP, $id); + + $this->eventDispatcher->notifyEvent('delete.userGroup', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo eliminado')); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves create action + */ + public function saveCreateAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_CREATE)) { + return; + } + + try { + $form = new UserGroupForm(); + $form->validate(ActionsInterface::GROUP_CREATE); + + $groupData = $form->getItemData(); + + $id = $this->userGroupService->create($groupData); + $this->userGroupService->logAction($id, ActionsInterface::GROUP_CREATE); + $this->userToGroupService->add($id, $groupData->getUsers()); + + $this->addCustomFieldsForItem(ActionsInterface::GROUP, $id); + + $this->eventDispatcher->notifyEvent('create.userGroup', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo creado')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves edit action + * + * @param $id + */ + public function saveEditAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_EDIT)) { + return; + } + + try { + $form = new UserGroupForm($id); + $form->validate(ActionsInterface::GROUP_EDIT); + + $groupData = $form->getItemData(); + + $this->userGroupService->update($groupData); + $this->userGroupService->logAction($id, ActionsInterface::GROUP_EDIT); + $this->userToGroupService->update($groupData->getUsergroupId(), $groupData->getUsers()); + + $this->updateCustomFieldsForItem(ActionsInterface::GROUP, $id); + + $this->eventDispatcher->notifyEvent('edit.useGroup', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo actualizado')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * View action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function viewAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::GROUP_VIEW)) { + return; + } + + $this->view->assign('header', __('Ver Grupo')); + $this->view->assign('isView', true); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.userGroup', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Initialize class + */ + protected function initialize() + { + $this->checkLoggedIn(); + + $this->userGroupService = new UserGroupService(); + $this->userToGroupService = new UserToGroupService(); + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php new file mode 100644 index 00000000..3e983200 --- /dev/null +++ b/app/modules/web/Controllers/UserProfileController.php @@ -0,0 +1,290 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use SP\Controller\ControllerBase; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\SPException; +use SP\Core\Exceptions\ValidationException; +use SP\Core\SessionUtil; +use SP\DataModel\ProfileData; +use SP\Forms\UserProfileForm; +use SP\Http\JsonResponse; +use SP\Http\Request; +use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Mvc\Controller\CrudControllerInterface; +use SP\Services\UserProfile\UserProfileService; + +/** + * Class UserProfileController + * + * @package SP\Modules\Web\Controllers + */ +class UserProfileController extends ControllerBase implements CrudControllerInterface +{ + use JsonTrait; + use ItemTrait; + + /** + * @var UserProfileService + */ + protected $userProfileService; + + /** + * Search action + */ + public function searchAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_SEARCH)) { + return; + } + + $itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + $grid = $itemsGridHelper->getUserProfilesGrid($this->userProfileService->search($this->getSearchData($this->configData)))->updatePager(); + + $this->view->addTemplate('datagrid-table', 'grid'); + $this->view->assign('index', Request::analyze('activetab', 0)); + $this->view->assign('data', $grid); + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Create action + * + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function createAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_CREATE)) { + return; + } + + $this->view->assign(__FUNCTION__, 1); + $this->view->assign('header', __('Nuevo Perfil')); + $this->view->assign('isView', false); + $this->view->assign('route', 'userProfile/saveCreate'); + + try { + $this->setViewData(); + + $this->eventDispatcher->notifyEvent('show.userProfile.create', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Sets view data for displaying user's data + * + * @param $profileId + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Defuse\Crypto\Exception\CryptoException + */ + protected function setViewData($profileId = null) + { + $this->view->addTemplate('userprofile', 'itemshow'); + + $profile = $profileId ? $this->userProfileService->getById($profileId) : new ProfileData(); + + $this->view->assign('profile', $profile); + + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); + + if ($this->view->isView === true) { + $this->view->assign('usedBy', $this->userProfileService->getUsersForProfile($profileId)); + + $this->view->assign('disabled', 'disabled'); + $this->view->assign('readonly', 'readonly'); + } else { + $this->view->assign('disabled'); + $this->view->assign('readonly'); + } + + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::PROFILE, $profileId)); + } + + /** + * Edit action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function editAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_EDIT)) { + return; + } + + $this->view->assign('header', __('Editar Perfil')); + $this->view->assign('isView', false); + $this->view->assign('route', 'userProfile/saveEdit/' . $id); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.userProfile.edit', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Delete action + * + * @param $id + */ + public function deleteAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_DELETE)) { + return; + } + + try { + $this->userProfileService->logAction($id, ActionsInterface::PROFILE_DELETE); + $this->userProfileService->delete($id); + + $this->deleteCustomFieldsForItem(ActionsInterface::PROFILE, $id); + + $this->eventDispatcher->notifyEvent('delete.userProfile', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil eliminado')); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves create action + */ + public function saveCreateAction() + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_CREATE)) { + return; + } + + try { + $form = new UserProfileForm(); + $form->validate(ActionsInterface::PROFILE_CREATE); + + $profileData = $form->getItemData(); + + $id = $this->userProfileService->create($profileData); + $this->userProfileService->logAction($id, ActionsInterface::PROFILE_CREATE); + + $this->addCustomFieldsForItem(ActionsInterface::PROFILE, $id); + + $this->eventDispatcher->notifyEvent('create.userProfile', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil creado')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * Saves edit action + * + * @param $id + */ + public function saveEditAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_EDIT)) { + return; + } + + try { + $form = new UserProfileForm($id); + $form->validate(ActionsInterface::PROFILE_EDIT); + + $profileData = $form->getItemData(); + + $this->userProfileService->update($profileData); + $this->userProfileService->logAction($id, ActionsInterface::PROFILE_EDIT); + + $this->updateCustomFieldsForItem(ActionsInterface::PROFILE, $id); + + $this->eventDispatcher->notifyEvent('edit.userProfile', $this); + + $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil actualizado')); + } catch (ValidationException $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } catch (SPException $e) { + debugLog($e->getMessage(), true); + + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + } + + /** + * View action + * + * @param $id + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function viewAction($id) + { + if (!$this->acl->checkUserAccess(ActionsInterface::PROFILE_VIEW)) { + return; + } + + $this->view->assign('header', __('Ver Perfil')); + $this->view->assign('isView', true); + + try { + $this->setViewData($id); + + $this->eventDispatcher->notifyEvent('show.userProfile', $this); + } catch (\Exception $e) { + $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); + } + + $this->returnJsonResponseData(['html' => $this->render()]); + } + + /** + * Initialize class + */ + protected function initialize() + { + $this->checkLoggedIn(); + + $this->userProfileService = new UserProfileService(); + } +} \ No newline at end of file diff --git a/app/modules/web/themes/material-blue/views/_partials/body-footer.inc b/app/modules/web/themes/material-blue/views/_partials/body-footer.inc index a460fbf8..30358392 100644 --- a/app/modules/web/themes/material-blue/views/_partials/body-footer.inc +++ b/app/modules/web/themes/material-blue/views/_partials/body-footer.inc @@ -6,7 +6,7 @@