diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php
index 8050a04c..d7033cba 100644
--- a/app/modules/web/Controllers/AccessManagerController.php
+++ b/app/modules/web/Controllers/AccessManagerController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\DataModel\ItemSearchData;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
@@ -103,7 +104,7 @@ class AccessManagerController extends ControllerBase
$this->tabsGridHelper->addTab($this->getPublicLinksList());
}
- $this->eventDispatcher->notifyEvent('show.itemlist.accesses', $this);
+ $this->eventDispatcher->notifyEvent('show.itemlist.accesses', new Event($this));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE), Request::analyze('tabIndex', 0));
diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php
index 406d4bac..4c5b2edf 100644
--- a/app/modules/web/Controllers/AccountController.php
+++ b/app/modules/web/Controllers/AccountController.php
@@ -24,9 +24,12 @@
namespace SP\Modules\Web\Controllers;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\NotFoundExceptionInterface;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Crypt\Vault;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\Core\SessionUtil;
@@ -74,9 +77,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$accountSearchHelper->getSearchBox();
$accountSearchHelper->getAccountSearch();
- $this->eventDispatcher->notifyEvent('show.account.search', $this);
+ $this->eventDispatcher->notifyEvent('show.account.search', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -95,7 +98,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$AccountSearchHelper = $this->dic->get(AccountSearchHelper::class);
$AccountSearchHelper->getAccountSearch();
- $this->eventDispatcher->notifyEvent('show.account.search', $this);
+ $this->eventDispatcher->notifyEvent('show.account.search', new Event($this));
$data = [
'sk' => SessionUtil::getSessionKey(),
@@ -104,7 +107,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->returnJsonResponseData($data);
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -141,9 +144,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->accountService->incrementViewCounter($id);
- $this->eventDispatcher->notifyEvent('show.account', $this);
+ $this->eventDispatcher->notifyEvent('show.account', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -219,12 +222,12 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->view->assign('accountData', $accountData);
- $this->eventDispatcher->notifyEvent('show.account.link', $this);
+ $this->eventDispatcher->notifyEvent('show.account.link', new Event($this));
} else {
ErrorUtil::showErrorFull($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, 'account-link');
}
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorFull($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, 'account-link');
}
@@ -251,9 +254,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
);
$this->view->assign('formRoute', 'account/saveCreate');
- $this->eventDispatcher->notifyEvent('show.account.create', $this);
+ $this->eventDispatcher->notifyEvent('show.account.create', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -290,9 +293,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
);
$this->view->assign('formRoute', 'account/saveCopy');
- $this->eventDispatcher->notifyEvent('show.account.copy', $this);
+ $this->eventDispatcher->notifyEvent('show.account.copy', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -332,9 +335,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->accountService->incrementViewCounter($id);
- $this->eventDispatcher->notifyEvent('show.account.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.account.edit', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -370,9 +373,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
);
$this->view->assign('formRoute', 'account/saveDelete');
- $this->eventDispatcher->notifyEvent('show.account.delete', $this);
+ $this->eventDispatcher->notifyEvent('show.account.delete', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -410,9 +413,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->view->assign('accountPassDateChange', gmdate('Y-m-d', $accountDetailsResponse->getAccountVData()->getPassDateChange()));
- $this->eventDispatcher->notifyEvent('show.account.editpass', $this);
+ $this->eventDispatcher->notifyEvent('show.account.editpass', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -448,9 +451,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->view->assign('formRoute', 'account/saveRestore');
- $this->eventDispatcher->notifyEvent('show.account.history', $this);
+ $this->eventDispatcher->notifyEvent('show.account.history', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -475,9 +478,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->view->addTemplate('account-request');
$this->view->assign('formRoute', 'account/saveRequest');
- $this->eventDispatcher->notifyEvent('show.account.request', $this);
+ $this->eventDispatcher->notifyEvent('show.account.request', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
@@ -506,11 +509,11 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
'html' => $this->render()
];
- $this->eventDispatcher->notifyEvent('show.account.pass', $this);
+ $this->eventDispatcher->notifyEvent('show.account.pass', new Event($this));
$this->returnJsonResponseData($data);
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, $e->getMessage());
}
@@ -538,7 +541,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
'accpass' => $accountPassHelper->getPassword($account, $this->acl, AccountPasswordHelper::TYPE_NORMAL),
];
- $this->eventDispatcher->notifyEvent('copy.account.pass', $this);
+ $this->eventDispatcher->notifyEvent('copy.account.pass', new Event($this));
$this->returnJsonResponseData($data);
}
@@ -555,8 +558,6 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
/**
* Saves create action
- *
- * @throws \SP\Core\Dic\ContainerException
*/
public function saveCreateAction()
{
@@ -569,7 +570,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->addCustomFieldsForItem(ActionsInterface::ACCOUNT, $accountId);
- $this->eventDispatcher->notifyEvent('create.account', $this);
+ $this->eventDispatcher->notifyEvent('create.account', new Event($this));
$this->returnJsonResponseData(
[
@@ -581,8 +582,8 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
);
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -606,7 +607,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->updateCustomFieldsForItem(ActionsInterface::ACCOUNT, $id);
- $this->eventDispatcher->notifyEvent('edit.account', $this);
+ $this->eventDispatcher->notifyEvent('edit.account', new Event($this));
$this->returnJsonResponseData(
[
@@ -619,7 +620,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -641,7 +642,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
$this->accountService->editPassword($form->getItemData());
- $this->eventDispatcher->notifyEvent('edit.account.pass', $this);
+ $this->eventDispatcher->notifyEvent('edit.account.pass', new Event($this));
$this->returnJsonResponseData(
[
@@ -654,7 +655,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -673,7 +674,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
try {
$this->accountService->editRestore($historyId, $id);
- $this->eventDispatcher->notifyEvent('edit.account.restore', $this);
+ $this->eventDispatcher->notifyEvent('edit.account.restore', new Event($this));
$this->returnJsonResponseData(
[
@@ -684,7 +685,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
__u('Cuenta restaurada')
);
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -701,7 +702,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
if ($this->accountService->delete($id)) {
$this->deleteCustomFieldsForItem(ActionsInterface::ACCOUNT, $id);
- $this->eventDispatcher->notifyEvent('delete.account', $this);
+ $this->eventDispatcher->notifyEvent('delete.account', new Event($this));
$this->returnJsonResponseData(
['nextAction' => Acl::getActionRoute(ActionsInterface::ACCOUNT_SEARCH)],
@@ -710,7 +711,7 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
);
}
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -719,8 +720,9 @@ class AccountController extends ControllerBase implements CrudControllerInterfac
/**
* Initialize class
*
- * @throws \Psr\Container\ContainerExceptionInterface
- * @throws \Psr\Container\NotFoundExceptionInterface
+ * @throws ContainerExceptionInterface
+ * @throws NotFoundExceptionInterface
+ * @throws \SP\Services\Auth\AuthException
*/
protected function initialize()
{
diff --git a/app/modules/web/Controllers/AccountFileController.php b/app/modules/web/Controllers/AccountFileController.php
index 67c6563f..a1880f07 100644
--- a/app/modules/web/Controllers/AccountFileController.php
+++ b/app/modules/web/Controllers/AccountFileController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\DataModel\FileData;
use SP\Html\Html;
@@ -73,7 +74,7 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
$this->view->assign('fileData', $fileData);
$this->view->assign('isImage', 1);
- $this->eventDispatcher->notifyEvent('show.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('show.accountFile', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
}
@@ -81,12 +82,12 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
if (mb_strtoupper($fileData->getExtension()) === 'TXT') {
$this->view->assign('data', htmlentities($fileData->getContent()));
- $this->eventDispatcher->notifyEvent('show.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('show.accountFile', new Event($this));
$this->returnJsonResponseData(['html' => $this->render()]);
}
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -115,11 +116,11 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
header('Content-Description: PHP Generated Data');
header('Content-transfer-encoding: binary');
- $this->eventDispatcher->notifyEvent('download.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('download.accountFile', new Event($this));
exit($fileData->getContent());
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
}
}
@@ -179,15 +180,15 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
$this->accountFileService->create($fileData);
- $this->eventDispatcher->notifyEvent('upload.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('upload.accountFile', new Event($this));
$this->returnJsonResponse(0, __u('Archivo guardado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(1, $e->getMessage(), [$e->getHint()]);
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -244,11 +245,11 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
try {
$this->accountFileService->delete($id);
- $this->eventDispatcher->notifyEvent('delete.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('delete.accountFile', new Event($this));
$this->returnJsonResponse(0, __('Archivo Eliminado'));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -298,9 +299,9 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
return;
}
- $this->eventDispatcher->notifyEvent('list.accountFile', $this);
+ $this->eventDispatcher->notifyEvent('list.accountFile', new Event($this));
} catch (\Exception $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
}
diff --git a/app/modules/web/Controllers/ApiTokenController.php b/app/modules/web/Controllers/ApiTokenController.php
index d13895c1..349be057 100644
--- a/app/modules/web/Controllers/ApiTokenController.php
+++ b/app/modules/web/Controllers/ApiTokenController.php
@@ -28,6 +28,7 @@ use Defuse\Crypto\Exception\CryptoException;
use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\AuthTokenData;
@@ -100,8 +101,10 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.authToken.create', $this);
+ $this->eventDispatcher->notifyEvent('show.authToken.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -158,8 +161,10 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.authToken.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.authToken.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -182,11 +187,11 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
$this->deleteCustomFieldsForItem(ActionsInterface::APITOKEN, $id);
- $this->eventDispatcher->notifyEvent('delete.authToken', $this);
+ $this->eventDispatcher->notifyEvent('delete.authToken', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización eliminada'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -213,21 +218,21 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
$this->addCustomFieldsForItem(ActionsInterface::APITOKEN, $id);
- $this->eventDispatcher->notifyEvent('create.authToken', $this);
+ $this->eventDispatcher->notifyEvent('create.authToken', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Autorización creada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (EnvironmentIsBrokenException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (CryptoException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -252,11 +257,11 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
if ($form->isRefresh()){
$this->authTokenService->refreshAndUpdate($form->getItemData());
- $this->eventDispatcher->notifyEvent('refresh.authToken', $this);
+ $this->eventDispatcher->notifyEvent('refresh.authToken', new Event($this));
} else {
$this->authTokenService->update($form->getItemData());
- $this->eventDispatcher->notifyEvent('edit.authToken', $this);
+ $this->eventDispatcher->notifyEvent('edit.authToken', new Event($this));
}
$this->updateCustomFieldsForItem(ActionsInterface::APITOKEN, $id);
@@ -265,11 +270,11 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (CryptoException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -293,8 +298,10 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.authToken', $this);
+ $this->eventDispatcher->notifyEvent('show.authToken', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/CategoryController.php b/app/modules/web/Controllers/CategoryController.php
index b2de80ca..7d26d0f6 100644
--- a/app/modules/web/Controllers/CategoryController.php
+++ b/app/modules/web/Controllers/CategoryController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\CategoryData;
@@ -95,8 +96,10 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.category.create', $this);
+ $this->eventDispatcher->notifyEvent('show.category.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -150,8 +153,10 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.category.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.category.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -175,11 +180,11 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
$this->deleteCustomFieldsForItem(ActionsInterface::CATEGORY, $id);
- $this->eventDispatcher->notifyEvent('delete.category', $this);
+ $this->eventDispatcher->notifyEvent('delete.category', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría eliminada'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -204,13 +209,13 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
$this->addCustomFieldsForItem(ActionsInterface::CATEGORY, $id);
- $this->eventDispatcher->notifyEvent('create.category', $this);
+ $this->eventDispatcher->notifyEvent('create.category', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría creada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -236,13 +241,13 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
$this->updateCustomFieldsForItem(ActionsInterface::CATEGORY, $id);
- $this->eventDispatcher->notifyEvent('edit.category', $this);
+ $this->eventDispatcher->notifyEvent('edit.category', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Categoría actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -266,8 +271,10 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.category', $this);
+ $this->eventDispatcher->notifyEvent('show.category', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/ClientController.php b/app/modules/web/Controllers/ClientController.php
index b861c7d8..341c3092 100644
--- a/app/modules/web/Controllers/ClientController.php
+++ b/app/modules/web/Controllers/ClientController.php
@@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ClientData;
@@ -96,8 +97,10 @@ class ClientController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.client.create', $this);
+ $this->eventDispatcher->notifyEvent('show.client.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -151,8 +154,10 @@ class ClientController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.client.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.client.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -175,11 +180,11 @@ class ClientController extends ControllerBase implements CrudControllerInterface
$this->deleteCustomFieldsForItem(ActionsInterface::CLIENT, $id);
- $this->eventDispatcher->notifyEvent('delete.client', $this);
+ $this->eventDispatcher->notifyEvent('delete.client', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente eliminado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -202,13 +207,13 @@ class ClientController extends ControllerBase implements CrudControllerInterface
$this->clientService->create($form->getItemData());
- $this->eventDispatcher->notifyEvent('create.client', $this);
+ $this->eventDispatcher->notifyEvent('create.client', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -232,13 +237,13 @@ class ClientController extends ControllerBase implements CrudControllerInterface
$this->clientService->update($form->getItemData());
- $this->eventDispatcher->notifyEvent('edit.client', $this);
+ $this->eventDispatcher->notifyEvent('edit.client', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Cliente actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -262,8 +267,10 @@ class ClientController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.client', $this);
+ $this->eventDispatcher->notifyEvent('show.client', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/ConfigAccountController.php b/app/modules/web/Controllers/ConfigAccountController.php
new file mode 100644
index 00000000..cad36e40
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigAccountController.php
@@ -0,0 +1,105 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+
+/**
+ * Class ConfigAccountController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigAccountController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \SP\Core\Exceptions\InvalidArgumentException
+ */
+ public function saveAction()
+ {
+ $configData = clone $this->config->getConfigData();
+
+ // Accounts
+ $globalSearchEnabled = Request::analyze('globalsearch', false, false, true);
+ $accountPassToImageEnabled = Request::analyze('account_passtoimage', false, false, true);
+ $accountLinkEnabled = Request::analyze('account_link', false, false, true);
+ $accountFullGroupAccessEnabled = Request::analyze('account_fullgroup_access', false, false, true);
+ $accountCount = Request::analyze('account_count', 10);
+ $resultsAsCardsEnabled = Request::analyze('resultsascards', false, false, true);
+
+ $configData->setGlobalSearch($globalSearchEnabled);
+ $configData->setAccountPassToImage($accountPassToImageEnabled);
+ $configData->setAccountLink($accountLinkEnabled);
+ $configData->setAccountFullGroupAccess($accountFullGroupAccessEnabled);
+ $configData->setAccountCount($accountCount);
+ $configData->setResultsAsCards($resultsAsCardsEnabled);
+
+ // Files
+ $filesEnabled = Request::analyze('files_enabled', false, false, true);
+ $filesAllowedSize = Request::analyze('files_allowed_size', 1024);
+ $filesAllowedExts = Request::analyze('files_allowed_exts');
+
+ if ($filesEnabled && $filesAllowedSize >= 16384) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('El tamaño máximo por archivo es de 16MB'));
+ }
+
+ $configData->setFilesAllowedExts($filesAllowedExts);
+ $configData->setFilesEnabled($filesEnabled);
+ $configData->setFilesAllowedSize($filesAllowedSize);
+
+ // Public Links
+ $pubLinksEnabled = Request::analyze('publinks_enabled', false, false, true);
+ $pubLinksImageEnabled = Request::analyze('publinks_image_enabled', false, false, true);
+ $pubLinksMaxTime = Request::analyze('publinks_maxtime', 10);
+ $pubLinksMaxViews = Request::analyze('publinks_maxviews', 3);
+
+ $configData->setPublinksEnabled($pubLinksEnabled);
+ $configData->setPublinksImageEnabled($pubLinksImageEnabled);
+ $configData->setPublinksMaxTime($pubLinksMaxTime * 60);
+ $configData->setPublinksMaxViews($pubLinksMaxViews);
+
+ $this->eventDispatcher->notifyEvent('save.config.account', new Event($this));
+
+ $this->saveConfig($configData, $this->config);
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::ACCOUNT_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigBackupController.php b/app/modules/web/Controllers/ConfigBackupController.php
new file mode 100644
index 00000000..f52f3076
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigBackupController.php
@@ -0,0 +1,98 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+use SP\Services\Backup\FileBackupService;
+use SP\Services\Export\XmlExportService;
+
+/**
+ * Class ConfigBackupController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigBackupController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \Psr\Container\ContainerExceptionInterface
+ * @throws \Psr\Container\NotFoundExceptionInterface
+ */
+ public function fileBackupAction()
+ {
+ if ($this->config->getConfigData()->isDemoEnabled()) {
+ $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
+ }
+
+ try {
+ $backupService = new FileBackupService();
+ $backupService->doBackup();
+
+ $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de backup finalizado'));
+ } catch (\Exception $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+
+ /**
+ * @throws \Psr\Container\ContainerExceptionInterface
+ * @throws \Psr\Container\NotFoundExceptionInterface
+ */
+ public function xmlExportAction()
+ {
+ $exportPassword = Request::analyzeEncrypted('exportPwd');
+ $exportPasswordR = Request::analyzeEncrypted('exportPwdR');
+
+ if (!empty($exportPassword) && $exportPassword !== $exportPasswordR) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Las claves no coinciden'));
+ }
+
+ try {
+ $exportService = $this->dic->get(XmlExportService::class);
+ $exportService->doExport($exportPassword);
+
+ $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de exportación finalizado'));
+ } catch (\Exception $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::BACKUP_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage(), [$e->getHint()]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigEncryptionController.php b/app/modules/web/Controllers/ConfigEncryptionController.php
new file mode 100644
index 00000000..bb440f1a
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigEncryptionController.php
@@ -0,0 +1,210 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\NotFoundExceptionInterface;
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Crypt\Hash;
+use SP\Core\Crypt\Session as CryptSession;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Core\TaskFactory;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\JsonTrait;
+use SP\Services\Config\ConfigService;
+use SP\Services\Crypt\MasterPassService;
+use SP\Services\Crypt\TemporaryMasterPassService;
+use SP\Services\Crypt\UpdateMasterPassRequest;
+use SP\Services\ServiceException;
+use SP\Util\Util;
+
+/**
+ * Class ConfigEncryptionController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigEncryptionController extends SimpleControllerBase
+{
+ use JsonTrait;
+
+ /**
+ * @throws ContainerExceptionInterface
+ * @throws NotFoundExceptionInterface
+ * @throws \SP\Services\Config\ParameterNotFoundException
+ */
+ public function saveAction()
+ {
+ $mastePassService = $this->dic->get(MasterPassService::class);
+
+ $currentMasterPass = Request::analyzeEncrypted('curMasterPwd');
+ $newMasterPass = Request::analyzeEncrypted('newMasterPwd');
+ $newMasterPassR = Request::analyzeEncrypted('newMasterPwdR');
+ $confirmPassChange = Request::analyze('confirmPassChange', 0, false, 1);
+ $noAccountPassChange = Request::analyze('chkNoAccountChange', 0, false, 1);
+
+ if (!$mastePassService->checkUserUpdateMPass($this->session->getUserData()->getLastUpdateMPass())) {
+ $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'));
+ }
+
+ if ($confirmPassChange === false) {
+ $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'));
+ }
+
+ if ($newMasterPass !== $newMasterPassR) {
+ $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'));
+ }
+
+ if ($this->config->getConfigData()->isDemoEnabled()) {
+ $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
+ }
+
+ $configService = $this->dic->get(ConfigService::class);
+
+ if (!$noAccountPassChange) {
+ Util::lockApp();
+
+ $request = new UpdateMasterPassRequest(
+ $currentMasterPass,
+ $newMasterPass,
+ $configService->getByParam('masterPwd'),
+ TaskFactory::create(__FUNCTION__, 'masterpass')
+ );
+
+ try {
+ $mastePassService->changeMasterPassword($request);
+ $configService->save('masterPwd', $request->getHash());
+ $configService->save('lastupdatempass', time());
+ } catch (\Exception $e) {
+ processException($e);
+
+ $this->returnJsonResponseException($e);
+ } finally {
+ Util::unlockApp();
+
+ TaskFactory::end($request->getTask()->getTaskId());
+ }
+ } else {
+ try {
+ $configService->save('masterPwd', Hash::hashKey($newMasterPass));
+ $configService->save('lastupdatempass', time());
+ } catch (\Exception $e) {
+ processException($e);
+
+ $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')]);
+ }
+
+ /**
+ * Refresh master password hash
+ */
+ public function refreshAction()
+ {
+ if ($this->config->getConfigData()->isDemoEnabled()) {
+ $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
+ }
+
+ try {
+ $configService = $this->dic->get(ConfigService::class);
+ $configService->save('masterPwd', Hash::hashKey(CryptSession::getSessionKey()));
+
+ $this->eventDispatcher->notifyEvent('refresh.masterPassword', new Event($this, [__u('Hash de clave maestra actualizado')]));
+
+ $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Hash de clave maestra actualizado'));
+ } catch (\Exception $e) {
+ processException($e);
+
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al actualizar el hash de la clave maestra'));
+ }
+ }
+
+ /**
+ * Create a temporary master pass
+ */
+ public function saveTempAction()
+ {
+ try {
+ $temporaryMasterPassService = $this->dic->get(TemporaryMasterPassService::class);
+ $temporaryMasterPassService->create(Request::analyze('tmpass_maxtime', 3600));
+
+ $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'));
+ } catch (ServiceException $e) {
+ $this->returnJsonResponseException($e);
+ }
+
+
+// $tempMasterGroup = Request::analyze('tmpass_group', 0);
+// $tempMasterEmail = Request::analyze('tmpass_chkSendEmail', 0, false, 1);
+//
+// $this->LogMessage->addDescription(__('Clave Temporal Generada', false));
+//
+// if ($tempMasterEmail) {
+// $Message = new NoticeMessage();
+// $Message->setTitle(sprintf(__('Clave Maestra %s'), Util::getAppInfo('appname')));
+// $Message->addDescription(__('Se ha generado una nueva clave para el acceso a sysPass y se solicitará en el siguiente inicio.'));
+// $Message->addDescription('');
+// $Message->addDescription(sprintf(__('La nueva clave es: %s'), $tempMasterPass));
+// $Message->addDescription('');
+// $Message->addDescription(__('No olvide acceder lo antes posible para guardar los cambios.'));
+//
+// if ($tempMasterGroup !== 0) {
+// Email::sendEmailBatch($Message, UserUtil::getUserGroupEmail($tempMasterGroup));
+// } else {
+// Email::sendEmailBatch($Message, UserUtil::getUsersEmail());
+// }
+// }
+//
+// $this->JsonResponse->setStatus(0);
+
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::ENCRYPTION_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigGeneralController.php b/app/modules/web/Controllers/ConfigGeneralController.php
new file mode 100644
index 00000000..234c4c7d
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigGeneralController.php
@@ -0,0 +1,162 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+
+/**
+ * Class ConfigGeneral
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigGeneralController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \SP\Core\Exceptions\InvalidArgumentException
+ */
+ public function saveAction()
+ {
+ $messages = [];
+ $configData = clone $this->config->getConfigData();
+
+ // General
+ $siteLang = Request::analyze('sitelang');
+ $siteTheme = Request::analyze('sitetheme', 'material-blue');
+ $sessionTimeout = Request::analyze('session_timeout', 300);
+ $httpsEnabled = Request::analyze('https_enabled', false, false, true);
+ $debugEnabled = Request::analyze('debug', false, false, true);
+ $maintenanceEnabled = Request::analyze('maintenance', false, false, true);
+ $checkUpdatesEnabled = Request::analyze('updates', false, false, true);
+ $checkNoticesEnabled = Request::analyze('notices', false, false, true);
+ $encryptSessionEnabled = Request::analyze('encryptsession', false, false, true);
+
+ $configData->setSiteLang($siteLang);
+ $configData->setSiteTheme($siteTheme);
+ $configData->setSessionTimeout($sessionTimeout);
+ $configData->setHttpsEnabled($httpsEnabled);
+ $configData->setDebug($debugEnabled);
+ $configData->setMaintenance($maintenanceEnabled);
+ $configData->setCheckUpdates($checkUpdatesEnabled);
+ $configData->setChecknotices($checkNoticesEnabled);
+ $configData->setEncryptSession($encryptSessionEnabled);
+
+ // Events
+ $logEnabled = Request::analyze('log_enabled', false, false, true);
+ $syslogEnabled = Request::analyze('syslog_enabled', false, false, true);
+ $remoteSyslogEnabled = Request::analyze('remotesyslog_enabled', false, false, true);
+ $syslogServer = Request::analyze('remotesyslog_server');
+ $syslogPort = Request::analyze('remotesyslog_port', 0);
+
+ $configData->setLogEnabled($logEnabled);
+ $configData->setSyslogEnabled($syslogEnabled);
+
+ if ($remoteSyslogEnabled && (!$syslogServer || !$syslogPort)) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de syslog remoto'));
+ }
+
+ if ($remoteSyslogEnabled) {
+ $configData->setSyslogRemoteEnabled($remoteSyslogEnabled);
+ $configData->setSyslogServer($syslogServer);
+ $configData->setSyslogPort($syslogPort);
+ } elseif ($configData->isSyslogEnabled()) {
+ $configData->setSyslogRemoteEnabled(false);
+
+ $messages[] = __u('Syslog remoto deshabilitado');
+ }
+
+ // Proxy
+ $proxyEnabled = Request::analyze('proxy_enabled', false, false, true);
+ $proxyServer = Request::analyze('proxy_server');
+ $proxyPort = Request::analyze('proxy_port', 0);
+ $proxyUser = Request::analyze('proxy_user');
+ $proxyPass = Request::analyzeEncrypted('proxy_pass');
+
+
+ // Valores para Proxy
+ if ($proxyEnabled && (!$proxyServer || !$proxyPort)) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Proxy'));
+ }
+
+ if ($proxyEnabled) {
+ $configData->setProxyEnabled(true);
+ $configData->setProxyServer($proxyServer);
+ $configData->setProxyPort($proxyPort);
+ $configData->setProxyUser($proxyUser);
+ $configData->setProxyPass($proxyPass);
+
+ $messages[] = __u('Proxy habiltado');
+ } elseif ($configData->isProxyEnabled()) {
+ $configData->setProxyEnabled(false);
+
+ $messages[] = __u('Proxy deshabilitado');
+ }
+
+ // Autentificación
+ $authBasicEnabled = Request::analyze('authbasic_enabled', false, false, true);
+ $authBasicAutologinEnabled = Request::analyze('authbasic_enabled', false, false, true);
+ $authBasicDomain = Request::analyze('authbasic_domain');
+ $authSsoDefaultGroup = Request::analyze('sso_defaultgroup', false, false, true);
+ $authSsoDefaultProfile = Request::analyze('sso_defaultprofile', false, false, true);
+
+ // Valores para Autentificación
+ if ($authBasicEnabled) {
+ $configData->setAuthBasicEnabled(true);
+ $configData->setAuthBasicAutoLoginEnabled($authBasicAutologinEnabled);
+ $configData->setAuthBasicDomain($authBasicDomain);
+ $configData->setSsoDefaultGroup($authSsoDefaultGroup);
+ $configData->setSsoDefaultProfile($authSsoDefaultProfile);
+
+ $messages[] = __u('Auth Basic habilitada');
+ } elseif ($configData->isAuthBasicEnabled()) {
+ $configData->setAuthBasicEnabled(false);
+ $configData->setAuthBasicAutoLoginEnabled(false);
+
+ $messages[] = __u('Auth Basic deshabiltada');
+ }
+
+ $this->eventDispatcher->notifyEvent('save.config.general', new Event($this, $messages));
+
+ $this->saveConfig($configData, $this->config);
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::CONFIG_GENERAL)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigLdapController.php b/app/modules/web/Controllers/ConfigLdapController.php
new file mode 100644
index 00000000..5c8be8e2
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigLdapController.php
@@ -0,0 +1,101 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+
+/**
+ * Class ConfigLdapController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigLdapController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \SP\Core\Exceptions\InvalidArgumentException
+ */
+ public function saveAction()
+ {
+ $messages = [];
+ $configData = clone $this->config->getConfigData();
+
+ // LDAP
+ $ldapEnabled = Request::analyze('ldap_enabled', false, false, true);
+ $ldapADSEnabled = Request::analyze('ldap_ads', false, false, true);
+ $ldapServer = Request::analyze('ldap_server');
+ $ldapBase = Request::analyze('ldap_base');
+ $ldapGroup = Request::analyze('ldap_group');
+ $ldapDefaultGroup = Request::analyze('ldap_defaultgroup', 0);
+ $ldapDefaultProfile = Request::analyze('ldap_defaultprofile', 0);
+ $ldapBindUser = Request::analyze('ldap_binduser');
+ $ldapBindPass = Request::analyzeEncrypted('ldap_bindpass');
+
+ // Valores para la configuración de LDAP
+ if ($ldapEnabled && (!$ldapServer || !$ldapBase || !$ldapBindUser)) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de LDAP'));
+ }
+
+ if ($ldapEnabled) {
+ $configData->setLdapEnabled(true);
+ $configData->setLdapAds($ldapADSEnabled);
+ $configData->setLdapServer($ldapServer);
+ $configData->setLdapBase($ldapBase);
+ $configData->setLdapGroup($ldapGroup);
+ $configData->setLdapDefaultGroup($ldapDefaultGroup);
+ $configData->setLdapDefaultProfile($ldapDefaultProfile);
+ $configData->setLdapBindUser($ldapBindUser);
+ $configData->setLdapBindPass($ldapBindPass);
+
+ $messages[] = __u('LDAP habiltado');
+ } elseif ($configData->isLdapEnabled()) {
+ $configData->setLdapEnabled(false);
+
+ $messages[] = __u('LDAP deshabilitado');
+ }
+
+ $this->eventDispatcher->notifyEvent('save.config.ldap', new Event($this, $messages));
+
+ $this->saveConfig($configData, $this->config);
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::LDAP_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigMailController.php b/app/modules/web/Controllers/ConfigMailController.php
new file mode 100644
index 00000000..89359b47
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigMailController.php
@@ -0,0 +1,106 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+
+/**
+ * Class ConfigMailController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigMailController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \SP\Core\Exceptions\InvalidArgumentException
+ */
+ public function saveAction()
+ {
+ $messages = [];
+ $configData = clone $this->config->getConfigData();
+
+ // Mail
+ $mailEnabled = Request::analyze('mail_enabled', false, false, true);
+ $mailServer = Request::analyze('mail_server');
+ $mailPort = Request::analyze('mail_port', 25);
+ $mailUser = Request::analyze('mail_user');
+ $mailPass = Request::analyzeEncrypted('mail_pass');
+ $mailSecurity = Request::analyze('mail_security');
+ $mailFrom = Request::analyze('mail_from');
+ $mailRequests = Request::analyze('mail_requestsenabled', false, false, true);
+ $mailAuth = Request::analyze('mail_authenabled', false, false, true);
+
+ // Valores para la configuración del Correo
+ if ($mailEnabled && (!$mailServer || !$mailFrom)) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Correo'));
+ }
+
+ if ($mailEnabled) {
+ $configData->setMailEnabled(true);
+ $configData->setMailRequestsEnabled($mailRequests);
+ $configData->setMailServer($mailServer);
+ $configData->setMailPort($mailPort);
+ $configData->setMailSecurity($mailSecurity);
+ $configData->setMailFrom($mailFrom);
+
+ if ($mailAuth) {
+ $configData->setMailAuthenabled($mailAuth);
+ $configData->setMailUser($mailUser);
+ $configData->setMailPass($mailPass);
+ }
+
+ $messages[] = __u('Correo habiltado');
+ } elseif ($configData->isMailEnabled()) {
+ $configData->setMailEnabled(false);
+ $configData->setMailRequestsEnabled(false);
+ $configData->setMailAuthenabled(false);
+
+ $messages[] = __u('Correo deshabilitado');
+ }
+
+ $this->eventDispatcher->notifyEvent('save.config.mail', new Event($this, $messages));
+
+ $this->saveConfig($configData, $this->config);
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::MAIL_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponseException($e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ConfigManagerController.php b/app/modules/web/Controllers/ConfigManagerController.php
index dbd33ba4..07d0d62a 100644
--- a/app/modules/web/Controllers/ConfigManagerController.php
+++ b/app/modules/web/Controllers/ConfigManagerController.php
@@ -29,6 +29,7 @@ use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Crypt\CryptSessionHandler;
use SP\Core\CryptMasterPass;
+use SP\Core\Events\Event;
use SP\Core\Language;
use SP\Core\Plugin\PluginUtil;
use SP\Core\Task;
@@ -63,6 +64,7 @@ class ConfigManagerController extends ControllerBase
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \SP\Core\Exceptions\InvalidArgumentException
* @throws \SP\Services\Config\ParameterNotFoundException
+ * @throws \SP\Core\Exceptions\SPException
*/
public function indexAction()
{
@@ -76,6 +78,7 @@ class ConfigManagerController extends ControllerBase
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \SP\Core\Exceptions\InvalidArgumentException
* @throws \SP\Services\Config\ParameterNotFoundException
+ * @throws \SP\Core\Exceptions\SPException
*/
protected function getTabs()
{
@@ -118,7 +121,7 @@ class ConfigManagerController extends ControllerBase
}
- $this->eventDispatcher->notifyEvent('show.config', $this);
+ $this->eventDispatcher->notifyEvent('show.config', new Event($this));
$this->tabsHelper->renderTabs(Acl::getActionRoute(ActionsInterface::CONFIG), Request::analyze('tabIndex', 0));
@@ -261,7 +264,7 @@ class ConfigManagerController extends ControllerBase
$template->addTemplate('backup');
$template->assign('siteName', Util::getAppInfo('appname'));
- $template->assign('backupDir', Bootstrap::$SERVERROOT . '/backup');
+ $template->assign('backupDir', BACKUP_PATH);
$template->assign('backupPath', Bootstrap::$WEBROOT . '/backup');
$backupHash = $this->configData->getBackupHash();
@@ -270,7 +273,7 @@ class ConfigManagerController extends ControllerBase
$backupFile = $template->siteName . '-' . $backupHash . '.tar.gz';
$template->assign('backupFile', [
- 'absolute' => $template->backupDir . DIRECTORY_SEPARATOR . $backupFile,
+ 'absolute' => BACKUP_PATH . DIRECTORY_SEPARATOR . $backupFile,
'relative' => $template->backupPath . '/' . $backupFile,
'filename' => $backupFile
]);
@@ -278,7 +281,7 @@ class ConfigManagerController extends ControllerBase
$backupDbFile = $template->siteName . '_db-' . $backupHash . '.sql';
$template->assign('backupDbFile', [
- 'absolute' => $template->backupDir . DIRECTORY_SEPARATOR . $backupDbFile,
+ 'absolute' => BACKUP_PATH . DIRECTORY_SEPARATOR . $backupDbFile,
'relative' => $template->backupPath . '/' . $backupDbFile,
'filename' => $backupDbFile
]);
@@ -291,7 +294,7 @@ class ConfigManagerController extends ControllerBase
$exportFile = $template->siteName . '-' . $exportHash . '.xml';
$template->assign('exportFile', [
- 'absolute' => $template->backupDir . DIRECTORY_SEPARATOR . $exportFile,
+ 'absolute' => BACKUP_PATH . DIRECTORY_SEPARATOR . $exportFile,
'relative' => $template->backupPath . '/' . $exportFile,
'filename' => $exportFile
]);
diff --git a/app/modules/web/Controllers/ConfigWikiController.php b/app/modules/web/Controllers/ConfigWikiController.php
new file mode 100644
index 00000000..e38a1b6d
--- /dev/null
+++ b/app/modules/web/Controllers/ConfigWikiController.php
@@ -0,0 +1,119 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Core\Acl\UnauthorizedPageException;
+use SP\Core\Events\Event;
+use SP\Core\Exceptions\SPException;
+use SP\Http\JsonResponse;
+use SP\Http\Request;
+use SP\Modules\Web\Controllers\Traits\ConfigTrait;
+
+/**
+ * Class ConfigWikiController
+ *
+ * @package SP\Modules\Web\Controllers
+ */
+class ConfigWikiController extends SimpleControllerBase
+{
+ use ConfigTrait;
+
+ /**
+ * @throws \SP\Core\Exceptions\InvalidArgumentException
+ */
+ public function saveAction()
+ {
+ $messages = [];
+ $configData = clone $this->config->getConfigData();
+
+ // Wiki
+ $wikiEnabled = Request::analyze('wiki_enabled', false, false, true);
+ $wikiSearchUrl = Request::analyze('wiki_searchurl');
+ $wikiPageUrl = Request::analyze('wiki_pageurl');
+ $wikiFilter = Request::analyze('wiki_filter');
+
+ // Valores para la conexión a la Wiki
+ if ($wikiEnabled && (!$wikiSearchUrl || !$wikiPageUrl || !$wikiFilter)) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Faltan parámetros de Wiki'));
+ }
+
+ if ($wikiEnabled) {
+ $configData->setWikiEnabled(true);
+ $configData->setWikiSearchurl($wikiSearchUrl);
+ $configData->setWikiPageurl($wikiPageUrl);
+ $configData->setWikiFilter(explode(',', $wikiFilter));
+
+ $messages[] = __u('Wiki habiltada');
+ } elseif ($configData->isWikiEnabled()) {
+ $configData->setWikiEnabled(false);
+
+ $messages[] = __u('Wiki deshabilitada');
+ }
+
+ // DokuWiki
+ $dokuWikiEnabled = Request::analyze('dokuwiki_enabled', false, false, true);
+ $dokuWikiUrl = Request::analyze('dokuwiki_url');
+ $dokuWikiUrlBase = Request::analyze('dokuwiki_urlbase');
+ $dokuWikiUser = Request::analyze('dokuwiki_user');
+ $dokuWikiPass = Request::analyzeEncrypted('dokuwiki_pass');
+ $dokuWikiNamespace = Request::analyze('dokuwiki_namespace');
+
+ // 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'));
+ }
+
+ if ($dokuWikiEnabled) {
+ $configData->setDokuwikiEnabled(true);
+ $configData->setDokuwikiUrl($dokuWikiUrl);
+ $configData->setDokuwikiUrlBase(trim($dokuWikiUrlBase, '/'));
+ $configData->setDokuwikiUser($dokuWikiUser);
+ $configData->setDokuwikiPass($dokuWikiPass);
+ $configData->setDokuwikiNamespace($dokuWikiNamespace);
+
+ $messages[] = __u('DokuWiki habilitada');
+ } elseif ($configData->isDokuwikiEnabled()) {
+ $configData->setDokuwikiEnabled(false);
+
+ $messages[] = __u('DokuWiki deshabilitada');
+ }
+
+ $this->eventDispatcher->notifyEvent('save.config.wiki', new Event($this, $messages));
+
+ $this->saveConfig($configData, $this->config);
+ }
+
+ protected function initialize()
+ {
+ try {
+ if (!$this->checkAccess(ActionsInterface::WIKI_CONFIG)) {
+ throw new UnauthorizedPageException(SPException::INFO);
+ }
+ } catch (UnauthorizedPageException $e) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage(), [$e->getHint()]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/ControllerBase.php b/app/modules/web/Controllers/ControllerBase.php
index 37ed1fc9..e9405e26 100644
--- a/app/modules/web/Controllers/ControllerBase.php
+++ b/app/modules/web/Controllers/ControllerBase.php
@@ -189,7 +189,7 @@ abstract class ControllerBase
try {
echo $this->view->render();
} catch (FileNotFoundException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
echo $e->getMessage();
}
@@ -205,7 +205,7 @@ abstract class ControllerBase
try {
return $this->view->render();
} catch (FileNotFoundException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
return $e->getMessage();
}
diff --git a/app/modules/web/Controllers/CustomFieldController.php b/app/modules/web/Controllers/CustomFieldController.php
index 5fdcff61..ade376cd 100644
--- a/app/modules/web/Controllers/CustomFieldController.php
+++ b/app/modules/web/Controllers/CustomFieldController.php
@@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\CustomFieldDefinitionData;
@@ -98,8 +99,10 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.customField.create', $this);
+ $this->eventDispatcher->notifyEvent('show.customField.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -156,8 +159,10 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.customField.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.customField.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -180,11 +185,11 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
$this->deleteCustomFieldsForItem(ActionsInterface::CUSTOMFIELD, $id);
- $this->eventDispatcher->notifyEvent('delete.customField', $this);
+ $this->eventDispatcher->notifyEvent('delete.customField', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo eliminado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -205,13 +210,13 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
$this->customFieldService->create($form->getItemData());
- $this->eventDispatcher->notifyEvent('create.customField', $this);
+ $this->eventDispatcher->notifyEvent('create.customField', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -235,13 +240,13 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
$this->customFieldService->update($form->getItemData());
- $this->eventDispatcher->notifyEvent('edit.customField', $this);
+ $this->eventDispatcher->notifyEvent('edit.customField', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Campo actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -265,8 +270,10 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.customField', $this);
+ $this->eventDispatcher->notifyEvent('show.customField', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php
index 4dacbcbd..a4c54b49 100644
--- a/app/modules/web/Controllers/Helpers/LayoutHelper.php
+++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php
@@ -124,7 +124,7 @@ class LayoutHelper extends HelperBase
// Cargar la clave pública en la sesión
SessionUtil::loadPublicKey();
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
}
$this->getResourcesLinks();
diff --git a/app/modules/web/Controllers/ItemManagerController.php b/app/modules/web/Controllers/ItemManagerController.php
index d9e8851f..1a8133de 100644
--- a/app/modules/web/Controllers/ItemManagerController.php
+++ b/app/modules/web/Controllers/ItemManagerController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\DataModel\ItemSearchData;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
@@ -118,7 +119,7 @@ class ItemManagerController extends ControllerBase
$this->tabsGridHelper->addTab($this->getPluginsList());
}
- $this->eventDispatcher->notifyEvent('show.itemlist.items', $this);
+ $this->eventDispatcher->notifyEvent('show.itemlist.items', new Event($this));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE), Request::analyze('tabIndex', 0));
diff --git a/app/modules/web/Controllers/MainController.php b/app/modules/web/Controllers/MainController.php
index db4b1e48..4c251671 100644
--- a/app/modules/web/Controllers/MainController.php
+++ b/app/modules/web/Controllers/MainController.php
@@ -117,7 +117,7 @@ class MainController extends ControllerBase implements ActionsInterface
// Cargar la clave pública en la sesión
SessionUtil::loadPublicKey();
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
}
$this->getResourcesLinks();
diff --git a/app/modules/web/Controllers/PublicLinkController.php b/app/modules/web/Controllers/PublicLinkController.php
index a0e68121..426d9a8a 100644
--- a/app/modules/web/Controllers/PublicLinkController.php
+++ b/app/modules/web/Controllers/PublicLinkController.php
@@ -24,9 +24,9 @@
namespace SP\Modules\Web\Controllers;
-use Defuse\Crypto\Exception\CryptoException;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\PublicLinkListData;
@@ -98,8 +98,10 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.publicLink.create', $this);
+ $this->eventDispatcher->notifyEvent('show.publicLink.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -150,15 +152,11 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
try {
$this->publicLinkService->refresh($id);
- $this->eventDispatcher->notifyEvent('edit.publicLink.refresh', $this);
+ $this->eventDispatcher->notifyEvent('edit.publicLink.refresh', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace actualizado'));
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
-
- $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (CryptoException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -183,8 +181,10 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.publicLink.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.publicLink.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -208,11 +208,11 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
$this->deleteCustomFieldsForItem(ActionsInterface::PUBLICLINK, $id);
- $this->eventDispatcher->notifyEvent('delete.publicLink', $this);
+ $this->eventDispatcher->notifyEvent('delete.publicLink', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace eliminado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -223,7 +223,6 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
- * @throws \SP\Core\Dic\ContainerException
*/
public function saveCreateAction()
{
@@ -238,17 +237,13 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
$this->publicLinkService->create($form->getItemData());
// $this->publicLinkService->logAction($id, ActionsInterface::PUBLICLINK_CREATE);
- $this->eventDispatcher->notifyEvent('create.publicLink', $this);
+ $this->eventDispatcher->notifyEvent('create.publicLink', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Enlace creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (CryptoException $e) {
- debugLog($e->getMessage(), true);
-
- $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -282,8 +277,10 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.publicLink', $this);
+ $this->eventDispatcher->notifyEvent('show.publicLink', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/SimpleControllerBase.php b/app/modules/web/Controllers/SimpleControllerBase.php
index a38da2e3..bb5f8f49 100644
--- a/app/modules/web/Controllers/SimpleControllerBase.php
+++ b/app/modules/web/Controllers/SimpleControllerBase.php
@@ -28,6 +28,7 @@ use DI\Container;
use Interop\Container\ContainerInterface;
use Klein\Klein;
use SP\Config\Config;
+use SP\Core\Acl\Acl;
use SP\Core\Events\EventDispatcher;
use SP\Core\Session\Session;
use SP\Core\UI\Theme;
@@ -74,6 +75,10 @@ abstract class SimpleControllerBase
* @var ContainerInterface
*/
protected $dic;
+ /**
+ * @var Acl
+ */
+ protected $acl;
/**
* SimpleControllerBase constructor.
@@ -95,6 +100,7 @@ abstract class SimpleControllerBase
$this->theme = $this->dic->get(Theme::class);
$this->eventDispatcher = $this->dic->get(EventDispatcher::class);
$this->router = $this->dic->get(Klein::class);
+ $this->acl = $this->dic->get(Acl::class);
if (method_exists($this, 'initialize')) {
$this->initialize();
@@ -109,4 +115,15 @@ abstract class SimpleControllerBase
$this->checkLoggedInSession($this->session);
$this->checkSecurityToken($this->session);
}
+
+ /**
+ * Comprobar si está permitido el acceso al módulo/página.
+ *
+ * @param null $action La acción a comprobar
+ * @return bool
+ */
+ protected function checkAccess($action)
+ {
+ return $this->session->getUserData()->getIsAdminApp() || $this->acl->checkUserAccess($action);
+ }
}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/TagController.php b/app/modules/web/Controllers/TagController.php
index 518e93cd..58622b00 100644
--- a/app/modules/web/Controllers/TagController.php
+++ b/app/modules/web/Controllers/TagController.php
@@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\TagData;
@@ -96,8 +97,10 @@ class TagController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.tag.create', $this);
+ $this->eventDispatcher->notifyEvent('show.tag.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -149,8 +152,10 @@ class TagController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.tag.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.tag.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -173,11 +178,11 @@ class TagController extends ControllerBase implements CrudControllerInterface
$this->deleteCustomFieldsForItem(ActionsInterface::TAG, $id);
- $this->eventDispatcher->notifyEvent('delete.tag', $this);
+ $this->eventDispatcher->notifyEvent('delete.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta eliminada'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -200,13 +205,13 @@ class TagController extends ControllerBase implements CrudControllerInterface
$this->tagService->create($form->getItemData());
- $this->eventDispatcher->notifyEvent('create.tag', $this);
+ $this->eventDispatcher->notifyEvent('create.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta creada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -230,13 +235,13 @@ class TagController extends ControllerBase implements CrudControllerInterface
$this->tagService->update($form->getItemData());
- $this->eventDispatcher->notifyEvent('edit.tag', $this);
+ $this->eventDispatcher->notifyEvent('edit.tag', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Etiqueta actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -260,8 +265,10 @@ class TagController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.tag', $this);
+ $this->eventDispatcher->notifyEvent('show.tag', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/Traits/ConfigTrait.php b/app/modules/web/Controllers/Traits/ConfigTrait.php
new file mode 100644
index 00000000..004a0842
--- /dev/null
+++ b/app/modules/web/Controllers/Traits/ConfigTrait.php
@@ -0,0 +1,68 @@
+.
+ */
+
+namespace SP\Modules\Web\Controllers\Traits;
+
+use SP\Bootstrap;
+use SP\Config\Config;
+use SP\Config\ConfigData;
+use SP\Http\JsonResponse;
+use SP\Util\Util;
+
+/**
+ * Trait ConfigTrait
+ *
+ * @package SP\Modules\Web\Controllers\Traits
+ */
+trait ConfigTrait
+{
+ use JsonTrait;
+
+ /**
+ * Guardar la configuración
+ *
+ * @param ConfigData $configData
+ * @param Config $config
+ */
+ protected function saveConfig(ConfigData $configData, Config $config)
+ {
+ try {
+ if ($configData->isDemoEnabled()) {
+ $this->returnJsonResponse(JsonResponse::JSON_WARNING, __u('Ey, esto es una DEMO!!'));
+ }
+
+ $config->saveConfig($configData);
+
+ if ($configData->isMaintenance()) {
+ Util::lockApp(false);
+ } elseif (Bootstrap::$LOCK > 0) {
+ Util::unlockApp(false);
+ }
+
+ $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Configuración actualizada'));
+ } catch (\Exception $e) {
+ $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error al guardar la configuración'));
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/Traits/JsonTrait.php b/app/modules/web/Controllers/Traits/JsonTrait.php
index d3e98847..8246358a 100644
--- a/app/modules/web/Controllers/Traits/JsonTrait.php
+++ b/app/modules/web/Controllers/Traits/JsonTrait.php
@@ -24,6 +24,7 @@
namespace SP\Modules\Web\Controllers\Traits;
+use SP\Core\Exceptions\SPException;
use SP\Http\JsonResponse;
use SP\Util\Json;
@@ -72,6 +73,25 @@ trait JsonTrait
}
+ Json::returnJson($jsonResponse);
+ }
+
+ /**
+ * Returns JSON response
+ *
+ * @param \Exception $exception
+ * @param int $status Status code
+ */
+ protected function returnJsonResponseException(\Exception $exception, $status = JsonResponse::JSON_ERROR)
+ {
+ $jsonResponse = new JsonResponse();
+ $jsonResponse->setStatus($status);
+ $jsonResponse->setDescription($exception->getMessage());
+
+ if ($exception instanceof SPException && $exception->getHint() !== null ) {
+ $jsonResponse->setMessages([$exception->getHint()]);
+ }
+
Json::returnJson($jsonResponse);
}
}
\ No newline at end of file
diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php
index a2454417..486fbb89 100644
--- a/app/modules/web/Controllers/UserController.php
+++ b/app/modules/web/Controllers/UserController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\Core\SessionUtil;
@@ -100,8 +101,10 @@ class UserController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.user.create', $this);
+ $this->eventDispatcher->notifyEvent('show.user.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -159,8 +162,10 @@ class UserController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.user.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.user.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -193,8 +198,10 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->view->assign('user', $user);
- $this->eventDispatcher->notifyEvent('show.user.editPass', $this);
+ $this->eventDispatcher->notifyEvent('show.user.editPass', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -220,11 +227,11 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->deleteCustomFieldsForItem(ActionsInterface::USER, $id);
- $this->eventDispatcher->notifyEvent('delete.user', $this);
+ $this->eventDispatcher->notifyEvent('delete.user', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario eliminado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -248,7 +255,7 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->addCustomFieldsForItem(ActionsInterface::USER, $id);
- $this->eventDispatcher->notifyEvent('create.user', $this);
+ $this->eventDispatcher->notifyEvent('create.user', new Event($this));
if ($form->getItemData()->isIsChangePass()
&& !AuthUtil::mailPassRecover($form->getItemData())
@@ -263,8 +270,8 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -291,7 +298,7 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->updateCustomFieldsForItem(ActionsInterface::USER, $id);
- $this->eventDispatcher->notifyEvent('edit.user', $this);
+ $this->eventDispatcher->notifyEvent('edit.user', new Event($this));
if ($form->getItemData()->isIsChangePass()
&& !AuthUtil::mailPassRecover($form->getItemData())
@@ -306,8 +313,8 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Usuario actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -331,13 +338,13 @@ class UserController extends ControllerBase implements CrudControllerInterface
$this->userService->updatePass($form->getItemData());
// $this->userService->logAction($id, ActionsInterface::USER_EDIT_PASS);
- $this->eventDispatcher->notifyEvent('edit.user.pass', $this);
+ $this->eventDispatcher->notifyEvent('edit.user.pass', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave actualizada'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -362,8 +369,10 @@ class UserController extends ControllerBase implements CrudControllerInterface
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.user', $this);
+ $this->eventDispatcher->notifyEvent('show.user', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php
index 0bb50563..3c5c4ef4 100644
--- a/app/modules/web/Controllers/UserGroupController.php
+++ b/app/modules/web/Controllers/UserGroupController.php
@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\UserGroupData;
@@ -102,8 +103,10 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.userGroup.create', $this);
+ $this->eventDispatcher->notifyEvent('show.userGroup.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -159,8 +162,10 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.userGroup.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.userGroup.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -184,11 +189,11 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
$this->deleteCustomFieldsForItem(ActionsInterface::GROUP, $id);
- $this->eventDispatcher->notifyEvent('delete.userGroup', $this);
+ $this->eventDispatcher->notifyEvent('delete.userGroup', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo eliminado'));
} catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -215,13 +220,13 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
$this->addCustomFieldsForItem(ActionsInterface::GROUP, $id);
- $this->eventDispatcher->notifyEvent('create.userGroup', $this);
+ $this->eventDispatcher->notifyEvent('create.userGroup', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -250,13 +255,13 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
$this->updateCustomFieldsForItem(ActionsInterface::GROUP, $id);
- $this->eventDispatcher->notifyEvent('edit.useGroup', $this);
+ $this->eventDispatcher->notifyEvent('edit.useGroup', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Grupo actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -280,8 +285,10 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.userGroup', $this);
+ $this->eventDispatcher->notifyEvent('show.userGroup', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php
index fb65c390..5050f75b 100644
--- a/app/modules/web/Controllers/UserProfileController.php
+++ b/app/modules/web/Controllers/UserProfileController.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
-use SP\Core\Exceptions\SPException;
+use SP\Core\Events\Event;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ProfileData;
use SP\Forms\UserProfileForm;
@@ -95,8 +95,10 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData();
- $this->eventDispatcher->notifyEvent('show.userProfile.create', $this);
+ $this->eventDispatcher->notifyEvent('show.userProfile.create', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(1, $e->getMessage());
}
@@ -152,8 +154,10 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.userProfile.edit', $this);
+ $this->eventDispatcher->notifyEvent('show.userProfile.edit', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -177,11 +181,11 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
$this->deleteCustomFieldsForItem(ActionsInterface::PROFILE, $id);
- $this->eventDispatcher->notifyEvent('delete.userProfile', $this);
+ $this->eventDispatcher->notifyEvent('delete.userProfile', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil eliminado'));
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -207,13 +211,13 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
$this->addCustomFieldsForItem(ActionsInterface::PROFILE, $id);
- $this->eventDispatcher->notifyEvent('create.userProfile', $this);
+ $this->eventDispatcher->notifyEvent('create.userProfile', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil creado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -241,13 +245,13 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
$this->updateCustomFieldsForItem(ActionsInterface::PROFILE, $id);
- $this->eventDispatcher->notifyEvent('edit.userProfile', $this);
+ $this->eventDispatcher->notifyEvent('edit.userProfile', new Event($this));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Perfil actualizado'));
} catch (ValidationException $e) {
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
- } catch (SPException $e) {
- debugLog($e->getMessage(), true);
+ } catch (\Exception $e) {
+ processException($e);
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
@@ -271,8 +275,10 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
try {
$this->setViewData($id);
- $this->eventDispatcher->notifyEvent('show.userProfile', $this);
+ $this->eventDispatcher->notifyEvent('show.userProfile', new Event($this));
} catch (\Exception $e) {
+ processException($e);
+
$this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage());
}
diff --git a/app/modules/web/themes/material-blue/views/config/accounts.inc b/app/modules/web/themes/material-blue/views/config/accounts.inc
index a536a8ca..1281b3a8 100644
--- a/app/modules/web/themes/material-blue/views/config/accounts.inc
+++ b/app/modules/web/themes/material-blue/views/config/accounts.inc
@@ -2,7 +2,7 @@
-
-
@@ -66,8 +62,10 @@
-
-
@@ -79,8 +77,8 @@
-
@@ -277,6 +275,7 @@
";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=f.account.save;b.data={r:"account/saveDelete/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);k.search()})}}})},viewPass:function(a){e.info("account:showpass");var b=a.data("parent-id")||0,b=0===
-b?a.data("item-id"):b,d=a.data("history")||0,g=c.appRequests().getRequestOpts();g.url=f.entrypoint;g.method="get";g.data={r:a.data("action-route")+"/"+b+"/"+d,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(g,function(a){0!==a.status?c.msg.out(a):(a=$(a.data.html),p(a),l=setTimeout(function(){$.magnificPopup.close()},3E4),a.on("mouseleave",function(){clearTimeout(l);l=setTimeout(function(){$.magnificPopup.close()},3E4)}).on("mouseenter",function(){0!==l&&clearTimeout(l)}))})},copyPass:function(a){e.info("account:copypass");
-var b=a.data("parent-id"),b=0===b?a.data("item-id"):b,d=c.appRequests().getRequestOpts();d.url=f.entrypoint;d.method="get";d.async=!1;d.data={r:a.data("action-route")+"/"+b+"/"+a.data("history"),sk:c.sk.get(),isAjax:1};return c.appRequests().getActionCall(d)},copy:function(a){e.info("account:copy");n(c.appRequests().getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},saveFavorite:function(a,b){e.info("account:saveFavorite");var d="on"===a.data("status"),g={r:(d?a.data("action-id-off"):
-a.data("action-id-on"))+"/"+a.data("item-id"),sk:c.sk.get(),isAjax:1},q=c.appRequests().getRequestOpts();q.url=f.account.saveFavorite;q.data=g;c.appRequests().getActionCall(q,function(g){c.msg.out(g);0===g.status&&(a.data("status",d?"off":"on"),"function"===typeof b&&b())})},request:function(a){e.info("account:request");var b=c.appRequests().getRequestOpts();b.url=f.account.request;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},menu:function(c){c.hide();c.parent().children(".actions-optional").show(250)},
-sort:function(c){e.info("account:sort");var a=$("#frmSearch");a.find('input[name="skey"]').val(c.data("key"));a.find('input[name="sorder"]').val(c.data("dir"));a.find('input[name="start"]').val(c.data("start"));k.search()},editPass:function(a){e.info("account:editpass");var b=a.data("parent-id"),b=void 0===b?a.data("item-id"):b;n(c.appRequests().getRouteForQuery(a.data("action-route"),b),"account")},saveEditRestore:function(a){e.info("account:restore");var b=c.appRequests().getRequestOpts();b.url=
-f.entrypoint+"?r="+a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("item-id");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&n(c.appRequests().getRouteForQuery(a.data.nextAction,a.data.itemId),"account")})},listFiles:function(a){e.info("account:getfiles");var b=c.appRequests().getRequestOpts();b.method="get";b.type="html";b.url=f.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("item-id"),del:a.data("delete"),
+var $jscomp={scope:{},findInternal:function(c,e,k){c instanceof String&&(c=String(c));for(var f=c.length,m=0;m