* [FIX] Wrong behavior when returning controller's method result

* [MOD] Code refactoring
This commit is contained in:
nuxsmin
2018-08-22 20:22:50 +02:00
parent 3c78910569
commit b2687c58a6
40 changed files with 653 additions and 653 deletions

View File

@@ -96,8 +96,6 @@ final class AccountController extends ControllerBase implements CrudControllerIn
/**
* Search action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function searchAction()
{
@@ -112,7 +110,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
'html' => $this->render()
];
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
} catch (\Exception $e) {
processException($e);
@@ -530,6 +528,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param int $id Account's ID
* @param int $parentId
*
* @return bool
*/
public function viewPassAction($id, $parentId = 0)
{
@@ -555,11 +555,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cuenta'), $account->getName()))
);
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -567,6 +567,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn
* Display account's password
*
* @param int $id Account's ID
*
* @return bool
*/
public function viewPassHistoryAction($id)
{
@@ -590,11 +592,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cuenta'), $account->getName()))
);
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -603,11 +605,10 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param int $id Account's ID
*
* @return bool
* @throws Helpers\HelperException
* @throws SPException
* @throws \Defuse\Crypto\Exception\CryptoException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function copyPassAction($id)
{
@@ -625,7 +626,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cuenta'), $account->getName()))
);
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
}
/**
@@ -633,11 +634,10 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param int $id Account's ID
*
* @return bool
* @throws Helpers\HelperException
* @throws SPException
* @throws \Defuse\Crypto\Exception\CryptoException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function copyPassHistoryAction($id)
{
@@ -655,7 +655,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cuenta'), $account->getName()))
);
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
}
/**
@@ -691,7 +691,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
[
'itemId' => $accountId,
'nextAction' => Acl::getActionRoute(Acl::ACCOUNT_EDIT)
@@ -700,11 +700,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
__u('Cuenta creada')
);
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -713,8 +713,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param $id Account's ID
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditAction($id)
{
@@ -737,7 +736,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
[
'itemId' => $id,
'nextAction' => Acl::getActionRoute(Acl::ACCOUNT_VIEW)
@@ -746,11 +745,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
__u('Cuenta actualizada')
);
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -759,8 +758,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param $id Account's ID
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditPassAction($id)
{
@@ -779,7 +777,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
[
'itemId' => $id,
'nextAction' => Acl::getActionRoute(Acl::ACCOUNT_VIEW)
@@ -788,11 +786,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
__u('Clave actualizada')
);
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -802,8 +800,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
* @param int $historyId Account's history ID
* @param int $id Account's ID
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditRestoreAction($historyId, $id)
{
@@ -819,7 +816,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
[
'itemId' => $id,
'nextAction' => Acl::getActionRoute(Acl::ACCOUNT_VIEW)
@@ -830,7 +827,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -839,8 +836,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param int $id Account's ID
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @return bool
*/
public function saveDeleteAction($id)
{
@@ -854,27 +850,27 @@ final class AccountController extends ControllerBase implements CrudControllerIn
new Event($this, EventMessage::factory()->addDescription(__u('Cuentas eliminadas')))
);
$this->returnJsonResponseData(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
} else {
$accountDetails = $this->accountService->getById($id)->getAccountVData();
$this->accountService->delete($id);
$this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id);
$this->eventDispatcher->notifyEvent('delete.account',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
}
$accountDetails = $this->accountService->getById($id)->getAccountVData();
$this->accountService->delete($id);
$this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id);
$this->eventDispatcher->notifyEvent('delete.account',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -883,8 +879,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
*
* @param $id Account's ID
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveRequestAction($id)
{
@@ -910,7 +905,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addData('userId', $accountDetails->userEditId))
);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
[
'itemId' => $id,
'nextAction' => Acl::getActionRoute(Acl::ACCOUNT)
@@ -919,11 +914,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn
__u('Solicitud realizada')
);
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -44,33 +44,37 @@ final class AccountFavoriteController extends SimpleControllerBase
/**
* @param $accountId
*
* @return bool
*/
public function markAction($accountId)
{
try {
$this->accountFavoriteService->add($accountId, $this->session->getUserData()->getId());
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorito añadido'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorito añadido'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @param $accountId
*
* @return bool
*/
public function unmarkAction($accountId)
{
try {
$this->accountFavoriteService->delete($accountId, $this->session->getUserData()->getId());
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorito eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorito eliminado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -59,6 +59,8 @@ final class AccountFileController extends ControllerBase implements CrudControll
* View action
*
* @param $id
*
* @return bool
*/
public function viewAction($id)
{
@@ -81,7 +83,7 @@ final class AccountFileController extends ControllerBase implements CrudControll
->addDetail(__u('Archivo'), $fileData->getName()))
);
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
if (mb_strtoupper($fileData->getExtension()) === 'TXT') {
@@ -94,15 +96,15 @@ final class AccountFileController extends ControllerBase implements CrudControll
->addDetail(__u('Archivo'), $fileData->getName()))
);
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Archivo no soportado para visualizar'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Archivo no soportado para visualizar'));
}
/**
@@ -142,6 +144,8 @@ final class AccountFileController extends ControllerBase implements CrudControll
* Upload action
*
* @param int $accountId
*
* @return bool
*/
public function uploadAction($accountId)
{
@@ -227,15 +231,15 @@ final class AccountFileController extends ControllerBase implements CrudControll
)
);
$this->returnJsonResponse(0, __u('Archivo guardado'));
return $this->returnJsonResponse(0, __u('Archivo guardado'));
} catch (SPException $e) {
processException($e);
$this->returnJsonResponse(1, $e->getMessage(), [$e->getHint()]);
return $this->returnJsonResponse(1, $e->getMessage(), [$e->getHint()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -248,14 +252,14 @@ final class AccountFileController extends ControllerBase implements CrudControll
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::ACCOUNT_FILE_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -296,6 +300,8 @@ final class AccountFileController extends ControllerBase implements CrudControll
* Delete action
*
* @param $id
*
* @return bool
*/
public function deleteAction($id = null)
{
@@ -308,22 +314,22 @@ final class AccountFileController extends ControllerBase implements CrudControll
->addDescription(__u('Archivos eliminados')))
);
$this->returnJsonResponse(0, __u('Archivos eliminados'));
} else {
$this->eventDispatcher->notifyEvent('delete.accountFile',
new Event($this, EventMessage::factory()
->addDescription(__u('Archivo eliminado'))
->addDetail(__u('Archivo'), $id))
);
$this->accountFileService->delete($id);
$this->returnJsonResponse(0, __u('Archivo Eliminado'));
return $this->returnJsonResponse(0, __u('Archivos eliminados'));
}
$this->eventDispatcher->notifyEvent('delete.accountFile',
new Event($this, EventMessage::factory()
->addDescription(__u('Archivo eliminado'))
->addDetail(__u('Archivo'), $id))
);
$this->accountFileService->delete($id);
return $this->returnJsonResponse(0, __u('Archivo Eliminado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -49,20 +49,21 @@ final class AccountHistoryManagerController extends ControllerBase
protected $accountHistoryService;
/**
* @return bool
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
*/
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::ACCOUNTMGR_HISTORY_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -85,6 +86,8 @@ final class AccountHistoryManagerController extends ControllerBase
* Delete action
*
* @param $id
*
* @return bool
*/
public function deleteAction($id = null)
{
@@ -96,25 +99,24 @@ final class AccountHistoryManagerController extends ControllerBase
new Event($this, EventMessage::factory()->addDescription(__u('Cuentas eliminadas')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
} else {
$accountDetails = $this->accountHistoryService->getById($id);
$this->accountHistoryService->delete($id);
$this->eventDispatcher->notifyEvent('delete.accountHistory',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
}
$accountDetails = $this->accountHistoryService->getById($id);
$this->accountHistoryService->delete($id);
$this->eventDispatcher->notifyEvent('delete.accountHistory',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -122,6 +124,8 @@ final class AccountHistoryManagerController extends ControllerBase
* Saves restore action
*
* @param int $id Account's history ID
*
* @return bool
*/
public function restoreAction($id)
{
@@ -143,11 +147,11 @@ final class AccountHistoryManagerController extends ControllerBase
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta restaurada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta restaurada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -54,14 +54,14 @@ final class AccountManagerController extends ControllerBase
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::ACCOUNTMGR_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -84,6 +84,8 @@ final class AccountManagerController extends ControllerBase
* Delete action
*
* @param $id
*
* @return bool
*/
public function deleteAction($id = null)
{
@@ -97,27 +99,27 @@ final class AccountManagerController extends ControllerBase
new Event($this, EventMessage::factory()->addDescription(__u('Cuentas eliminadas')))
);
$this->returnJsonResponseData(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
} else {
$accountDetails = $this->accountService->getById($id)->getAccountVData();
$this->accountService->delete($id);
$this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id);
$this->eventDispatcher->notifyEvent('delete.account',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
return $this->returnJsonResponseData(JsonResponse::JSON_SUCCESS, __u('Cuentas eliminadas'));
}
$accountDetails = $this->accountService->getById($id)->getAccountVData();
$this->accountService->delete($id);
$this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id);
$this->eventDispatcher->notifyEvent('delete.account',
new Event($this, EventMessage::factory()
->addDescription(__u('Cuenta eliminada'))
->addDetail(__u('Cuenta'), $accountDetails->getName())
->addDetail(__u('Cliente'), $accountDetails->getClientName()))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cuenta eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -62,14 +62,14 @@ final class AuthTokenController extends ControllerBase implements CrudController
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -90,13 +90,11 @@ final class AuthTokenController extends ControllerBase implements CrudController
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -108,13 +106,13 @@ final class AuthTokenController extends ControllerBase implements CrudController
$this->setViewData();
$this->eventDispatcher->notifyEvent('show.authToken.create', new Event($this));
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
$this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -156,12 +154,12 @@ final class AuthTokenController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Autorización'));
@@ -172,13 +170,13 @@ final class AuthTokenController extends ControllerBase implements CrudController
$this->setViewData($id);
$this->eventDispatcher->notifyEvent('show.authToken.edit', new Event($this));
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
$this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -186,13 +184,12 @@ final class AuthTokenController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -207,25 +204,25 @@ final class AuthTokenController extends ControllerBase implements CrudController
->addDescription(__u('Autorizaciones eliminadas')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorizaciones eliminadas'));
} else {
$this->authTokenService->delete($id);
$this->deleteCustomFieldsForItem(Acl::AUTHTOKEN, $id);
$this->eventDispatcher->notifyEvent('delete.authToken',
new Event($this,
EventMessage::factory()
->addDescription(__u('Autorización eliminada'))
->addDetail(__u('Autorización'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorizaciones eliminadas'));
}
$this->authTokenService->delete($id);
$this->deleteCustomFieldsForItem(Acl::AUTHTOKEN, $id);
$this->eventDispatcher->notifyEvent('delete.authToken',
new Event($this,
EventMessage::factory()
->addDescription(__u('Autorización eliminada'))
->addDetail(__u('Autorización'), $id))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -235,7 +232,7 @@ final class AuthTokenController extends ControllerBase implements CrudController
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -250,13 +247,13 @@ final class AuthTokenController extends ControllerBase implements CrudController
$this->eventDispatcher->notifyEvent('create.authToken', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización creada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización creada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -265,13 +262,12 @@ final class AuthTokenController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -300,13 +296,13 @@ final class AuthTokenController extends ControllerBase implements CrudController
$this->updateCustomFieldsForItem(Acl::AUTHTOKEN, $id, $this->request);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -315,12 +311,12 @@ final class AuthTokenController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::AUTHTOKEN_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Autorización'));
@@ -334,13 +330,13 @@ final class AuthTokenController extends ControllerBase implements CrudController
->addDescription(__u('Autorización visualizada'))
->addDetail(__u('Autorización'), $id))
);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
$this->returnJsonResponseData(['html' => $this->render()]);
}
/**

View File

@@ -67,7 +67,7 @@ final class BootstrapController extends SimpleControllerBase
'files_allowed_exts' => $this->configData->getFilesAllowedExts()
];
$this->returnJsonResponseData($data);
return $this->returnJsonResponseData($data);
}
/**

View File

@@ -60,14 +60,14 @@ final class CategoryController extends ControllerBase implements CrudControllerI
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -88,13 +88,11 @@ final class CategoryController extends ControllerBase implements CrudControllerI
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -107,11 +105,11 @@ final class CategoryController extends ControllerBase implements CrudControllerI
$this->eventDispatcher->notifyEvent('show.category.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -123,6 +121,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
* @throws \SP\Services\ServiceException
* @throws \SP\Repositories\NoSuchItemException
*/
protected function setViewData($categoryId = null)
{
@@ -152,12 +151,12 @@ final class CategoryController extends ControllerBase implements CrudControllerI
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Categoría'));
@@ -169,11 +168,11 @@ final class CategoryController extends ControllerBase implements CrudControllerI
$this->eventDispatcher->notifyEvent('show.category.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -182,13 +181,12 @@ final class CategoryController extends ControllerBase implements CrudControllerI
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -203,38 +201,35 @@ final class CategoryController extends ControllerBase implements CrudControllerI
->addDescription(__u('Categorías eliminadas')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categorías eliminadas'));
} else {
$this->categoryService->delete($id);
$this->deleteCustomFieldsForItem(Acl::CATEGORY, $id);
$this->eventDispatcher->notifyEvent('delete.category',
new Event($this,
EventMessage::factory()
->addDescription(__u('Categoría eliminada'))
->addDetail(__u('Categoría'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categorías eliminadas'));
}
$this->categoryService->delete($id);
$this->deleteCustomFieldsForItem(Acl::CATEGORY, $id);
$this->eventDispatcher->notifyEvent('delete.category',
new Event($this,
EventMessage::factory()
->addDescription(__u('Categoría eliminada'))
->addDetail(__u('Categoría'), $id))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* Saves create action
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -254,13 +249,13 @@ final class CategoryController extends ControllerBase implements CrudControllerI
->addDetail(__u('Categoría'), $itemData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría creada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría creada'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -269,14 +264,12 @@ final class CategoryController extends ControllerBase implements CrudControllerI
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -296,13 +289,13 @@ final class CategoryController extends ControllerBase implements CrudControllerI
->addDetail(__u('Categoría'), $itemData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -311,12 +304,12 @@ final class CategoryController extends ControllerBase implements CrudControllerI
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CATEGORY_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Categoría'));
@@ -327,11 +320,11 @@ final class CategoryController extends ControllerBase implements CrudControllerI
$this->eventDispatcher->notifyEvent('show.category', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -61,14 +61,14 @@ final class ClientController extends ControllerBase implements CrudControllerInt
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -89,13 +89,11 @@ final class ClientController extends ControllerBase implements CrudControllerInt
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -108,11 +106,11 @@ final class ClientController extends ControllerBase implements CrudControllerInt
$this->eventDispatcher->notifyEvent('show.client.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -124,6 +122,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
* @throws \SP\Services\ServiceException
* @throws \SP\Repositories\NoSuchItemException
*/
protected function setViewData($clientId = null)
{
@@ -153,12 +152,12 @@ final class ClientController extends ControllerBase implements CrudControllerInt
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Cliente'));
@@ -170,11 +169,11 @@ final class ClientController extends ControllerBase implements CrudControllerInt
$this->eventDispatcher->notifyEvent('show.client.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -183,13 +182,12 @@ final class ClientController extends ControllerBase implements CrudControllerInt
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -203,24 +201,23 @@ final class ClientController extends ControllerBase implements CrudControllerInt
->addDescription(__u('Clientes eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clientes eliminados'));
} else {
$this->clientService->delete($id);
$this->deleteCustomFieldsForItem(Acl::CLIENT, $id);
$this->eventDispatcher->notifyEvent('delete.client',
new Event($this, EventMessage::factory()
->addDescription(__u('Cliente eliminado'))
->addDetail(__u('Cliente'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clientes eliminados'));
}
$this->clientService->delete($id);
$this->deleteCustomFieldsForItem(Acl::CLIENT, $id);
$this->eventDispatcher->notifyEvent('delete.client',
new Event($this, EventMessage::factory()
->addDescription(__u('Cliente eliminado'))
->addDetail(__u('Cliente'), $id))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente eliminado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -230,7 +227,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -248,13 +245,13 @@ final class ClientController extends ControllerBase implements CrudControllerInt
->addDetail(__u('Cliente'), $itemData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -262,11 +259,13 @@ final class ClientController extends ControllerBase implements CrudControllerInt
* Saves edit action
*
* @param $id
*
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -282,13 +281,13 @@ final class ClientController extends ControllerBase implements CrudControllerInt
->addDetail(__u('Cliente'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -297,12 +296,12 @@ final class ClientController extends ControllerBase implements CrudControllerInt
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CLIENT_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Cliente'));
@@ -313,11 +312,11 @@ final class ClientController extends ControllerBase implements CrudControllerInt
$this->eventDispatcher->notifyEvent('show.client', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -67,7 +67,7 @@ final class ConfigAccountController extends SimpleControllerBase
$filesAllowedSize = $this->request->analyzeInt('files_allowed_size', 1024);
if ($filesAllowedSize >= 16384) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('El tamaño máximo por archivo es de 16MB'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('El tamaño máximo por archivo es de 16MB'));
}
$configData->setFilesEnabled(true);
@@ -107,6 +107,9 @@ final class ConfigAccountController extends SimpleControllerBase
});
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -115,7 +118,7 @@ final class ConfigAccountController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -45,13 +45,12 @@ final class ConfigBackupController extends SimpleControllerBase
use ConfigTrait;
/**
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function fileBackupAction()
{
if ($this->config->getConfigData()->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
try {
@@ -65,19 +64,18 @@ final class ConfigBackupController extends SimpleControllerBase
->addDescription(__u('Copia de la aplicación y base de datos realizada correctamente')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de backup finalizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de backup finalizado'));
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function xmlExportAction()
{
@@ -85,7 +83,7 @@ final class ConfigBackupController extends SimpleControllerBase
$exportPasswordR = $this->request->analyzeEncrypted('exportPwdR');
if (!empty($exportPassword) && $exportPassword !== $exportPasswordR) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves no coinciden'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves no coinciden'));
}
try {
@@ -126,16 +124,19 @@ final class ConfigBackupController extends SimpleControllerBase
)
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de exportación finalizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de exportación finalizado'));
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -144,7 +145,7 @@ final class ConfigBackupController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -49,6 +49,7 @@ final class ConfigEncryptionController extends SimpleControllerBase
use JsonTrait;
/**
* @return bool
* @throws \SP\Repositories\NoSuchItemException
* @throws \SP\Services\ServiceException
*/
@@ -64,31 +65,31 @@ final class ConfigEncryptionController extends SimpleControllerBase
$taskId = $this->request->analyzeString('taskId');
if (!$mastePassService->checkUserUpdateMPass($this->session->getUserData()->getLastUpdateMPass())) {
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Clave maestra actualizada'), [__u('Reinicie la sesión para cambiarla')]);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Clave maestra actualizada'), [__u('Reinicie la sesión para cambiarla')]);
}
if (empty($newMasterPass) || empty($currentMasterPass)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Clave maestra no indicada'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Clave maestra no indicada'));
}
if ($confirmPassChange === false) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Se ha de confirmar el cambio de clave'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Se ha de confirmar el cambio de clave'));
}
if ($newMasterPass === $currentMasterPass) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves son idénticas'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves son idénticas'));
}
if ($newMasterPass !== $newMasterPassR) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves maestras no coinciden'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves maestras no coinciden'));
}
if (!$mastePassService->checkMasterPassword($currentMasterPass)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('La clave maestra actual no coincide'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('La clave maestra actual no coincide'));
}
if ($this->config->getConfigData()->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
$configService = $this->dic->get(ConfigService::class);
@@ -116,7 +117,7 @@ final class ConfigEncryptionController extends SimpleControllerBase
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} finally {
Util::unlockApp();
@@ -134,11 +135,11 @@ final class ConfigEncryptionController extends SimpleControllerBase
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al guardar el hash de la clave maestra'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al guardar el hash de la clave maestra'));
}
}
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Clave maestra actualizada'), [__u('Reinicie la sesión para cambiarla')]);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Clave maestra actualizada'), [__u('Reinicie la sesión para cambiarla')]);
}
/**
@@ -147,7 +148,7 @@ final class ConfigEncryptionController extends SimpleControllerBase
public function refreshAction()
{
if ($this->config->getConfigData()->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
try {
@@ -157,14 +158,14 @@ final class ConfigEncryptionController extends SimpleControllerBase
$this->eventDispatcher->notifyEvent('refresh.masterPassword.hash',
new Event($this, EventMessage::factory()->addDescription(__u('Hash de clave maestra actualizado'))));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Hash de clave maestra actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Hash de clave maestra actualizado'));
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al actualizar el hash de la clave maestra'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al actualizar el hash de la clave maestra'));
}
}
@@ -186,26 +187,29 @@ final class ConfigEncryptionController extends SimpleControllerBase
try {
$temporaryMasterPassService->sendByEmailForGroup($groupId, $key);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'), [__u('Email enviado')]);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'), [__u('Email enviado')]);
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Clave Temporal Generada'), [__u('Error al enviar email')]);
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Clave Temporal Generada'), [__u('Error al enviar email')]);
}
}
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'));
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -214,7 +218,7 @@ final class ConfigEncryptionController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -86,7 +86,7 @@ final class ConfigGeneralController extends SimpleControllerBase
if ($remoteSyslogEnabled) {
if (!$syslogServer || !$syslogPort) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de syslog remoto'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de syslog remoto'));
}
$configData->setSyslogRemoteEnabled(true);
@@ -112,7 +112,7 @@ final class ConfigGeneralController extends SimpleControllerBase
// Valores para Proxy
if ($proxyEnabled && (!$proxyServer || !$proxyPort)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Proxy'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Proxy'));
}
if ($proxyEnabled) {
@@ -159,11 +159,14 @@ final class ConfigGeneralController extends SimpleControllerBase
$eventMessage->addDescription(__u('Auth Basic deshabiltada'));
}
$this->saveConfig($configData, $this->config, function () use ($eventMessage) {
return $this->saveConfig($configData, $this->config, function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent('save.config.general', new Event($this, $eventMessage));
});
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -172,7 +175,7 @@ final class ConfigGeneralController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -53,7 +53,7 @@ final class ConfigImportController extends SimpleControllerBase
public function importAction()
{
if ($this->config->getConfigData()->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
$importParams = new ImportParams();
@@ -77,10 +77,10 @@ final class ConfigImportController extends SimpleControllerBase
);
if ($counter > 0) {
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Importación finalizada'), [__u('Revise el registro de eventos para más detalles')]);
} else {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('No se importaron cuentas'), [__u('Revise el registro de eventos para más detalles')]);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Importación finalizada'), [__u('Revise el registro de eventos para más detalles')]);
}
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('No se importaron cuentas'), [__u('Revise el registro de eventos para más detalles')]);
} catch (\Exception $e) {
processException($e);
@@ -89,10 +89,13 @@ final class ConfigImportController extends SimpleControllerBase
->addDescription($e->getMessage()))
);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -101,7 +104,7 @@ final class ConfigImportController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -66,7 +66,7 @@ final class ConfigLdapController extends SimpleControllerBase
// Valores para la configuración de LDAP
if ($ldapEnabled && !($ldapParams->getServer() || $ldapParams->getSearchBase() || $ldapParams->getBindDn())) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
}
if ($ldapEnabled) {
@@ -91,14 +91,14 @@ final class ConfigLdapController extends SimpleControllerBase
$eventMessage->addDescription(__u('LDAP deshabilitado'));
} else {
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Sin cambios'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Sin cambios'));
}
$this->saveConfig($configData, $this->config, function () use ($eventMessage) {
return $this->saveConfig($configData, $this->config, function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent('save.config.ldap', new Event($this, $eventMessage));
});
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -134,7 +134,7 @@ final class ConfigLdapController extends SimpleControllerBase
// Valores para la configuración de LDAP
if (!($ldapParams->getServer() || $ldapParams->getSearchBase() || $ldapParams->getBindDn())) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
}
$ldapCheckService = $this->dic->get(LdapCheckService::class);
@@ -146,7 +146,7 @@ final class ConfigLdapController extends SimpleControllerBase
$template->addTemplate('results', 'itemshow');
$template->assign('header', __('Resultados'));
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
['template' => $template->render(), 'items' => $data['results']],
JsonResponse::JSON_SUCCESS,
__u('Conexión a LDAP correcta'),
@@ -155,7 +155,7 @@ final class ConfigLdapController extends SimpleControllerBase
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
// $this->JsonResponse->addMessage(__('Revise el registro de eventos para más detalles', false));
}
}
@@ -170,7 +170,7 @@ final class ConfigLdapController extends SimpleControllerBase
// Valores para la configuración de LDAP
if (!($ldapParams->getServer() || $ldapParams->getSearchBase() || $ldapParams->getBindDn())) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
}
$ldapCheckService = $this->dic->get(LdapCheckService::class);
@@ -189,7 +189,7 @@ final class ConfigLdapController extends SimpleControllerBase
$template->assign('header', __('Resultados'));
$template->assign('results', $data);
$this->returnJsonResponseData(
return $this->returnJsonResponseData(
['template' => $template->render(), 'items' => $data['results']],
JsonResponse::JSON_SUCCESS,
__u('Conexión a LDAP correcta'),
@@ -198,7 +198,7 @@ final class ConfigLdapController extends SimpleControllerBase
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
// $this->JsonResponse->addMessage(__('Revise el registro de eventos para más detalles', false));
}
}
@@ -213,7 +213,7 @@ final class ConfigLdapController extends SimpleControllerBase
{
try {
if ($this->configData->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
$ldapImportParams = new LdapImportParams();
@@ -260,7 +260,7 @@ final class ConfigLdapController extends SimpleControllerBase
throw new SPException(__u('No se encontraron objetos para sincronizar'));
}
$this->returnJsonResponse(
return $this->returnJsonResponse(
JsonResponse::JSON_SUCCESS,
__u('Importación de usuarios de LDAP realizada'),
[
@@ -272,10 +272,13 @@ final class ConfigLdapController extends SimpleControllerBase
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -286,11 +289,11 @@ final class ConfigLdapController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (CheckException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -65,7 +65,7 @@ final class ConfigMailController extends SimpleControllerBase
// Valores para la configuración del Correo
if ($mailEnabled && (!$mailServer || !$mailFrom || count($mailRecipients) === 0)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Correo'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Correo'));
}
if ($mailEnabled) {
@@ -99,10 +99,10 @@ final class ConfigMailController extends SimpleControllerBase
$eventMessage->addDescription(__u('Correo deshabilitado'));
} else {
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Sin cambios'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Sin cambios'));
}
$this->saveConfig($configData, $this->config, function () use ($eventMessage) {
return $this->saveConfig($configData, $this->config, function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent('save.config.mail', new Event($this, $eventMessage));
});
}
@@ -122,7 +122,7 @@ final class ConfigMailController extends SimpleControllerBase
// Valores para la configuración del Correo
if (!$mailParams->server || empty($mailParams->from) || empty($mailRecipients)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Correo'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Correo'));
}
if ($mailParams->mailAuthenabled) {
@@ -139,7 +139,7 @@ final class ConfigMailController extends SimpleControllerBase
->addDetail(__u('Destinatario'), $mailRecipients[0]))
);
$this->returnJsonResponse(
return $this->returnJsonResponse(
JsonResponse::JSON_SUCCESS,
__u('Correo enviado'),
[__u('Compruebe su buzón de correo')]
@@ -149,10 +149,13 @@ final class ConfigMailController extends SimpleControllerBase
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -161,7 +164,7 @@ final class ConfigMailController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -56,7 +56,7 @@ final class ConfigWikiController extends SimpleControllerBase
// Valores para la conexión a la Wiki
if ($wikiEnabled && (!$wikiSearchUrl || !$wikiPageUrl || !$wikiFilter)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Wiki'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Wiki'));
}
if ($wikiEnabled) {
@@ -84,7 +84,7 @@ final class ConfigWikiController extends SimpleControllerBase
// Valores para la conexión a la API de DokuWiki
if ($dokuWikiEnabled && (!$dokuWikiUrl || !$dokuWikiUrlBase)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de DokuWiki'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de DokuWiki'));
}
if ($dokuWikiEnabled) {
@@ -104,11 +104,14 @@ final class ConfigWikiController extends SimpleControllerBase
$eventMessage->addDescription(__u('DokuWiki deshabilitada'));
}
$this->saveConfig($configData, $this->config, function () use ($eventMessage) {
return $this->saveConfig($configData, $this->config, function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent('save.config.wiki', new Event($this, $eventMessage));
});
}
/**
* @return bool
*/
protected function initialize()
{
try {
@@ -117,7 +120,7 @@ final class ConfigWikiController extends SimpleControllerBase
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -62,14 +62,14 @@ final class CustomFieldController extends ControllerBase implements CrudControll
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -90,13 +90,11 @@ final class CustomFieldController extends ControllerBase implements CrudControll
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -109,11 +107,11 @@ final class CustomFieldController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('show.customField.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(1, $e->getMessage());
return $this->returnJsonResponseException($e);
}
}
@@ -124,6 +122,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll
*
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
* @throws \SP\Repositories\NoSuchItemException
*/
protected function setViewData($customFieldId = null)
{
@@ -152,12 +151,12 @@ final class CustomFieldController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Campo'));
@@ -169,11 +168,11 @@ final class CustomFieldController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('show.customField.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponseException($e);
}
}
@@ -182,13 +181,12 @@ final class CustomFieldController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -199,18 +197,18 @@ final class CustomFieldController extends ControllerBase implements CrudControll
new Event($this, EventMessage::factory()->addDescription(__u('Campos eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campos eliminados'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campos eliminados'));
} else {
$this->customFieldService->delete($id);
$this->eventDispatcher->notifyEvent('delete.customField', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo eliminado'));
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponseException($e);
}
}
@@ -220,7 +218,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -237,13 +235,13 @@ final class CustomFieldController extends ControllerBase implements CrudControll
->addDetail(__u('Campo'), $itemData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -251,11 +249,13 @@ final class CustomFieldController extends ControllerBase implements CrudControll
* Saves edit action
*
* @param $id
*
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -272,13 +272,13 @@ final class CustomFieldController extends ControllerBase implements CrudControll
->addDetail(__u('Campo'), $itemData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponseException($e);
}
}
@@ -287,12 +287,12 @@ final class CustomFieldController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::CUSTOMFIELD_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Campo'));
@@ -305,10 +305,10 @@ final class CustomFieldController extends ControllerBase implements CrudControll
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**

View File

@@ -91,13 +91,13 @@ final class EventlogController extends ControllerBase
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::EVENTLOG_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table-simple', 'grid');
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -112,17 +112,15 @@ final class EventlogController extends ControllerBase
new Event($this, EventMessage::factory()->addDescription(__u('Registro de eventos vaciado')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Registro de eventos vaciado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Registro de eventos vaciado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \SP\Services\Auth\AuthException
*/
protected function initialize()

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -29,16 +29,20 @@ use Throwable;
/**
* Class HelperException
*
* @package SP\Modules\Web\Controllers\Helpers
*/
final class HelperException extends Exception
{
/**
* Construct the exception. Note: The message is NOT binary safe.
* @link http://php.net/manual/en/exception.construct.php
* @param string $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
*
* @link http://php.net/manual/en/exception.construct.php
*
* @param string $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
* @param Throwable $previous [optional] The previous throwable used for the exception chaining.
*
* @since 5.1.0
*/
public function __construct($message = "", $code = 0, Throwable $previous = null)

View File

@@ -24,8 +24,6 @@
namespace SP\Modules\Web\Controllers;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use SP\Core\Exceptions\SPException;
use SP\Core\Language;
use SP\Core\PhpExtensionChecker;
@@ -46,8 +44,7 @@ final class InstallController extends ControllerBase
use JsonTrait;
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* indexAction
*/
public function indexAction()
{
@@ -72,9 +69,6 @@ final class InstallController extends ControllerBase
/**
* Performs sysPass installation
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function installAction()
{
@@ -92,11 +86,11 @@ final class InstallController extends ControllerBase
try {
$this->dic->get(Installer::class)->run($installData);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Instalación finalizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Instalación finalizada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -77,21 +77,18 @@ final class LoginController extends ControllerBase
);
}
$this->returnJsonResponseData(['url' => $loginResponmse->getRedirect()]);
return $this->returnJsonResponseData(['url' => $loginResponmse->getRedirect()]);
} catch (\Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->returnJsonResponse($e->getCode(), $e->getMessage());
return $this->returnJsonResponse($e->getCode(), $e->getMessage());
}
}
/**
* Logout action
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function logoutAction()
{

View File

@@ -24,8 +24,6 @@
namespace SP\Modules\Web\Controllers;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use SP\Core\Acl\Acl;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
@@ -94,13 +92,12 @@ final class NotificationController extends ControllerBase implements CrudControl
*
* @param $id
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Notificación'));
@@ -111,11 +108,11 @@ final class NotificationController extends ControllerBase implements CrudControl
$this->eventDispatcher->notifyEvent('show.notification', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -153,31 +150,29 @@ final class NotificationController extends ControllerBase implements CrudControl
}
/**
* @return bool
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
*/
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
* Create action
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -190,11 +185,11 @@ final class NotificationController extends ControllerBase implements CrudControl
$this->eventDispatcher->notifyEvent('show.notification.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -203,13 +198,12 @@ final class NotificationController extends ControllerBase implements CrudControl
*
* @param $id
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -222,11 +216,11 @@ final class NotificationController extends ControllerBase implements CrudControl
$this->eventDispatcher->notifyEvent('show.notification.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -234,11 +228,13 @@ final class NotificationController extends ControllerBase implements CrudControl
* Delete action
*
* @param $id
*
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -255,27 +251,27 @@ final class NotificationController extends ControllerBase implements CrudControl
->addDescription(__u('Notificaciones eliminadas')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificaciones eliminadas'));
} else {
if ($this->userData->getIsAdminApp()) {
$this->notificationService->deleteAdmin($id);
} else {
$this->notificationService->delete($id);
}
$this->eventDispatcher->notifyEvent('delete.notification',
new Event($this,
EventMessage::factory()
->addDescription(__u('Notificación eliminada'))
->addDetail(__u('Notificación'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificaciones eliminadas'));
}
if ($this->userData->getIsAdminApp()) {
$this->notificationService->deleteAdmin($id);
} else {
$this->notificationService->delete($id);
}
$this->eventDispatcher->notifyEvent('delete.notification',
new Event($this,
EventMessage::factory()
->addDescription(__u('Notificación eliminada'))
->addDetail(__u('Notificación'), $id))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación eliminada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -283,11 +279,13 @@ final class NotificationController extends ControllerBase implements CrudControl
* Check action
*
* @param $id
*
* @return bool
*/
public function checkAction($id)
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_CHECK)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -300,11 +298,11 @@ final class NotificationController extends ControllerBase implements CrudControl
->addDetail(__u('Notificación'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación leída'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación leída'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -314,7 +312,7 @@ final class NotificationController extends ControllerBase implements CrudControl
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -329,11 +327,11 @@ final class NotificationController extends ControllerBase implements CrudControl
->addDescription(__u('Notificación creada')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación creada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación creada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -341,11 +339,13 @@ final class NotificationController extends ControllerBase implements CrudControl
* Saves edit action
*
* @param $id
*
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::NOTIFICATION_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -360,17 +360,15 @@ final class NotificationController extends ControllerBase implements CrudControl
->addDescription(__u('Notificación actualizada')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notificación actualizada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws \SP\Services\Auth\AuthException
*/
protected function initialize()

View File

@@ -94,14 +94,14 @@ final class PluginController extends ControllerBase
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::PLUGIN_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -109,13 +109,12 @@ final class PluginController extends ControllerBase
*
* @param $id
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PLUGIN_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Plugin'));
@@ -126,11 +125,11 @@ final class PluginController extends ControllerBase
$this->eventDispatcher->notifyEvent('show.plugin', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -167,6 +166,8 @@ final class PluginController extends ControllerBase
* enableAction
*
* @param $id
*
* @return bool
*/
public function enableAction($id)
{
@@ -178,11 +179,11 @@ final class PluginController extends ControllerBase
EventMessage::factory()->addDescription(__u('Plugin habilitado')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin habilitado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin habilitado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -190,6 +191,8 @@ final class PluginController extends ControllerBase
* disableAction
*
* @param $id
*
* @return bool
*/
public function disableAction($id)
{
@@ -201,11 +204,11 @@ final class PluginController extends ControllerBase
EventMessage::factory()->addDescription(__u('Plugin deshabilitado')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin deshabilitado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin deshabilitado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -213,6 +216,8 @@ final class PluginController extends ControllerBase
* resetAction
*
* @param $id
*
* @return bool
*/
public function resetAction($id)
{
@@ -224,11 +229,11 @@ final class PluginController extends ControllerBase
EventMessage::factory()->addDescription(__u('Plugin restablecido')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin restablecido'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin restablecido'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -65,14 +65,14 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -93,13 +93,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -112,11 +110,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('show.publicLink.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -156,13 +154,12 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
*
* @param int $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function refreshAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_REFRESH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -170,11 +167,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('edit.publicLink.refresh', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace actualizado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -183,12 +180,12 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Enlace Público'));
@@ -200,11 +197,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('show.publicLink.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -213,13 +210,12 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -233,7 +229,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
->addDescription(__u('Enlaces eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlaces eliminados'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlaces eliminados'));
} else {
$this->publicLinkService->delete($id);
@@ -245,25 +241,22 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
->addDetail(__u('Enlace'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace eliminado'));
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
/**
* Saves create action
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -274,13 +267,13 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('create.publicLink', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -290,13 +283,12 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
* @param int $accountId
* @param int $notify
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveCreateFromAccountAction($accountId, $notify)
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -310,11 +302,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('create.publicLink.account', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -333,12 +325,12 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PUBLICLINK_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Enlace'));
@@ -349,11 +341,11 @@ final class PublicLinkController extends ControllerBase implements CrudControlle
$this->eventDispatcher->notifyEvent('show.publicLink', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -72,7 +72,7 @@ final class StatusController extends SimpleControllerBase
$pubVersion = $matches['major'] . $matches['minor'] . $matches['patch'] . '.' . $matches['build'];
if (Version::checkVersion(Version::getVersionStringNormalized(), $pubVersion)) {
$this->returnJsonResponseData([
return $this->returnJsonResponseData([
'version' => $requestData->tag_name,
'url' => $requestData->html_url,
'title' => $requestData->name,
@@ -81,21 +81,20 @@ final class StatusController extends SimpleControllerBase
]);
}
$this->returnJsonResponseData([]);
return;
return $this->returnJsonResponseData([]);
}
}
logger($requestData->message);
}
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Versión no disponible'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Versión no disponible'));
} catch (ClientException $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (CheckException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -128,20 +127,19 @@ final class StatusController extends SimpleControllerBase
];
}
$this->returnJsonResponseData($notices);
return;
return $this->returnJsonResponseData($notices);
}
logger($requestData->message);
}
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Notificaciones no disponibles'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Notificaciones no disponibles'));
} catch (ClientException $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (CheckException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -59,14 +59,14 @@ final class TagController extends ControllerBase implements CrudControllerInterf
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::TAG_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -87,13 +87,11 @@ final class TagController extends ControllerBase implements CrudControllerInterf
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::TAG_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -106,11 +104,11 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('show.tag.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -148,12 +146,12 @@ final class TagController extends ControllerBase implements CrudControllerInterf
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::TAG_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Etiqueta'));
@@ -165,11 +163,11 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('show.tag.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -178,13 +176,12 @@ final class TagController extends ControllerBase implements CrudControllerInterf
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::TAG_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -195,7 +192,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('delete.tag.selection', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiquetas eliminadas'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiquetas eliminadas'));
} else {
$this->tagService->delete($id);
@@ -203,12 +200,12 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('delete.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta eliminada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta eliminada'));
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -218,7 +215,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::TAG_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -229,13 +226,13 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('create.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta creada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta creada'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -243,11 +240,13 @@ final class TagController extends ControllerBase implements CrudControllerInterf
* Saves edit action
*
* @param $id
*
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::TAG_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -258,13 +257,13 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('edit.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -273,12 +272,12 @@ final class TagController extends ControllerBase implements CrudControllerInterf
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::TAG_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Etiqueta'));
@@ -289,11 +288,11 @@ final class TagController extends ControllerBase implements CrudControllerInterf
$this->eventDispatcher->notifyEvent('show.tag', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -45,12 +45,14 @@ trait ConfigTrait
* @param ConfigData $configData
* @param Config $config
* @param callable|null $onSuccess
*
* @return bool
*/
protected function saveConfig(ConfigData $configData, Config $config, callable $onSuccess = null)
{
try {
if ($configData->isDemoEnabled()) {
$this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
return $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
}
$config->saveConfig($configData);
@@ -63,11 +65,11 @@ trait ConfigTrait
$onSuccess();
}
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Configuración actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Configuración actualizada'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al guardar la configuración'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al guardar la configuración'));
}
}
}

View File

@@ -30,7 +30,6 @@ use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Services\Upgrade\UpgradeAppService;
use SP\Services\Upgrade\UpgradeDatabaseService;
use SP\Services\Upgrade\UpgradeException;
use SP\Services\Upgrade\UpgradeUtil;
/**
@@ -63,11 +62,11 @@ final class UpgradeController extends ControllerBase
public function upgradeAction()
{
if ($this->request->analyzeBool('chkConfirm', false) === false) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Es necesario confirmar la actualización'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Es necesario confirmar la actualización'));
}
if ($this->request->analyzeString('key') !== $this->configData->getUpgradeKey()) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Código de seguridad incorrecto'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Código de seguridad incorrecto'));
}
@@ -88,11 +87,11 @@ final class UpgradeController extends ControllerBase
$this->configData->setUpgradeKey(null);
$this->config->saveConfig($this->configData, false);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Aplicación actualizada correctamente'), [__u('En 5 segundos será redirigido al login')]);
} catch (UpgradeException $e) {
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Aplicación actualizada correctamente'), [__u('En 5 segundos será redirigido al login')]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
}

View File

@@ -66,14 +66,14 @@ final class UserController extends ControllerBase implements CrudControllerInter
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::USER_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -94,13 +94,11 @@ final class UserController extends ControllerBase implements CrudControllerInter
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::USER_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -113,11 +111,11 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->eventDispatcher->notifyEvent('show.user.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -180,12 +178,12 @@ final class UserController extends ControllerBase implements CrudControllerInter
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::USER_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -198,11 +196,11 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->eventDispatcher->notifyEvent('show.user.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -211,13 +209,13 @@ final class UserController extends ControllerBase implements CrudControllerInter
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editPassAction($id)
{
// Comprobar si el usuario a modificar es distinto al de la sesión
if (!$this->acl->checkUserAccess(Acl::USER_EDIT_PASS, $id)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('userpass', 'itemshow');
@@ -235,11 +233,11 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->eventDispatcher->notifyEvent('show.user.editPass', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -248,13 +246,12 @@ final class UserController extends ControllerBase implements CrudControllerInter
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::USER_DELETE)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -269,7 +266,7 @@ final class UserController extends ControllerBase implements CrudControllerInter
new Event($this, EventMessage::factory()->addDescription(__u('Usuarios eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuarios eliminados'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuarios eliminados'));
} else {
$this->userService->delete($id);
@@ -281,12 +278,12 @@ final class UserController extends ControllerBase implements CrudControllerInter
->addDetail(__u('Usuario'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario eliminado'));
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -296,7 +293,7 @@ final class UserController extends ControllerBase implements CrudControllerInter
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::USER_CREATE)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -317,13 +314,13 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->checkChangeUserPass($itemData);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -351,13 +348,12 @@ final class UserController extends ControllerBase implements CrudControllerInter
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::USER_EDIT)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -378,13 +374,13 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->checkChangeUserPass($itemData);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -392,11 +388,13 @@ final class UserController extends ControllerBase implements CrudControllerInter
* Saves edit action
*
* @param $id
*
* @return bool
*/
public function saveEditPassAction($id)
{
if (!$this->acl->checkUserAccess(Acl::USER_EDIT_PASS, $id)) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -413,13 +411,13 @@ final class UserController extends ControllerBase implements CrudControllerInter
->addDetail(__u('Usuario'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -428,12 +426,12 @@ final class UserController extends ControllerBase implements CrudControllerInter
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::USER_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -445,11 +443,11 @@ final class UserController extends ControllerBase implements CrudControllerInter
$this->eventDispatcher->notifyEvent('show.user', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -67,14 +67,14 @@ final class UserGroupController extends ControllerBase implements CrudController
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::GROUP_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -95,13 +95,11 @@ final class UserGroupController extends ControllerBase implements CrudController
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::GROUP_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -114,11 +112,11 @@ final class UserGroupController extends ControllerBase implements CrudController
$this->eventDispatcher->notifyEvent('show.userGroup.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -130,6 +128,7 @@ final class UserGroupController extends ControllerBase implements CrudController
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
* @throws \SP\Services\ServiceException
* @throws \SP\Repositories\NoSuchItemException
*/
protected function setViewData($userGroupId = null)
{
@@ -161,12 +160,12 @@ final class UserGroupController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::GROUP_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Grupo'));
@@ -178,11 +177,11 @@ final class UserGroupController extends ControllerBase implements CrudController
$this->eventDispatcher->notifyEvent('show.userGroup.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -191,13 +190,12 @@ final class UserGroupController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::GROUP_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -210,7 +208,7 @@ final class UserGroupController extends ControllerBase implements CrudController
new Event($this, EventMessage::factory()->addDescription(__u('Grupos eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupos eliminados'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupos eliminados'));
} else {
$this->userGroupService->delete($id);
@@ -222,12 +220,12 @@ final class UserGroupController extends ControllerBase implements CrudController
->addDetail(__u('Grupo'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo eliminado'));
}
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -237,7 +235,7 @@ final class UserGroupController extends ControllerBase implements CrudController
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::GROUP_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -256,13 +254,13 @@ final class UserGroupController extends ControllerBase implements CrudController
->addDetail(__u('Nombre'), $groupData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -271,13 +269,12 @@ final class UserGroupController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::GROUP_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -296,13 +293,13 @@ final class UserGroupController extends ControllerBase implements CrudController
->addDetail(__u('Nombre'), $groupData->getName()))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -311,12 +308,12 @@ final class UserGroupController extends ControllerBase implements CrudController
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::GROUP_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Grupo'));
@@ -327,11 +324,11 @@ final class UserGroupController extends ControllerBase implements CrudController
$this->eventDispatcher->notifyEvent('show.userGroup', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -104,13 +104,13 @@ final class UserPassResetController extends ControllerBase
$this->dic->get(MailService::class)->send(__('Cambio de Clave'), $email, UserPassRecoverService::getMailMessage($hash));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Solicitud enviada'), [__u('En breve recibirá un correo para completar la solicitud.')]);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Solicitud enviada'), [__u('En breve recibirá un correo para completar la solicitud.')]);
} catch (\Exception $e) {
processException($e);
$this->addTracking();
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -187,13 +187,13 @@ final class UserPassResetController extends ControllerBase
->addDetail(__u('Usuario'), $userId))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada'));
} catch (\Exception $e) {
processException($e);
$this->addTracking();
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -61,14 +61,14 @@ final class UserProfileController extends ControllerBase implements CrudControll
public function searchAction()
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_SEARCH)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
}
/**
@@ -89,13 +89,11 @@ final class UserProfileController extends ControllerBase implements CrudControll
/**
* Create action
*
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function createAction()
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign(__FUNCTION__, 1);
@@ -108,11 +106,11 @@ final class UserProfileController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('show.userProfile.create', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -124,6 +122,7 @@ final class UserProfileController extends ControllerBase implements CrudControll
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
* @throws \SP\Services\ServiceException
* @throws \SP\Repositories\NoSuchItemException
*/
protected function setViewData($profileId = null)
{
@@ -156,12 +155,12 @@ final class UserProfileController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function editAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Editar Perfil'));
@@ -173,11 +172,11 @@ final class UserProfileController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('show.userProfile.edit', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -186,13 +185,12 @@ final class UserProfileController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function deleteAction($id = null)
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_DELETE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -205,24 +203,24 @@ final class UserProfileController extends ControllerBase implements CrudControll
new Event($this, EventMessage::factory()->addDescription(__u('Perfiles eliminados')))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfiles eliminados'));
} else {
$this->userProfileService->delete($id);
$this->deleteCustomFieldsForItem(Acl::PROFILE, $id);
$this->eventDispatcher->notifyEvent('delete.userProfile',
new Event($this, EventMessage::factory()
->addDescription(__u('Perfil eliminado'))
->addDetail(__u('Perfil'), $id))
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil eliminado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfiles eliminados'));
}
$this->userProfileService->delete($id);
$this->deleteCustomFieldsForItem(Acl::PROFILE, $id);
$this->eventDispatcher->notifyEvent('delete.userProfile',
new Event($this, EventMessage::factory()
->addDescription(__u('Perfil eliminado'))
->addDetail(__u('Perfil'), $id))
);
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil eliminado'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -232,7 +230,7 @@ final class UserProfileController extends ControllerBase implements CrudControll
public function saveCreateAction()
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_CREATE)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -247,13 +245,13 @@ final class UserProfileController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('create.userProfile', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil creado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil creado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -262,13 +260,12 @@ final class UserProfileController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @return bool
*/
public function saveEditAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_EDIT)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
try {
@@ -284,13 +281,13 @@ final class UserProfileController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('edit.userProfile', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil actualizado'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}
@@ -299,12 +296,12 @@ final class UserProfileController extends ControllerBase implements CrudControll
*
* @param $id
*
* @throws \Psr\Container\ContainerExceptionInterface
* @return bool
*/
public function viewAction($id)
{
if (!$this->acl->checkUserAccess(Acl::PROFILE_VIEW)) {
return;
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('No tiene permisos para realizar esta operación'));
}
$this->view->assign('header', __('Ver Perfil'));
@@ -315,11 +312,11 @@ final class UserProfileController extends ControllerBase implements CrudControll
$this->eventDispatcher->notifyEvent('show.userProfile', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
return $this->returnJsonResponseData(['html' => $this->render()]);
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -67,11 +67,11 @@ final class UserSettingsGeneralController extends SimpleControllerBase
// Guardar las preferencias en la sesión
$userData->setPreferences($userPreferencesData);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Preferencias actualizadas'));
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Preferencias actualizadas'));
} catch (\Exception $e) {
processException($e);
$this->returnJsonResponseException($e);
return $this->returnJsonResponseException($e);
}
}

View File

@@ -57,7 +57,7 @@ final class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-beta';
const BUILD = 18081002;
const BUILD = 18082201;
/**
* @var DatabaseSetupInterface