[Pkg-owncloud-commits] [owncloud] 06/34: Set overwrite.cli.url configs on setup

David Prévot taffit at moszumanska.debian.org
Fri Oct 17 01:32:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 48a1e69f5e803d61edcd7d083fd8e794f5bf194d
Author: Joas Schilling <nickvergessen at gmx.de>
Date:   Mon Oct 13 11:18:24 2014 +0200

    Set overwrite.cli.url configs on setup
    
    Correctly use overwrite.cli.url value when generating absolute urls in CLI
    
    Fix #11500
    
    Backport and squash of the following from master, in order:
    - f0fcaff9b957f1e6c04f9bfd9b8e0eb84f78bbf8
    - 923de0afd9a7e717a5e1d25747caf4840633db25
    - a487ce76e86940c94801da6157bcf70ed4005c1f
    - bd3ebdbd135b30946fdf55b41b5e96497d0c3e4a
---
 config/config.sample.php     |  7 +++++++
 lib/private/setup.php        |  2 +-
 lib/private/urlgenerator.php | 13 +++++++------
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/config/config.sample.php b/config/config.sample.php
index ffbcbea..d86d46a 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -330,6 +330,13 @@ $CONFIG = array(
 'overwritecondaddr' => '',
 
 /**
+ * Use this configuration parameter to specify the base url for any urls which are
+ * generated within ownCloud using any kind of command line tools (cron or occ).
+ * The value should contain the full base URL: ``https://www.example.com/owncloud``
+ */
+'overwrite.cli.url' => '',
+
+/**
  * The URL of your proxy server, for example ``proxy.example.com:8081``.
  */
 'proxy' => '',
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 2747922..2ad569c 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -82,7 +82,7 @@ class OC_Setup {
 		//write the config file
 		OC_Config::setValue('trusted_domains', $trustedDomains);
 		OC_Config::setValue('datadirectory', $datadir);
-		OC_Config::setValue('overwritewebroot', OC::$WEBROOT);
+		OC_Config::setValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT);
 		OC_Config::setValue('dbtype', $dbtype);
 		OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
 		try {
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php
index af5d977..1844925 100644
--- a/lib/private/urlgenerator.php
+++ b/lib/private/urlgenerator.php
@@ -147,13 +147,14 @@ class URLGenerator implements IURLGenerator {
 	 * @return string the absolute version of the url
 	 */
 	public function getAbsoluteURL($url) {
-		$separator = $url[0] === '/' ? '' : '/';
+		$url = ($url[0] !== '/') ? '/' . $url : $url;
 
-		// The ownCloud web root can already be prepended.
-		$webRoot = substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT
-			? ''
-			: \OC::$WEBROOT;
+		if (\OC::$CLI) {
+			return $this->config->getSystemValue('overwrite.cli.url') . $url;
+		}
 
-		return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost(). $webRoot . $separator . $url;
+		// The ownCloud web root can already be prepended.
+		$webRoot = (strpos($url, \OC::$WEBROOT) === 0) ? '' : \OC::$WEBROOT;
+		return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . $webRoot . $url;
 	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list