From 885d6902eb4469a890d25f46f5a49f2d3fbbc170 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Thu, 9 Nov 2017 16:07:57 +0100
Subject: [PATCH] [REFACTORING] History add syntax

---
 core/Controllers/StatusController.php         | 24 +++++++-------
 core/Controllers/UserController.php           | 16 +++++-----
 core/Models/UserModelAbstract.php             | 32 +++++++++----------
 .../Controllers/NotificationController.php    | 26 +++++++--------
 4 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/core/Controllers/StatusController.php b/core/Controllers/StatusController.php
index 89e189b76e7..abf1abfac11 100755
--- a/core/Controllers/StatusController.php
+++ b/core/Controllers/StatusController.php
@@ -87,10 +87,10 @@ class StatusController
             $return['status'] = StatusModel::getById(['id' => $aArgs['id']])[0];
 
             HistoryController::add([
-                'table_name' => 'status', 
-                'record_id'  => $return['status']['id'], 
-                'event_type' => 'ADD', 
-                'event_id'   => 'statusup',
+                'tableName' => 'status',
+                'recordId'  => $return['status']['id'],
+                'eventType' => 'ADD',
+                'eventId'   => 'statusup',
                 'info'       => _STATUS_ADDED . ' : ' . $return['status']['id']
             ]);
 
@@ -120,10 +120,10 @@ class StatusController
             $return['status'] = StatusModel::getByIdentifier(['identifier' => $aArgs['identifier']])[0];
 
             HistoryController::add([
-                'table_name' => 'status', 
-                'record_id'  => $return['status']['id'], 
-                'event_type' => 'UP', 
-                'event_id'   => 'statusup',
+                'tableName' => 'status',
+                'recordId'  => $return['status']['id'],
+                'eventType' => 'UP',
+                'eventId'   => 'statusup',
                 'info'       => _MODIFY_STATUS . ' : ' . $return['status']['id']
             ]);
             
@@ -149,10 +149,10 @@ class StatusController
             StatusModel::delete(['identifier' => $aArgs['identifier']]);
 
             HistoryController::add([
-                'table_name' => 'status', 
-                'record_id'  => $statusDeleted[0]['id'], 
-                'event_type' => 'DEL', 
-                'event_id'   => 'statusdel',
+                'tableName' => 'status',
+                'recordId'  => $statusDeleted[0]['id'],
+                'eventType' => 'DEL',
+                'eventId'   => 'statusdel',
                 'info'       => _STATUS_DELETED . ' : ' . $statusDeleted[0]['id']
             ]);
         } else {
diff --git a/core/Controllers/UserController.php b/core/Controllers/UserController.php
index c84f3d5f61b..9cdec912944 100755
--- a/core/Controllers/UserController.php
+++ b/core/Controllers/UserController.php
@@ -241,10 +241,10 @@ class UserController
 
         UserModel::activateAbsenceById(['userId' => $user['user_id']]);
         HistoryController::add([
-            'table_name'    => 'users',
-            'record_id'     => $user['user_id'],
-            'event_type'    => 'ABS',
-            'event_id'      => 'userabs',
+            'tableName'    => 'users',
+            'recordId'     => $user['user_id'],
+            'eventType'    => 'ABS',
+            'eventId'      => 'userabs',
             'info'          => _ABS_USER. " {$user['firstname']} {$user['lastname']}"
         ]);
 
@@ -280,10 +280,10 @@ class UserController
 
             UserModel::desactivateAbsenceById(['id' => $aArgs['id']]);
             HistoryController::add([
-                'table_name'    => 'users',
-                'record_id'     => $user['user_id'],
-                'event_type'    => 'RET',
-                'event_id'      => 'userabs',
+                'tableName'    => 'users',
+                'recordId'     => $user['user_id'],
+                'eventType'    => 'RET',
+                'eventId'      => 'userabs',
                 'info'          => "{$user['firstname']} {$user['lastname']} " ._BACK_FROM_VACATION
             ]);
 
diff --git a/core/Models/UserModelAbstract.php b/core/Models/UserModelAbstract.php
index c9546ab4eb9..3cabd475451 100755
--- a/core/Models/UserModelAbstract.php
+++ b/core/Models/UserModelAbstract.php
@@ -603,10 +603,10 @@ class UserModelAbstract
         $groupInfos = GroupModel::getById(['groupId' => $aArgs['groupId']]);
 
         HistoryController::add([
-            'table_name' => 'users', 
-            'record_id'  =>$user['user_id'], 
-            'event_type' => 'GROUP ADD', 
-            'event_id'   => 'groupadded',
+            'tableName' => 'users',
+            'recordId'  =>$user['user_id'],
+            'eventType' => 'GROUP ADD',
+            'eventId'   => 'groupadded',
             'info'       =>$_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_GROUP.' '.$groupInfos['group_desc']
         ]);
 
@@ -648,10 +648,10 @@ class UserModelAbstract
         $groupInfos = GroupModel::getById(['groupId' => $aArgs['groupId']]);
 
         HistoryController::add([
-            'table_name' => 'users', 
-            'record_id'  =>$user['user_id'], 
-            'event_type' => 'GROUP DELETED', 
-            'event_id'   => 'groupdeleted',
+            'tableName' => 'users',
+            'recordId'  =>$user['user_id'],
+            'eventType' => 'GROUP DELETED',
+            'eventId'   => 'groupdeleted',
             'info'       =>$_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_GROUP.' '.$groupInfos['group_desc']
         ]);
 
@@ -695,10 +695,10 @@ class UserModelAbstract
         $entityInfos = EntityModel::getByID(['entityId' => $aArgs['entityId']]);
 
         HistoryController::add([
-            'table_name' => 'users', 
-            'record_id'  => $user['user_id'],
-            'event_type' => 'ENTITY ADD', 
-            'event_id'   => 'entityadded',
+            'tableName' => 'users',
+            'recordId'  => $user['user_id'],
+            'eventType' => 'ENTITY ADD',
+            'eventId'   => 'entityadded',
             'info'       => $_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_ENTITY.' '.$entityInfos['entity_label']
         ]);
 
@@ -793,10 +793,10 @@ class UserModelAbstract
         $entityInfos=EntityModel::getByID(['entityId' => $aArgs['entityId']]);
 
         HistoryController::add([
-            'table_name' => 'users', 
-            'record_id'  =>$user['user_id'], 
-            'event_type' => 'ENTITY DELETE', 
-            'event_id'   => 'entitydeleted',
+            'tableName' => 'users',
+            'recordId'  =>$user['user_id'],
+            'eventType' => 'ENTITY DELETE',
+            'eventId'   => 'entitydeleted',
             'info'       =>$_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_ENTITY.' '.$entityInfos['entity_label']
         ]);
 
diff --git a/modules/notifications/Controllers/NotificationController.php b/modules/notifications/Controllers/NotificationController.php
index 321b432a1ee..6bed5cb4bcd 100644
--- a/modules/notifications/Controllers/NotificationController.php
+++ b/modules/notifications/Controllers/NotificationController.php
@@ -99,11 +99,11 @@ class NotificationController
 
             if (NotificationModel::create($data)) {
                 HistoryController::add([
-                'table_name' => 'notifications',
-                'record_id'  => $data['notification_id'],
-                'event_type' => 'ADD',
-                'event_id'   => 'notificationsadd',
-                'info'       => _ADD_NOTIFICATIONS . ' : ' . $data['notification_id']
+                    'tableName' => 'notifications',
+                    'recordId'  => $data['notification_id'],
+                    'eventType' => 'ADD',
+                    'eventId'   => 'notificationsadd',
+                    'info'       => _ADD_NOTIFICATIONS . ' : ' . $data['notification_id']
                 ]);
                 return $response->withJson(NotificationModel::getByNotificationId(['notificationId' => $data['notification_id']]));
             } else {
@@ -134,10 +134,10 @@ class NotificationController
         $notification = NotificationModel::getById(['notificationId' => $data['notification_id']]);
 
         HistoryController::add([
-            'table_name' => 'notifications',
-            'record_id'  => $data['notification_sid'],
-            'event_type' => 'UP',
-            'event_id'   => 'notificationsup',
+            'tableName' => 'notifications',
+            'recordId'  => $data['notification_sid'],
+            'eventType' => 'UP',
+            'eventId'   => 'notificationsup',
             'info'       => _MODIFY_NOTIFICATIONS . ' : ' . $data['notification_sid']
         ]);
 
@@ -153,10 +153,10 @@ class NotificationController
         NotificationModel::delete(['notification_sid' => $aArgs['id']]);
 
         HistoryController::add([
-                'table_name' => 'notifications',
-                'record_id'  => $aArgs['id'],
-                'event_type' => 'DEL',
-                'event_id'   => 'notificationsdel',
+                'tableName' => 'notifications',
+                'recordId'  => $aArgs['id'],
+                'eventType' => 'DEL',
+                'eventId'   => 'notificationsdel',
                 'info'       => _DELETE_NOTIFICATIONS . ' : ' . $aArgs['id']
             ]);
 
-- 
GitLab