diff --git a/apps/maarch_entreprise/xml/services.xml b/apps/maarch_entreprise/xml/services.xml index 46e19f72132dd4df8eebf149b30abe514f885ed5..7da21b4b9dea9c0db4fbd51038a7267c930e0c5f 100755 --- a/apps/maarch_entreprise/xml/services.xml +++ b/apps/maarch_entreprise/xml/services.xml @@ -436,7 +436,19 @@ <id>admin_indexing_models</id> <name>_ADMIN_INDEXING_MODELS</name> <comment>_ADMIN_INDEXING_MODELS</comment> - <servicepage>/administration/users</servicepage> + <servicepage>/administration/indexing-models</servicepage> + <servicetype>admin</servicetype> + <category>organisation</category> + <system_service>false</system_service> + <style>fa fa-user</style> + <enabled>true</enabled> + <angular>true</angular> + </SERVICE> + <SERVICE> + <id>admin_custom_fields</id> + <name>_ADMIN_CUSTOM_FIELDS</name> + <comment>_ADMIN_CUSTOM_FIELDS</comment> + <servicepage>/administration/custom_fields</servicepage> <servicetype>admin</servicetype> <category>organisation</category> <system_service>false</system_service> diff --git a/sql/develop.sql b/sql/develop.sql index 520d45f414159b8574e02d6e7075c49f24316c06..b51c30c6a47bf2f8600922a39079276b9efdf143 100755 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -137,12 +137,16 @@ CREATE TABLE indexing_models ) WITH (OIDS=FALSE); +DROP TYPE IF EXISTS indexing_models_fields_type; +CREATE TYPE indexing_models_fields_type AS ENUM ('standard', 'custom'); + DROP TABLE IF EXISTS indexing_models_fields; CREATE TABLE indexing_models_fields ( id SERIAL NOT NULL, model_id INTEGER NOT NULL, - label character varying(256) NOT NULL, + type indexing_models_fields_type NOT NULL, + identifier INTEGER NOT NULL, mandatory BOOLEAN NOT NULL, value text, unit INTEGER, diff --git a/sql/structure.sql b/sql/structure.sql index e48b993d7a0a69425b931b21c4e91e08c580a23f..75e88238d2e1113251186ef409346baa2a955c18 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -2027,14 +2027,17 @@ CREATE TABLE indexing_models ) WITH (OIDS=FALSE); +CREATE TYPE indexing_models_fields_type AS ENUM ('standard', 'custom'); + CREATE TABLE indexing_models_fields ( - id SERIAL NOT NULL, - model_id INTEGER NOT NULL, - label character varying(256) NOT NULL, - mandatory BOOLEAN NOT NULL, - value text, - unit INTEGER, - CONSTRAINT indexing_models_fields_pkey PRIMARY KEY (id) + id SERIAL NOT NULL, + model_id INTEGER NOT NULL, + type indexing_models_fields_type NOT NULL, + identifier INTEGER NOT NULL, + mandatory BOOLEAN NOT NULL, + value text, + unit INTEGER, + CONSTRAINT indexing_models_fields_pkey PRIMARY KEY (id) ) WITH (OIDS=FALSE); diff --git a/src/app/customField/controllers/CustomFieldController.php b/src/app/customField/controllers/CustomFieldController.php index 62f1f03d2efe8aead507d6bfe6c8c702bd3a1f02..45e46ad2d82d10110bd6d83d4f75748038b848c6 100644 --- a/src/app/customField/controllers/CustomFieldController.php +++ b/src/app/customField/controllers/CustomFieldController.php @@ -18,6 +18,8 @@ namespace CustomField\controllers; use CustomField\models\CustomFieldModel; +use Group\models\ServiceModel; +use IndexingModel\models\IndexingModelFieldModel; use Respect\Validation\Validator; use Slim\Http\Request; use Slim\Http\Response; @@ -26,9 +28,9 @@ class CustomFieldController { public function create(Request $request, Response $response) { -// if (!ServiceModel::hasService(['id' => 'admin_parameters', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { -// return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); -// } + if (!ServiceModel::hasService(['id' => 'admin_custom_fields', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } $body = $request->getParsedBody(); @@ -56,9 +58,9 @@ class CustomFieldController public function update(Request $request, Response $response, array $args) { -// if (!ServiceModel::hasService(['id' => 'admin_parameters', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { -// return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); -// } + if (!ServiceModel::hasService(['id' => 'admin_custom_fields', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } $field = CustomFieldModel::getById(['select' => [1], 'id' => $args['id']]); if (empty($field)) { @@ -92,17 +94,19 @@ class CustomFieldController public function delete(Request $request, Response $response, array $args) { -// if (!ServiceModel::hasService(['id' => 'admin_parameters', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { -// return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); -// } + if (!ServiceModel::hasService(['id' => 'admin_custom_fields', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } + + IndexingModelFieldModel::delete(['where' => ['type = ?', 'identifier = ?'], 'data' => ['custom', $args['id']]]); + + //TODO Suppression des valeurs liés aux courriers ? CustomFieldModel::delete([ 'where' => ['id = ?'], 'data' => [$args['id']] ]); - //TODO Suppression des valeurs liés aux courriers ? - return $response->withStatus(204); } } diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index f3308b8055a4f459f06bf12d49dfa34ee7fdfb96..27e8ec656b36c724ec68281af99a2f0bd3ea26fb 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -199,6 +199,7 @@ define('_SECURITIES', 'Securities'); define('_EMAILSERVER_PARAM', 'Mail server'); define('_EMAILSERVER_PARAM_DESC', 'Link your mail serveur with application in order to send emails.'); define('_ADMIN_INDEXING_MODELS', 'Indexing models administration'); +define('_ADMIN_CUSTOM_FIELDS', 'Custom fields administration'); // SERVICES define('_REDIRECT_TO_ACTION', 'Redirect to an action'); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index 0f4342c56ec13268b729f550802b1f0bb5ee39d7..4b87f67b381eb69fba7e75818fb37148a396504e 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -199,6 +199,7 @@ define('_SECURITIES', 'Sécurités'); define('_EMAILSERVER_PARAM', 'Serveur e-mail'); define('_EMAILSERVER_PARAM_DESC', 'Connecter votre serveur e-mail à Maarch Courrier afin de pouvoir envoyer des courriels.'); define('_ADMIN_INDEXING_MODELS', 'Administration des modèles d\'indexation'); +define('_ADMIN_CUSTOM_FIELDS', 'Administration des champs customisés'); // SERVICES define('_REDIRECT_TO_ACTION', 'Rediriger vers une action'); diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php index f227e5f1287628d3a925c710ed729935961e61bb..bf8c219ad1085d20fd34d6eb892333ed8c2d6f47 100755 --- a/src/core/lang/lang-nl.php +++ b/src/core/lang/lang-nl.php @@ -198,6 +198,7 @@ define('_SECURITIES', 'Veiligheden'); define('_EMAILSERVER_PARAM', '_TO_TRANSLATE'); define('_EMAILSERVER_PARAM_DESC', '_TO_TRANSLATE'); define('_ADMIN_INDEXING_MODELS', 'Indexing models administration'); // translate +define('_ADMIN_CUSTOM_FIELDS', 'Custom fields administration'); // translate //SERVICES define('_REDIRECT_TO_ACTION', 'Doorsturen naar een andere actie');