From 7eda2e321c1317de8a3014f12a66459f1ba1107f Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Tue, 6 Feb 2018 18:36:00 +0100
Subject: [PATCH] FEAT #64 refactoring administration

---
 .../notification-administration.component.js  |  18 +-
 .../notification-administration.component.ts  |  20 +-
 .../notifications-administration.component.js |   6 +-
 .../notifications-administration.component.ts |  11 +-
 .../js/angular/lang/lang-en.js                |   4 +-
 .../js/angular/lang/lang-en.ts                |   4 +-
 .../js/angular/lang/lang-fr.js                |   4 +-
 .../js/angular/lang/lang-fr.ts                |   4 +-
 composer.json                                 |   2 +-
 core/Test/NotificationsControllerTest.php     |  20 +-
 .../Controllers/NotificationController.php    | 234 ------------------
 .../Models/NotificationsModel.php             |  21 --
 .../Models/NotificationsModelAbstract.php     |  33 ---
 package-lock.json                             |   2 +-
 rest/index.php                                |  13 +-
 .../history/controllers/HistoryController.php |   8 +-
 .../controllers/NotificationController.php    | 212 ++++++++++++++++
 .../NotificationsEventsController.php         |   6 +-
 .../models}/NotificationModel.php             |   2 +-
 .../models}/NotificationModelAbstract.php     |  27 +-
 .../models}/NotificationsEventsModel.php      |   2 +-
 .../NotificationsEventsModelAbstract.php      |   2 +-
 22 files changed, 305 insertions(+), 350 deletions(-)
 delete mode 100644 modules/notifications/Controllers/NotificationController.php
 delete mode 100755 modules/notifications/Models/NotificationsModel.php
 delete mode 100755 modules/notifications/Models/NotificationsModelAbstract.php
 create mode 100644 src/app/notification/controllers/NotificationController.php
 rename {modules/notifications/Controllers => src/app/notification/controllers}/NotificationsEventsController.php (92%)
 mode change 100755 => 100644
 rename {modules/notifications/Models => src/app/notification/models}/NotificationModel.php (91%)
 rename {modules/notifications/Models => src/app/notification/models}/NotificationModelAbstract.php (93%)
 rename {modules/notifications/Models => src/app/notification/models}/NotificationsEventsModel.php (91%)
 mode change 100755 => 100644
 rename {modules/notifications/Models => src/app/notification/models}/NotificationsEventsModelAbstract.php (96%)
 mode change 100755 => 100644

diff --git a/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.js
index f144482a5e1..020cc65e5df 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.js
+++ b/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.js
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
 Object.defineProperty(exports, "__esModule", { value: true });
 var core_1 = require("@angular/core");
 var http_1 = require("@angular/common/http");
-var translate_component_1 = require("../translate.component");
 var router_1 = require("@angular/router");
+var translate_component_1 = require("../translate.component");
 var notification_service_1 = require("../notification.service");
 var NotificationAdministrationComponent = /** @class */ (function () {
     function NotificationAdministrationComponent(http, route, router, notify) {
@@ -27,9 +27,14 @@ var NotificationAdministrationComponent = /** @class */ (function () {
         this.lang = translate_component_1.LANG;
     }
     NotificationAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) {
-        if ($j('#ariane')[0]) {
-            $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > <a onclick='location.hash = \"/administration/notifications\"' style='cursor: pointer'>notifications</a>";
+        var breadCrumb = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > <a onclick='location.hash = \"/administration/notifications\"' style='cursor: pointer'>" + this.lang.notifications + "</a> > ";
+        if (this.creationMode == true) {
+            breadCrumb += this.lang.notificationCreation;
+        }
+        else {
+            breadCrumb += this.lang.notificationModification;
         }
+        $j('#ariane')[0].innerHTML = breadCrumb;
     };
     NotificationAdministrationComponent.prototype.ngOnInit = function () {
         var _this = this;
@@ -49,7 +54,7 @@ var NotificationAdministrationComponent = /** @class */ (function () {
             }
             else {
                 _this.creationMode = false;
-                _this.http.get(_this.coreUrl + 'rest/administration/notifications/' + params['identifier'])
+                _this.http.get(_this.coreUrl + 'rest/notifications/' + params['identifier'])
                     .subscribe(function (data) {
                     _this.notification = data.notification;
                     _this.loading = false;
@@ -102,7 +107,7 @@ var NotificationAdministrationComponent = /** @class */ (function () {
             this.http.post(this.coreUrl + 'rest/notifications', this.notification)
                 .subscribe(function (data) {
                 _this.router.navigate(['/administration/notifications']);
-                _this.notify.success(_this.lang.newNotificationAdded + ' « ' + _this.notification.notification_id + ' »');
+                _this.notify.success(_this.lang.newNotificationAdded);
             }, function (err) {
                 _this.notify.error(err.error.errors);
             });
@@ -111,7 +116,7 @@ var NotificationAdministrationComponent = /** @class */ (function () {
             this.http.put(this.coreUrl + 'rest/notifications/' + this.notification.notification_sid, this.notification)
                 .subscribe(function (data) {
                 _this.router.navigate(['/administration/notifications']);
-                _this.notify.success(_this.lang.notificationUpdated + ' « ' + _this.notification.notification_id + ' »');
+                _this.notify.success(_this.lang.notificationUpdated);
             }, function (err) {
                 _this.notify.error(err.error.errors);
             });
@@ -120,7 +125,6 @@ var NotificationAdministrationComponent = /** @class */ (function () {
     NotificationAdministrationComponent = __decorate([
         core_1.Component({
             templateUrl: angularGlobals["notification-administrationView"],
-            styleUrls: ['../../node_modules/bootstrap/dist/css/bootstrap.min.css'],
             providers: [notification_service_1.NotificationService]
         }),
         __metadata("design:paramtypes", [http_1.HttpClient, router_1.ActivatedRoute, router_1.Router, notification_service_1.NotificationService])
diff --git a/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.ts
index 368072511f1..8fde0c1948b 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/administration/notification-administration.component.ts
@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
+import { Router, ActivatedRoute } from '@angular/router';
 import { LANG } from '../translate.component';
-import { ActivatedRoute, Router } from '@angular/router';
 import { NotificationService } from '../notification.service';
 
 declare function $j(selector: any) : any;
@@ -10,7 +10,6 @@ declare var angularGlobals : any;
 
 @Component({
     templateUrl : angularGlobals["notification-administrationView"],
-    styleUrls   : ['../../node_modules/bootstrap/dist/css/bootstrap.min.css'],
     providers   : [NotificationService]
 })
 export class NotificationAdministrationComponent implements OnInit {
@@ -28,10 +27,15 @@ export class NotificationAdministrationComponent implements OnInit {
     constructor(public http: HttpClient, private route: ActivatedRoute, private router: Router, private notify: NotificationService) {
     }
 
-    updateBreadcrumb(applicationName: string){
-        if ($j('#ariane')[0]) {
-            $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > <a onclick='location.hash = \"/administration/notifications\"' style='cursor: pointer'>notifications</a>";
+    updateBreadcrumb(applicationName: string) {
+        var breadCrumb = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>"+this.lang.administration+"</a> > <a onclick='location.hash = \"/administration/notifications\"' style='cursor: pointer'>"+this.lang.notifications+"</a> > ";
+
+        if(this.creationMode == true){
+            breadCrumb += this.lang.notificationCreation;
+        } else {
+            breadCrumb += this.lang.notificationModification;
         }
+        $j('#ariane')[0].innerHTML = breadCrumb;
     }
 
     ngOnInit(): void {
@@ -52,7 +56,7 @@ export class NotificationAdministrationComponent implements OnInit {
                     });
             } else {
                 this.creationMode = false;
-                this.http.get(this.coreUrl + 'rest/administration/notifications/' + params['identifier'])
+                this.http.get(this.coreUrl + 'rest/notifications/' + params['identifier'])
                     .subscribe((data : any) => {
             
                         this.notification = data.notification;
@@ -102,7 +106,7 @@ export class NotificationAdministrationComponent implements OnInit {
             this.http.post(this.coreUrl + 'rest/notifications', this.notification)
                 .subscribe((data : any) => {
                     this.router.navigate(['/administration/notifications']);
-                    this.notify.success(this.lang.newNotificationAdded+' « '+this.notification.notification_id+' »');
+                    this.notify.success(this.lang.newNotificationAdded);
                 },(err) => {
                     this.notify.error(err.error.errors);
                 });
@@ -110,7 +114,7 @@ export class NotificationAdministrationComponent implements OnInit {
             this.http.put(this.coreUrl + 'rest/notifications/' + this.notification.notification_sid, this.notification)
                 .subscribe((data : any) => {
                     this.router.navigate(['/administration/notifications']);
-                    this.notify.success(this.lang.notificationUpdated+' « '+this.notification.notification_id+' »');
+                    this.notify.success(this.lang.notificationUpdated);
                 },(err) => {
                     this.notify.error(err.error.errors);
                 });
diff --git a/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.js
index 0b09f4564ce..0d22bd7e984 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.js
+++ b/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.js
@@ -35,8 +35,9 @@ var NotificationsAdministrationComponent = /** @class */ (function () {
         });
     };
     NotificationsAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) {
-        $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > " +
-            "<a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.admin_notifications;
+        if ($j('#ariane')[0]) {
+            $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.notifications;
+        }
     };
     NotificationsAdministrationComponent.prototype.deleteNotification = function (notification) {
         var _this = this;
@@ -54,7 +55,6 @@ var NotificationsAdministrationComponent = /** @class */ (function () {
     NotificationsAdministrationComponent = __decorate([
         core_1.Component({
             templateUrl: angularGlobals["notifications-administrationView"],
-            styleUrls: ['../../node_modules/bootstrap/dist/css/bootstrap.min.css'],
             providers: [notification_service_1.NotificationService]
         }),
         __metadata("design:paramtypes", [http_1.HttpClient, notification_service_1.NotificationService])
diff --git a/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.ts
index 23608487adb..e2fdccff504 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/administration/notifications-administration.component.ts
@@ -1,15 +1,17 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, ViewChild, OnInit } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { LANG } from '../translate.component';
 import { NotificationService } from '../notification.service';
 
+
+
 declare function $j(selector: any) : any;
 
 declare var angularGlobals : any;
 
+
 @Component({
     templateUrl : angularGlobals["notifications-administrationView"],
-    styleUrls   : ['../../node_modules/bootstrap/dist/css/bootstrap.min.css'],
     providers   : [NotificationService]
 })
 export class NotificationsAdministrationComponent implements OnInit {
@@ -40,8 +42,9 @@ export class NotificationsAdministrationComponent implements OnInit {
     }
 
     updateBreadcrumb(applicationName: string) {
-        $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > "+
-                                            "<a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.admin_notifications;
+        if ($j('#ariane')[0]) {
+            $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>"+this.lang.administration+"</a> > "+this.lang.notifications;
+        }
     }
 
     deleteNotification(notification : any) {
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.js b/apps/maarch_entreprise/js/angular/lang/lang-en.js
index b51eeb87c59..83dd1cb2faf 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-en.js
+++ b/apps/maarch_entreprise/js/angular/lang/lang-en.js
@@ -115,7 +115,9 @@ exports.LANG_EN = {
     "newPsw": "New password",
     "newSignature": "New signature",
     "notes": "Notes",
-    "notifications": "Notifications",
+    "notifications": "Notification(s)",
+    "notificationCreation": "Notification creation",
+    "notificationModification": "Notification modification",
     "no": "No",
     "noReplacement": "No replacement",
     "parameter": "Parameter",
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
index c1a6618854c..e00fc48be5c 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
@@ -113,7 +113,9 @@ export const LANG_EN = {
     "newPsw"                    : "New password",
     "newSignature"              : "New signature",
     "notes"                     : "Notes",
-    "notifications"             : "Notifications",
+    "notifications"             : "Notification(s)",
+    "notificationCreation"      : "Notification creation",
+    "notificationModification"  : "Notification modification",  
     "no"                        : "No",
     "noReplacement"             : "No replacement",
     "parameter"                 : "Parameter",
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.js b/apps/maarch_entreprise/js/angular/lang/lang-fr.js
index b21b119c1fd..0b52d56c8c3 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-fr.js
+++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.js
@@ -137,7 +137,9 @@ exports.LANG_FR = {
     "noReplacement": "Aucun remplacement",
     "noResult": "Aucun résultat",
     "notes": "Annotations",
-    "notifications": "Notifications",
+    "notifications": "Notification(s)",
+    "notificationCreation": "Création d'une notification",
+    "notificationModification": "Modification de la notification",
     "outOf": "sur",
     "page": "Page",
     "parameter": "Paramètre",
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
index 488a892ba9b..fd9e1626cbd 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
@@ -135,7 +135,9 @@ export const LANG_FR = {
     "noReplacement"                : "Aucun remplacement",
     "noResult"                     : "Aucun résultat",
     "notes"                        : "Annotations",
-    "notifications"                : "Notifications",
+    "notifications"                : "Notification(s)",
+    "notificationCreation"         : "Création d'une notification",
+    "notificationModification"     : "Modification de la notification",  
     "outOf"                        : "sur",
     "page"                         : "Page",
     "parameter"                     : "Paramètre",
diff --git a/composer.json b/composer.json
index 30dc307bb30..4c8a91175ea 100755
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
             "Entity\\"        : "src/app/entity/",
             "History\\"       : "src/app/history/",
             "Listinstance\\"  : "src/app/listinstance/",
+            "Notification\\"  : "src/app/notification/",
             "Parameter\\"     : "src/app/parameter/",
             "Priority\\"      : "src/app/priority/",
             "Report\\"        : "src/app/report/",
@@ -20,7 +21,6 @@
             "Convert\\"       : "modules/convert/",
             "Entities\\"      : "modules/entities/",
             "Notes\\"         : "modules/notes/",
-            "Notifications\\" : "modules/notifications/",
             "Templates\\"     : "modules/templates/",
             "Visa\\"          : "modules/visa/"
     	}
diff --git a/core/Test/NotificationsControllerTest.php b/core/Test/NotificationsControllerTest.php
index 1a1fbc65608..e6240921314 100644
--- a/core/Test/NotificationsControllerTest.php
+++ b/core/Test/NotificationsControllerTest.php
@@ -19,7 +19,7 @@ class NotificationControllerTest extends TestCase
     public function testReadAll()
     {
         //  TEST GET // READ // NEED TO HAVE RED IN BDD 
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
         $response     = $NotificationController->get($request, new \Slim\Http\Response());
@@ -31,7 +31,7 @@ class NotificationControllerTest extends TestCase
     public function testCreate()
     {
         //  CREATE
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
 
@@ -75,7 +75,7 @@ class NotificationControllerTest extends TestCase
     public function testCreateFail1()
     {
         //Fail Create 1
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
 
@@ -102,7 +102,7 @@ class NotificationControllerTest extends TestCase
     public function testCreateFail2()
     {
         //Fail Create 2
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
 
@@ -130,7 +130,7 @@ class NotificationControllerTest extends TestCase
     public function testUpdate()
     {
         //  UPDATE
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
         $aArgs = [
@@ -173,7 +173,7 @@ class NotificationControllerTest extends TestCase
 
     public function testRead(){
         //READ
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
         $response     = $NotificationController->getById($request, new \Slim\Http\Response(), ['id' => 'warning5']);
@@ -191,7 +191,7 @@ class NotificationControllerTest extends TestCase
 
     // public function testReadFail(){
     //     //I CANT READ BECAUSE NO ID
-    //     $NotificationController = new \Notifications\Controllers\NotificationController();
+    //     $NotificationController = new \Notification\controllers\NotificationController();
     //     $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
     //     $request        = \Slim\Http\Request::createFromEnvironment($environment);
     //     $response     = $NotificationController->getById($request, new \Slim\Http\Response(), ['id' => '']);
@@ -201,7 +201,7 @@ class NotificationControllerTest extends TestCase
 
     public function testReadFail2(){
         //I CANT READ BECAUSE NO EXIST
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
         $request        = \Slim\Http\Request::createFromEnvironment($environment);
         $response     = $NotificationController->getById($request, new \Slim\Http\Response(), ['id' => 'BamBam']);
@@ -211,7 +211,7 @@ class NotificationControllerTest extends TestCase
 
     // public function testDeleteFail()
     // {
-    //     $NotificationController = new \Notifications\Controllers\NotificationController();
+    //     $NotificationController = new \Notification\controllers\NotificationController();
 
     //     //  DELETE
     //     $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']);
@@ -224,7 +224,7 @@ class NotificationControllerTest extends TestCase
 
     public function testDelete()
     {
-        $NotificationController = new \Notifications\Controllers\NotificationController();
+        $NotificationController = new \Notification\controllers\NotificationController();
 
         //  DELETE
         $environment    = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']);
diff --git a/modules/notifications/Controllers/NotificationController.php b/modules/notifications/Controllers/NotificationController.php
deleted file mode 100644
index 4be50b21122..00000000000
--- a/modules/notifications/Controllers/NotificationController.php
+++ /dev/null
@@ -1,234 +0,0 @@
-<?php
-
-/**
-* Copyright Maarch since 2008 under licence GPLv3.
-* See LICENCE.txt file at the root folder for more details.
-* This file is part of Maarch software.
-*
-*/
-
-/**
-* @brief Notifications Controller
-* @author dev@maarch.org
-* @ingroup notifications
-*/
-
-namespace Notifications\Controllers;
-
-
-use History\controllers\HistoryController;
-use Psr\Http\Message\RequestInterface;
-use Psr\Http\Message\ResponseInterface;
-use Respect\Validation\Validator;
-use Notifications\Models\NotificationModel;
-use Core\Models\ServiceModel;
-
-
-class NotificationController
-{
-    public function get(RequestInterface $request, ResponseInterface $response)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $notification['notifications'] = NotificationModel::get(['select' => ['notification_sid', 'notification_id', 'description', 'is_enabled', 'event_id', 'notification_mode', 'template_id', 'diffusion_type']]);
-
-        return $response->withJson($notification);
-    }
-
-    public function getById(RequestInterface $request, ResponseInterface $response, $aArgs)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $notification['notifications'] = NotificationModel::getByNotificationId(['notificationId' => $aArgs['id'], 'select' => ['notification_sid', 'notification_id', 'description', 'is_enabled', 'event_id', 'notification_mode', 'template_id', 'diffusion_type','diffusion_properties', 'attachfor_type','attachfor_properties']]);
-        if (empty($notification['notifications'])) {
-                return $response->withStatus(400)->withJson(['errors' => 'Notification not found']);
-        }
-
-        return $response->withJson($notification);
-    }
-    
-
-    public function create(RequestInterface $request, ResponseInterface $response)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $data = $request->getParams();
-        if(empty($data['notification_id'])){
-            return $response->withStatus(400)->withJson(['errors' => 'Notification error : notification_id is empty']);
-        }
-        $notificationInDb = NotificationModel::getByNotificationId(['notificationId' => $data['notification_id'], 'select' => ['notification_sid']]);
-        
-        if($data){
-            if(is_int($notificationInDb['notification_sid'])) {
-                 return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_ALREADY_EXIST]);               
-            }elseif(strlen($data['description']) > 255) {
-                return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_DESCRIPTION_TOO_LONG]);
-            }elseif(strlen($data['event_id']) > 255 && is_string($data['event_id'])) {
-                return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_EVENT_TOO_LONG]);
-            }elseif(strlen($data['notification_mode']) > 30){
-                return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_MODE_TOO_LONG]);
-            }elseif(Validator::intType()->notEmpty()->validate($data['template_id'])){
-                return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_TEMPLATE_NOT_A_INT]);
-            }elseif(!is_string($data['diffusion_type'])){
-                return $response->withStatus(400)->withJson(['errors' => _NOTIFICATIONS_ERROR.' '._NOTIF_DIFFUSION_IS_A_INT]);
-            }
-
-            if($data['is_enabled'] == true){
-                $data['is_enabled'] = 'Y';
-            }else{
-                $data['is_enabled'] = 'N';
-            }
-
-            $data['notification_mode'] = 'EMAIL';
-            
-            if($data['diffusion_properties']){
-                $data['diffusion_properties'] = implode(",", $data['diffusion_properties']);
-            }
-            
-            if($data['attachfor_properties']){
-                $data['attachfor_properties'] = implode(",", $data['attachfor_properties']);
-            }else{
-                $data['attachfor_properties'] = '';
-            }
-
-            if (NotificationModel::create($data)) {
-                HistoryController::add([
-                    '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 {
-                return $response->withStatus(400)->withJson(['errors' => 'Notification Create Error']);
-            }
-
-        }
-    }
-
-    public function update(RequestInterface $request, ResponseInterface $response, $aArgs)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $data = $request->getParams();
-
-        $data['notification_sid'] = $aArgs['id'];
-        $data['diffusion_properties'] = implode(",", $data['diffusion_properties']);
-        
-        $data['attachfor_properties'] = implode(",", $data['attachfor_properties']);
-        if (!empty($errors)) {
-            return $response->withStatus(500)->withJson(['errors' => $errors]);
-        }
-
-        NotificationModel::update($data);
-
-        $notification = NotificationModel::getById(['notificationId' => $data['notification_id']]);
-
-        HistoryController::add([
-            'tableName' => 'notifications',
-            'recordId'  => $data['notification_sid'],
-            'eventType' => 'UP',
-            'eventId'   => 'notificationsup',
-            'info'       => _MODIFY_NOTIFICATIONS . ' : ' . $data['notification_sid']
-        ]);
-
-        return $response->withJson(['notification'=> $notification]);
-    }
-
-    public function delete(RequestInterface $request, ResponseInterface $response, $aArgs)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        NotificationModel::delete(['notification_sid' => $aArgs['id']]);
-
-        HistoryController::add([
-                'tableName' => 'notifications',
-                'recordId'  => $aArgs['id'],
-                'eventType' => 'DEL',
-                'eventId'   => 'notificationsdel',
-                'info'       => _DELETE_NOTIFICATIONS . ' : ' . $aArgs['id']
-            ]);
-
-
-        return $response->withJson([
-            'success' => _DELETED_NOTIFICATION,
-            'notifications' => NotificationModel::get(['select' => ['notification_sid', 'notification_id', 'description', 'is_enabled', 'event_id', 'notification_mode', 'template_id', 'diffusion_type']])
-        ]);
-    }
-
-    public function getNewNotificationForAdministration(RequestInterface $request, ResponseInterface $response)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $notification = [];
-        $notification['diffusion_properties'] = [];
-        $notification['attachfor_properties'] = [];
-        $data = [];
-
-        $data['event'] = NotificationModel::getEvent();
-        $data['template'] = NotificationModel::getTemplate();
-        $data['diffusionType'] = NotificationModel::getDiffusionType();
-        $data['groups'] = NotificationModel::getDiffusionTypeGroups();
-        $data['users'] = NotificationModel::getDiffusionTypesUsers();
-        $data['entities'] = NotificationModel::getDiffusionTypeEntities();
-        $data['status'] = NotificationModel::getDiffusionTypeStatus();
-
-        $notification['data'] = $data;
-
-        return $response->withJson(['notification'=>$notification]);
-    }
-
-    public function getNotificationForAdministration(RequestInterface $request, ResponseInterface $response, $aArgs)
-    {
-        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $_SESSION['user']['UserId'], 'location' => 'notifications', 'type' => 'admin'])) {
-            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
-        }
-
-        $notification = NotificationModel::getById(['notification_sid' => $aArgs['id'], 'select' => ['notification_sid', 'notification_id', 'description', 'is_enabled', 'event_id', 'notification_mode', 'template_id', 'diffusion_type','diffusion_properties', 'attachfor_type','attachfor_properties']]);
-
-        $notification['diffusion_properties'] = explode(",",$notification['diffusion_properties']);
-        
-        foreach ($notification['diffusion_properties'] as $key => $value) {
-            $notification['diffusion_properties'][$value] = $value;
-            unset($notification['diffusion_properties'][$key]);
-        }
-
-        $notification['attachfor_properties'] = explode(",",$notification['attachfor_properties']);
-        
-        foreach ($notification['attachfor_properties'] as $key => $value) {
-            $notification['attachfor_properties'][$value] = $value;
-            unset($notification['attachfor_properties'][$key]);
-        }
-        
-        if (empty($notification)) {
-                return $response->withStatus(400)->withJson(['errors' => 'Notification not found']);
-        }
-        $data = [];
-
-        $data['event'] = NotificationModel::getEvent();
-        $data['template'] = NotificationModel::getTemplate();
-        $data['diffusionType'] = NotificationModel::getDiffusionType();
-        $data['groups'] = NotificationModel::getDiffusionTypeGroups();
-        $data['users'] = NotificationModel::getDiffusionTypesUsers();
-        $data['entities'] = NotificationModel::getDiffusionTypeEntities();
-        $data['status'] = NotificationModel::getDiffusionTypeStatus();
-
-        $notification['data'] = $data;
-        
-
-        return $response->withJson(['notification'=>$notification]);
-    }
-}
\ No newline at end of file
diff --git a/modules/notifications/Models/NotificationsModel.php b/modules/notifications/Models/NotificationsModel.php
deleted file mode 100755
index 273c40a475b..00000000000
--- a/modules/notifications/Models/NotificationsModel.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-/**
-* Copyright Maarch since 2008 under licence GPLv3.
-* See LICENCE.txt file at the root folder for more details.
-* This file is part of Maarch software.
-*
-*/
-
-/**
-* @brief Notifications Model
-* @author dev@maarch.org
-* @ingroup core
-*/
-
-namespace Notifications\Models;
-
-class NotificationsModel extends NotificationsModelAbstract
-{
-    // Do your stuff in this class
-}
diff --git a/modules/notifications/Models/NotificationsModelAbstract.php b/modules/notifications/Models/NotificationsModelAbstract.php
deleted file mode 100755
index 4db4bcf4619..00000000000
--- a/modules/notifications/Models/NotificationsModelAbstract.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/**
-* Copyright Maarch since 2008 under licence GPLv3.
-* See LICENCE.txt file at the root folder for more details.
-* This file is part of Maarch software.
-*
-*/
-
-/**
-* @brief Notifications Model
-* @author dev@maarch.org
-* @ingroup core
-*/
-
-namespace Notifications\Models;
-
-use Core\Models\DatabaseModel;
-
-class NotificationsModelAbstract
-{
-    public static function getEnableNotifications()
-    {
-        $aReturn = DatabaseModel::select([
-            'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
-            'table'     => ['notifications'],
-            'where'     => ['is_enabled = ?'],
-            'data'      => ['Y']
-        ]);
-
-        return $aReturn;
-    }
-}
diff --git a/package-lock.json b/package-lock.json
index d56f962b81a..1d2e14b37f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -168,7 +168,7 @@
     "@types/jquery": {
       "version": "2.0.48",
       "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.48.tgz",
-      "integrity": "sha1-PpDYzeLSkBXlWDAX94MMs5dbLu8=",
+      "integrity": "sha512-nNLzUrVjaRV/Ds1eHZLYTd7IZxs38cwwLSaqMJj8OTXY8xNUbxSK69bi9cMLvQ7dm/IBeQ1wHwQ0S1uYa0rd2w==",
       "dev": true
     },
     "@types/node": {
diff --git a/rest/index.php b/rest/index.php
index 2d7d70a0ff5..5af34ef0d17 100755
--- a/rest/index.php
+++ b/rest/index.php
@@ -114,8 +114,6 @@ $app->get('/administration', \Core\Controllers\CoreController::class . ':getAdmi
 $app->get('/administration/users', \Core\Controllers\UserController::class . ':getUsersForAdministration');
 $app->get('/administration/users/new', \Core\Controllers\UserController::class . ':getNewUserForAdministration');
 $app->get('/administration/users/{id}', \Core\Controllers\UserController::class . ':getUserForAdministration');
-$app->get('/administration/notifications/new', \Notifications\Controllers\NotificationController::class . ':getNewNotificationForAdministration');
-$app->get('/administration/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':getNotificationForAdministration');
 
 //Baskets
 $app->get('/baskets', \Basket\controllers\BasketController::class . ':get');
@@ -241,11 +239,12 @@ $app->put('/actions/{id}', \Action\controllers\ActionController::class . ':updat
 $app->delete('/actions/{id}', \Action\controllers\ActionController::class . ':delete');
 
 //Notifications
-$app->get('/notifications', \Notifications\Controllers\NotificationController::class . ':get');
-$app->post('/notifications', \Notifications\Controllers\NotificationController::class . ':create');
-$app->get('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':getById');
-$app->put('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':update');
-$app->delete('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':delete');
+$app->get('/notifications', \Notification\controllers\NotificationController::class . ':get');
+$app->post('/notifications', \Notification\controllers\NotificationController::class . ':create');
+$app->put('/notifications/{id}', \Notification\controllers\NotificationController::class . ':update');
+$app->delete('/notifications/{id}', \Notification\controllers\NotificationController::class . ':delete');
+$app->get('/administration/notifications/new', \Notification\controllers\NotificationController::class . ':initNotification');
+$app->get('/notifications/{id}', \Notification\controllers\NotificationController::class . ':getBySid');
 
 //Reports
 $app->get('/reports/groups', \Report\controllers\ReportController::class . ':getGroups');
diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php
index db259474ac3..06d881426ca 100644
--- a/src/app/history/controllers/HistoryController.php
+++ b/src/app/history/controllers/HistoryController.php
@@ -19,6 +19,7 @@ use Core\Models\UserModel;
 use Core\Models\ServiceModel;
 use Core\Models\ValidatorModel;
 use History\models\HistoryModel;
+use Notification\controllers\NotificationsEventsController;
 use Slim\Http\Request;
 use Slim\Http\Response;
 
@@ -81,11 +82,8 @@ class HistoryController
             'eventId'   => $aArgs['eventId'],
         ]);
 
-        //TODO V2
-//        $core = new \core_tools();
-//        if ($core->is_module_loaded("notifications")) {
-//            NotificationsEventsController::fill_event_stack($event_id, $table_name, $record_id, $user, $info);
-//        }
+        NotificationsEventsController::fill_event_stack($event_id, $table_name, $record_id, $user, $info);
+
     }
 
     private static function addToLog4php(array $aArgs)
diff --git a/src/app/notification/controllers/NotificationController.php b/src/app/notification/controllers/NotificationController.php
new file mode 100644
index 00000000000..81b9366375a
--- /dev/null
+++ b/src/app/notification/controllers/NotificationController.php
@@ -0,0 +1,212 @@
+<?php
+
+/**
+* Copyright Maarch since 2008 under licence GPLv3.
+* See LICENCE.txt file at the root folder for more details.
+* This file is part of Maarch software.
+*
+*/
+
+/**
+* @brief Notifications Controller
+* @author dev@maarch.org
+* @ingroup notifications
+*/
+
+namespace Notification\controllers;
+
+use History\controllers\HistoryController;
+use Respect\Validation\Validator;
+use Notification\models\NotificationModel;
+use Core\Models\ServiceModel;
+use Slim\Http\Request;
+use Slim\Http\Response;
+
+class NotificationController
+{
+    public function get(Request $request, Response $response)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        return $response->withJson(['notifications' => NotificationModel::get()]);
+    }
+
+    public function getBySid(Request $request, Response $response, $aArgs)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $notification = NotificationModel::getById(['notification_sid' => $aArgs['id'], 'select' => ['notification_sid', 'notification_id', 'description', 'is_enabled', 'event_id', 'notification_mode', 'template_id', 'diffusion_type','diffusion_properties', 'attachfor_type','attachfor_properties']]);
+
+        $notification['diffusion_properties'] = explode(",", $notification['diffusion_properties']);
+        
+        foreach ($notification['diffusion_properties'] as $key => $value) {
+            $notification['diffusion_properties'][$value] = $value;
+            unset($notification['diffusion_properties'][$key]);
+        }
+
+        $notification['attachfor_properties'] = explode(",", $notification['attachfor_properties']);
+        
+        foreach ($notification['attachfor_properties'] as $key => $value) {
+            $notification['attachfor_properties'][$value] = $value;
+            unset($notification['attachfor_properties'][$key]);
+        }
+        
+        if (empty($notification)) {
+            return $response->withStatus(400)->withJson(['errors' => 'Notification not found']);
+        }
+        $data = [];
+
+        $data['event']         = NotificationModel::getEvent();
+        $data['template']      = NotificationModel::getTemplate();
+        $data['diffusionType'] = NotificationModel::getDiffusionType();
+        $data['groups']        = NotificationModel::getDiffusionTypeGroups();
+        $data['users']         = NotificationModel::getDiffusionTypesUsers();
+        $data['entities']      = NotificationModel::getDiffusionTypeEntities();
+        $data['status']        = NotificationModel::getDiffusionTypeStatus();
+
+        $notification['data'] = $data;
+
+        return $response->withJson(['notification'=>$notification]);
+    }
+
+    public function create(Request $request, Response $response)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $data = $request->getParams();
+        if (empty($data['notification_id'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'Notification error : notification_id is empty']);
+        }
+        $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]);
+
+        } elseif (!Validator::length(0, 254)->validate($data['description'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'Description is too long']);
+
+        } elseif (!Validator::length(0, 254)->validate($data['event_id'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'event_id is too long']);
+
+        } elseif (!Validator::length(0, 30)->validate($data['notification_mode'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'notification_mode is too long']);
+
+        } elseif (Validator::intType()->notEmpty()->validate($data['template_id'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'wrong format for template_id']);
+        }
+
+        if ($data['is_enabled'] == true) {
+            $data['is_enabled'] = 'Y';
+        } else {
+            $data['is_enabled'] = 'N';
+        }
+
+        $data['notification_mode'] = 'EMAIL';
+        
+        if ($data['diffusion_properties']) {
+            $data['diffusion_properties'] = implode(",", $data['diffusion_properties']);
+        }
+        
+        if ($data['attachfor_properties']) {
+            $data['attachfor_properties'] = implode(",", $data['attachfor_properties']);
+        } else {
+            $data['attachfor_properties'] = '';
+        }
+
+        if (NotificationModel::create($data)) {
+            HistoryController::add([
+                '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 {
+            return $response->withStatus(400)->withJson(['errors' => 'Notification Create Error']);
+        }
+
+    }
+
+    public function update(Request $request, Response $response, $aArgs)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $data = $request->getParams();
+
+        $data['notification_sid']     = $aArgs['id'];
+        $data['diffusion_properties'] = implode(",", $data['diffusion_properties']);
+        
+        $data['attachfor_properties'] = implode(",", $data['attachfor_properties']);
+
+        NotificationModel::update($data);
+
+        $notification = NotificationModel::getById(['notificationId' => $data['notification_id']]);
+
+        HistoryController::add([
+            'tableName' => 'notifications',
+            'recordId'  => $data['notification_sid'],
+            'eventType' => 'UP',
+            'eventId'   => 'notificationsup',
+            'info'      => _MODIFY_NOTIFICATIONS . ' : ' . $data['notification_sid']
+        ]);
+
+        return $response->withJson(['notification'=> $notification]);
+    }
+
+    public function delete(Request $request, Response $response, $aArgs)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        NotificationModel::delete(['notification_sid' => $aArgs['id']]);
+
+        HistoryController::add([
+                'tableName' => 'notifications',
+                'recordId'  => $aArgs['id'],
+                'eventType' => 'DEL',
+                'eventId'   => 'notificationsdel',
+                'info'      => _DELETE_NOTIFICATIONS . ' : ' . $aArgs['id']
+            ]);
+
+
+        return $response->withJson([
+            'success' => _DELETED_NOTIFICATION,
+            'notifications' => NotificationModel::get()
+        ]);
+    }
+
+    public function initNotification(Request $request, Response $response)
+    {
+        if (!ServiceModel::hasService(['id' => 'admin_notif', 'userId' => $GLOBALS['userId'], 'location' => 'notifications', 'type' => 'admin'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $notification = [];
+        $notification['diffusion_properties'] = [];
+        $notification['attachfor_properties'] = [];
+        $data = [];
+
+        $data['event']         = NotificationModel::getEvent();
+        $data['template']      = NotificationModel::getTemplate();
+        $data['diffusionType'] = NotificationModel::getDiffusionType();
+        $data['groups']        = NotificationModel::getDiffusionTypeGroups();
+        $data['users']         = NotificationModel::getDiffusionTypesUsers();
+        $data['entities']      = NotificationModel::getDiffusionTypeEntities();
+        $data['status']        = NotificationModel::getDiffusionTypeStatus();
+
+        $notification['data'] = $data;
+
+        return $response->withJson(['notification'=>$notification]);
+    }
+
+}
diff --git a/modules/notifications/Controllers/NotificationsEventsController.php b/src/app/notification/controllers/NotificationsEventsController.php
old mode 100755
new mode 100644
similarity index 92%
rename from modules/notifications/Controllers/NotificationsEventsController.php
rename to src/app/notification/controllers/NotificationsEventsController.php
index ed13c356891..d9264fe133f
--- a/modules/notifications/Controllers/NotificationsEventsController.php
+++ b/src/app/notification/controllers/NotificationsEventsController.php
@@ -13,10 +13,10 @@
 * @ingroup core
 */
 
-namespace Notifications\Controllers;
+namespace Notification\controllers;
 
-use Notifications\Models\NotificationsEventsModel;
-use Notifications\Models\NotificationsModel;
+use Notification\models\NotificationsEventsModel;
+use Notification\models\NotificationsModel;
 
 class NotificationsEventsController
 {
diff --git a/modules/notifications/Models/NotificationModel.php b/src/app/notification/models/NotificationModel.php
similarity index 91%
rename from modules/notifications/Models/NotificationModel.php
rename to src/app/notification/models/NotificationModel.php
index 65f546fba85..6cd12078f33 100644
--- a/modules/notifications/Models/NotificationModel.php
+++ b/src/app/notification/models/NotificationModel.php
@@ -13,7 +13,7 @@
 * @ingroup Module
 */
 
-namespace Notifications\Models;
+namespace Notification\models;
 
 class NotificationModel extends NotificationModelAbstract
 {
diff --git a/modules/notifications/Models/NotificationModelAbstract.php b/src/app/notification/models/NotificationModelAbstract.php
similarity index 93%
rename from modules/notifications/Models/NotificationModelAbstract.php
rename to src/app/notification/models/NotificationModelAbstract.php
index b12bfa7ce6a..1add9cfbbf7 100644
--- a/modules/notifications/Models/NotificationModelAbstract.php
+++ b/src/app/notification/models/NotificationModelAbstract.php
@@ -13,18 +13,21 @@
 * @ingroup Module
 */
 
-namespace Notifications\Models;
+namespace Notification\models;
 
 use Core\Models\DatabaseModel;
 use Core\Models\ValidatorModel;
 use Entity\models\EntityModel;
 use Status\models\StatusModel;
 use Core\Models\GroupModelAbstract;
+use SrcCore\models\CoreConfigModel;
 
 class NotificationModelAbstract 
 {
     public static function get(array $aArgs = [])
     {
+        ValidatorModel::arrayType($aArgs, ['select']);
+
         $aNotifications = DatabaseModel::select([
             'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
             'table'     => ['notifications']
@@ -136,13 +139,13 @@ class NotificationModelAbstract
         ]);
 
         //get event system
-        // $customId = CoreConfigModel::getCustomId();
+        $customId = CoreConfigModel::getCustomId();
 
-        // if (file_exists('custom/' .$customId. 'modules/notifications/xml/event_type.xml')) {
-        //     $path = 'custom/' .$customId. 'modules/notifications/xml/event_type.xml';
-        // } else {
+        if (file_exists('custom/' .$customId. 'modules/notifications/xml/event_type.xml')) {
+            $path = 'custom/' .$customId. 'modules/notifications/xml/event_type.xml';
+        } else {
             $path = 'modules/notifications/xml/event_type.xml';
-        // }
+        }
         $xmlfile = simplexml_load_file($path);
         if ($xmlfile) {
             foreach ($xmlfile->event_type as $eventType) {
@@ -325,4 +328,16 @@ class NotificationModelAbstract
         return $status;
     }
 
+    public static function getEnableNotifications()
+    {
+        $aReturn = DatabaseModel::select([
+            'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
+            'table'     => ['notifications'],
+            'where'     => ['is_enabled = ?'],
+            'data'      => ['Y']
+        ]);
+
+        return $aReturn;
+    }
+
 }
diff --git a/modules/notifications/Models/NotificationsEventsModel.php b/src/app/notification/models/NotificationsEventsModel.php
old mode 100755
new mode 100644
similarity index 91%
rename from modules/notifications/Models/NotificationsEventsModel.php
rename to src/app/notification/models/NotificationsEventsModel.php
index fc6008d2372..be53cfb3d70
--- a/modules/notifications/Models/NotificationsEventsModel.php
+++ b/src/app/notification/models/NotificationsEventsModel.php
@@ -13,7 +13,7 @@
 * @ingroup core
 */
 
-namespace Notifications\Models;
+namespace Notification\models;
 
 class NotificationsEventsModel extends NotificationsEventsModelAbstract
 {
diff --git a/modules/notifications/Models/NotificationsEventsModelAbstract.php b/src/app/notification/models/NotificationsEventsModelAbstract.php
old mode 100755
new mode 100644
similarity index 96%
rename from modules/notifications/Models/NotificationsEventsModelAbstract.php
rename to src/app/notification/models/NotificationsEventsModelAbstract.php
index e7bdc94ac2d..98ef74ba687
--- a/modules/notifications/Models/NotificationsEventsModelAbstract.php
+++ b/src/app/notification/models/NotificationsEventsModelAbstract.php
@@ -13,7 +13,7 @@
 * @ingroup core
 */
 
-namespace Notifications\Models;
+namespace Notification\models;
 
 use Core\Models\DatabaseModel;
 use Core\Models\ValidatorModel;
-- 
GitLab