aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/admin.php51
-rw-r--r--apps/files/appinfo/app.php2
-rw-r--r--apps/files/appinfo/info.xml6
-rw-r--r--apps/files/l10n/it.js4
-rw-r--r--apps/files/l10n/it.json4
-rw-r--r--apps/files/lib/Controller/ViewController.php12
-rw-r--r--apps/files/lib/Settings/Admin.php93
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php93
-rw-r--r--apps/files/tests/Settings/AdminTest.php83
9 files changed, 207 insertions, 141 deletions
diff --git a/apps/files/admin.php b/apps/files/admin.php
deleted file mode 100644
index ad7b16a3a23..00000000000
--- a/apps/files/admin.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Clark Tomlinson <fallen013@gmail.com>
- * @author Frank Karlitschek <frank@karlitschek.de>
- * @author Michael Göhler <somebody.here@gmx.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-$htaccessWorking=(getenv('htaccessWorking')=='true');
-$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
-$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
-$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
-if($_POST && \OC::$server->getRequest()->passesCSRFCheck()) {
- if(isset($_POST['maxUploadSize'])) {
- if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
- $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
- }
- }
-}
-
-$htaccessWritable=is_writable(OC::$SERVERROOT.'/.htaccess');
-$userIniWritable=is_writable(OC::$SERVERROOT.'/.user.ini');
-
-$tmpl = new OCP\Template( 'files', 'admin' );
-$tmpl->assign( 'uploadChangable', ($htaccessWorking and $htaccessWritable) or $userIniWritable );
-$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
-// max possible makes only sense on a 32 bit system
-$tmpl->assign( 'displayMaxPossibleUploadSize', PHP_INT_SIZE===4);
-$tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX));
-return $tmpl->fetchPage();
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php
index 850c335c27d..afb327e24ba 100644
--- a/apps/files/appinfo/app.php
+++ b/apps/files/appinfo/app.php
@@ -26,8 +26,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-\OCP\App::registerAdmin('files', 'admin');
-
$l = \OC::$server->getL10N('files');
\OC::$server->getNavigationManager()->add(function () {
diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml
index 8b26a6af711..513940f73a9 100644
--- a/apps/files/appinfo/info.xml
+++ b/apps/files/appinfo/info.xml
@@ -6,7 +6,7 @@
<licence>AGPL</licence>
<author>Robin Appelman, Vincent Petry</author>
<default_enable/>
- <version>1.6.0</version>
+ <version>1.6.1</version>
<types>
<filesystem/>
</types>
@@ -22,4 +22,8 @@
<job>OCA\Files\BackgroundJob\DeleteOrphanedItems</job>
<job>OCA\Files\BackgroundJob\CleanupFileLocks</job>
</background-jobs>
+
+ <settings>
+ <admin>OCA\Files\Settings\Admin</admin>
+ </settings>
</info>
diff --git a/apps/files/l10n/it.js b/apps/files/l10n/it.js
index 363419c3643..3865d5861a2 100644
--- a/apps/files/l10n/it.js
+++ b/apps/files/l10n/it.js
@@ -132,6 +132,8 @@ OC.L10N.register(
"No favorites" : "Nessun preferito",
"Files and folders you mark as favorite will show up here" : "I file e le cartelle che marchi come preferiti saranno mostrati qui",
"Text file" : "File di testo",
- "New text file.txt" : "Nuovo file di testo.txt"
+ "New text file.txt" : "Nuovo file di testo.txt",
+ "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Utilizza questo indirizzo per <a href=\"%s\" target=\"_blank\">accedere ai tuoi file con WebDAV</a>",
+ "Cancel upload" : "Annulla caricamento"
},
"nplurals=2; plural=(n != 1);");
diff --git a/apps/files/l10n/it.json b/apps/files/l10n/it.json
index 16571b6bd98..a37bc1d5ce7 100644
--- a/apps/files/l10n/it.json
+++ b/apps/files/l10n/it.json
@@ -130,6 +130,8 @@
"No favorites" : "Nessun preferito",
"Files and folders you mark as favorite will show up here" : "I file e le cartelle che marchi come preferiti saranno mostrati qui",
"Text file" : "File di testo",
- "New text file.txt" : "Nuovo file di testo.txt"
+ "New text file.txt" : "Nuovo file di testo.txt",
+ "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Utilizza questo indirizzo per <a href=\"%s\" target=\"_blank\">accedere ai tuoi file con WebDAV</a>",
+ "Cancel upload" : "Annulla caricamento"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
} \ No newline at end of file
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 9dbe06ff789..779a2c7aadc 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -195,18 +195,6 @@ class ViewController extends Controller {
\OCP\Util::addscript('files', 'keyboardshortcuts');
\OCP\Util::addscript('files', 'navigation');
- // if IE8 and "?dir=path&view=someview" was specified, reformat the URL to use a hash like "#?dir=path&view=someview"
- $isIE8 = $this->request->isUserAgent([Request::USER_AGENT_IE_8]);
- if ($isIE8 && ($dir !== '' || $view !== '')) {
- $dir = !empty($dir) ? $dir : '/';
- $view = !empty($view) ? $view : 'files';
- $hash = '#?dir=' . \OCP\Util::encodePath($dir);
- if ($view !== 'files') {
- $hash .= '&view=' . urlencode($view);
- }
- return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index') . $hash);
- }
-
// mostly for the home storage's free space
// FIXME: Make non static
$storageInfo = $this->getStorageInfo();
diff --git a/apps/files/lib/Settings/Admin.php b/apps/files/lib/Settings/Admin.php
new file mode 100644
index 00000000000..9ec23d47517
--- /dev/null
+++ b/apps/files/lib/Settings/Admin.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files\Settings;
+
+use bantu\IniGetWrapper\IniGetWrapper;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IRequest;
+use OCP\Settings\ISettings;
+use OCP\Util;
+
+class Admin implements ISettings {
+
+ /** @var IniGetWrapper */
+ private $iniWrapper;
+
+ /** @var IRequest */
+ private $request;
+
+ public function __construct(IniGetWrapper $iniWrapper, IRequest $request) {
+ $this->iniWrapper = $iniWrapper;
+ $this->request = $request;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $htaccessWorking = (getenv('htaccessWorking') == 'true');
+ $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess');
+ $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini');
+
+ $upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize');
+ $post_max_size = $this->iniWrapper->getBytes('post_max_size');
+ $maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size));
+ if($_POST && $this->request->passesCSRFCheck()) {
+ if(isset($_POST['maxUploadSize'])) {
+ if(($setMaxSize = \OC_Files::setUploadLimit(Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
+ $maxUploadFilesize = Util::humanFileSize($setMaxSize);
+ }
+ }
+ }
+
+ $parameters = [
+ 'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ),
+ 'uploadMaxFilesize' => $maxUploadFilesize,
+ // max possible makes only sense on a 32 bit system
+ 'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4,
+ 'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX),
+ ];
+
+ return new TemplateResponse('files', 'admin', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'additional';
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the admin section. The forms are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
+ *
+ * E.g.: 70
+ */
+ public function getPriority() {
+ return 5;
+ }
+
+}
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index 373f8c25152..12ff779d6f1 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -73,22 +73,22 @@ class ViewControllerTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->request = $this->getMock('\OCP\IRequest');
- $this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
- $this->navigationManager = $this->getMock('\OCP\INavigationManager');
- $this->l10n = $this->getMock('\OCP\IL10N');
- $this->config = $this->getMock('\OCP\IConfig');
- $this->eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->userSession = $this->getMock('\OCP\IUserSession');
- $this->appManager = $this->getMock('\OCP\App\IAppManager');
- $this->user = $this->getMock('\OCP\IUser');
+ $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
+ $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
+ $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
+ $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
+ $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->eventDispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
+ $this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')->getMock();
+ $this->user = $this->getMockBuilder('\OCP\IUser')->getMock();
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser1'));
$this->userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
- $this->rootFolder = $this->getMock('\OCP\Files\Folder');
+ $this->rootFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController')
->setConstructorArgs([
'files',
@@ -109,60 +109,7 @@ class ViewControllerTest extends TestCase {
->getMock();
}
- public function testIndexWithIE8RedirectAndDirDefined() {
- $this->request
- ->expects($this->once())
- ->method('isUserAgent')
- ->with(['/MSIE 8.0/'])
- ->will($this->returnValue(true));
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkToRoute')
- ->with('files.view.index')
- ->will($this->returnValue('/apps/files/'));
-
- $expected = new Http\RedirectResponse('/apps/files/#?dir=MyDir');
- $this->assertEquals($expected, $this->viewController->index('MyDir'));
- }
-
- public function testIndexWithIE8RedirectAndViewDefined() {
- $this->request
- ->expects($this->once())
- ->method('isUserAgent')
- ->with(['/MSIE 8.0/'])
- ->will($this->returnValue(true));
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkToRoute')
- ->with('files.view.index')
- ->will($this->returnValue('/apps/files/'));
-
- $expected = new Http\RedirectResponse('/apps/files/#?dir=/&view=MyView');
- $this->assertEquals($expected, $this->viewController->index('', 'MyView'));
- }
-
- public function testIndexWithIE8RedirectAndViewAndDirDefined() {
- $this->request
- ->expects($this->once())
- ->method('isUserAgent')
- ->with(['/MSIE 8.0/'])
- ->will($this->returnValue(true));
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkToRoute')
- ->with('files.view.index')
- ->will($this->returnValue('/apps/files/'));
-
- $expected = new RedirectResponse('/apps/files/#?dir=MyDir&view=MyView');
- $this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
- }
-
public function testIndexWithRegularBrowser() {
- $this->request
- ->expects($this->once())
- ->method('isUserAgent')
- ->with(['/MSIE 8.0/'])
- ->will($this->returnValue(false));
$this->viewController
->expects($this->once())
->method('getStorageInfo')
@@ -329,12 +276,12 @@ class ViewControllerTest extends TestCase {
* @dataProvider showFileMethodProvider
*/
public function testShowFileRouteWithFolder($useShowFile) {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$node->expects($this->once())
->method('getPath')
->will($this->returnValue('/testuser1/files/test/sub'));
- $baseFolder = $this->getMock('\OCP\Files\Folder');
+ $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('get')
@@ -368,19 +315,19 @@ class ViewControllerTest extends TestCase {
* @dataProvider showFileMethodProvider
*/
public function testShowFileRouteWithFile($useShowFile) {
- $parentNode = $this->getMock('\OCP\Files\Folder');
+ $parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$parentNode->expects($this->once())
->method('getPath')
->will($this->returnValue('testuser1/files/test'));
- $baseFolder = $this->getMock('\OCP\Files\Folder');
+ $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('get')
->with('testuser1/files/')
->will($this->returnValue($baseFolder));
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$node->expects($this->once())
->method('getParent')
->will($this->returnValue($parentNode));
@@ -415,7 +362,7 @@ class ViewControllerTest extends TestCase {
* @dataProvider showFileMethodProvider
*/
public function testShowFileRouteWithInvalidFileId($useShowFile) {
- $baseFolder = $this->getMock('\OCP\Files\Folder');
+ $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('get')
->with('testuser1/files/')
@@ -446,13 +393,13 @@ class ViewControllerTest extends TestCase {
->with('files_trashbin')
->will($this->returnValue(true));
- $parentNode = $this->getMock('\OCP\Files\Folder');
+ $parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$parentNode->expects($this->once())
->method('getPath')
->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
- $baseFolderFiles = $this->getMock('\OCP\Files\Folder');
- $baseFolderTrash = $this->getMock('\OCP\Files\Folder');
+ $baseFolderFiles = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $baseFolderTrash = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->at(0))
->method('get')
@@ -468,7 +415,7 @@ class ViewControllerTest extends TestCase {
->with(123)
->will($this->returnValue([]));
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$node->expects($this->once())
->method('getParent')
->will($this->returnValue($parentNode));
diff --git a/apps/files/tests/Settings/AdminTest.php b/apps/files/tests/Settings/AdminTest.php
new file mode 100644
index 00000000000..1ab8a992879
--- /dev/null
+++ b/apps/files/tests/Settings/AdminTest.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files\Tests\Settings;
+
+use bantu\IniGetWrapper\IniGetWrapper;
+use OCA\Files\Settings\Admin;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IRequest;
+use OCP\Util;
+use Test\TestCase;
+
+class AdminTest extends TestCase {
+ /** @var Admin */
+ private $admin;
+ /** @var IniGetWrapper */
+ private $iniGetWrapper;
+ /** @var IRequest */
+ private $request;
+
+ public function setUp() {
+ parent::setUp();
+ $this->iniGetWrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')->disableOriginalConstructor()->getMock();
+ $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
+ $this->admin = new Admin(
+ $this->iniGetWrapper,
+ $this->request
+ );
+ }
+
+ public function testGetForm() {
+ $htaccessWorking = (getenv('htaccessWorking') == 'true');
+ $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess');
+ $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini');
+
+ $this->iniGetWrapper
+ ->expects($this->at(0))
+ ->method('getBytes')
+ ->with('upload_max_filesize')
+ ->willReturn(1234);
+ $this->iniGetWrapper
+ ->expects($this->at(1))
+ ->method('getBytes')
+ ->with('post_max_size')
+ ->willReturn(1234);
+ $params = [
+ 'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ),
+ 'uploadMaxFilesize' => '1 KB',
+ 'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4,
+ 'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX),
+ ];
+ $expected = new TemplateResponse('files', 'admin', $params, '');
+ $this->assertEquals($expected, $this->admin->getForm());
+ }
+
+ public function testGetSection() {
+ $this->assertSame('additional', $this->admin->getSection());
+ }
+
+ public function testGetPriority() {
+ $this->assertSame(5, $this->admin->getPriority());
+ }
+}