Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-09-08 17:58:17 +0300
committerGitHub <noreply@github.com>2016-09-08 17:58:17 +0300
commit36c554718f1d1b1c2604f1bbf2446018e74b5c77 (patch)
tree77e880b7f855838f68457c82a27488dee7a3e1a7
parent0ffb5e075b50f434337615c8939659249533bd9f (diff)
parent407198245432ce26fd0c2f7ae6ae23be6727600a (diff)
Merge pull request #1325 from nextcloud/backport-1323-show-download-button-for-updates-atm-9
[stable9] Show an download button instead of the updater
-rw-r--r--apps/updatenotification/controller/admincontroller.php1
-rw-r--r--apps/updatenotification/js/admin.js25
-rw-r--r--apps/updatenotification/lib/updatechecker.php3
-rw-r--r--apps/updatenotification/templates/admin.php6
-rw-r--r--apps/updatenotification/tests/UpdateCheckerTest.php15
-rw-r--r--apps/updatenotification/tests/controller/AdminControllerTest.php8
-rw-r--r--config/config.sample.php2
-rw-r--r--lib/private/updater.php2
-rw-r--r--tests/lib/updater.php24
9 files changed, 36 insertions, 50 deletions
diff --git a/apps/updatenotification/controller/admincontroller.php b/apps/updatenotification/controller/admincontroller.php
index 8635b3f3e3d..55ef26c59a7 100644
--- a/apps/updatenotification/controller/admincontroller.php
+++ b/apps/updatenotification/controller/admincontroller.php
@@ -134,6 +134,7 @@ class AdminController extends Controller {
'channels' => $channels,
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
'updaterRequirementsFulfilled' => $this->isCompatibleWithUpdater(),
+ 'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
];
return new TemplateResponse($this->appName, 'admin', $params, '');
diff --git a/apps/updatenotification/js/admin.js b/apps/updatenotification/js/admin.js
index 3bc5dd21527..4332df78909 100644
--- a/apps/updatenotification/js/admin.js
+++ b/apps/updatenotification/js/admin.js
@@ -13,32 +13,7 @@
/**
* Creates a new authentication token and loads the updater URL
*/
-var loginToken = '';
$(document).ready(function(){
- $('#oca_updatenotification_button').click(function() {
- // Load the new token
- $.ajax({
- url: OC.generateUrl('/apps/updatenotification/credentials')
- }).success(function(data) {
- loginToken = data;
- $.ajax({
- url: OC.webroot+'/updater/',
- headers: {
- 'X-Updater-Auth': loginToken
- },
- method: 'POST',
- success: function(data){
- if(data !== 'false') {
- var body = $('body');
- $('head').remove();
- body.html(data);
- body.removeAttr('id');
- body.attr('id', 'body-settings');
- }
- }
- });
- });
- });
$('#release-channel').change(function() {
var newChannel = $('#release-channel').find(":selected").val();
$.post(
diff --git a/apps/updatenotification/lib/updatechecker.php b/apps/updatenotification/lib/updatechecker.php
index 32eab405a62..153a6ae4aa3 100644
--- a/apps/updatenotification/lib/updatechecker.php
+++ b/apps/updatenotification/lib/updatechecker.php
@@ -48,6 +48,9 @@ class UpdateChecker {
if(substr($data['web'], 0, 8) === 'https://') {
$result['updateLink'] = $data['web'];
}
+ if(substr($data['url'], 0, 8) === 'https://') {
+ $result['downloadLink'] = $data['url'];
+ }
return $result;
}
diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php
index 67f693ce7ea..32ad7ffd1ad 100644
--- a/apps/updatenotification/templates/admin.php
+++ b/apps/updatenotification/templates/admin.php
@@ -20,10 +20,8 @@
<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
- <?php if($updaterRequirementsFulfilled === true): ?>
- <input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
- <?php else: ?>
- <br/><?php p($l->t('At the moment only manual updates are supported on your environment. This is very likely the case because functions such as shell_exec are not available.')); ?>
+ <?php if ($_['downloadLink']): ?>
+ <a href="<?php p($_['downloadLink']); ?>" class="button"><?php p($l->t('Download now')) ?></a>
<?php endif; ?>
<?php else: ?>
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php
index e83d4c9a24d..d8818a2e60e 100644
--- a/apps/updatenotification/tests/UpdateCheckerTest.php
+++ b/apps/updatenotification/tests/UpdateCheckerTest.php
@@ -46,13 +46,14 @@ class UpdateCheckerTest extends TestCase {
->method('check')
->willReturn([
'version' => 123,
- 'versionstring' => 'ownCloud 123',
+ 'versionstring' => 'Nextcloud 123',
'web'=> 'javascript:alert(1)',
+ 'url'=> 'javascript:alert(2)',
]);
$expected = [
'updateAvailable' => true,
- 'updateVersion' => 'ownCloud 123',
+ 'updateVersion' => 'Nextcloud 123',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
@@ -63,14 +64,16 @@ class UpdateCheckerTest extends TestCase {
->method('check')
->willReturn([
'version' => 123,
- 'versionstring' => 'ownCloud 123',
- 'web'=> 'https://owncloud.org/myUrl',
+ 'versionstring' => 'Nextcloud 123',
+ 'web'=> 'https://docs.nextcloud.com/myUrl',
+ 'url'=> 'https://downloads.nextcloud.org/server',
]);
$expected = [
'updateAvailable' => true,
- 'updateVersion' => 'ownCloud 123',
- 'updateLink' => 'https://owncloud.org/myUrl',
+ 'updateVersion' => 'Nextcloud 123',
+ 'updateLink' => 'https://docs.nextcloud.com/myUrl',
+ 'downloadLink' => 'https://downloads.nextcloud.org/server',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
diff --git a/apps/updatenotification/tests/controller/AdminControllerTest.php b/apps/updatenotification/tests/controller/AdminControllerTest.php
index 18135239e9e..ef07fbc498b 100644
--- a/apps/updatenotification/tests/controller/AdminControllerTest.php
+++ b/apps/updatenotification/tests/controller/AdminControllerTest.php
@@ -127,6 +127,7 @@ class AdminControllerTest extends TestCase {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => true,
+ 'downloadLink' => '',
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
@@ -160,7 +161,10 @@ class AdminControllerTest extends TestCase {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
- ->willReturn(['updateVersion' => '8.1.2']);
+ ->willReturn([
+ 'updateVersion' => '8.1.2',
+ 'downloadLink' => 'https://downloads.nextcloud.org/server',
+ ]);
$this->adminController
->expects($this->once())
->method('isCompatibleWithUpdater')
@@ -173,6 +177,7 @@ class AdminControllerTest extends TestCase {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => false,
+ 'downloadLink' => 'https://downloads.nextcloud.org/server',
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
@@ -219,6 +224,7 @@ class AdminControllerTest extends TestCase {
'channels' => $channels,
'newVersionString' => '',
'updaterRequirementsFulfilled' => true,
+ 'downloadLink' => '',
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
diff --git a/config/config.sample.php b/config/config.sample.php
index ca020113a36..538dd9d7a6e 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -498,7 +498,7 @@ $CONFIG = array(
/**
* URL that Nextcloud should use to look for updates
*/
-'updater.server.url' => 'https://updates.nextcloud.org/server/',
+'updater.server.url' => 'https://updates.nextcloud.com/update-server/',
/**
* Release channel to use for updates
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 58d5bec7cbf..2ebc332bd56 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -144,7 +144,7 @@ class Updater extends BasicEmitter {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}
- $updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.org/server/');
+ $updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/update-server/');
$this->config->setAppValue('core', 'lastupdatedat', time());
diff --git a/tests/lib/updater.php b/tests/lib/updater.php
index 1363fb735ca..2ceb2604076 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/updater.php
@@ -222,8 +222,8 @@ class UpdaterTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
- ->with('updater.server.url', 'https://updates.nextcloud.org/server/')
- ->willReturn('https://updates.nextcloud.org/server/');
+ ->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
+ ->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
@@ -253,7 +253,7 @@ class UpdaterTest extends \Test\TestCase {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
- ->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
+ ->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());
@@ -268,8 +268,8 @@ class UpdaterTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
- ->with('updater.server.url', 'https://updates.nextcloud.org/server/')
- ->willReturn('https://updates.nextcloud.org/server/');
+ ->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
+ ->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
@@ -293,7 +293,7 @@ class UpdaterTest extends \Test\TestCase {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
- ->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
+ ->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame([], $this->updater->check());
@@ -315,8 +315,8 @@ class UpdaterTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
- ->with('updater.server.url', 'https://updates.nextcloud.org/server/')
- ->willReturn('https://updates.nextcloud.org/server/');
+ ->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
+ ->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
@@ -342,7 +342,7 @@ class UpdaterTest extends \Test\TestCase {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
- ->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
+ ->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());
@@ -359,8 +359,8 @@ class UpdaterTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
- ->with('updater.server.url', 'https://updates.nextcloud.org/server/')
- ->willReturn('https://updates.nextcloud.org/server/');
+ ->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
+ ->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
@@ -384,7 +384,7 @@ class UpdaterTest extends \Test\TestCase {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
- ->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
+ ->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());