diff --git a/core/Test/NotificationScheduleControllerTest.php b/core/Test/NotificationScheduleControllerTest.php index e3f3aff65a0c34fbc05bebe0336a2e5829dec781..94cc4abb03860ca8e3db501d12a8ac5509c26360 100644 --- a/core/Test/NotificationScheduleControllerTest.php +++ b/core/Test/NotificationScheduleControllerTest.php @@ -29,7 +29,7 @@ class NotificationScheduleControllerTest extends TestCase ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->createScriptNotificationRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->createScriptNotification($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); $this->assertSame("notification_sid is not a numeric", $responseBody->errors[0]); @@ -46,7 +46,7 @@ class NotificationScheduleControllerTest extends TestCase ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->createScriptNotificationRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->createScriptNotification($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); $this->assertSame(true, $responseBody); @@ -79,7 +79,7 @@ class NotificationScheduleControllerTest extends TestCase array_push($aArgs, $newCrontab); $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->saveCrontabRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->create($fullRequest, new \Slim\Http\Response()); $responseBodyFail = json_decode((string)$response->getBody()); $this->assertSame("dom is empty", $responseBodyFail->errors[0]); @@ -104,7 +104,7 @@ class NotificationScheduleControllerTest extends TestCase array_push($aArgs, $newCrontab); $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->saveCrontabRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->create($fullRequest, new \Slim\Http\Response()); $responseBodyCreate = json_decode((string)$response->getBody()); $this->assertSame(true, $responseBodyCreate); @@ -155,7 +155,7 @@ class NotificationScheduleControllerTest extends TestCase $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->saveCrontabRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); $this->assertSame(true, $responseBody); @@ -194,7 +194,7 @@ class NotificationScheduleControllerTest extends TestCase $request = \Slim\Http\Request::createFromEnvironment($environment); $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->saveCrontabRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->create($fullRequest, new \Slim\Http\Response()); $responseBodyFail = json_decode((string)$response->getBody()); $this->assertSame("Problem with crontab", $responseBodyFail->errors); @@ -211,7 +211,7 @@ class NotificationScheduleControllerTest extends TestCase $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $NotificationScheduleController->saveCrontabRest($fullRequest, new \Slim\Http\Response()); + $response = $NotificationScheduleController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); $this->assertSame(true, $responseBody); diff --git a/rest/index.php b/rest/index.php index 1a954979c1a374d679d26412166d9a4ec7805041..9b9edb0faa9008541bfb3494487fb2d5468c152c 100755 --- a/rest/index.php +++ b/rest/index.php @@ -248,6 +248,10 @@ $app->delete('/notifications/{id}', \Notification\controllers\NotificationContro $app->get('/administration/notifications/new', \Notification\controllers\NotificationController::class . ':initNotification'); $app->get('/notifications/{id}', \Notification\controllers\NotificationController::class . ':getBySid'); +$app->get('/notificationsSchedule', \Notification\controllers\NotificationScheduleController::class . ':get'); +$app->post('/notificationsSchedule', \Notification\controllers\NotificationScheduleController::class . ':create'); +$app->post('/scriptNotification', \Notification\controllers\NotificationScheduleController::class . ':createScriptNotification'); + //Reports $app->get('/reports/groups', \Report\controllers\ReportController::class . ':getGroups'); $app->get('/reports/groups/{groupId}', \Report\controllers\ReportController::class . ':getByGroupId'); diff --git a/src/app/notification/controllers/NotificationController.php b/src/app/notification/controllers/NotificationController.php index c4069a96c8b41422d8604acbe8c6dd69b24df3fb..045fc6bff242526db58646813c90a28aaf973978 100644 --- a/src/app/notification/controllers/NotificationController.php +++ b/src/app/notification/controllers/NotificationController.php @@ -18,6 +18,7 @@ namespace Notification\controllers; use History\controllers\HistoryController; use Respect\Validation\Validator; use Notification\models\NotificationModel; +use Notification\models\NotificationScheduleModel; use Core\Models\ServiceModel; use Slim\Http\Request; use Slim\Http\Response; @@ -120,7 +121,7 @@ class NotificationController if (NotificationModel::create($data)) { if (PHP_OS == "Linux") { $notificationAdded = NotificationModel::getByNotificationId(['notificationId' => $data['notification_id'], 'select' => ['notification_sid']]); - NotificationScheduleController::createScriptNotification($notificationAdded['notification_sid'], $data['notification_id']); + NotificationScheduleModel::createScriptNotification(['notification_sid' => $notificationAdded['notification_sid'], 'notification_id' => $data['notification_id']]); } HistoryController::add([ @@ -160,7 +161,7 @@ class NotificationController $notification = NotificationModel::getById(['notification_sid' => $data['notification_sid']]); if (PHP_OS == "Linux") { - NotificationScheduleController::createScriptNotification($data['notification_sid'], $notification['notification_id']); + NotificationScheduleModel::createScriptNotification(['notification_sid' => $data['notification_sid'], 'notification_id' => $notification['notification_id']]); } HistoryController::add([ @@ -206,7 +207,7 @@ class NotificationController } $filename.="_".$aArgs['id'].".sh"; - $cronTab = NotificationScheduleController::getCrontab(); + $cronTab = NotificationScheduleModel::getCrontab(); $flagCron = false; @@ -226,7 +227,7 @@ class NotificationController } if ($flagCron) { - NotificationScheduleController::saveCrontab($cronTab); + NotificationScheduleModel::saveCrontab($cronTab); } unlink($pathToFolow . 'modules/notifications/batch/scripts/' . $filename); diff --git a/src/app/notification/controllers/NotificationScheduleController.php b/src/app/notification/controllers/NotificationScheduleController.php index e12d6ed5cb4f72afddd666bd6ebb7fc02b113355..e7299298e468758de247269b9cc8518b4eb89c95 100644 --- a/src/app/notification/controllers/NotificationScheduleController.php +++ b/src/app/notification/controllers/NotificationScheduleController.php @@ -15,9 +15,9 @@ namespace Notification\controllers; -use History\controllers\HistoryController; use Respect\Validation\Validator; use Notification\models\NotificationModel; +use Notification\models\NotificationScheduleModel; use Core\Models\ServiceModel; use Slim\Http\Request; use Slim\Http\Response; @@ -32,19 +32,20 @@ class NotificationScheduleController } return $response->withJson([ - 'crontab' => self::getCrontab(), - 'authorizedNotification' => self::getAuthorizedNotifications(), + 'crontab' => NotificationScheduleModel::getCrontab(), + 'authorizedNotification' => NotificationScheduleController::getAuthorizedNotifications(), ]); } - public function saveCrontabRest(Request $request, Response $response) + // Save Crontab + 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 (!self::checkCrontab($data)) { + if (!NotificationScheduleController::checkCrontab($data)) { return $response->withStatus(500)->withJson(['errors' => 'Problem with crontab']); } @@ -62,97 +63,11 @@ class NotificationScheduleController return $response->withStatus(500)->withJson(['errors' => $errors]); } - self::saveCrontab($data); + NotificationScheduleModel::saveCrontab(["crontab" => $data]); return $response->withJson(true); } - public static function saveCrontab($data) - { - $aCrontab = self::getCrontab(false); - - $file = []; - foreach ($data as $id => $cronValue) { - if ($cronValue['state'] == 'hidden') { - $file[$id] = "{$aCrontab[$id]['m']}\t{$aCrontab[$id]['h']}\t{$aCrontab[$id]['dom']}\t{$aCrontab[$id]['mon']}\t{$aCrontab[$id]['dow']}\t{$aCrontab[$id]['cmd']}"; - } elseif ($cronValue['state'] != 'deleted') { - $file[$id] = "{$cronValue['m']}\t{$cronValue['h']}\t{$cronValue['dom']}\t{$cronValue['mon']}\t{$cronValue['dow']}\t{$cronValue['cmd']}"; - } - } - - $output = ''; - - if (isset($file)) { - foreach ($file as $l) { - $output .= "$l\n"; - } - } - - $output = preg_replace("!\n+$!", "\n", $output); - file_put_contents('/tmp/crontab.plain', print_r($file, true)); - file_put_contents('/tmp/crontab.txt', $output); - - exec('crontab /tmp/crontab.txt'); - - HistoryController::add([ - 'tableName' => 'notifications', - 'recordId' => $GLOBALS['userId'], - 'eventType' => 'UP', - 'eventId' => 'notificationadd', - 'info' => _NOTIFICATION_SCHEDULE_UPDATED - ]); - - return true; - } - - public static function getCrontab($getHiddenValue = true) - { - $crontab = shell_exec('crontab -l'); - $lines = explode("\n", $crontab); - $data = array(); - $customId = CoreConfigModel::getCustomId(); - $corePath = dirname(__FILE__, 5) . '/'; - - foreach ($lines as $cronLine) { - $cronLine = trim($cronLine); - if (strpos($cronLine, '#') !== false) { - $cronLine = substr($cronLine, 0, strpos($cronLine, '#')); - } - if (empty($cronLine)) { - continue; - } - $cronLine = preg_replace('![ \t]+!', ' ', $cronLine); - if ($cronLine[0] == '@') { - list($time, $cmd) = explode(' ', $cronLine, 2); - } else { - list($m, $h, $dom, $mon, $dow, $cmd) = explode(' ', $cronLine, 6); - } - - if ($customId <> '') { - $pathToFolow = $corePath . 'custom/'.$customId . '/'; - } else { - $pathToFolow = $corePath; - } - - $state = "normal"; - if (strpos($cmd, $pathToFolow.'modules/notifications/batch/scripts/') !== 0 && $getHiddenValue) { - $cmd = "hidden"; - $state = 'hidden'; - } - - $data[] = array( - 'm' => $m, - 'h' => $h, - 'dom' => $dom, - 'mon' => $mon, - 'dow' => $dow, - 'cmd' => $cmd, - 'state' => $state - ); - } - return $data; - } - protected static function getAuthorizedNotifications() { $aNotification = NotificationModel::getEnableNotifications(['select' => ['notification_sid', 'description']]); @@ -186,7 +101,7 @@ class NotificationScheduleController protected static function checkCrontab($crontabToSave) { $customId = CoreConfigModel::getCustomId(); - $crontabBeforeSave = self::getCrontab(); + $crontabBeforeSave = NotificationScheduleModel::getCrontab(); $corePath = dirname(__FILE__, 5) . '/'; foreach ($crontabToSave as $id => $cronValue) { if ($cronValue['state'] != "hidden" && $crontabBeforeSave[$id]['state'] == "hidden") { @@ -214,7 +129,7 @@ class NotificationScheduleController return $returnValue; } - public function createScriptNotificationRest(Request $request, Response $response) + public function createScriptNotification(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']); @@ -239,76 +154,9 @@ class NotificationScheduleController $notification_sid = $data['notification_sid']; $notification_id = $data['notification_id']; - self::createScriptNotification($notification_sid, $notification_id); + NotificationScheduleModel::createScriptNotification(['notification_sid' => $notification_sid, 'notification_id' => $notification_id]); return $response->withJson(true); } - public static function createScriptNotification($notification_sid, $notification_id) - { - - //Creer le script sh pour les notifications - $filename = "notification"; - $customId = CoreConfigModel::getCustomId(); - if (isset($customId) && $customId<>"") { - $filename.="_".str_replace(" ", "", $customId); - } - $filename.="_".$notification_sid.".sh"; - - $corePath = dirname(__FILE__, 5) . '/'; - - if (file_exists($corePath. 'custom/'.$customId .'/modules/notifications/batch/config/config.xml')) { - $ConfigNotif = $corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config.xml'; - } elseif (file_exists($corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config_'.$customId.'.xml')) { - $ConfigNotif = $corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config_'.$customId.'.xml'; - } elseif (file_exists($corePath. 'modules/notifications/batch/config/config_'.$customId.'.xml')) { - $ConfigNotif = $corePath. 'modules/notifications/batch/config/config_'.$customId.'.xml'; - } else { - $ConfigNotif = $corePath. 'modules/notifications/batch/config/config.xml'; - } - - if ($customId <> '') { - $pathToFolow = $corePath . 'custom/'.$customId . '/'; - if (!file_exists($pathToFolow.'modules/notifications/batch/scripts/')) { - mkdir($pathToFolow.'modules/notifications/batch/scripts/', 0777, true); - } - $file_open = fopen($pathToFolow.'modules/notifications/batch/scripts/'.$filename, 'w+'); - } else { - $pathToFolow = $corePath; - $file_open = fopen($pathToFolow.'modules/notifications/batch/scripts/'.$filename, 'w+'); - } - - fwrite($file_open, '#!/bin/sh'); - fwrite($file_open, "\n"); - fwrite($file_open, 'path=\''.$corePath.'modules/notifications/batch/\''); - fwrite($file_open, "\n"); - fwrite($file_open, 'cd $path'); - fwrite($file_open, "\n"); - if ($notification_id == 'BASKETS') { - fwrite($file_open, 'php \'basket_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); - } elseif ($notification_id == 'RELANCE1' || $notification_id == 'RELANCE2' || $notification_id == 'RET1' || $notification_id == 'RET2') { - fwrite($file_open, 'php \'stack_letterbox_alerts.php\' -c '.$ConfigNotif); - fwrite($file_open, "\n"); - fwrite($file_open, 'php \'process_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); - } else { - fwrite($file_open, 'php \'process_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); - } - fwrite($file_open, "\n"); - fwrite($file_open, 'cd $path'); - fwrite($file_open, "\n"); - fwrite($file_open, 'php \'process_email_stack.php\' -c '.$ConfigNotif); - fwrite($file_open, "\n"); - 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 true; - } } diff --git a/src/app/notification/models/NotificationModelAbstract.php b/src/app/notification/models/NotificationModelAbstract.php index c29bd75913b71f586c718c3fa0eae0f5366dec5f..cee3d20eb08bc2dec49de352d3b7d969eb501e02 100644 --- a/src/app/notification/models/NotificationModelAbstract.php +++ b/src/app/notification/models/NotificationModelAbstract.php @@ -328,7 +328,7 @@ class NotificationModelAbstract return $status; } - public static function getEnableNotifications() + public static function getEnableNotifications(array $aArgs = []) { $aReturn = DatabaseModel::select([ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], diff --git a/src/app/notification/models/NotificationScheduleModel.php b/src/app/notification/models/NotificationScheduleModel.php new file mode 100644 index 0000000000000000000000000000000000000000..6b05d364127f3bdfebbcff7c67e6f0380003ec37 --- /dev/null +++ b/src/app/notification/models/NotificationScheduleModel.php @@ -0,0 +1,21 @@ +<?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 Schedule Model +* @author dev@maarch.org +* @ingroup Module +*/ + +namespace Notification\models; + +class NotificationScheduleModel extends NotificationScheduleModelAbstract +{ + // Do your stuff in this class +} diff --git a/src/app/notification/models/NotificationScheduleModelAbstract.php b/src/app/notification/models/NotificationScheduleModelAbstract.php new file mode 100644 index 0000000000000000000000000000000000000000..bac131403c7f585dcf1f72db863ee6105ba4246b --- /dev/null +++ b/src/app/notification/models/NotificationScheduleModelAbstract.php @@ -0,0 +1,186 @@ +<?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 Module +*/ + +namespace Notification\models; + +use Core\Models\ValidatorModel; +use SrcCore\models\CoreConfigModel; +use History\controllers\HistoryController; + +class NotificationScheduleModelAbstract +{ + public static function saveCrontab(array $aArgs = []) + { + $aCrontab = NotificationScheduleModel::getCrontab(['setHiddenValue' => false]); + + $file = []; + foreach ($aArgs['crontab'] as $id => $cronValue) { + if ($cronValue['state'] == 'hidden') { + $file[$id] = "{$aCrontab[$id]['m']}\t{$aCrontab[$id]['h']}\t{$aCrontab[$id]['dom']}\t{$aCrontab[$id]['mon']}\t{$aCrontab[$id]['dow']}\t{$aCrontab[$id]['cmd']}"; + } elseif ($cronValue['state'] != 'deleted') { + $file[$id] = "{$cronValue['m']}\t{$cronValue['h']}\t{$cronValue['dom']}\t{$cronValue['mon']}\t{$cronValue['dow']}\t{$cronValue['cmd']}"; + } + } + + $output = ''; + + if (isset($file)) { + foreach ($file as $l) { + $output .= "$l\n"; + } + } + + $output = preg_replace("!\n+$!", "\n", $output); + file_put_contents('/tmp/crontab.plain', print_r($file, true)); + file_put_contents('/tmp/crontab.txt', $output); + + exec('crontab /tmp/crontab.txt'); + + HistoryController::add([ + 'tableName' => 'notifications', + 'recordId' => $GLOBALS['userId'], + 'eventType' => 'UP', + 'eventId' => 'notificationadd', + 'info' => _NOTIFICATION_SCHEDULE_UPDATED + ]); + + return true; + } + + public static function getCrontab(array $aArgs = []) + { + if (!isset($aArgs["setHiddenValue"])) { + $aArgs["setHiddenValue"] = true; + } + + $crontab = shell_exec('crontab -l'); + $lines = explode("\n", $crontab); + $data = array(); + $customId = CoreConfigModel::getCustomId(); + $corePath = dirname(__FILE__, 5) . '/'; + + foreach ($lines as $cronLine) { + $cronLine = trim($cronLine); + if (strpos($cronLine, '#') !== false) { + $cronLine = substr($cronLine, 0, strpos($cronLine, '#')); + } + if (empty($cronLine)) { + continue; + } + $cronLine = preg_replace('![ \t]+!', ' ', $cronLine); + if ($cronLine[0] == '@') { + list($time, $cmd) = explode(' ', $cronLine, 2); + } else { + list($m, $h, $dom, $mon, $dow, $cmd) = explode(' ', $cronLine, 6); + } + + if ($customId <> '') { + $pathToFolow = $corePath . 'custom/'.$customId . '/'; + } else { + $pathToFolow = $corePath; + } + + $state = "normal"; + if (strpos($cmd, $pathToFolow.'modules/notifications/batch/scripts/') !== 0 && $aArgs["setHiddenValue"]) { + $cmd = "hidden"; + $state = 'hidden'; + } + + $data[] = array( + 'm' => $m, + 'h' => $h, + 'dom' => $dom, + 'mon' => $mon, + 'dow' => $dow, + 'cmd' => $cmd, + 'state' => $state + ); + } + return $data; + } + + public static function createScriptNotification(array $aArgs = []) + { + ValidatorModel::notEmpty($aArgs, ['notification_sid', 'notification_id']); + ValidatorModel::intVal($aArgs, ['notification_sid']); + + $notification_sid = $aArgs['notification_sid']; + $notification_id = $aArgs['notification_id']; + + //Creer le script sh pour les notifications + $filename = "notification"; + $customId = CoreConfigModel::getCustomId(); + if (isset($customId) && $customId<>"") { + $filename.="_".str_replace(" ", "", $customId); + } + $filename.="_".$notification_sid.".sh"; + + $corePath = dirname(__FILE__, 5) . '/'; + + if (file_exists($corePath. 'custom/'.$customId .'/modules/notifications/batch/config/config.xml')) { + $ConfigNotif = $corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config.xml'; + } elseif (file_exists($corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config_'.$customId.'.xml')) { + $ConfigNotif = $corePath. 'custom/'. $customId .'/modules/notifications/batch/config/config_'.$customId.'.xml'; + } elseif (file_exists($corePath. 'modules/notifications/batch/config/config_'.$customId.'.xml')) { + $ConfigNotif = $corePath. 'modules/notifications/batch/config/config_'.$customId.'.xml'; + } else { + $ConfigNotif = $corePath. 'modules/notifications/batch/config/config.xml'; + } + + if ($customId <> '') { + $pathToFolow = $corePath . 'custom/'.$customId . '/'; + if (!file_exists($pathToFolow.'modules/notifications/batch/scripts/')) { + mkdir($pathToFolow.'modules/notifications/batch/scripts/', 0777, true); + } + $file_open = fopen($pathToFolow.'modules/notifications/batch/scripts/'.$filename, 'w+'); + } else { + $pathToFolow = $corePath; + $file_open = fopen($pathToFolow.'modules/notifications/batch/scripts/'.$filename, 'w+'); + } + + fwrite($file_open, '#!/bin/sh'); + fwrite($file_open, "\n"); + fwrite($file_open, 'path=\''.$corePath.'modules/notifications/batch/\''); + fwrite($file_open, "\n"); + fwrite($file_open, 'cd $path'); + fwrite($file_open, "\n"); + if ($notification_id == 'BASKETS') { + fwrite($file_open, 'php \'basket_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); + } elseif ($notification_id == 'RELANCE1' || $notification_id == 'RELANCE2' || $notification_id == 'RET1' || $notification_id == 'RET2') { + fwrite($file_open, 'php \'stack_letterbox_alerts.php\' -c '.$ConfigNotif); + fwrite($file_open, "\n"); + fwrite($file_open, 'php \'process_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); + } else { + fwrite($file_open, 'php \'process_event_stack.php\' -c '.$ConfigNotif.' -n '.$notification_id); + } + fwrite($file_open, "\n"); + fwrite($file_open, 'cd $path'); + fwrite($file_open, "\n"); + fwrite($file_open, 'php \'process_email_stack.php\' -c '.$ConfigNotif); + fwrite($file_open, "\n"); + 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 true; + } +}