diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index b1e3341d..e8964156 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -69,10 +69,10 @@ $Tpl->assign('actionId', $actionId); $Tpl->assign('id', $itemId); $Tpl->assign('activeTabId', $itemId); $Tpl->assign('queryTimeStart', microtime()); -$Tpl->assign('userId', $UserData->getUserId()); +$Tpl->assign('userId', $UserData->getId()); $Tpl->assign('userGroupId', $UserData->getUserGroupId()); -$Tpl->assign('userIsAdminApp', $UserData->isUserIsAdminApp()); -$Tpl->assign('userIsAdminAcc', $UserData->isUserIsAdminAcc()); +$Tpl->assign('userIsAdminApp', $UserData->isIsAdminApp()); +$Tpl->assign('userIsAdminAcc', $UserData->isIsAdminAcc()); $Tpl->assign('themeUri', $theme->getThemeUri()); switch ($actionId) { @@ -144,7 +144,7 @@ switch ($actionId) { $ConfigData = $dic->get(\SP\Config\ConfigData::class); // Se comprueba si se debe de mostrar la vista de depuración -if ($UserData->isUserIsAdminApp() && $ConfigData->isDebug()) { +if ($UserData->isIsAdminApp() && $ConfigData->isDebug()) { $Controller->getDebug(); } diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php index 68d07ca2..f0fec5ba 100644 --- a/app/modules/web/Controllers/AccessManagerController.php +++ b/app/modules/web/Controllers/AccessManagerController.php @@ -31,11 +31,11 @@ use SP\DataModel\ItemSearchData; use SP\Http\Request; use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper; use SP\Modules\Web\Controllers\Helpers\TabsGridHelper; -use SP\Services\ApiToken\ApiTokenService; -use SP\Services\PublicLink\PublicLinkService; -use SP\Services\User\UserService; -use SP\Services\UserGroup\UserGroupService; -use SP\Services\UserProfile\UserProfileService; +use SP\Repositories\ApiToken\ApiTokenRepository; +use SP\Repositories\PublicLink\PublicLinkRepository; +use SP\Repositories\User\UserRepository; +use SP\Repositories\UserGroup\UserGroupRepository; +use SP\Repositories\UserProfile\UserProfileRepository; /** * Class AccessMgmtController @@ -111,7 +111,7 @@ class AccessManagerController extends ControllerBase */ protected function getUsersList() { - $service = new UserService(); + $service = new UserRepository(); return $this->itemsGridHelper->getUsersGrid($service->search($this->itemSearchData))->updatePager(); } @@ -121,7 +121,7 @@ class AccessManagerController extends ControllerBase */ protected function getUsersGroupList() { - $service = new UserGroupService(); + $service = new UserGroupRepository(); return $this->itemsGridHelper->getUserGroupsGrid($service->search($this->itemSearchData))->updatePager(); } @@ -131,7 +131,7 @@ class AccessManagerController extends ControllerBase */ protected function getUsersProfileList() { - $service = new UserProfileService(); + $service = new UserProfileRepository(); return $this->itemsGridHelper->getUserProfilesGrid($service->search($this->itemSearchData))->updatePager(); } @@ -141,7 +141,7 @@ class AccessManagerController extends ControllerBase */ protected function getApiTokensList() { - $service = new ApiTokenService(); + $service = new ApiTokenRepository(); return $this->itemsGridHelper->getApiTokensGrid($service->search($this->itemSearchData))->updatePager(); } @@ -151,7 +151,7 @@ class AccessManagerController extends ControllerBase */ protected function getPublicLinksList() { - $service = new PublicLinkService(); + $service = new PublicLinkRepository(); 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 392e568b..4d45e8f5 100644 --- a/app/modules/web/Controllers/AccountController.php +++ b/app/modules/web/Controllers/AccountController.php @@ -33,6 +33,7 @@ use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\Core\SessionUtil; use SP\DataModel\AccountExtData; +use SP\DataModel\Dto\AccountDetailsResponse; use SP\Forms\AccountForm; use SP\Http\JsonResponse; use SP\Http\Request; @@ -44,8 +45,10 @@ 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\Repositories\Account\AccountRepository; +use SP\Repositories\PublicLink\PublicLinkRepository; +use SP\Services\Account\AccountFileService; use SP\Services\Account\AccountService; -use SP\Services\PublicLink\PublicLinkService; use SP\Util\ErrorUtil; use SP\Util\ImageUtil; use SP\Util\Util; @@ -59,6 +62,10 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { use JsonTrait; use ItemTrait; + /** + * @var AccountService + */ + protected $accountService; /** * Index action @@ -70,7 +77,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac try { $AccountSearchHelper = new AccountSearchHelper($this->view, $this->config, $this->session, $this->eventDispatcher); $AccountSearchHelper->getSearchBox(); - $AccountSearchHelper->getSearch(); + $AccountSearchHelper->getAccountSearch(); $this->eventDispatcher->notifyEvent('show.account.search', $this); } catch (\Exception $e) { @@ -91,7 +98,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountSearchHelper = new AccountSearchHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountSearchHelper->getSearch(); + $AccountSearchHelper->getAccountSearch(); $this->eventDispatcher->notifyEvent('show.account.search', $this); @@ -117,11 +124,21 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function viewAction($id) { try { + $accountDetailsResponse = $this->accountService->getById($id); + $this->accountService + ->withUsersById($accountDetailsResponse) + ->withUserGroupsById($accountDetailsResponse) + ->withTagsById($accountDetailsResponse); + $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_VIEW); + $AccountHelper->setAccount( + $accountDetailsResponse, + $this->accountService, + ActionsInterface::ACCOUNT_VIEW + ); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -136,7 +153,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->view->assign('isView', true); - $AccountHelper->getAccountService()->incrementViewCounter(); + $this->accountService->incrementViewCounter($id); + $AccountHelper->setCommonData(); $this->eventDispatcher->notifyEvent('show.account', $this); @@ -160,11 +178,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $LayoutHelper->getPublicLayout('account-link', 'account'); try { - $publicLinkService = new PublicLinkService(); + $publicLinkService = new PublicLinkRepository(); $publicLinkData = $publicLinkService->getByHash($hash); - if (time() < $publicLinkData->getPublicLinkDateExpire() - && $publicLinkData->getPublicLinkCountViews() < $publicLinkData->getPublicLinkMaxCountViews() + if (time() < $publicLinkData->getDateExpire() + && $publicLinkData->getCountViews() < $publicLinkData->getMaxCountViews() ) { $publicLinkService->addLinkView($publicLinkData); @@ -186,15 +204,14 @@ class AccountController extends ControllerBase implements CrudControllerInterfac // Notice::getItem($NoticeData)->add(); // } - $accountService = new AccountService(); - $accountService->incrementViewCounter($publicLinkData->getPublicLinkItemId()); - $accountService->incrementDecryptCounter($publicLinkData->getPublicLinkItemId()); + $this->accountService->incrementViewCounter($publicLinkData->getItemId()); + $this->accountService->incrementDecryptCounter($publicLinkData->getItemId()); /** @var Vault $vault */ - $vault = unserialize($publicLinkData->getPublicLinkData()); + $vault = unserialize($publicLinkData->getData()); /** @var AccountExtData $accountData */ - $accountData = Util::unserialize(AccountExtData::class, $vault->getData(PublicLinkService::getKeyForHash($this->config, $publicLinkData))); + $accountData = Util::unserialize(AccountExtData::class, $vault->getData(PublicLinkRepository::getKeyForHash($this->config, $publicLinkData))); $this->view->assign('title', [ @@ -208,7 +225,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->view->assign('useImage', $this->configData->isPublinksImageEnabled() || $this->configData->isAccountPassToImage()); if ($this->view->useImage) { - $this->view->assign('accountPassImage', ImageUtil::convertText($accountData->getAccountPass())); + $this->view->assign('accountPassImage', ImageUtil::convertText($accountData->getPass())); } else { $this->view->assign('copyPassRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); } @@ -245,9 +262,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $this->view->addTemplate('files-list', 'account'); - $this->view->assign('accountId', $id); $this->view->assign('deleteEnabled', Request::analyze('del', 0)); - $this->view->assign('files', FileUtil::getAccountFiles($id)); + + $this->view->assign('files', (new AccountFileService())->getByAccountId($id)); $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)); @@ -278,7 +295,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $AccountHelper->setActionId(ActionsInterface::ACCOUNT_CREATE); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -312,11 +329,21 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function copyAction($id) { try { + $accountDetailsResponse = $this->accountService->getById($id); + $this->accountService + ->withUsersById($accountDetailsResponse) + ->withUserGroupsById($accountDetailsResponse) + ->withTagsById($accountDetailsResponse); + $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_COPY); + $AccountHelper->setAccount( + $accountDetailsResponse, + $this->accountService, + ActionsInterface::ACCOUNT_COPY + ); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -350,11 +377,21 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function editAction($id) { try { + $accountDetailsResponse = $this->accountService->getById($id); + $this->accountService + ->withUsersById($accountDetailsResponse) + ->withUserGroupsById($accountDetailsResponse) + ->withTagsById($accountDetailsResponse); + $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_EDIT); + $AccountHelper->setAccount( + $accountDetailsResponse, + $this->accountService, + ActionsInterface::ACCOUNT_EDIT + ); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -368,7 +405,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac ); $this->view->assign('formRoute', 'account/saveEdit'); - $AccountHelper->getAccountService()->incrementViewCounter(); + $this->accountService->incrementViewCounter($id); + $AccountHelper->setCommonData(); $this->eventDispatcher->notifyEvent('show.account.edit', $this); @@ -389,11 +427,20 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function deleteAction($id) { try { + $accountDetailsResponse = $this->accountService->getById($id); + $this->accountService + ->withUsersById($accountDetailsResponse) + ->withUserGroupsById($accountDetailsResponse); + $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_DELETE); + $AccountHelper->setAccount( + $accountDetailsResponse, + $this->accountService, + ActionsInterface::ACCOUNT_DELETE + ); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -427,11 +474,20 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function editPassAction($id) { try { + $accountDetailsResponse = $this->accountService->getById($id); + $this->accountService + ->withUsersById($accountDetailsResponse) + ->withUserGroupsById($accountDetailsResponse); + $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_EDIT_PASS); + $AccountHelper->setAccount( + $accountDetailsResponse, + $this->accountService, + ActionsInterface::ACCOUNT_EDIT_PASS + ); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -445,7 +501,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac ); $this->view->assign('formRoute', 'account/saveEditPass'); - $this->view->assign('accountPassDateChange', gmdate('Y-m-d', $AccountHelper->getAccountData()->getAccountPassDateChange())); + $this->view->assign('accountPassDateChange', gmdate('Y-m-d', $AccountHelper->getAccountDetailsResponse()->getAccountVData()->getPassDateChange())); $this->eventDispatcher->notifyEvent('show.account.editpass', $this); } catch (\Exception $e) { @@ -466,10 +522,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_VIEW_HISTORY); + + // FIXME: Crear servicio AccountHistoryService + $AccountHelper->setAccountDataHistory($this->accountService->getById($id), ActionsInterface::ACCOUNT_VIEW_HISTORY); // Obtener los datos de la cuenta antes y comprobar el acceso - if (!$AccountHelper->checkAccess($this)) { + if (!$AccountHelper->checkAccess()) { return; } @@ -482,7 +540,6 @@ class AccountController extends ControllerBase implements CrudControllerInterfac ] ); $this->view->assign('formRoute', 'account/saveRestore'); - $this->view->assign('isView', true); $AccountHelper->setCommonData(); @@ -506,7 +563,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_REQUEST); + $AccountHelper->setAccount( + $this->accountService->getById($id), + $this->accountService, + ActionsInterface::ACCOUNT_REQUEST + ); $this->view->addTemplate('account-request'); $this->view->assign('formRoute', 'account/saveRequest'); @@ -531,13 +592,13 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function viewPassAction($id, $isHistory) { try { - $accountService = new AccountService(); $accountPassHelper = new AccountPasswordHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $account = $isHistory === 0 ? $accountService->getPasswordForId($id) : $accountService->getPasswordHistoryForId($id); + // FIXME: JS no envía isHistory + $account = $isHistory === 0 ? $this->accountService->getPasswordForId($id) : $this->accountService->getPasswordHistoryForId($id); $data = [ - 'acclogin' => $account->getAccountLogin(), + 'acclogin' => $account->getLogin(), 'accpass' => $accountPassHelper->getPassword($account, $this->acl, AccountPasswordHelper::TYPE_FULL), 'useimage' => $this->configData->isAccountPassToImage(), 'html' => $this->render() @@ -560,17 +621,14 @@ class AccountController extends ControllerBase implements CrudControllerInterfac * @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 + * @throws \SP\Core\Exceptions\InvalidArgumentException */ public function copyPassAction($id, $isHistory) { - $accountService = new AccountService(); $accountPassHelper = new AccountPasswordHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $account = $isHistory === 0 ? $accountService->getPasswordForId($id) : $accountService->getPasswordHistoryForId($id); + $account = $isHistory === 0 ? $this->accountService->getPasswordForId($id) : $this->accountService->getPasswordHistoryForId($id); $data = [ 'accpass' => $accountPassHelper->getPassword($account, $this->acl, AccountPasswordHelper::TYPE_NORMAL), @@ -597,20 +655,17 @@ class AccountController extends ControllerBase implements CrudControllerInterfac try { $form = new AccountForm(); $form->validate(ActionsInterface::ACCOUNT_CREATE); - $form->getItemData()->setAccountUserId($this->userData->getUserId()); + $form->getItemData()->userId = $this->userData->getId(); - $accountService = new AccountService(); - $account = $accountService->create($form->getItemData()); + $accountId = $this->accountService->create($form->getItemData()); - $this->addCustomFieldsForItem(ActionsInterface::ACCOUNT, $account->getId()); - - $accountService->logAction($account->getId(), ActionsInterface::ACCOUNT_CREATE); + $this->addCustomFieldsForItem(ActionsInterface::ACCOUNT, $accountId); $this->eventDispatcher->notifyEvent('create.account', $this); $this->returnJsonResponseData( [ - 'itemId' => $account->getId(), + 'itemId' => $accountId, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT) ], JsonResponse::JSON_SUCCESS, @@ -636,13 +691,10 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $form = new AccountForm($id); $form->validate(ActionsInterface::ACCOUNT_EDIT); - $accountService = new AccountService(); - $accountService->update($form->getItemData()); + $this->accountService->update($form->getItemData()); $this->updateCustomFieldsForItem(ActionsInterface::ACCOUNT, $id); - $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT); - $this->eventDispatcher->notifyEvent('edit.account', $this); $this->returnJsonResponseData( @@ -673,10 +725,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $form = new AccountForm($id); $form->validate(ActionsInterface::ACCOUNT_EDIT_PASS); - $accountService = new AccountService(); - $accountService->editPassword($form->getItemData()); - - $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT_PASS); + $this->accountService->editPassword($form->getItemData()); $this->eventDispatcher->notifyEvent('edit.account.pass', $this); @@ -706,10 +755,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function saveEditRestoreAction($historyId, $id) { try { - $accountService = new AccountService(); - $accountService->editRestore($historyId, $id); - - $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT_RESTORE); + $this->accountService->editRestore($historyId, $id); $this->eventDispatcher->notifyEvent('edit.account.restore', $this); @@ -736,13 +782,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac public function saveDeleteAction($id) { try { - $accountService = new AccountService(); - - if ($accountService->delete($id)) { + if ($this->accountService->delete($id)) { $this->deleteCustomFieldsForItem(ActionsInterface::ACCOUNT, $id); // FIXME: obtener cuenta antes de eliminar -// $accountService->logAccountAction($id, ActionsInterface::ACCOUNT_DELETE); +// $accountRepository->logAccountAction($id, ActionsInterface::ACCOUNT_DELETE); $this->eventDispatcher->notifyEvent('delete.account', $this); @@ -767,5 +811,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac if ($this->actionName !== 'viewLinkAction') { $this->checkLoggedIn(); } + + $this->accountService = new AccountService(); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/BootstrapController.php b/app/modules/web/Controllers/BootstrapController.php index 88e7e780..0a236577 100644 --- a/app/modules/web/Controllers/BootstrapController.php +++ b/app/modules/web/Controllers/BootstrapController.php @@ -25,13 +25,13 @@ namespace SP\Modules\Web\Controllers; use Exception; -use SP\Auth\Browser\Browser; use SP\Bootstrap; use SP\Core\CryptPKI; use SP\Core\Plugin\PluginUtil; use SP\Core\SessionFactory; use SP\Http\Cookies; use SP\Http\Response; +use SP\Providers\Auth\Browser\Browser; /** * Class BootstrapController @@ -55,7 +55,7 @@ class BootstrapController extends SimpleControllerBase 'max_file_size' => $configData->getFilesAllowedSize(), 'check_updates' => $this->session->getAuthCompleted() && ($configData->isCheckUpdates() || $configData->isChecknotices()) - && ($this->session->getUserData()->isUserIsAdminApp() || $configData->isDemoEnabled()), + && ($this->session->getUserData()->getIsAdminApp() || $configData->isDemoEnabled()), 'timezone' => date_default_timezone_get(), 'debug' => DEBUG || $configData->isDebug(), 'cookies_enabled' => Cookies::checkCookies(), diff --git a/app/modules/web/Controllers/CategoryController.php b/app/modules/web/Controllers/CategoryController.php index ccb514de..d8179b3d 100644 --- a/app/modules/web/Controllers/CategoryController.php +++ b/app/modules/web/Controllers/CategoryController.php @@ -39,7 +39,7 @@ 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\Category\CategoryService; +use SP\Repositories\Category\CategoryRepository; /** * Class CategoryController @@ -52,7 +52,7 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa use ItemTrait; /** - * @var CategoryService + * @var CategoryRepository */ protected $categoryService; @@ -276,7 +276,7 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa { $this->checkLoggedIn(); - $this->categoryService = new CategoryService(); + $this->categoryService = new CategoryRepository(); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php index 9a7a9a7b..29bc6442 100644 --- a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php @@ -24,8 +24,8 @@ namespace SP\Modules\Web\Controllers\Helpers; -use SP\Account\AccountSearch; -use SP\Account\AccountsSearchItem; +use SP\Account\AccountSearchFilter; +use SP\Account\AccountSearchItem; use SP\Core\Acl\ActionsInterface; use SP\Core\SessionUtil; use SP\Html\DataGrid\DataGrid; @@ -36,9 +36,10 @@ use SP\Html\DataGrid\DataGridHeaderSort; use SP\Html\DataGrid\DataGridPager; use SP\Html\DataGrid\DataGridSort; use SP\Http\Request; -use SP\Mgmt\Categories\Category; -use SP\Mgmt\Customers\Customer; -use SP\Mgmt\Tags\Tag; +use SP\Repositories\Category\CategoryRepository; +use SP\Repositories\Client\ClientRepository; +use SP\Repositories\Tag\TagRepository; +use SP\Services\Account\AccountSearchService; /** * Class AccountSearch @@ -55,8 +56,8 @@ class AccountSearchHelper extends HelperBase private $queryTimeStart = 0; /** @var bool */ private $isAjax = false; - /** @var AccountSearch */ - private $search; + /** @var AccountSearchFilter */ + private $accountSearchFilter; /** * @param boolean $isAjax @@ -73,42 +74,43 @@ class AccountSearchHelper extends HelperBase { $this->view->addTemplate('search-searchbox'); - $this->view->assign('customers', Customer::getItem()->getItemsForSelectByUser()); - $this->view->assign('categories', Category::getItem()->getItemsForSelect()); - $this->view->assign('tags', Tag::getItem()->getItemsForSelect()); + $clientService = new ClientRepository(); + + $this->view->assign('customers', $clientService->getItemsForSelectByUser()); + $this->view->assign('categories', CategoryRepository::getServiceItems()); + $this->view->assign('tags', TagRepository::getServiceItems()); } /** * Obtener los resultados de una búsqueda * - * @throws \InvalidArgumentException * @throws \Psr\Container\ContainerExceptionInterface * @throws \SP\Core\Exceptions\SPException */ - public function getSearch() + public function getAccountSearch() { $this->view->addTemplate('search-index'); $this->view->assign('isAjax', $this->isAjax); - $this->filterOn = ($this->search->getSortKey() > 1 - || $this->search->getCustomerId() - || $this->search->getCategoryId() - || $this->search->getTagsId() - || $this->search->getTxtSearch() - || $this->search->isSearchFavorites() - || $this->search->isSortViews()); + $this->filterOn = ($this->accountSearchFilter->getSortKey() > 1 + || $this->accountSearchFilter->getClientId() + || $this->accountSearchFilter->getCategoryId() + || $this->accountSearchFilter->getTagsId() + || $this->accountSearchFilter->getTxtSearch() + || $this->accountSearchFilter->isSearchFavorites() + || $this->accountSearchFilter->isSortViews()); - $UserPreferences = $this->session->getUserPreferences(); + $userPreferences = $this->session->getUserData()->getPreferences(); - AccountsSearchItem::$accountLink = $UserPreferences->isAccountLink(); - AccountsSearchItem::$topNavbar = $UserPreferences->isTopNavbar(); - AccountsSearchItem::$optionalActions = $UserPreferences->isOptionalActions(); - AccountsSearchItem::$wikiEnabled = $this->configData->isWikiEnabled(); - AccountsSearchItem::$dokuWikiEnabled = $this->configData->isDokuwikiEnabled(); - AccountsSearchItem::$isDemoMode = $this->configData->isDemoEnabled(); + AccountSearchItem::$accountLink = $userPreferences->isAccountLink(); + AccountSearchItem::$topNavbar = $userPreferences->isTopNavbar(); + AccountSearchItem::$optionalActions = $userPreferences->isOptionalActions(); + AccountSearchItem::$wikiEnabled = $this->configData->isWikiEnabled(); + AccountSearchItem::$dokuWikiEnabled = $this->configData->isDokuwikiEnabled(); + AccountSearchItem::$isDemoMode = $this->configData->isDemoEnabled(); - if (AccountsSearchItem::$wikiEnabled) { + if (AccountSearchItem::$wikiEnabled) { $wikiFilter = array_map(function ($value) { return preg_quote($value, '/'); }, $this->configData->getWikiFilter()); @@ -117,14 +119,16 @@ class AccountSearchHelper extends HelperBase $this->view->assign('wikiPageUrl', $this->configData->getWikiPageurl()); } + $accountSearchService = new AccountSearchService(); + $Grid = $this->getGrid(); - $Grid->getData()->setData($this->search->processSearchResults()); + $Grid->getData()->setData($accountSearchService->processSearchResults($this->accountSearchFilter)); $Grid->updatePager(); $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); // Establecer el filtro de búsqueda en la sesión como un objeto - $this->session->setSearchFilters($this->search); + $this->session->setSearchFilters($this->accountSearchFilter); $this->view->assign('data', $Grid); } @@ -144,7 +148,7 @@ class AccountSearchHelper extends HelperBase $GridActionOptional->setName(__('Más Acciones')); $GridActionOptional->setTitle(__('Más Acciones')); $GridActionOptional->setIcon($icons->getIconOptional()); - $GridActionOptional->setReflectionFilter(AccountsSearchItem::class, 'isShowOptional'); + $GridActionOptional->setReflectionFilter(AccountSearchItem::class, 'isShowOptional'); $GridActionOptional->addData('onclick', 'account/menu'); $GridPager = new DataGridPager(); @@ -152,17 +156,18 @@ class AccountSearchHelper extends HelperBase $GridPager->setIconNext($icons->getIconNavNext()); $GridPager->setIconFirst($icons->getIconNavFirst()); $GridPager->setIconLast($icons->getIconNavLast()); - $GridPager->setSortKey($this->search->getSortKey()); - $GridPager->setSortOrder($this->search->getSortOrder()); - $GridPager->setLimitStart($this->search->getLimitStart()); - $GridPager->setLimitCount($this->search->getLimitCount()); + $GridPager->setSortKey($this->accountSearchFilter->getSortKey()); + $GridPager->setSortOrder($this->accountSearchFilter->getSortOrder()); + $GridPager->setLimitStart($this->accountSearchFilter->getLimitStart()); + $GridPager->setLimitCount($this->accountSearchFilter->getLimitCount()); $GridPager->setOnClickFunction('account/sort'); $GridPager->setFilterOn($this->filterOn); $GridPager->setSourceAction(new DataGridActionSearch(ActionsInterface::ACCOUNT_SEARCH)); + $userPreferences = $this->session->getUserData()->getPreferences(); + $showOptionalActions = $userPreferences->isOptionalActions() || $userPreferences->isResultsAsCards() || ($userPreferences->getUserId() === 0 && $this->configData->isResultsAsCards()); + $actions = new AccountActionsHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $UserPreferences = $this->session->getUserPreferences(); - $showOptionalActions = $UserPreferences->isOptionalActions() || $UserPreferences->isResultsAsCards() || ($UserPreferences->getUserId() === 0 && $this->configData->isResultsAsCards()); $Grid = new DataGrid(); $Grid->setId('gridSearch'); @@ -195,35 +200,35 @@ class AccountSearchHelper extends HelperBase $GridSortCustomer = new DataGridSort(); $GridSortCustomer->setName(__('Cliente')) ->setTitle(__('Ordenar por Cliente')) - ->setSortKey(AccountSearch::SORT_CUSTOMER) + ->setSortKey(AccountSearchFilter::SORT_CLIENT) ->setIconUp($icons->getIconUp()) ->setIconDown($icons->getIconDown()); $GridSortName = new DataGridSort(); $GridSortName->setName(__('Nombre')) ->setTitle(__('Ordenar por Nombre')) - ->setSortKey(AccountSearch::SORT_NAME) + ->setSortKey(AccountSearchFilter::SORT_NAME) ->setIconUp($icons->getIconUp()) ->setIconDown($icons->getIconDown()); $GridSortCategory = new DataGridSort(); $GridSortCategory->setName(__('Categoría')) ->setTitle(__('Ordenar por Categoría')) - ->setSortKey(AccountSearch::SORT_CATEGORY) + ->setSortKey(AccountSearchFilter::SORT_CATEGORY) ->setIconUp($icons->getIconUp()) ->setIconDown($icons->getIconDown()); $GridSortLogin = new DataGridSort(); $GridSortLogin->setName(__('Usuario')) ->setTitle(__('Ordenar por Usuario')) - ->setSortKey(AccountSearch::SORT_LOGIN) + ->setSortKey(AccountSearchFilter::SORT_LOGIN) ->setIconUp($icons->getIconUp()) ->setIconDown($icons->getIconDown()); $GridSortUrl = new DataGridSort(); $GridSortUrl->setName(__('URL / IP')) ->setTitle(__('Ordenar por URL / IP')) - ->setSortKey(AccountSearch::SORT_URL) + ->setSortKey(AccountSearchFilter::SORT_URL) ->setIconUp($icons->getIconUp()) ->setIconDown($icons->getIconDown()); @@ -257,44 +262,50 @@ class AccountSearchHelper extends HelperBase { $userData = $this->session->getUserData(); - $this->view->assign('isAdmin', $userData->isUserIsAdminApp() || $userData->isUserIsAdminAcc()); + $this->view->assign('isAdmin', $userData->getIsAdminApp() || $userData->getIsAdminAcc()); $this->view->assign('showGlobalSearch', $this->configData->isGlobalSearch() && $this->session->getUserProfile()->isAccGlobalSearch()); // Obtener el filtro de búsqueda desde la sesión - $this->search = $this->getFilters(); + $this->accountSearchFilter = $this->getFilters(); - $this->view->assign('searchCustomer', $this->search->getCustomerId()); - $this->view->assign('searchCategory', $this->search->getCategoryId()); - $this->view->assign('searchTags', $this->search->getTagsId()); - $this->view->assign('searchTxt', $this->search->getTxtSearch()); - $this->view->assign('searchGlobal', $this->search->getGlobalSearch()); - $this->view->assign('searchFavorites', $this->search->isSearchFavorites()); + $this->view->assign('searchCustomer', $this->accountSearchFilter->getClientId()); + $this->view->assign('searchCategory', $this->accountSearchFilter->getCategoryId()); + $this->view->assign('searchTags', $this->accountSearchFilter->getTagsId()); + $this->view->assign('searchTxt', $this->accountSearchFilter->getTxtSearch()); + $this->view->assign('searchGlobal', $this->accountSearchFilter->getGlobalSearch()); + $this->view->assign('searchFavorites', $this->accountSearchFilter->isSearchFavorites()); } /** * Set search filters * - * @return AccountSearch + * @return AccountSearchFilter */ private function getFilters() { - if (empty(Request::analyze('sk'))) { + $accountSearchFilter = $this->session->getSearchFilters(); + + if ($accountSearchFilter !== null && empty(Request::analyze('sk'))) { // Obtener el filtro de búsqueda desde la sesión - return $this->session->getSearchFilters(); + return $accountSearchFilter; } - $this->search = new AccountSearch(); - $this->search->setSortKey(Request::analyze('skey', 0)); - $this->search->setSortOrder(Request::analyze('sorder', 0)); - $this->search->setLimitStart(Request::analyze('start', 0)); - $this->search->setLimitCount(Request::analyze('rpp', 0)); - $this->search->setGlobalSearch(Request::analyze('gsearch', false)); - $this->search->setCustomerId(Request::analyze('customer', 0)); - $this->search->setCategoryId(Request::analyze('category', 0)); - $this->search->setTagsId(Request::analyze('tags')); - $this->search->setSearchFavorites(Request::analyze('searchfav', false)); - $this->search->setTxtSearch(Request::analyze('search')); + $userPreferences = $this->session->getUserData()->getPreferences(); + $limitCount = ($userPreferences->getResultsPerPage() > 0) ? $userPreferences->getResultsPerPage() : $this->configData->getAccountCount(); - return $this->search; + $accountSearchFilter = new AccountSearchFilter(); + $accountSearchFilter->setSortKey(Request::analyze('skey', 0)); + $accountSearchFilter->setSortOrder(Request::analyze('sorder', 0)); + $accountSearchFilter->setLimitStart(Request::analyze('start', 0)); + $accountSearchFilter->setLimitCount(Request::analyze('rpp', $limitCount)); + $accountSearchFilter->setGlobalSearch(Request::analyze('gsearch', false)); + $accountSearchFilter->setClientId(Request::analyze('customer', 0)); + $accountSearchFilter->setCategoryId(Request::analyze('category', 0)); + $accountSearchFilter->setTagsId(Request::analyze('tags')); + $accountSearchFilter->setSearchFavorites(Request::analyze('searchfav', false)); + $accountSearchFilter->setTxtSearch(Request::analyze('search')); + $accountSearchFilter->setSortViews($userPreferences->isSortViews()); + + return $accountSearchFilter; } } \ No newline at end of file diff --git a/app/modules/web/Controllers/Helpers/ItemsGridHelper.php b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php index 8199694b..3c1b8bf5 100644 --- a/app/modules/web/Controllers/Helpers/ItemsGridHelper.php +++ b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php @@ -37,7 +37,7 @@ use SP\Html\DataGrid\DataGridData; use SP\Html\DataGrid\DataGridHeader; use SP\Html\DataGrid\DataGridPager; use SP\Html\DataGrid\DataGridTab; -use SP\Services\CustomField\CustomFieldDefService; +use SP\Repositories\CustomField\CustomFieldDefRepository; /** * Class Grids con las plantillas de tablas de datos @@ -77,9 +77,9 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('category_id'); - $GridData->addDataRowSource('category_name'); - $GridData->addDataRowSource('category_description'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('description'); $GridData->setData($data); // Grid @@ -179,10 +179,10 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('customer_id'); - $GridData->addDataRowSource('customer_name'); - $GridData->addDataRowSource('customer_description'); - $GridData->addDataRowSource('customer_isGlobal', false, function ($value) { + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('description'); + $GridData->addDataRowSource('isGlobal', false, function ($value) { return $value ? __u('SI') : __u('NO'); }); $GridData->setData($data); @@ -265,7 +265,7 @@ class ItemsGridHelper extends HelperBase $GridData->setDataRowSourceId('id'); $GridData->addDataRowSource('name'); $GridData->addDataRowSource('moduleId', false, function ($value) { - return CustomFieldDefService::getFieldModuleById($value); + return CustomFieldDefRepository::getFieldModuleById($value); }); $GridData->addDataRowSource('typeName'); $GridData->setData($data); @@ -348,8 +348,8 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); $GridData->setDataRowSourceId('id'); - $GridData->addDataRowSource('account_name'); - $GridData->addDataRowSource('customer_name'); + $GridData->addDataRowSource('accountName'); + $GridData->addDataRowSource('clientName'); $GridData->addDataRowSource('name'); $GridData->addDataRowSource('type'); $GridData->addDataRowSource('size'); @@ -417,9 +417,9 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('account_id'); - $GridData->addDataRowSource('account_name'); - $GridData->addDataRowSource('customer_name'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('clientName'); $GridData->setData($data); // Grid @@ -478,12 +478,12 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('acchistory_id'); - $GridData->addDataRowSource('acchistory_name'); - $GridData->addDataRowSource('customer_name'); - $GridData->addDataRowSource('acchistory_date'); - $GridData->addDataRowSourceWithIcon('acchistory_isModify', $iconEdit->setTitle(__('Modificada'))->setClass('opacity50')); - $GridData->addDataRowSourceWithIcon('acchistory_isDeleted', $iconDelete->setTitle(__('Eliminada'))->setClass('opacity50')); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('clientName'); + $GridData->addDataRowSource('date'); + $GridData->addDataRowSourceWithIcon('isModify', $iconEdit->setTitle(__('Modificada'))->setClass('opacity50')); + $GridData->addDataRowSourceWithIcon('isDeleted', $iconDelete->setTitle(__('Eliminada'))->setClass('opacity50')); $GridData->setData($data); // Grid @@ -550,15 +550,15 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('user_id'); - $GridData->addDataRowSource('user_name'); - $GridData->addDataRowSource('user_login'); - $GridData->addDataRowSource('userprofile_name'); - $GridData->addDataRowSource('usergroup_name'); - $GridData->addDataRowSourceWithIcon('user_isAdminApp', $this->icons->getIconAppAdmin()); - $GridData->addDataRowSourceWithIcon('user_isAdminAcc', $this->icons->getIconAccAdmin()); - $GridData->addDataRowSourceWithIcon('user_isLdap', $this->icons->getIconLdapUser()); - $GridData->addDataRowSourceWithIcon('user_isDisabled', $this->icons->getIconDisabled()); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('login'); + $GridData->addDataRowSource('userProfileName'); + $GridData->addDataRowSource('userGroupName'); + $GridData->addDataRowSourceWithIcon('isAdminApp', $this->icons->getIconAppAdmin()); + $GridData->addDataRowSourceWithIcon('isAdminAcc', $this->icons->getIconAccAdmin()); + $GridData->addDataRowSourceWithIcon('isLdap', $this->icons->getIconLdapUser()); + $GridData->addDataRowSourceWithIcon('isDisabled', $this->icons->getIconDisabled()); $GridData->setData($data); // Grid @@ -641,7 +641,7 @@ class ItemsGridHelper extends HelperBase $GridActionEditPass->setTitle(__('Cambiar Clave de Usuario')); $GridActionEditPass->setIcon($this->icons->getIconEditPass()); $GridActionEditPass->setOnClickFunction('appMgmt/show'); - $GridActionEditPass->setFilterRowSource('user_isLdap'); + $GridActionEditPass->setFilterRowSource('isLdap'); $GridActionEditPass->addData('action-route', Acl::getActionRoute(ActionsInterface::USER_EDIT_PASS)); $Grid->setDataActions($GridActionEditPass); @@ -674,9 +674,9 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('usergroup_id'); - $GridData->addDataRowSource('usergroup_name'); - $GridData->addDataRowSource('usergroup_description'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('description'); $GridData->setData($data); // Grid @@ -763,8 +763,8 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('userprofile_id'); - $GridData->addDataRowSource('userprofile_name'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); $GridData->setData($data); // Grid @@ -852,9 +852,9 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('authtoken_id'); - $GridData->addDataRowSource('user_login'); - $GridData->addDataRowSource('authtoken_actionId'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('userLogin'); + $GridData->addDataRowSource('actionId'); $GridData->setData($data); // Grid @@ -946,11 +946,11 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('publicLink_id'); - $GridData->addDataRowSource('account_name'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('accountName'); $GridData->addDataRowSource('getDateAddFormat', true); $GridData->addDataRowSource('getDateExpireFormat', true); - $GridData->addDataRowSource('user_login'); + $GridData->addDataRowSource('userLogin'); $GridData->addDataRowSource('getNotifyString', true); $GridData->addDataRowSource('getCountViewsString', true); $GridData->setData($data); @@ -1038,8 +1038,8 @@ class ItemsGridHelper extends HelperBase // Grid Data $GridData = new DataGridData(); - $GridData->setDataRowSourceId('tag_id'); - $GridData->addDataRowSource('tag_name'); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('name'); $GridData->setData($data); // Grid diff --git a/app/modules/web/Controllers/PublicLinkController.php b/app/modules/web/Controllers/PublicLinkController.php index 3d49325a..62a2a098 100644 --- a/app/modules/web/Controllers/PublicLinkController.php +++ b/app/modules/web/Controllers/PublicLinkController.php @@ -41,7 +41,7 @@ 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; +use SP\Repositories\PublicLink\PublicLinkRepository; /** * Class PublicLinkController @@ -54,7 +54,7 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter use ItemTrait; /** - * @var PublicLinkService + * @var PublicLinkRepository */ protected $publicLinkService; @@ -124,7 +124,7 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); if ($this->view->isView === true) { - $this->view->assign('publicLinkURL', PublicLinkService::getLinkForHash($publicLink->getPublicLinkHash())); + $this->view->assign('publicLinkURL', PublicLinkRepository::getLinkForHash($publicLink->getHash())); $this->view->assign('disabled', 'disabled'); $this->view->assign('readonly', 'readonly'); } else { @@ -290,6 +290,6 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter { $this->checkLoggedIn(); - $this->publicLinkService = new PublicLinkService(); + $this->publicLinkService = new PublicLinkRepository(); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php index 98584d09..477bd858 100644 --- a/app/modules/web/Controllers/UserGroupController.php +++ b/app/modules/web/Controllers/UserGroupController.php @@ -30,7 +30,7 @@ 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\DataModel\UserGroupData; use SP\Forms\UserGroupForm; use SP\Http\JsonResponse; use SP\Http\Request; @@ -38,9 +38,10 @@ 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; +use SP\Repositories\User\UserRepository; +use SP\Repositories\UserGroup\UserGroupRepository; +use SP\Repositories\UserGroup\UserToGroupService; +use SP\Repositories\UserGroup\UserToUserGroupRepository; /** * Class GroupController @@ -53,13 +54,13 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf use ItemTrait; /** - * @var UserGroupService + * @var UserGroupRepository */ protected $userGroupService; /** - * @var UserToGroupService + * @var UserToUserGroupRepository */ - protected $userToGroupService; + protected $userToUserGroupService; /** * Search action @@ -110,19 +111,17 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf /** * Sets view data for displaying user's data * - * @param $groupId - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Defuse\Crypto\Exception\CryptoException + * @param $userGroupId */ - protected function setViewData($groupId = null) + protected function setViewData($userGroupId = null) { $this->view->addTemplate('usergroup', 'itemshow'); - $group = $groupId ? $this->userGroupService->getById($groupId) : new GroupData(); + $group = $userGroupId ? $this->userGroupService->getById($userGroupId) : new UserGroupData(); $this->view->assign('group', $group); - $this->view->assign('users', UserService::getServiceItems()); - $this->view->assign('groupUsers', $this->userToGroupService->getById($groupId)); + $this->view->assign('users', UserRepository::getServiceItems()); + $this->view->assign('groupUsers', $this->userToUserGroupService->getById($userGroupId)); $this->view->assign('sk', SessionUtil::getSessionKey(true)); $this->view->assign('nextAction', Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)); @@ -135,7 +134,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf $this->view->assign('readonly'); } - $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::GROUP, $groupId)); + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::GROUP, $userGroupId)); } /** @@ -209,7 +208,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf $id = $this->userGroupService->create($groupData); $this->userGroupService->logAction($id, ActionsInterface::GROUP_CREATE); - $this->userToGroupService->add($id, $groupData->getUsers()); + $this->userToUserGroupService->add($id, $groupData->getUsers()); $this->addCustomFieldsForItem(ActionsInterface::GROUP, $id); @@ -244,7 +243,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf $this->userGroupService->update($groupData); $this->userGroupService->logAction($id, ActionsInterface::GROUP_EDIT); - $this->userToGroupService->update($groupData->getUsergroupId(), $groupData->getUsers()); + $this->userToUserGroupService->update($groupData->getId(), $groupData->getUsers()); $this->updateCustomFieldsForItem(ActionsInterface::GROUP, $id); @@ -293,7 +292,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf { $this->checkLoggedIn(); - $this->userGroupService = new UserGroupService(); - $this->userToGroupService = new UserToGroupService(); + $this->userGroupService = new UserGroupRepository(); + $this->userToUserGroupService = new UserToUserGroupRepository(); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php index 3e983200..8a6aad16 100644 --- a/app/modules/web/Controllers/UserProfileController.php +++ b/app/modules/web/Controllers/UserProfileController.php @@ -38,7 +38,7 @@ 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; +use SP\Repositories\UserProfile\UserProfileRepository; /** * Class UserProfileController @@ -51,7 +51,7 @@ class UserProfileController extends ControllerBase implements CrudControllerInte use ItemTrait; /** - * @var UserProfileService + * @var UserProfileRepository */ protected $userProfileService; @@ -285,6 +285,6 @@ class UserProfileController extends ControllerBase implements CrudControllerInte { $this->checkLoggedIn(); - $this->userProfileService = new UserProfileService(); + $this->userProfileService = new UserProfileRepository(); } } \ No newline at end of file diff --git a/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc b/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc index 8b96809a..5b3e689a 100644 --- a/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc +++ b/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc @@ -18,11 +18,11 @@