From 4b9e8f04d24a37d3aab0c0b70d30462102e36e44 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 8 Feb 2018 17:53:17 +0100
Subject: [PATCH] FEAT #65 language notification, action, status

---
 core/Test/NotificationControllerTest.php         |  2 +-
 src/app/action/controllers/ActionController.php  |  6 +++---
 .../controllers/NotificationController.php       |  2 +-
 .../NotificationScheduleController.php           | 16 ++++++++++++++++
 src/core/lang/lang-en.php                        | 14 +++++++++++++-
 src/core/lang/lang-fr.php                        | 14 +++++++++++++-
 6 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/core/Test/NotificationControllerTest.php b/core/Test/NotificationControllerTest.php
index bc5c5fbd6cd..28d4e5d744b 100644
--- a/core/Test/NotificationControllerTest.php
+++ b/core/Test/NotificationControllerTest.php
@@ -107,7 +107,7 @@ class NotificationControllerTest extends TestCase
         $fullRequest  = \httpRequestCustom::addContentInBody($aArgs, $request);
         $response     = $NotificationController->create($fullRequest, new \Slim\Http\Response());
         $responseBody = json_decode((string)$response->getBody());
-        $this->assertSame('Erreur sur la Notification:  identifiant déjà existant', $responseBody->errors);
+        $this->assertSame('identifiant déjà existant', $responseBody->errors);
     }
 
     public function testRead()
diff --git a/src/app/action/controllers/ActionController.php b/src/app/action/controllers/ActionController.php
index 83e4c5e4c29..e9267b0e43d 100644
--- a/src/app/action/controllers/ActionController.php
+++ b/src/app/action/controllers/ActionController.php
@@ -116,7 +116,7 @@ class ActionController
             'recordId'  => $obj['id'],
             'eventType' => 'ADD',
             'eventId'   => 'actionadd',
-            'info'      => _ACTION. ' "' . $obj['label_action'] .'" ' ._ADDED
+            'info'      => _ACTION_ADDED . ' : ' . $obj['label_action']
         ]);
 
         return $response->withJson(
@@ -160,7 +160,7 @@ class ActionController
             'recordId'  => $obj['id'],
             'eventType' => 'UP',
             'eventId'   => 'actionup',
-            'info'      => _ACTION. ' "' . $obj['label_action'] .'" ' ._UPDATED
+            'info'      => _ACTION_UPDATED. ' : ' . $obj['label_action']
         ]);
 
         return $response->withJson(
@@ -190,7 +190,7 @@ class ActionController
             'recordId'  => $aArgs['id'],
             'eventType' => 'DEL',
             'eventId'   => 'actiondel',
-            'info'      => _ACTION. ' "' . $action['label_action'] .'" ' ._DELETED
+            'info'      => _ACTION_DELETED. ' : ' . $action['label_action']
         ]);
 
         return $response->withJson(['action' => ActionModel::get()]);
diff --git a/src/app/notification/controllers/NotificationController.php b/src/app/notification/controllers/NotificationController.php
index b35c6fe2baa..f11d8629def 100644
--- a/src/app/notification/controllers/NotificationController.php
+++ b/src/app/notification/controllers/NotificationController.php
@@ -95,7 +95,7 @@ class NotificationController
         $notificationInDb = NotificationModel::getByNotificationId(['notificationId' => $data['notification_id'], 'select' => ['notification_sid']]);
         
         if (Validator::notEmpty()->validate($notificationInDb)) {
-            return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_ALREADY_EXIST]);
+            return $response->withStatus(400)->withJson(['errors' => _NOTIF_ALREADY_EXIST]);
         }
 
         if ($data['is_enabled'] == true) {
diff --git a/src/app/notification/controllers/NotificationScheduleController.php b/src/app/notification/controllers/NotificationScheduleController.php
index e9dc8ef6646..2b5ab70e481 100644
--- a/src/app/notification/controllers/NotificationScheduleController.php
+++ b/src/app/notification/controllers/NotificationScheduleController.php
@@ -87,6 +87,14 @@ class NotificationScheduleController
 
         exec('crontab /tmp/crontab.txt');
 
+        HistoryController::add([
+            'tableName' => 'notifications',
+            'recordId'  => $GLOBALS['userId'],
+            'eventType' => 'UP',
+            'eventId'   => 'notificationadd',
+            'info'      => _NOTIFICATION_SCHEDULE_UPDATED
+        ]);
+
         return $response->withJson(true);
     }
 
@@ -278,6 +286,14 @@ class NotificationScheduleController
         fclose($file_open);
         shell_exec("chmod +x " . escapeshellarg($pathToFolow . "modules/notifications/batch/scripts/" . $filename));
 
+        HistoryController::add([
+            'tableName' => 'notifications',
+            'recordId'  => $notification_id,
+            'eventType' => 'ADD',
+            'eventId'   => 'notificationadd',
+            'info'      => _NOTIFICATION_SCRIPT_ADDED
+        ]);
+
         return $response->withJson(true);
     }
 }
diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php
index b1391fb35f1..0e04c34b2e0 100644
--- a/src/core/lang/lang-en.php
+++ b/src/core/lang/lang-en.php
@@ -12,14 +12,24 @@
  * @author dev@maarch.org
  */
 
-define('_BASKETS_SORT_MODIFICATION', 'Baskets order modification');
+define('_ACTION_ADDED', 'Action added');
+define('_ACTION_DELETED', 'Action deleted');
+define('_ACTION_UPDATED', 'Action updated');
+define('_ADD_NOTIFICATIONS', 'Notification created');
+define('_ALREADY_EXISTS', 'already exists');
 define('_BASKET_CREATION', 'Basket creation');
 define('_BASKET_MODIFICATION', 'Basket modification');
 define('_BASKET_SUPPRESSION', 'Basket suppression');
+define('_BASKETS_SORT_MODIFICATION', 'Baskets order modification');
+define('_DELETE_NOTIFICATIONS', 'Notification deleted');
 define('_ENTITY_CREATION', 'Entity creation');
 define('_ENTITY_MODIFICATION', 'Entity modification');
 define('_ENTITY_SUPPRESSION', 'Entity suppression');
 define('_INVALID_CLAUSE', 'Clause is not valid');
+define('_MODIFY_NOTIFICATIONS', 'Notification updated');
+define('_MODIFY_STATUS', 'Statut updated');
+define('_NOTIFICATION_SCHEDULE_UPDATED', 'Notification scheduled updated');
+define('_NOTIFICATION_SCRIPT_ADDED', 'Script created');
 define('_PARAMETER_CREATION', 'Parameter creation');
 define('_PARAMETER_MODIFICATION', 'Parameter modification');
 define('_PARAMETER_SUPPRESSION', 'Parameter suppression');
@@ -27,3 +37,5 @@ define('_PRIORITY_CREATION', 'Priority creation');
 define('_PRIORITY_MODIFICATION', 'Priority modification');
 define('_PRIORITY_SUPPRESSION', 'Priority suppression');
 define('_REPORT_MODIFICATION', 'Report modification');
+define('_STATUS_ADDED', 'Statut added');
+define('_STATUS_DELETED', 'Statut deleted');
\ No newline at end of file
diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php
index 2839e2dcd0c..d2849a74e14 100644
--- a/src/core/lang/lang-fr.php
+++ b/src/core/lang/lang-fr.php
@@ -12,14 +12,24 @@
  * @author dev@maarch.org
  */
 
-define('_BASKETS_SORT_MODIFICATION', 'Modification ordre bannettes');
+define('_ACTION_ADDED', 'Action ajoutée');
+define('_ACTION_DELETED', 'Action supprimée');
+define('_ACTION_UPDATED', 'Action modifiée');
+define('_ADD_NOTIFICATIONS', 'Notification créée');
+define('_ALREADY_EXISTS', 'existe déjà');
 define('_BASKET_CREATION', 'Création bannette');
 define('_BASKET_MODIFICATION', 'Modification bannette');
 define('_BASKET_SUPPRESSION', 'Suppression bannette');
+define('_BASKETS_SORT_MODIFICATION', 'Modification ordre bannettes');
+define('_DELETE_NOTIFICATIONS', 'Notification supprimée');
 define('_ENTITY_CREATION', 'Création entité');
 define('_ENTITY_MODIFICATION', 'Modification entité');
 define('_ENTITY_SUPPRESSION', 'Suppression entité');
 define('_INVALID_CLAUSE', 'Clause non valide');
+define('_MODIFY_NOTIFICATIONS', 'Notification modifiée');
+define('_MODIFY_STATUS', 'Statut modifié');
+define('_NOTIFICATION_SCHEDULE_UPDATED', 'La planification des notifications a été mise à jour');
+define('_NOTIFICATION_SCRIPT_ADDED', 'Le script de la notification a été créé');
 define('_PARAMETER_CREATION', 'Création paramètre');
 define('_PARAMETER_MODIFICATION', 'Modification paramètre');
 define('_PARAMETER_SUPPRESSION', 'Suppression paramètre');
@@ -27,3 +37,5 @@ define('_PRIORITY_CREATION', 'Création priorité');
 define('_PRIORITY_MODIFICATION', 'Modification priorité');
 define('_PRIORITY_SUPPRESSION', 'Suppression priorité');
 define('_REPORT_MODIFICATION', 'Modification états et édition');
+define('_STATUS_ADDED', 'Statut ajouté');
+define('_STATUS_DELETED', 'Statut supprimé');
-- 
GitLab