From fb0eed635d10c34d6020d51ea39212846ddd352b Mon Sep 17 00:00:00 2001
From: Florian Bogner <f.bogner@pcsg.de>
Date: Mon, 5 Dec 2016 15:58:35 +0100
Subject: [PATCH] fix: Cronservice will now try to use the vhost as domain
 instead of the host in the config files

---
 src/QUI/Cron/CronService.php | 37 +++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/QUI/Cron/CronService.php b/src/QUI/Cron/CronService.php
index 0d1edc8..12a198f 100644
--- a/src/QUI/Cron/CronService.php
+++ b/src/QUI/Cron/CronService.php
@@ -14,7 +14,9 @@ class CronService
     private $https;
     private $packageDir;
 
-
+    /**
+     * CronService constructor.
+     */
     public function __construct()
     {
         $host    = QUI::$Conf->get("globals", "host");
@@ -22,18 +24,31 @@ class CronService
         $opt_dir = QUI::$Conf->get("globals", "opt_dir");
         $url_dir = QUI::$Conf->get("globals", "url_dir");
 
-        // Parse Domain and protocol
-        if (strpos($host, "https://") !== false) {
-            $this->https  = true;
-            $this->domain = str_replace("https://", "", $host);
-        } elseif (strpos($host, "http://") !== false) {
-            $this->https  = false;
-            $this->domain = str_replace("http://", "", $host);
-        } else {
-            $this->https  = false;
-            $this->domain = $host;
+        // VHost Domain
+        $vhost        = QUI::getProjectManager()->getStandard()->getVHost(true, true);
+        $this->domain = $vhost;
+
+        // Check if https should be used.
+        if (substr($vhost, 0, 8) == 'https://') {
+            $this->https = true;
         }
 
+        // Read the domain from the config file if no vhost could be detected.
+        if (empty($vhost)) {
+            // Parse Domain and protocol
+            if (strpos($host, "https://") !== false) {
+                $this->https  = true;
+                $this->domain = str_replace("https://", "", $host);
+            } elseif (strpos($host, "http://") !== false) {
+                $this->https  = false;
+                $this->domain = str_replace("http://", "", $host);
+            } else {
+                $this->https  = false;
+                $this->domain = $host;
+            }
+        }
+
+
         // Parse Package dir
         $this->packageDir = $url_dir . str_replace($cms_dir, "", $opt_dir);
     }
-- 
GitLab