diff --git a/ajax/ajax_filesMgmt.php b/ajax/ajax_filesMgmt.php index d59fc201..8f0e0bd4 100644 --- a/ajax/ajax_filesMgmt.php +++ b/ajax/ajax_filesMgmt.php @@ -23,7 +23,7 @@ */ use SP\Account\AccountUtil; -use SP\Core\ActionsInterface; +use SP\Core\Acl\ActionsInterface; use SP\Core\Exceptions\SPException; use SP\Core\SessionUtil; use SP\DataModel\FileData; @@ -65,7 +65,7 @@ $fileId = Request::analyze('fileId', 0); $Log = new Log(); $LogMessage = $Log->getLogMessage(); -if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { +if ($actionId === ActionsInterface::ACCOUNT_FILE_UPLOAD) { if ($accountId === 0 || !is_array($_FILES['inFile'])) { Response::printJson(__('CONSULTA INVÁLIDA')); } @@ -145,9 +145,9 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { } catch (SPException $e) { Response::printJson(__('No se pudo guardar el archivo')); } -} elseif ($actionId === ActionsInterface::ACTION_ACC_FILES_DOWNLOAD - || $actionId === ActionsInterface::ACTION_ACC_FILES_VIEW - || $actionId === ActionsInterface::ACTION_MGM_FILES_VIEW +} elseif ($actionId === ActionsInterface::ACCOUNT_FILE_DOWNLOAD + || $actionId === ActionsInterface::ACCOUNT_FILE_VIEW + || $actionId === ActionsInterface::FILE_VIEW ) { // Verificamos que el ID sea numérico if (!is_numeric($fileId) || $fileId === 0) { @@ -168,7 +168,7 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { $LogMessage->addDetails(__('Tamaño', false), $FileData->getRoundSize() . 'KB'); $Log->writeLog(); - if ($actionId === ActionsInterface::ACTION_ACC_FILES_DOWNLOAD) { + if ($actionId === ActionsInterface::ACCOUNT_FILE_DOWNLOAD) { // Enviamos el archivo al navegador header('Set-Cookie: fileDownload=true; path=/'); header('Cache-Control: max-age=60, must-revalidate'); @@ -192,7 +192,7 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) { exit(); } } -} elseif ($actionId === ActionsInterface::ACTION_ACC_FILES_DELETE) { +} elseif ($actionId === ActionsInterface::ACCOUNT_FILE_DELETE) { // Verificamos que el ID sea numérico if (!is_numeric($fileId) || $fileId === 0) { Response::printJson(__('No es un ID de archivo válido')); diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index 7bdc374d..fb26eef8 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -29,7 +29,7 @@ use SP\Controller\EventlogController; use SP\Controller\ItemListController; use SP\Controller\NoticesController; use SP\Controller\UserPreferencesController; -use SP\Core\ActionsInterface; +use SP\Core\Acl\ActionsInterface; use SP\Core\SessionFactory; use SP\Core\Template; use SP\Http\Request; @@ -76,65 +76,65 @@ $Tpl->assign('userIsAdminAcc', $UserData->isUserIsAdminAcc()); $Tpl->assign('themeUri', $theme->getThemeUri()); switch ($actionId) { - case ActionsInterface::ACTION_ACC_SEARCH: + case ActionsInterface::ACCOUNT_SEARCH: $Controller = new AccountSearchController($Tpl); $Controller->doAction(); break; - case ActionsInterface::ACTION_ACC_NEW: - case ActionsInterface::ACTION_ACC_COPY: - case ActionsInterface::ACTION_ACC_EDIT: - case ActionsInterface::ACTION_ACC_EDIT_PASS: - case ActionsInterface::ACTION_ACC_VIEW: - case ActionsInterface::ACTION_ACC_VIEW_HISTORY: - case ActionsInterface::ACTION_ACC_DELETE: - case ActionsInterface::ACTION_ACC_REQUEST: + case ActionsInterface::ACCOUNT_CREATE: + case ActionsInterface::ACCOUNT_COPY: + case ActionsInterface::ACCOUNT_EDIT: + case ActionsInterface::ACCOUNT_EDIT_PASS: + case ActionsInterface::ACCOUNT_VIEW: + case ActionsInterface::ACCOUNT_VIEW_HISTORY: + case ActionsInterface::ACCOUNT_DELETE: + case ActionsInterface::ACCOUNT_REQUEST: $Controller = new AccountController($Tpl, $itemId); $Controller->doAction($actionId); break; - case ActionsInterface::ACTION_USR: - case ActionsInterface::ACTION_USR_USERS: - case ActionsInterface::ACTION_USR_GROUPS: - case ActionsInterface::ACTION_USR_PROFILES: - case ActionsInterface::ACTION_MGM_APITOKENS: - case ActionsInterface::ACTION_MGM_PUBLICLINKS: + case ActionsInterface::ACCESS_MANAGE: + case ActionsInterface::USER: + case ActionsInterface::GROUP: + case ActionsInterface::PROFILE: + case ActionsInterface::APITOKEN: + case ActionsInterface::PUBLICLINK: $Controller = new ItemListController($Tpl); $Controller->doAction(ItemListController::TYPE_ACCESSES); break; - case ActionsInterface::ACTION_MGM: - case ActionsInterface::ACTION_MGM_CATEGORIES: - case ActionsInterface::ACTION_MGM_CUSTOMERS: - case ActionsInterface::ACTION_MGM_CUSTOMFIELDS: - case ActionsInterface::ACTION_MGM_FILES: - case ActionsInterface::ACTION_MGM_ACCOUNTS: - case ActionsInterface::ACTION_MGM_TAGS: + case ActionsInterface::ITEMS_MANAGE: + case ActionsInterface::CATEGORY: + case ActionsInterface::CLIENT: + case ActionsInterface::CUSTOMFIELD: + case ActionsInterface::FILE: + case ActionsInterface::ACCOUNTMGR: + case ActionsInterface::TAG: $Controller = new ItemListController($Tpl); $Controller->doAction(ItemListController::TYPE_ACCOUNTS); break; - case ActionsInterface::ACTION_CFG: - case ActionsInterface::ACTION_CFG_GENERAL: - case ActionsInterface::ACTION_CFG_WIKI: - case ActionsInterface::ACTION_CFG_LDAP: - case ActionsInterface::ACTION_CFG_MAIL: - case ActionsInterface::ACTION_CFG_ENCRYPTION: - case ActionsInterface::ACTION_CFG_ENCRYPTION_TEMPPASS: - case ActionsInterface::ACTION_CFG_BACKUP: - case ActionsInterface::ACTION_CFG_EXPORT: - case ActionsInterface::ACTION_CFG_IMPORT: + case ActionsInterface::CONFIG: + case ActionsInterface::CONFIG_GENERAL: + case ActionsInterface::WIKI_CONFIG: + case ActionsInterface::LDAP_CONFIG: + case ActionsInterface::MAIL_CONFIG: + case ActionsInterface::ENCRYPTION_CONFIG: + case ActionsInterface::ENCRYPTION_TEMPPASS: + case ActionsInterface::BACKUP_CONFIG: + case ActionsInterface::EXPORT_CONFIG: + case ActionsInterface::IMPORT_CONFIG: $Controller = new ConfigController($Tpl); $Controller->doAction(); break; - case ActionsInterface::ACTION_EVL: + case ActionsInterface::EVENTLOG: $Controller = new EventlogController($Tpl); $Controller->doAction(); break; - case ActionsInterface::ACTION_USR_PREFERENCES: - case ActionsInterface::ACTION_USR_PREFERENCES_GENERAL: - case ActionsInterface::ACTION_USR_PREFERENCES_SECURITY: + case ActionsInterface::PREFERENCE: + case ActionsInterface::PREFERENCE_GENERAL: + case ActionsInterface::PREFERENCE_SECURITY: $Controller = new UserPreferencesController($Tpl); $Controller->doAction(); break; - case ActionsInterface::ACTION_NOT: - case ActionsInterface::ACTION_NOT_USER: + case ActionsInterface::NOTICE: + case ActionsInterface::NOTICE_USER: $Controller = new NoticesController($Tpl); $Controller->doAction(); break; diff --git a/ajax/ajax_userPrefsSave.php b/ajax/ajax_userPrefsSave.php index dcabce24..5871e98d 100644 --- a/ajax/ajax_userPrefsSave.php +++ b/ajax/ajax_userPrefsSave.php @@ -23,7 +23,7 @@ */ use Plugins\Authenticator\Authenticator; -use SP\Core\ActionsInterface; +use SP\Core\Acl\ActionsInterface; use SP\Core\Init; use SP\Core\Language; use SP\Core\SessionFactory; @@ -70,7 +70,7 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) { $actionId = Request::analyze('actionId', 0); $itemId = Request::analyze('itemId', 0); -if ($actionId === ActionsInterface::ACTION_USR_PREFERENCES_GENERAL) { +if ($actionId === ActionsInterface::PREFERENCE_GENERAL) { $UserPreferencesData = UserPreferences::getItem()->getById($itemId); $UserPreferencesData->setUserId($itemId); diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php new file mode 100644 index 00000000..d968bebb --- /dev/null +++ b/app/modules/web/Controllers/AccessManagerController.php @@ -0,0 +1,196 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use SP\Controller\ControllerBase; +use SP\Core\Acl\ActionsInterface; +use SP\DataModel\ItemSearchData; +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; + +/** + * Class AccessMgmtController + * + * @package SP\Modules\Web\Controllers + */ +class AccessManagerController extends ControllerBase +{ + /** + * @var ItemSearchData + */ + protected $itemSearchData; + /** + * @var ItemsGridHelper + */ + protected $itemsGridHelper; + /** + * @var TabsGridHelper + */ + protected $tabsGridHelper; + + public function indexAction() + { + $this->getGridTabs(); + } + + /** + * Returns a tabbed grid with items + * + * @throws \SP\Core\Exceptions\InvalidArgumentException + */ + protected function getGridTabs() + { + $this->itemSearchData = new ItemSearchData(); + $this->itemSearchData->setLimitCount($this->configData->getAccountCount()); + + $this->itemsGridHelper = new ItemsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + + $this->tabsGridHelper = new TabsGridHelper($this->view, $this->config, $this->session, $this->eventDispatcher); + + if ($this->checkAccess(ActionsInterface::USER)) { + $this->tabsGridHelper->addTab($this->getUsersList()); + } + + if ($this->checkAccess(ActionsInterface::GROUP)) { + $this->tabsGridHelper->addTab($this->getUsersGroupList()); + } + + if ($this->checkAccess(ActionsInterface::PROFILE)) { + $this->tabsGridHelper->addTab($this->getUsersProfileList()); + } + + if ($this->checkAccess(ActionsInterface::APITOKEN)) { + $this->tabsGridHelper->addTab($this->getApiTokensList()); + } + + if ($this->checkAccess(ActionsInterface::PUBLICLINK)) { + $this->tabsGridHelper->addTab($this->getPublicLinksList()); + } + + $this->eventDispatcher->notifyEvent('show.itemlist.accesses', $this); + + $this->tabsGridHelper->renderTabs(); + + $this->view(); + } + + /** + * 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; + } + + /** + * 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; + } + + /** + * 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; + } + + /** + * 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; + } + + /** + * Returns public links data tab + * + * @throws \SP\Core\Exceptions\InvalidArgumentException + */ + 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 TabsGridHelper + */ + public function getTabsGridHelper() + { + return $this->tabsGridHelper; + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php index 3390e737..9d06d1ed 100644 --- a/app/modules/web/Controllers/AccountController.php +++ b/app/modules/web/Controllers/AccountController.php @@ -24,14 +24,14 @@ namespace SP\Modules\Web\Controllers; -use SP\Core\Acl; +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\JsonTrait; use SP\Services\AccountService; use SP\Controller\ControllerBase; -use SP\Core\ActionsInterface; +use SP\Core\Acl\ActionsInterface; use SP\Core\Exceptions\SPException; use SP\Core\SessionUtil; use SP\Http\Request; @@ -40,7 +40,7 @@ use SP\Mgmt\Files\FileUtil; use SP\Modules\Web\Controllers\Helpers\AccountHelper; use SP\Modules\Web\Controllers\Helpers\AccountSearchHelper; use SP\Mvc\Controller\CrudControllerInterface; -use SP\Services\CustomFieldService; +use SP\Services\CustomField\CustomFieldService; /** * Class AccountController @@ -105,7 +105,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_VIEW); + $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_VIEW); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -148,7 +148,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac } try { - $this->setAction(ActionsInterface::ACTION_ACC_FILES); + $this->setAction(ActionsInterface::ACCOUNT_FILE); $this->view->addTemplate('files-list', 'account'); @@ -178,7 +178,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setActionId(ActionsInterface::ACTION_ACC_NEW); + $AccountHelper->setActionId(ActionsInterface::ACCOUNT_CREATE); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -216,7 +216,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_COPY); + $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_COPY); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -254,7 +254,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_EDIT); + $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_EDIT); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -293,7 +293,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_DELETE); + $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_DELETE); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -331,7 +331,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_EDIT_PASS); + $AccountHelper->setAccountData($id, ActionsInterface::ACCOUNT_EDIT_PASS); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -369,7 +369,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACTION_ACC_VIEW_HISTORY); + $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_VIEW_HISTORY); // Obtener los datos de la cuenta antes y comprobar el acceso if (!$AccountHelper->checkAccess($this)) { @@ -410,7 +410,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACTION_ACC_REQUEST); + $AccountHelper->setAccountDataHistory($id, ActionsInterface::ACCOUNT_REQUEST); $this->view->addTemplate('request'); $this->view->assign('formAction', 'account/saveRequest'); @@ -437,7 +437,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $accountService = new AccountService(); $accountPassHelper = new AccountPasswordHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $account = $isHistory === 0 ? $accountService->getAccountPass($id) : $accountService->getAccountPassHistory($id); + $account = $isHistory === 0 ? $accountService->getPasswordForId($id) : $accountService->getPasswordHistoryForId($id); $data = [ 'acclogin' => $account->getAccountLogin(), @@ -467,7 +467,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac $accountService = new AccountService(); $accountPassHelper = new AccountPasswordHelper($this->view, $this->config, $this->session, $this->eventDispatcher); - $account = $isHistory === 0 ? $accountService->getAccountPass($id) : $accountService->getAccountPassHistory($id); + $account = $isHistory === 0 ? $accountService->getPasswordForId($id) : $accountService->getPasswordHistoryForId($id); $data = [ 'accpass' => $accountPassHelper->getPassword($account, $this->acl, AccountPasswordHelper::TYPE_NORMAL), @@ -491,20 +491,20 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $form = new AccountForm(); - $form->validate(ActionsInterface::ACTION_ACC_NEW); + $form->validate(ActionsInterface::ACCOUNT_CREATE); $form->getItemData()->setAccountUserId($this->userData->getUserId()); $accountService = new AccountService(); - $account = $accountService->createAccount($form->getItemData()); + $account = $accountService->create($form->getItemData()); $customFieldService = new CustomFieldService(); - $customFieldService->addCustomFieldData(Request::analyze('customfield'), $account->getId(), ActionsInterface::ACTION_ACC); + $customFieldService->addCustomFieldData(Request::analyze('customfield'), $account->getId(), ActionsInterface::ACCOUNT); - $accountService->logAccountAction($account->getId(), ActionsInterface::ACTION_ACC_NEW); + $accountService->logAction($account->getId(), ActionsInterface::ACCOUNT_CREATE); $this->eventDispatcher->notifyEvent('add.account', $this); - $this->returnJsonResponse(0, __('Cuenta creada', false), ['itemId' => $account->getId(), 'nextAction' => Acl::getActionRoute(ActionsInterface::ACTION_ACC_EDIT)]); + $this->returnJsonResponse(0, __('Cuenta creada', false), ['itemId' => $account->getId(), 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)]); } catch (ValidationException $e) { $this->returnJsonResponse(1, $e->getMessage()); } catch (SPException $e) { @@ -523,19 +523,19 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $form = new AccountForm($id); - $form->validate(ActionsInterface::ACTION_ACC_EDIT); + $form->validate(ActionsInterface::ACCOUNT_EDIT); $accountService = new AccountService(); - $accountService->editAccount($form->getItemData()); + $accountService->edit($form->getItemData()); $customFieldService = new CustomFieldService(); - $customFieldService->updateCustomFieldData(Request::analyze('customfield'), $id, ActionsInterface::ACTION_ACC); + $customFieldService->updateCustomFieldData(Request::analyze('customfield'), $id, ActionsInterface::ACCOUNT); - $accountService->logAccountAction($id, ActionsInterface::ACTION_ACC_EDIT); + $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT); $this->eventDispatcher->notifyEvent('edit.account', $this); - $this->returnJsonResponse(0, __('Cuenta actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)]); + $this->returnJsonResponse(0, __('Cuenta actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); } catch (ValidationException $e) { $this->returnJsonResponse(1, $e->getMessage()); } catch (SPException $e) { @@ -554,16 +554,16 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $form = new AccountForm($id); - $form->validate(ActionsInterface::ACTION_ACC_EDIT_PASS); + $form->validate(ActionsInterface::ACCOUNT_EDIT_PASS); $accountService = new AccountService(); - $accountService->editAccountPass($form->getItemData()); + $accountService->editPassword($form->getItemData()); - $accountService->logAccountAction($id, ActionsInterface::ACTION_ACC_EDIT_PASS); + $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT_PASS); $this->eventDispatcher->notifyEvent('edit.account.pass', $this); - $this->returnJsonResponse(0, __('Clave actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)]); + $this->returnJsonResponse(0, __('Clave actualizada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); } catch (ValidationException $e) { $this->returnJsonResponse(1, $e->getMessage()); } catch (SPException $e) { @@ -583,13 +583,13 @@ class AccountController extends ControllerBase implements CrudControllerInterfac { try { $accountService = new AccountService(); - $accountService->editAccountRestore($historyId, $id); + $accountService->editRestore($historyId, $id); - $accountService->logAccountAction($id, ActionsInterface::ACTION_ACC_EDIT_RESTORE); + $accountService->logAction($id, ActionsInterface::ACCOUNT_EDIT_RESTORE); $this->eventDispatcher->notifyEvent('edit.account.restore', $this); - $this->returnJsonResponse(0, __('Cuenta restaurada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)]); + $this->returnJsonResponse(0, __('Cuenta restaurada', false), ['itemId' => $id, 'nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)]); } catch (ValidationException $e) { $this->returnJsonResponse(1, $e->getMessage()); } catch (SPException $e) { @@ -609,16 +609,16 @@ class AccountController extends ControllerBase implements CrudControllerInterfac try { $accountService = new AccountService(); - if ($accountService->deleteAccount($id)) { + if ($accountService->delete($id)) { $customFieldService = new CustomFieldService(); - $customFieldService->deleteCustomFieldData($id, ActionsInterface::ACTION_ACC); + $customFieldService->deleteCustomFieldData($id, ActionsInterface::ACCOUNT); // FIXME: obtener cuenta antes de eliminar -// $accountService->logAccountAction($id, ActionsInterface::ACTION_ACC_DELETE); +// $accountService->logAccountAction($id, ActionsInterface::ACCOUNT_DELETE); $this->eventDispatcher->notifyEvent('delete.account', $this); - $this->returnJsonResponse(0, __('Cuenta eliminada', false), ['nextAction' => Acl::getActionRoute(ActionsInterface::ACTION_ACC_SEARCH)]); + $this->returnJsonResponse(0, __('Cuenta eliminada', false), ['nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_SEARCH)]); } } catch (ValidationException $e) { $this->returnJsonResponse(1, $e->getMessage()); diff --git a/app/modules/web/Controllers/Helpers/AccountActionsHelper.php b/app/modules/web/Controllers/Helpers/AccountActionsHelper.php index c7059b3a..29fe6bf2 100644 --- a/app/modules/web/Controllers/Helpers/AccountActionsHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountActionsHelper.php @@ -3,8 +3,8 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Account\AccountsSearchItem; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\UI\ThemeIconsBase; use SP\Html\DataGrid\DataGridAction; use SP\Html\DataGrid\DataGridActionType; @@ -27,15 +27,15 @@ class AccountActionsHelper extends HelperBase public function getViewAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_VIEW); + $action->setId(ActionsInterface::ACCOUNT_VIEW); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Detalles de Cuenta')); $action->setTitle(__('Detalles de Cuenta')); $action->setIcon($this->icons->getIconView()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowView'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); return $action; @@ -47,16 +47,16 @@ class AccountActionsHelper extends HelperBase public function getViewPassAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_VIEW_PASS); + $action->setId(ActionsInterface::ACCOUNT_VIEW_PASS); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Ver Clave')); $action->setTitle(__('Ver Clave')); $action->setIcon($this->icons->getIconViewPass()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowViewPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW_PASS)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); $action->addData('action-full', 1); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW_PASS)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW_PASS)); $action->addAttribute('type', 'button'); return $action; @@ -68,15 +68,15 @@ class AccountActionsHelper extends HelperBase public function getEditPassAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_EDIT_PASS); + $action->setId(ActionsInterface::ACCOUNT_EDIT_PASS); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Modificar Clave de Cuenta')); $action->setTitle(__('Modificar Clave de Cuenta')); $action->setIcon($this->icons->getIconEditPass()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowViewPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_EDIT_PASS)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_EDIT_PASS)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS)); $action->addAttribute('type', 'button'); return $action; @@ -88,7 +88,7 @@ class AccountActionsHelper extends HelperBase public function getRestoreAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_EDIT_RESTORE); + $action->setId(ActionsInterface::ACCOUNT_EDIT_RESTORE); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Restaurar cuenta desde este punto')); $action->setTitle(__('Restaurar cuenta desde este punto')); @@ -107,7 +107,7 @@ class AccountActionsHelper extends HelperBase public function getSaveAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC); + $action->setId(ActionsInterface::ACCOUNT); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Guardar')); $action->setTitle(__('Guardar')); @@ -129,13 +129,13 @@ class AccountActionsHelper extends HelperBase $ClipboardIcon = $this->icons->getIconClipboard()->setClass('clip-pass-button'); $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_VIEW_PASS); + $action->setId(ActionsInterface::ACCOUNT_VIEW_PASS); $action->setType(DataGridActionType::VIEW_ITEM); $action->setName(__('Copiar Clave en Portapapeles')); $action->setTitle(__('Copiar Clave en Portapapeles')); $action->setIcon($ClipboardIcon); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowCopyPass'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_COPY_PASS)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY_PASS)); $action->addData('action-full', 0); $action->addData('action-sk', $this->view->sk); $action->addData('useclipboard', '1'); @@ -150,15 +150,15 @@ class AccountActionsHelper extends HelperBase public function getEditAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_EDIT); + $action->setId(ActionsInterface::ACCOUNT_EDIT); $action->setType(DataGridActionType::EDIT_ITEM); $action->setName(__('Editar Cuenta')); $action->setTitle(__('Editar Cuenta')); $action->setIcon($this->icons->getIconEdit()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowEdit'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_EDIT)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_EDIT)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT)); $action->addAttribute('type', 'button'); return $action; @@ -170,14 +170,14 @@ class AccountActionsHelper extends HelperBase public function getPublicLinkAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW); + $action->setId(ActionsInterface::PUBLICLINK_CREATE); $action->setName(__('Crear Enlace Público')); $action->setTitle(__('Crear Enlace Público')); $action->setIcon($this->icons->getIconPublicLink()); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::PUBLICLINK_CREATE)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'link/save'); - $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)); + $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); return $action; @@ -189,14 +189,14 @@ class AccountActionsHelper extends HelperBase public function getPublicLinkRefreshAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH); + $action->setId(ActionsInterface::PUBLICLINK_REFRESH); $action->setName(__('Actualizar Enlace Público')); $action->setTitle(__('Actualizar Enlace Público')); $action->setIcon($this->icons->getIconPublicLink()); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); $action->addData('action-sk', $this->view->sk); $action->addData('onclick', 'link/refresh'); - $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)); + $action->addData('nextaction-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'button'); return $action; @@ -208,15 +208,15 @@ class AccountActionsHelper extends HelperBase public function getCopyAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_COPY); + $action->setId(ActionsInterface::ACCOUNT_COPY); $action->setType(DataGridActionType::NEW_ITEM); $action->setName(__('Copiar Cuenta')); $action->setTitle(__('Copiar Cuenta')); $action->setIcon($this->icons->getIconCopy()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowCopy'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_COPY)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_COPY)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_COPY)); $action->addAttribute('type', 'button'); return $action; @@ -228,15 +228,15 @@ class AccountActionsHelper extends HelperBase public function getDeleteAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_DELETE); + $action->setId(ActionsInterface::ACCOUNT_DELETE); $action->setType(DataGridActionType::DELETE_ITEM); $action->setName(__('Eliminar Cuenta')); $action->setTitle(__('Eliminar Cuenta')); $action->setIcon($this->icons->getIconDelete()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowDelete'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_DELETE)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_DELETE)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_DELETE)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_DELETE)); $action->addAttribute('type', 'button'); return $action; @@ -248,14 +248,14 @@ class AccountActionsHelper extends HelperBase public function getRequestAction() { $action = new DataGridAction(); - $action->setId(ActionsInterface::ACTION_ACC_REQUEST); + $action->setId(ActionsInterface::ACCOUNT_REQUEST); $action->setName(__('Solicitar Modificación')); $action->setTitle(__('Solicitar Modificación')); $action->setIcon($this->icons->getIconEmail()); $action->setReflectionFilter(AccountsSearchItem::class, 'isShowRequest'); - $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACTION_ACC_REQUEST)); + $action->addData('action-id', Acl::getActionRoute(ActionsInterface::ACCOUNT_REQUEST)); $action->addData('action-sk', $this->view->sk); - $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACTION_ACC_VIEW)); + $action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW)); $action->addAttribute('type', 'submit'); return $action; diff --git a/app/modules/web/Controllers/Helpers/AccountHelper.php b/app/modules/web/Controllers/Helpers/AccountHelper.php index e5eb8acd..2b439319 100644 --- a/app/modules/web/Controllers/Helpers/AccountHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountHelper.php @@ -30,8 +30,8 @@ use SP\Account\AccountHistory; use SP\Account\AccountUtil; use SP\Account\UserAccounts; use SP\Controller\ControllerBase; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\Init; use SP\Core\SessionUtil; use SP\DataModel\AccountExtData; @@ -203,8 +203,8 @@ class AccountHelper extends HelperBase $this->view->assign('otherAccounts', AccountUtil::getAccountsForUser($this->session, $this->id)); $this->view->assign('linkedAccounts', AccountUtil::getLinkedAccounts($this->id, $this->session)); - $this->view->assign('addCustomerEnabled', $this->acl->checkUserAccess(ActionsInterface::ACTION_MGM_CUSTOMERS)); - $this->view->assign('addCategoryEnabled', $this->acl->checkUserAccess(ActionsInterface::ACTION_MGM_CATEGORIES)); + $this->view->assign('addCustomerEnabled', $this->acl->checkUserAccess(ActionsInterface::CLIENT)); + $this->view->assign('addCategoryEnabled', $this->acl->checkUserAccess(ActionsInterface::CATEGORY)); $this->view->assign('disabled', $this->view->isView ? 'disabled' : ''); $this->view->assign('readonly', $this->view->isView ? 'readonly' : ''); @@ -219,7 +219,7 @@ class AccountHelper extends HelperBase */ private function getCustomFieldsForItem() { - $this->view->assign('customFields', CustomField::getItem(new CustomFieldData(ActionsInterface::ACTION_ACC))->getById($this->id)); + $this->view->assign('customFields', CustomField::getItem(new CustomFieldData(ActionsInterface::ACCOUNT))->getById($this->id)); } /** @@ -293,7 +293,7 @@ class AccountHelper extends HelperBase $actionsEnabled[] = $actions->getEditAction()->addData('item-id', $accountData->getAccountId()); } - if ($this->actionId === ActionsInterface::ACTION_ACC_VIEW + if ($this->actionId === ActionsInterface::ACCOUNT_VIEW && !$this->AccountAcl->isShowEdit() && $this->configData->isMailRequestsEnabled() ) { diff --git a/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php b/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php index bf12e612..fa0dacfc 100644 --- a/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountPasswordHelper.php @@ -2,8 +2,8 @@ namespace SP\Modules\Web\Controllers\Helpers; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\Crypt\Crypt; use SP\Core\SessionUtil; use SP\DataModel\AccountPassData; @@ -21,12 +21,12 @@ class AccountPasswordHelper extends HelperBase const TYPE_NORMAL = 0; const TYPE_FULL = 1; - /** @var Acl */ + /** @var \SP\Core\Acl\Acl */ protected $acl; /** - * @param AccountPassData $account - * @param Acl $acl + * @param AccountPassData $account + * @param \SP\Core\Acl\Acl $acl * @param $type * @return string */ @@ -53,7 +53,7 @@ class AccountPasswordHelper extends HelperBase */ protected function getPasswordClear(AccountPassData $accountData) { - if (!$this->acl->checkUserAccess(ActionsInterface::ACTION_ACC_VIEW_PASS) + if (!$this->acl->checkUserAccess(ActionsInterface::ACCOUNT_VIEW_PASS) || $accountData->getAccountId() === 0 ) { throw new HelperException(__('No tiene permisos para acceder a esta cuenta', false)); diff --git a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php index 1f969e39..85e03645 100644 --- a/app/modules/web/Controllers/Helpers/AccountSearchHelper.php +++ b/app/modules/web/Controllers/Helpers/AccountSearchHelper.php @@ -26,8 +26,8 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Account\AccountSearch; use SP\Account\AccountsSearchItem; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\SessionUtil; use SP\Html\DataGrid\DataGrid; use SP\Html\DataGrid\DataGridAction; @@ -161,7 +161,7 @@ class AccountSearchHelper extends HelperBase $GridPager->setLimitCount($this->search->getLimitCount()); $GridPager->setOnClickFunction('account/sort'); $GridPager->setFilterOn($this->filterOn); - $GridPager->setSourceAction(new DataGridActionSearch(ActionsInterface::ACTION_ACC_SEARCH)); + $GridPager->setSourceAction(new DataGridActionSearch(ActionsInterface::ACCOUNT_SEARCH)); $actions = new AccountActionsHelper($this->view, $this->config, $this->session, $this->eventDispatcher); $UserPreferences = $this->session->getUserPreferences(); diff --git a/app/modules/web/Controllers/Helpers/ItemsGridHelper.php b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php new file mode 100644 index 00000000..2549e9fd --- /dev/null +++ b/app/modules/web/Controllers/Helpers/ItemsGridHelper.php @@ -0,0 +1,1160 @@ +. + */ + +namespace SP\Modules\Web\Controllers\Helpers; + +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; +use SP\Html\DataGrid\DataGridActionSearch; +use SP\Html\DataGrid\DataGridActionType; +use SP\Html\DataGrid\DataGridData; +use SP\Html\DataGrid\DataGridHeader; +use SP\Html\DataGrid\DataGridPager; +use SP\Html\DataGrid\DataGridTab; + +/** + * Class Grids con las plantillas de tablas de datos + * + * @package SP\Controller + */ +class ItemsGridHelper extends HelperBase +{ + protected $queryTimeStart; + /** + * @var ThemeIconsBase + */ + protected $icons; + /** + * @var \SP\Core\Acl\Acl + */ + protected $acl; + + /** + * @param \SP\Core\Acl\Acl $acl + */ + public function inject(Acl $acl) + { + $this->acl = $acl; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getCategoriesGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Descripción')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('category_id'); + $GridData->addDataRowSource('category_name'); + $GridData->addDataRowSource('category_description'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblCategories'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Categorías')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::CATEGORY_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchCategory'); + $GridActionSearch->setTitle(__('Buscar Categoría')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::CATEGORY_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nueva Categoría')); + $GridActionNew->setTitle(__('Nueva Categoría')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::CATEGORY_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Categoría')); + $GridActionEdit->setTitle(__('Editar Categoría')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_VIEW)); + + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::CATEGORY_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Categoría')); + $GridActionDel->setTitle(__('Eliminar Categoría')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CATEGORY_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * Devolver el paginador por defecto + * + * @param DataGridActionSearch $sourceAction + * @return DataGridPager + */ + protected function getPager(DataGridActionSearch $sourceAction) + { + $GridPager = new DataGridPager(); + $GridPager->setSourceAction($sourceAction); + $GridPager->setOnClickFunction('appMgmt/nav'); + $GridPager->setLimitStart(0); + $GridPager->setLimitCount($this->configData->getAccountCount()); + $GridPager->setIconPrev($this->icons->getIconNavPrev()); + $GridPager->setIconNext($this->icons->getIconNavNext()); + $GridPager->setIconFirst($this->icons->getIconNavFirst()); + $GridPager->setIconLast($this->icons->getIconNavLast()); + + return $GridPager; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getClientsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Descripción')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('customer_id'); + $GridData->addDataRowSource('customer_name'); + $GridData->addDataRowSource('customer_description'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblCustomers'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Clientes')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::CLIENT_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchCustomer'); + $GridActionSearch->setTitle(__('Buscar Cliente')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::CLIENT_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Cliente')); + $GridActionNew->setTitle(__('Nuevo Cliente')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::CLIENT_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Cliente')); + $GridActionEdit->setTitle(__('Editar Cliente')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::CLIENT_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Cliente')); + $GridActionDel->setTitle(__('Eliminar Cliente')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CLIENT_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getCustomFieldsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Módulo')); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Tipo')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('moduleName'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('typeName'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblCustomFields'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Campos Personalizados')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::CUSTOMFIELD_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchCustomField'); + $GridActionSearch->setTitle(__('Buscar Campo')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::CUSTOMFIELD_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Campo')); + $GridActionNew->setTitle(__('Nuevo Campo')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::CUSTOMFIELD_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Campo')); + $GridActionEdit->setTitle(__('Editar Campo')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::CUSTOMFIELD_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Campo')); + $GridActionDel->setTitle(__('Eliminar Campo')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::CUSTOMFIELD_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getFilesGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Cuenta')); + $GridHeaders->addHeader(__('Cliente')); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Tipo')); + $GridHeaders->addHeader(__('Tamaño')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('accfile_id'); + $GridData->addDataRowSource('account_name'); + $GridData->addDataRowSource('customer_name'); + $GridData->addDataRowSource('accfile_name'); + $GridData->addDataRowSource('accfile_type'); + $GridData->addDataRowSource('accfile_size'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblFiles'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Archivos')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::FILE_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchFile'); + $GridActionSearch->setTitle(__('Buscar Archivo')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::FILE_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::FILE_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Archivo')); + $GridActionView->setTitle(__('Ver Archivo')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('file/view'); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::FILE_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::FILE_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Archivo')); + $GridActionDel->setTitle(__('Eliminar Archivo')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::FILE_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getAccountsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Cliente')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('account_id'); + $GridData->addDataRowSource('account_name'); + $GridData->addDataRowSource('customer_name'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblAccounts'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Cuentas')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::ACCOUNTMGR_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchAccount'); + $GridActionSearch->setTitle(__('Buscar Cuenta')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::ACCOUNTMGR_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Cuenta')); + $GridActionDel->setTitle(__('Eliminar Cuenta')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getAccountsHistoryGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Cliente')); + $GridHeaders->addHeader(__('Fecha')); + $GridHeaders->addHeader(__('Estado')); + + $iconEdit = clone $this->icons->getIconEdit(); + $iconDelete = clone $this->icons->getIconDelete(); + + // 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')); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblAccountsHistory'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Cuentas (H)')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::ACCOUNTMGR_SEARCH_HISTORY); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchAccountHistory'); + $GridActionSearch->setTitle(__('Buscar Cuenta')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_SEARCH_HISTORY)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionRestore = new DataGridAction(); + $GridActionRestore->setId(ActionsInterface::ACCOUNTMGR_RESTORE); + $GridActionRestore->setType(DataGridActionType::EDIT_ITEM); + $GridActionRestore->setName(__('Restaurar Cuenta')); + $GridActionRestore->setTitle(__('Restaurar Cuenta')); + $GridActionRestore->setIcon($this->icons->getIconRestore()); + $GridActionRestore->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_RESTORE)); + +// $Grid->setDataActions($GridActionRestore); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::ACCOUNTMGR_DELETE_HISTORY); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Cuenta')); + $GridActionDel->setTitle(__('Eliminar Cuenta')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::ACCOUNTMGR_DELETE_HISTORY)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getUsersGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Login')); + $GridHeaders->addHeader(__('Perfil')); + $GridHeaders->addHeader(__('Grupo')); + $GridHeaders->addHeader(__('Propiedades')); + + // 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()); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblUsers'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Usuarios')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::USER_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchUser'); + $GridActionSearch->setTitle(__('Buscar Usuario')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::USER_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::USER_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Usuario')); + $GridActionNew->setTitle(__('Nuevo Usuario')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::USER_CREATE)); + + $Grid->setDataActions($GridActionNew); + + if ($this->acl->checkUserAccess(ActionsInterface::IMPORT_CONFIG) + && $this->configData->isLdapEnabled() + ) { + $GridActionLdapSync = new DataGridAction(); + $GridActionLdapSync->setId(ActionsInterface::LDAP_SYNC); + $GridActionLdapSync->setType(DataGridActionType::NEW_ITEM); + $GridActionLdapSync->setName(__('Importar usuarios de LDAP')); + $GridActionLdapSync->setTitle(__('Importar usuarios de LDAP')); + $GridActionLdapSync->setIcon(new FontIcon('get_app')); + $GridActionLdapSync->setSkip(true); + $GridActionLdapSync->setOnClickFunction('appMgmt/ldapSync'); + $GridActionLdapSync->addData('route', Acl::getActionRoute(ActionsInterface::LDAP_SYNC)); + + $Grid->setDataActions($GridActionLdapSync); + } + + // Grid item's actions + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::USER_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Detalles de Usuario')); + $GridActionView->setTitle(__('Ver Detalles de Usuario')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::USER_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::USER_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Usuario')); + $GridActionEdit->setTitle(__('Editar Usuario')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::USER_EDIT)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionEditPass = new DataGridAction(); + $GridActionEditPass->setId(ActionsInterface::USER_EDIT_PASS); + $GridActionEditPass->setType(DataGridActionType::EDIT_ITEM); + $GridActionEditPass->setName(__('Cambiar Clave de Usuario')); + $GridActionEditPass->setTitle(__('Cambiar Clave de Usuario')); + $GridActionEditPass->setIcon($this->icons->getIconEditPass()); + $GridActionEditPass->setOnClickFunction('appMgmt/show'); + $GridActionEditPass->setFilterRowSource('user_isLdap'); + $GridActionEditPass->addData('route', Acl::getActionRoute(ActionsInterface::USER_EDIT_PASS)); + + $Grid->setDataActions($GridActionEditPass); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::USER_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Usuario')); + $GridActionDel->setTitle(__('Eliminar Usuario')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::USER_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getGroupsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + $GridHeaders->addHeader(__('Descripción')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('usergroup_id'); + $GridData->addDataRowSource('usergroup_name'); + $GridData->addDataRowSource('usergroup_description'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblGroups'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Grupos')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::GROUP_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchGroup'); + $GridActionSearch->setTitle(__('Buscar Grupo')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::GROUP_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Grupo')); + $GridActionNew->setTitle(__('Nuevo Grupo')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::GROUP_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Grupo')); + $GridActionEdit->setTitle(__('Editar Grupo')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::GROUP_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Grupo')); + $GridActionDel->setTitle(__('Eliminar Grupo')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::GROUP_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getProfilesGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('userprofile_id'); + $GridData->addDataRowSource('userprofile_name'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblProfiles'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Perfiles')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::PROFILE_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchProfile'); + $GridActionSearch->setTitle(__('Buscar Perfil')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::PROFILE_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nuevo Perfil')); + $GridActionNew->setTitle(__('Nuevo Perfil')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::PROFILE_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Detalles de Perfil')); + $GridActionView->setTitle(__('Ver Detalles de Perfil')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::PROFILE_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Perfil')); + $GridActionEdit->setTitle(__('Editar Perfil')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::PROFILE_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Perfil')); + $GridActionDel->setTitle(__('Eliminar Perfil')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::PROFILE_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getApiTokensGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Usuario')); + $GridHeaders->addHeader(__('Acción')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('authtoken_id'); + $GridData->addDataRowSource('user_login'); + $GridData->addDataRowSource('authtoken_actionId'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblTokens'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Autorizaciones API')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::APITOKEN_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchToken'); + $GridActionSearch->setTitle(__('Buscar Token')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::APITOKEN_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nueva Autorización')); + $GridActionNew->setTitle(__('Nueva Autorización')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::APITOKEN_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver token de Autorización')); + $GridActionView->setTitle(__('Ver token de Autorización')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::APITOKEN_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Autorización')); + $GridActionEdit->setTitle(__('Editar Autorización')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->setOnClickFunction('appMgmt/show'); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::APITOKEN_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Autorización')); + $GridActionDel->setTitle(__('Eliminar Autorización')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::APITOKEN_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getPublicLinksGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Cuenta')); + $GridHeaders->addHeader(__('Fecha Creación')); + $GridHeaders->addHeader(__('Fecha Caducidad')); + $GridHeaders->addHeader(__('Usuario')); + $GridHeaders->addHeader(__('Notificar')); + $GridHeaders->addHeader(__('Visitas')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('publicLink_id'); + $GridData->addDataRowSource('accountName'); + $GridData->addDataRowSource('dateAdd'); + $GridData->addDataRowSource('dateExpire'); + $GridData->addDataRowSource('userLogin'); + $GridData->addDataRowSource('notify'); + $GridData->addDataRowSource('countViews'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblLinks'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Enlaces')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::PUBLICLINK_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchLink'); + $GridActionSearch->setTitle(__('Buscar Enlace')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::PUBLICLINK_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Enlace')); + $GridActionView->setTitle(__('Ver Enlace')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionRefresh = new DataGridAction(); + $GridActionRefresh->setId(ActionsInterface::PUBLICLINK_REFRESH); + $GridActionRefresh->setName(__('Renovar Enlace')); + $GridActionRefresh->setTitle(__('Renovar Enlace')); + $GridActionRefresh->setIcon($this->icons->getIconRefresh()); + $GridActionRefresh->setOnClickFunction('link/refresh'); + $GridActionRefresh->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_REFRESH)); + + $Grid->setDataActions($GridActionRefresh); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::PUBLICLINK_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Enlace')); + $GridActionDel->setTitle(__('Eliminar Enlace')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::PUBLICLINK_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getTagsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Nombre')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('tag_id'); + $GridData->addDataRowSource('tag_name'); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblTags'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Etiquetas')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::TAG_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchTag'); + $GridActionSearch->setTitle(__('Buscar Etiqueta')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::TAG_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(ActionsInterface::TAG_CREATE); + $GridActionNew->setType(DataGridActionType::NEW_ITEM); + $GridActionNew->setName(__('Nueva Etiqueta')); + $GridActionNew->setTitle(__('Nueva Etiqueta')); + $GridActionNew->setIcon($this->icons->getIconAdd()); + $GridActionNew->setSkip(true); + $GridActionNew->setOnClickFunction('appMgmt/show'); + $GridActionNew->addData('route', Acl::getActionRoute(ActionsInterface::TAG_VIEW)); + + $Grid->setDataActions($GridActionNew); + + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(ActionsInterface::TAG_EDIT); + $GridActionEdit->setType(DataGridActionType::EDIT_ITEM); + $GridActionEdit->setName(__('Editar Etiqueta')); + $GridActionEdit->setTitle(__('Editar Etiqueta')); + $GridActionEdit->setIcon($this->icons->getIconEdit()); + $GridActionEdit->addData('route', Acl::getActionRoute(ActionsInterface::TAG_VIEW)); + + $Grid->setDataActions($GridActionEdit); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(ActionsInterface::TAG_DELETE); + $GridActionDel->setType(DataGridActionType::DELETE_ITEM); + $GridActionDel->setName(__('Eliminar Etiqueta')); + $GridActionDel->setTitle(__('Eliminar Etiqueta')); + $GridActionDel->setIcon($this->icons->getIconDelete()); + $GridActionDel->setOnClickFunction('appMgmt/delete'); + $GridActionDel->addData('route', Acl::getActionRoute(ActionsInterface::TAG_DELETE)); + + $Grid->setDataActions($GridActionDel); + $Grid->setDataActions($GridActionDel, true); + + return $Grid; + } + + /** + * @return DataGridTab + * @throws InvalidArgumentException + */ + public function getPluginsGrid() + { + // Grid Header + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(__('Plugin')); + $GridHeaders->addHeader(__('Estado')); + + // Grid Data + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('plugin_id'); + $GridData->addDataRowSource('plugin_name'); + $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); + + // Grid + $Grid = new DataGridTab(); + $Grid->setId('tblPlugins'); + $Grid->setDataRowTemplate('datagrid-rows', 'grid'); + $Grid->setDataPagerTemplate('datagrid-nav-full', 'grid'); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(__('Plugins')); + $Grid->setTime(round(microtime() - $this->queryTimeStart, 5)); + + // Grid Actions + $GridActionSearch = new DataGridActionSearch(); + $GridActionSearch->setId(ActionsInterface::PLUGIN_SEARCH); + $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM); + $GridActionSearch->setName('frmSearchPlugin'); + $GridActionSearch->setTitle(__('Buscar Plugin')); + $GridActionSearch->setOnSubmitFunction('appMgmt/search'); + $GridActionSearch->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_SEARCH)); + + $Grid->setDataActions($GridActionSearch); + $Grid->setPager($this->getPager($GridActionSearch)); + + // Grid item's actions + $GridActionView = new DataGridAction(); + $GridActionView->setId(ActionsInterface::PLUGIN_VIEW); + $GridActionView->setType(DataGridActionType::VIEW_ITEM); + $GridActionView->setName(__('Ver Plugin')); + $GridActionView->setTitle(__('Ver Plugin')); + $GridActionView->setIcon($this->icons->getIconView()); + $GridActionView->setOnClickFunction('appMgmt/show'); + $GridActionView->setFilterRowSource('plugin_available', 0); + $GridActionView->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_VIEW)); + + $Grid->setDataActions($GridActionView); + + $GridActionEnable = new DataGridAction(); + $GridActionEnable->setId(ActionsInterface::PLUGIN_ENABLE); + $GridActionEnable->setName(__('Habilitar')); + $GridActionEnable->setTitle(__('Habilitar')); + $GridActionEnable->setIcon($this->icons->getIconEnabled()); + $GridActionEnable->setOnClickFunction('plugin/toggle'); + $GridActionEnable->setFilterRowSource('plugin_enabled'); + $GridActionEnable->setFilterRowSource('plugin_available', 0); + $GridActionEnable->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_ENABLE)); + + $Grid->setDataActions($GridActionEnable); + + $GridActionDisable = new DataGridAction(); + $GridActionDisable->setId(ActionsInterface::PLUGIN_DISABLE); + $GridActionDisable->setName(__('Deshabilitar')); + $GridActionDisable->setTitle(__('Deshabilitar')); + $GridActionDisable->setIcon($this->icons->getIconDisabled()); + $GridActionDisable->setOnClickFunction('plugin/toggle'); + $GridActionDisable->setFilterRowSource('plugin_enabled', 0); + $GridActionDisable->setFilterRowSource('plugin_available', 0); + $GridActionDisable->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_DISABLE)); + + $Grid->setDataActions($GridActionDisable); + + $GridActionReset = new DataGridAction(); + $GridActionReset->setId(ActionsInterface::PLUGIN_RESET); + $GridActionReset->setName(__('Restablecer Datos')); + $GridActionReset->setTitle(__('Restablecer Datos')); + $GridActionReset->setIcon($this->icons->getIconRefresh()); + $GridActionReset->setOnClickFunction('plugin/reset'); + $GridActionReset->setFilterRowSource('plugin_available', 0); + $GridActionReset->addData('route', Acl::getActionRoute(ActionsInterface::PLUGIN_RESET)); + + $Grid->setDataActions($GridActionReset); + + return $Grid; + } + + protected function initialize() + { + $this->icons = $this->view->getTheme()->getIcons(); + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php index b85b3481..ded30f4d 100644 --- a/app/modules/web/Controllers/Helpers/LayoutHelper.php +++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php @@ -25,8 +25,8 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Bootstrap; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\Core\Plugin\PluginUtil; @@ -223,59 +223,83 @@ class LayoutHelper extends HelperBase $icons = $this->theme->getIcons(); $ActionSearch = new DataGridAction(); - $ActionSearch->setId('account'); + $ActionSearch->setId(ActionsInterface::ACCOUNT); $ActionSearch->setTitle(__('Buscar')); $ActionSearch->setIcon($icons->getIconSearch()); - $ActionSearch->setData(['historyReset' => 1, 'view' => 'search']); + $ActionSearch->setData([ + 'historyReset' => 1, + 'view' => 'search', + 'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT) + ]); $this->view->append('actions', $ActionSearch); - if ($acl->checkUserAccess(ActionsInterface::ACTION_ACC_NEW)) { + if ($acl->checkUserAccess(ActionsInterface::ACCOUNT_CREATE)) { $ActionNew = new DataGridAction(); - $ActionNew->setId('account/create'); + $ActionNew->setId(ActionsInterface::ACCOUNT_CREATE); $ActionNew->setTitle(__('Nueva Cuenta')); $ActionNew->setIcon($icons->getIconAdd()); - $ActionNew->setData(['historyReset' => 0, 'view' => 'account']); + $ActionNew->setData([ + 'historyReset' => 0, + 'view' => 'account', + 'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT_CREATE) + ]); $this->view->append('actions', $ActionNew); } - if ($acl->checkUserAccess(ActionsInterface::ACTION_USR)) { + if ($acl->checkUserAccess(ActionsInterface::ACCESS_MANAGE)) { $ActionUsr = new DataGridAction(); - $ActionUsr->setId('users'); + $ActionUsr->setId(ActionsInterface::ACCESS_MANAGE); $ActionUsr->setTitle(__('Usuarios y Accesos')); $ActionUsr->setIcon($icons->getIconAccount()); - $ActionUsr->setData(['historyReset' => 0, 'view' => 'datatabs']); + $ActionUsr->setData([ + 'historyReset' => 0, + 'view' => 'datatabs', + 'route' => Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE) + ]); $this->view->append('actions', $ActionUsr); } - if ($acl->checkUserAccess(ActionsInterface::ACTION_MGM)) { + if ($acl->checkUserAccess(ActionsInterface::ITEMS_MANAGE)) { $ActionMgm = new DataGridAction(); - $ActionMgm->setId('items'); + $ActionMgm->setId(ActionsInterface::ITEMS_MANAGE); $ActionMgm->setTitle(__('Elementos y Personalización')); $ActionMgm->setIcon($icons->getIconGroup()); - $ActionMgm->setData(['historyReset' => 0, 'view' => 'datatabs']); + $ActionMgm->setData([ + 'historyReset' => 0, + 'view' => 'datatabs', + 'route' => Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE) + ]); $this->view->append('actions', $ActionMgm); } - if ($acl->checkUserAccess(ActionsInterface::ACTION_CFG)) { + if ($acl->checkUserAccess(ActionsInterface::CONFIG)) { $ActionConfig = new DataGridAction(); $ActionConfig->setId('config'); $ActionConfig->setTitle(__('Configuración')); $ActionConfig->setIcon($icons->getIconSettings()); - $ActionConfig->setData(['historyReset' => 1, 'view' => 'config']); + $ActionConfig->setData([ + 'historyReset' => 1, + 'view' => 'config', + 'route' => Acl::getActionRoute(ActionsInterface::CONFIG) + ]); $this->view->append('actions', $ActionConfig); } - if ($acl->checkUserAccess(ActionsInterface::ACTION_EVL) && $this->configData->isLogEnabled()) { + if ($acl->checkUserAccess(ActionsInterface::EVENTLOG) && $this->configData->isLogEnabled()) { $ActionEventlog = new DataGridAction(); - $ActionEventlog->setId('eventlog'); + $ActionEventlog->setId(ActionsInterface::EVENTLOG); $ActionEventlog->setTitle(__('Registro de Eventos')); $ActionEventlog->setIcon($icons->getIconHeadline()); - $ActionEventlog->setData(['historyReset' => 1, 'view' => 'eventlog']); + $ActionEventlog->setData([ + 'historyReset' => 1, + 'view' => 'eventlog', + 'route' => Acl::getActionRoute(ActionsInterface::EVENTLOG) + ]); $this->view->append('actions', $ActionEventlog); } diff --git a/app/modules/web/Controllers/Helpers/TabsGridHelper.php b/app/modules/web/Controllers/Helpers/TabsGridHelper.php new file mode 100644 index 00000000..aa8a0232 --- /dev/null +++ b/app/modules/web/Controllers/Helpers/TabsGridHelper.php @@ -0,0 +1,66 @@ +. + */ + +namespace SP\Modules\Web\Controllers\Helpers; + +use SP\Html\DataGrid\DataGridTab; + +/** + * Class TabsGridHelper + * + * @package SP\Modules\Web\Controllers\Helpers + */ +class TabsGridHelper extends HelperBase +{ + /** + * Máximo numero de acciones antes de agrupar + */ + const MAX_NUM_ACTIONS = 3; + /** + * @var DataGridTab[] + */ + protected $tabs = []; + + /** + * Inicializar las plantillas para las pestañas + */ + public function renderTabs() + { + $this->view->addTemplate('datatabs-grid', 'grid'); + + $this->view->assign('tabs', $this->tabs); + $this->view->assign('activeTab', 0); + $this->view->assign('maxNumActions', self::MAX_NUM_ACTIONS); + } + + /** + * Add a new data tab + * + * @param DataGridTab $tab + */ + public function addTab(DataGridTab $tab) + { + $this->tabs[] = $tab; + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/MainController.php b/app/modules/web/Controllers/MainController.php index d1449489..91135b65 100644 --- a/app/modules/web/Controllers/MainController.php +++ b/app/modules/web/Controllers/MainController.php @@ -29,8 +29,8 @@ defined('APP_ROOT') || die(); use SP\Account\AccountUtil; use SP\Controller\AccountController; use SP\Controller\ControllerBase; -use SP\Core\Acl; -use SP\Core\ActionsInterface; +use SP\Core\Acl\Acl; +use SP\Core\Acl\ActionsInterface; use SP\Core\DiFactory; use SP\Core\Exceptions\SPException; use SP\Core\Init; @@ -260,16 +260,16 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->addTemplate('body-header-menu'); $ActionSearch = new DataGridAction(); - $ActionSearch->setId(self::ACTION_ACC_SEARCH); + $ActionSearch->setId(self::ACCOUNT_SEARCH); $ActionSearch->setTitle(__('Buscar')); $ActionSearch->setIcon($this->icons->getIconSearch()); $ActionSearch->setData(['historyReset' => 1, 'view' => 'search']); $this->view->append('actions', $ActionSearch); - if (Acl::checkUserAccess(self::ACTION_ACC_NEW)) { + if (Acl::checkUserAccess(self::ACCOUNT_CREATE)) { $ActionNew = new DataGridAction(); - $ActionNew->setId(self::ACTION_ACC_NEW); + $ActionNew->setId(self::ACCOUNT_CREATE); $ActionNew->setTitle(__('Nueva Cuenta')); $ActionNew->setIcon($this->icons->getIconAdd()); $ActionNew->setData(['historyReset' => 0, 'view' => 'account']); @@ -277,9 +277,9 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionNew); } - if (Acl::checkUserAccess(self::ACTION_USR)) { + if (Acl::checkUserAccess(self::ACCESS_MANAGE)) { $ActionUsr = new DataGridAction(); - $ActionUsr->setId(self::ACTION_USR); + $ActionUsr->setId(self::ACCESS_MANAGE); $ActionUsr->setTitle(__('Usuarios y Accesos')); $ActionUsr->setIcon($this->icons->getIconAccount()); $ActionUsr->setData(['historyReset' => 0, 'view' => 'datatabs']); @@ -287,9 +287,9 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionUsr); } - if (Acl::checkUserAccess(self::ACTION_MGM)) { + if (Acl::checkUserAccess(self::ITEMS_MANAGE)) { $ActionMgm = new DataGridAction(); - $ActionMgm->setId(self::ACTION_MGM); + $ActionMgm->setId(self::ITEMS_MANAGE); $ActionMgm->setTitle(__('Elementos y Personalización')); $ActionMgm->setIcon($this->icons->getIconGroup()); $ActionMgm->setData(['historyReset' => 0, 'view' => 'datatabs']); @@ -297,9 +297,9 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionMgm); } - if (Acl::checkUserAccess(self::ACTION_CFG)) { + if (Acl::checkUserAccess(self::CONFIG)) { $ActionConfig = new DataGridAction(); - $ActionConfig->setId(self::ACTION_CFG); + $ActionConfig->setId(self::CONFIG); $ActionConfig->setTitle(__('Configuración')); $ActionConfig->setIcon($this->icons->getIconSettings()); $ActionConfig->setData(['historyReset' => 1, 'view' => 'config']); @@ -307,9 +307,9 @@ class MainController extends ControllerBase implements ActionsInterface $this->view->append('actions', $ActionConfig); } - if (Acl::checkUserAccess(self::ACTION_EVL) && $this->configData->isLogEnabled()) { + if (Acl::checkUserAccess(self::EVENTLOG) && $this->configData->isLogEnabled()) { $ActionEventlog = new DataGridAction(); - $ActionEventlog->setId(self::ACTION_EVL); + $ActionEventlog->setId(self::EVENTLOG); $ActionEventlog->setTitle(__('Registro de Eventos')); $ActionEventlog->setIcon($this->icons->getIconHeadline()); $ActionEventlog->setData(['historyReset' => 1, 'view' => 'eventlog']); diff --git a/app/modules/web/Controllers/SimpleControllerBase.php b/app/modules/web/Controllers/SimpleControllerBase.php index ded87f4a..379951ab 100644 --- a/app/modules/web/Controllers/SimpleControllerBase.php +++ b/app/modules/web/Controllers/SimpleControllerBase.php @@ -25,7 +25,7 @@ namespace SP\Modules\Web\Controllers; use SP\Config\Config; -use SP\Core\Acl; +use SP\Core\Acl\Acl; use SP\Core\Events\EventDispatcher; use SP\Core\Session\Session; use SP\Core\Traits\InjectableTrait; @@ -55,7 +55,7 @@ abstract class SimpleControllerBase protected $db; /** @var Theme */ protected $theme; - /** @var Acl */ + /** @var \SP\Core\Acl\Acl */ protected $acl; /** diff --git a/app/modules/web/Controllers/Traits/ItemTrait.php b/app/modules/web/Controllers/Traits/ItemTrait.php new file mode 100644 index 00000000..b3ff96b5 --- /dev/null +++ b/app/modules/web/Controllers/Traits/ItemTrait.php @@ -0,0 +1,73 @@ +. + */ + +namespace SP\Modules\Web\Controllers\Traits; + +use SP\Services\CustomField\CustomFieldService; +use SP\Services\UserGroup\UserGroupService; +use SP\Services\UserProfile\UserProfileService; + +/** + * Trait ItemTrait + * + * @package SP\Modules\Web\Controllers\Traits + */ +trait ItemTrait +{ + /** + * Obtener la lista de campos personalizados y sus valores + * + * @param $moduleId + * @param $itemId + * @return array + * @throws \Defuse\Crypto\Exception\CryptoException + */ + protected function getCustomFieldsForItem($moduleId, $itemId) + { + $customFieldService = new CustomFieldService(); + return $customFieldService->getForModuleById($moduleId, $itemId); + } + + /** + * Return user groups list + * + * @return array + */ + protected function getUserGroups() + { + $userGroupService = new UserGroupService(); + return $userGroupService->getItemsForSelect(); + } + + /** + * Return user profiles list + * + * @return array + */ + protected function getUserProfiles() + { + $userProfile = new UserProfileService(); + return $userProfile->getItemsForSelect(); + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php new file mode 100644 index 00000000..02d7d6d8 --- /dev/null +++ b/app/modules/web/Controllers/UserController.php @@ -0,0 +1,179 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use SP\Controller\ControllerBase; +use SP\Core\Acl\ActionsInterface; +use SP\Core\SessionUtil; +use SP\DataModel\UserData; +use SP\Modules\Web\Controllers\Traits\ItemTrait; +use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Mvc\Controller\CrudControllerInterface; +use SP\Services\User\UserService; + +/** + * Class UserController + * + * @package SP\Modules\Web\Controllers + */ +class UserController extends ControllerBase implements CrudControllerInterface +{ + use JsonTrait; + use ItemTrait; + + /** + * @var UserService + */ + protected $userService; + + /** + * Search action + */ + public function searchAction() + { + + } + + /** + * Create action + */ + public function createAction() + { + // TODO: Implement createAction() method. + } + + /** + * Edit action + * + * @param $id + * @throws \Defuse\Crypto\Exception\CryptoException + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function editAction($id) + { + $this->view->assign('header', __('Editar Usuario')); + $this->view->assign('isView', false); + $this->view->assign('isDisabled'); + $this->view->assign('isReadonly'); + + try { + $this->setViewData($id); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponse(0, '', ['html' => $this->render()]); + } + + /** + * Delete action + * + * @param $id + */ + public function deleteAction($id) + { + // TODO: Implement deleteAction() method. + } + + /** + * Saves create action + */ + public function saveCreateAction() + { + // TODO: Implement saveCreateAction() method. + } + + /** + * Saves edit action + * + * @param $id + */ + public function saveEditAction($id) + { + // TODO: Implement saveEditAction() method. + } + + /** + * Saves delete action + * + * @param $id + */ + public function saveDeleteAction($id) + { + // TODO: Implement saveDeleteAction() method. + } + + /** + * View action + * + * @param $id + */ + public function viewAction($id) + { + $this->view->assign('header', __('Ver Usuario')); + $this->view->assign('isView', true); + $this->view->assign('isDisabled', 'disabled'); + $this->view->assign('isReadonly', 'readonly'); + + try { + $this->setViewData($id); + } catch (\Exception $e) { + $this->returnJsonResponse(1, $e->getMessage()); + } + + $this->returnJsonResponse(0, '', ['html' => $this->render()]); + } + + /** + * Sets view data for displaying user's data + * + * @param $userId + * @throws \SP\Core\Exceptions\SPException + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Defuse\Crypto\Exception\CryptoException + */ + protected function setViewData($userId) + { + $this->view->addTemplate('users', 'itemshow'); + + $this->view->assign('user', $userId ? $this->userService->getById($userId) : new UserData()); + $this->view->assign('groups', $this->getUserGroups()); + $this->view->assign('profiles', $this->getUserProfiles()); + $this->view->assign('isUseSSO', $this->configData->isAuthBasicAutoLoginEnabled()); + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + + $this->view->assign('customFields', $this->getCustomFieldsForItem(ActionsInterface::USER, $userId)); + } + + /** + * Initialize class + */ + protected function initialize() + { + $this->checkLoggedIn(); + + $this->userService = new UserService(); + } +} \ No newline at end of file diff --git a/app/modules/web/themes/material-blue/views/_partials/body-header-menu.inc b/app/modules/web/themes/material-blue/views/_partials/body-header-menu.inc index a06ffd88..42ad8877 100644 --- a/app/modules/web/themes/material-blue/views/_partials/body-header-menu.inc +++ b/app/modules/web/themes/material-blue/views/_partials/body-header-menu.inc @@ -4,7 +4,7 @@ @@ -17,7 +17,6 @@ getData() as $dataName => $dataValue): ?> > @@ -29,7 +28,7 @@ 0): ?> notifications @@ -39,7 +38,7 @@ class="mdl-tooltip mdl-tooltip--bottom"> notifications @@ -60,7 +59,7 @@
  • security @@ -68,7 +67,7 @@
  • + data-action-id=""> account_circle
  • @@ -101,7 +100,7 @@ 0): ?>
    notifications @@ -109,7 +108,7 @@ notifications @@ -121,7 +120,7 @@ security @@ -130,7 +129,7 @@ + data-action-id=""> account_circle - getUserEditName()): ?> + getUserEditName()): ?> getAccountDateEdit(), $accountData->getUserEditName()); ?> diff --git a/app/modules/web/themes/material-blue/views/account/files-list.inc b/app/modules/web/themes/material-blue/views/account/files-list.inc index 5242c954..d19f43b6 100644 --- a/app/modules/web/themes/material-blue/views/account/files-list.inc +++ b/app/modules/web/themes/material-blue/views/account/files-list.inc @@ -16,7 +16,7 @@ title="getAccfileName(); ?>" alt="thumbnail" class="btn-action" data-item-id="getAccfileId(); ?>" - data-action-id="" + data-action-id="" data-onclick="file/view"/> @@ -25,7 +25,7 @@ getIconDelete()->getIcon(); ?> @@ -33,13 +33,13 @@ getIconDownload()->getIcon(); ?> getIconView()->getIcon(); ?> diff --git a/app/modules/web/themes/material-blue/views/account/files.inc b/app/modules/web/themes/material-blue/views/account/files.inc index 702eb539..6e9aeb7a 100644 --- a/app/modules/web/themes/material-blue/views/account/files.inc +++ b/app/modules/web/themes/material-blue/views/account/files.inc @@ -20,12 +20,12 @@ data-delete="isShowDelete(); ?>" data-sk=""> - +
    cloud_upload
    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 cb44a86c..1fc5d9e9 100644 --- a/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc +++ b/app/modules/web/themes/material-blue/views/account/linkedAccounts.inc @@ -17,7 +17,7 @@
  • diff --git a/app/modules/web/themes/material-blue/views/account/search-rows.inc b/app/modules/web/themes/material-blue/views/account/search-rows.inc index dda1b62a..804aa06e 100644 --- a/app/modules/web/themes/material-blue/views/account/search-rows.inc +++ b/app/modules/web/themes/material-blue/views/account/search-rows.inc @@ -9,10 +9,10 @@ */ ?>
  • diff --git a/app/modules/web/themes/material-blue/views/grid/datagrid-rows.inc b/app/modules/web/themes/material-blue/views/grid/datagrid-rows.inc index 07061802..f4c11a96 100644 --- a/app/modules/web/themes/material-blue/views/grid/datagrid-rows.inc +++ b/app/modules/web/themes/material-blue/views/grid/datagrid-rows.inc @@ -3,16 +3,18 @@ * @var $data SP\Html\DataGrid\DataGridTab * @var $this SP\Core\Template */ + use SP\Html\Html; ?> -getData()->getDataCount() > 0): ?> - getData()->getData() as $dataIndex => $dataItem): ?> - +getData()->getDataCount() > 0): + foreach ($data->getData()->getData() as $dataIndex => $dataItem): + if ($dataIndex === 'count'): continue; endif; - getData()->getDataRowSources()); ?> + $numFields = count($data->getData()->getDataRowSources()); + ?> @@ -33,9 +35,9 @@ use SP\Html\Html;
    - getDataActions()) > 0): ?> - getDataActions() as $action): ?> - isSkip()): + getDataActions()) > 0): + foreach ($data->getDataActions() as $action): + if (!$action->isSkip()): $filter = $action->getFilterRowSource(); if ($filter !== null) { @@ -49,11 +51,11 @@ use SP\Html\Html; ?> getIcon()->getIcon(); ?> + data-onclick="getOnClick(); ?>" + getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?> + >getIcon()->getIcon(); ?> getTitle(); ?> diff --git a/app/modules/web/themes/material-blue/views/grid/datatabs-grid.inc b/app/modules/web/themes/material-blue/views/grid/datatabs-grid.inc index 462b075c..73b846f6 100644 --- a/app/modules/web/themes/material-blue/views/grid/datatabs-grid.inc +++ b/app/modules/web/themes/material-blue/views/grid/datatabs-grid.inc @@ -15,17 +15,17 @@
      - getDataActions() as $action): ?> - getType() === \SP\Html\DataGrid\DataGridActionType::NEW_ITEM): ?> + getDataActions() as $action): + if ($action->getType() === \SP\Html\DataGrid\DataGridActionType::NEW_ITEM): + ?>
    • + data-onsubmit="getOnSubmit(); ?>" + getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
      - @@ -71,8 +73,7 @@
    • - - +