From 422316699b34f197a18d77a720fa761e860775cb Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Wed, 11 Dec 2019 11:02:55 +0100
Subject: [PATCH] FIX #12391 TIME 1 create baskets.sh script in install

---
 install/class/Class_Install.php | 55 +++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/install/class/Class_Install.php b/install/class/Class_Install.php
index 04c1646b5ae..cf086ddbbd5 100755
--- a/install/class/Class_Install.php
+++ b/install/class/Class_Install.php
@@ -561,6 +561,11 @@ class Install extends functions
             exit;
         }
 
+        if (!$this->setScriptNotificationBasketsSh()) {
+            return false;
+            exit;
+        }
+
         if (!$this->setConfig_LDAP()) {
             return false;
             exit;
@@ -648,6 +653,11 @@ class Install extends functions
             exit;
         }
 
+        if (!$this->setScriptNotificationBasketsSh()) {
+            return false;
+            exit;
+        }
+
         if (!$this->setConfig_LDAP()) {
             return false;
             exit;
@@ -954,6 +964,51 @@ class Install extends functions
         }
     }
 
+    private function setScriptNotificationBasketsSh()
+    {
+        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+            $res = 'cd '.realpath('.')."\modules\\notifications\\";
+            $res .= "\n";
+            $res .= '"'.realpath('.').'\..\..\php\php.exe" '.realpath('.').'\modules\\notifications\batch\basket_event_stack.php -c '.realpath('.')."\custom/cs_".$_SESSION['config']['databasename'].'\modules\\notifications\batch\config\config.xml\ -n BASKETS';
+            $res .= "\n";
+
+            $fp = @fopen(realpath('.').'/custom/cs_'.$_SESSION['config']['databasename'].'/modules/notifications/batch/scripts/BASKETS.bat', 'w+');
+            if (!$fp) {
+                return false;
+                exit;
+            }
+            $write = fwrite($fp, $res);
+            if (!$write) {
+                return false;
+                exit;
+            }
+
+            return true;
+        } elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'LIN') {
+            $res = '#!/bin/bash';
+            $res .= "\n";
+            $res .= "eventStackPath='".realpath('.')."/modules/notifications/batch/basket_event_stack.php'";
+            $res .= "\n";
+            $res .= 'cd '.realpath('.').'/modules/notifications/batch/';
+            $res .= "\n";
+            $res .= 'php $eventStackPath -c '.realpath('.').'/custom/cs_'.$_SESSION['config']['databasename'].'/modules/notifications/batch/config/config.xml -n BASKETS';
+            $res .= "\n";
+
+            $fp = @fopen(realpath('.').'/custom/cs_'.$_SESSION['config']['databasename'].'/modules/notifications/batch/scripts/BASKETS.sh', 'w+');
+            if (!$fp) {
+                return false;
+                exit;
+            }
+            $write = fwrite($fp, $res);
+            if (!$write) {
+                return false;
+                exit;
+            }
+
+            return true;
+        }
+    }
+
     private function setScriptNotificationSendmailSh()
     {
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
-- 
GitLab