diff options
Diffstat (limited to 'apps')
160 files changed, 3039 insertions, 1548 deletions
diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php index 9e515cdc687..961532daf50 100644 --- a/apps/dav/lib/connector/sabre/file.php +++ b/apps/dav/lib/connector/sabre/file.php @@ -349,6 +349,7 @@ class File extends Node implements IFile { if (empty($info)) { throw new NotImplemented('Invalid chunk name'); } + $chunk_handler = new \OC_FileChunking($info); $bytesWritten = $chunk_handler->store($info['index'], $data); @@ -376,15 +377,17 @@ class File extends Node implements IFile { $exists = $this->fileView->file_exists($targetPath); try { - $this->emitPreHooks($exists, $targetPath); + $this->fileView->lockFile($targetPath, ILockingProvider::LOCK_SHARED); - $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); + $this->emitPreHooks($exists, $targetPath); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_EXCLUSIVE); + /** @var \OC\Files\Storage\Storage $targetStorage */ + list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath); if ($needsPartFile) { // we first assembly the target file as a part file $partFile = $path . '/' . $info['name'] . '.ocTransferId' . $info['transferid'] . '.part'; - - + /** @var \OC\Files\Storage\Storage $targetStorage */ list($partStorage, $partInternalPath) = $this->fileView->resolvePath($partFile); @@ -392,8 +395,7 @@ class File extends Node implements IFile { // here is the final atomic rename $renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath); - - $fileExists = $this->fileView->file_exists($targetPath); + $fileExists = $targetStorage->file_exists($targetInternalPath); if ($renameOkay === false || $fileExists === false) { \OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::rename() failed', \OCP\Util::ERROR); // only delete if an error occurred and the target file was already created @@ -403,7 +405,7 @@ class File extends Node implements IFile { $partFile = null; $targetStorage->unlink($targetInternalPath); } - $this->changeLock(ILockingProvider::LOCK_SHARED); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED); throw new Exception('Could not rename part file assembled from chunks'); } } else { @@ -419,7 +421,7 @@ class File extends Node implements IFile { } } - $this->changeLock(ILockingProvider::LOCK_SHARED); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED); // since we skipped the view we need to scan and emit the hooks ourselves $this->fileView->getUpdater()->update($targetPath); @@ -427,6 +429,9 @@ class File extends Node implements IFile { $this->emitPostHooks($exists, $targetPath); $info = $this->fileView->getFileInfo($targetPath); + + $this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED); + return $info->getEtag(); } catch (\Exception $e) { if ($partFile !== null) { diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php index c9fc78a795f..61b5360cac1 100644 --- a/apps/dav/lib/connector/sabre/filesplugin.php +++ b/apps/dav/lib/connector/sabre/filesplugin.php @@ -132,6 +132,10 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { if ($sourceDir !== $destinationDir) { $sourceFileInfo = $this->fileView->getFileInfo($source); + if ($sourceFileInfo === false) { + throw new \Sabre\DAV\Exception\NotFound($source . ' does not exist'); + } + if (!$sourceFileInfo->isDeletable()) { throw new \Sabre\DAV\Exception\Forbidden($source . " cannot be deleted"); } diff --git a/apps/dav/lib/connector/sabre/lockplugin.php b/apps/dav/lib/connector/sabre/lockplugin.php index c564e066f8e..5840e59854c 100644 --- a/apps/dav/lib/connector/sabre/lockplugin.php +++ b/apps/dav/lib/connector/sabre/lockplugin.php @@ -62,7 +62,7 @@ class LockPlugin extends ServerPlugin { public function getLock(RequestInterface $request) { // we cant listen on 'beforeMethod:PUT' due to order of operations with setting up the tree // so instead we limit ourselves to the PUT method manually - if ($request->getMethod() !== 'PUT') { + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { return; } try { @@ -80,7 +80,7 @@ class LockPlugin extends ServerPlugin { } public function releaseLock(RequestInterface $request) { - if ($request->getMethod() !== 'PUT') { + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { return; } try { diff --git a/apps/dav/lib/rootcollection.php b/apps/dav/lib/rootcollection.php index 62ec3219caa..7de2c2aabe3 100644 --- a/apps/dav/lib/rootcollection.php +++ b/apps/dav/lib/rootcollection.php @@ -9,14 +9,19 @@ use Sabre\DAV\SimpleCollection; class RootCollection extends SimpleCollection { public function __construct() { + $config = \OC::$server->getConfig(); $principalBackend = new Principal( - \OC::$server->getConfig(), + $config, \OC::$server->getUserManager() ); + // as soon as debug mode is enabled we allow listing of principals + $disableListing = !$config->getSystemValue('debug', false); + + // setup the first level of the dav tree $principalCollection = new Collection($principalBackend); - $principalCollection->disableListing = true; + $principalCollection->disableListing = $disableListing; $filesCollection = new Files\RootCollection($principalBackend); - $filesCollection->disableListing = true; + $filesCollection->disableListing = $disableListing; $children = [ $principalCollection, diff --git a/apps/dav/tests/travis/litmus-v1.sh b/apps/dav/tests/travis/litmus-v1.sh new file mode 100644 index 00000000000..ab0690f392e --- /dev/null +++ b/apps/dav/tests/travis/litmus-v1.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +SCRIPT=`realpath $0` +SCRIPTPATH=`dirname $SCRIPT` + + +# start the server +php -S 127.0.0.1:8888 -t "$SCRIPTPATH/../../../.." & + + +# compile litmus +if [ ! -f /tmp/litmus/litmus-0.13.tar.gz ]; then + mkdir -p /tmp/litmus + wget -O /tmp/litmus/litmus-0.13.tar.gz http://www.webdav.org/neon/litmus/litmus-0.13.tar.gz + cd /tmp/litmus + tar -xzf litmus-0.13.tar.gz + cd /tmp/litmus/litmus-0.13 + ./configure + make +fi + +# run the tests +cd /tmp/litmus/litmus-0.13 +make URL=http://127.0.0.1:8888/remote.php/webdav CREDS="admin admin" TESTS="basic copymove props locks" check diff --git a/apps/dav/tests/travis/litmus-v2.sh b/apps/dav/tests/travis/litmus-v2.sh new file mode 100644 index 00000000000..892ad327d3b --- /dev/null +++ b/apps/dav/tests/travis/litmus-v2.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +SCRIPT=`realpath $0` +SCRIPTPATH=`dirname $SCRIPT` + + +# start the server +php -S 127.0.0.1:8888 -t "$SCRIPTPATH/../../../.." & + + +# compile litmus +if [ ! -f /tmp/litmus/litmus-0.13.tar.gz ]; then + mkdir -p /tmp/litmus + wget -O /tmp/litmus/litmus-0.13.tar.gz http://www.webdav.org/neon/litmus/litmus-0.13.tar.gz + cd /tmp/litmus + tar -xzf litmus-0.13.tar.gz + cd /tmp/litmus/litmus-0.13 + ./configure + make +fi + +# run the tests +cd /tmp/litmus/litmus-0.13 +make URL=http://127.0.0.1:8888/remote.php/dav/files/admin CREDS="admin admin" TESTS="basic copymove props locks" check diff --git a/apps/dav/tests/unit/connector/sabre/file.php b/apps/dav/tests/unit/connector/sabre/file.php index 9171fc3b786..d874b7f33c2 100644 --- a/apps/dav/tests/unit/connector/sabre/file.php +++ b/apps/dav/tests/unit/connector/sabre/file.php @@ -200,7 +200,9 @@ class File extends \Test\TestCase { $file = new \OCA\DAV\Connector\Sabre\File($view, $info); // put first chunk + $file->acquireLock(ILockingProvider::LOCK_SHARED); $this->assertNull($file->put('test data one')); + $file->releaseLock(ILockingProvider::LOCK_SHARED); $info = new \OC\Files\FileInfo('/test.txt-chunking-12345-2-1', null, null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL @@ -443,12 +445,12 @@ class File extends \Test\TestCase { $thrown = false; try { // beforeMethod locks - $view->lockFile('/test.txt', ILockingProvider::LOCK_SHARED); + $file->acquireLock(ILockingProvider::LOCK_SHARED); $file->put($this->getStream('test data')); // afterMethod unlocks - $view->unlockFile('/test.txt', ILockingProvider::LOCK_SHARED); + $file->releaseLock(ILockingProvider::LOCK_SHARED); } catch (\Sabre\DAV\Exception\BadRequest $e) { $thrown = true; } @@ -505,7 +507,9 @@ class File extends \Test\TestCase { 'permissions' => \OCP\Constants::PERMISSION_ALL ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); + $file->acquireLock(ILockingProvider::LOCK_SHARED); $this->assertNull($file->put('test data one')); + $file->releaseLock(ILockingProvider::LOCK_SHARED); $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt-chunking-12345-2-1', null, null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL @@ -515,7 +519,9 @@ class File extends \Test\TestCase { // action $thrown = false; try { + $file->acquireLock(ILockingProvider::LOCK_SHARED); $file->put($this->getStream('test data')); + $file->releaseLock(ILockingProvider::LOCK_SHARED); } catch (\OCA\DAV\Connector\Sabre\Exception\FileLocked $e) { $thrown = true; } diff --git a/apps/dav/tests/unit/connector/sabre/filesplugin.php b/apps/dav/tests/unit/connector/sabre/filesplugin.php index a91ca7a4ff7..db3bbabefd0 100644 --- a/apps/dav/tests/unit/connector/sabre/filesplugin.php +++ b/apps/dav/tests/unit/connector/sabre/filesplugin.php @@ -251,4 +251,17 @@ class FilesPlugin extends \Test\TestCase { $this->plugin->checkMove('FolderA/test.txt', 'test.txt'); } + + /** + * @expectedException \Sabre\DAV\Exception\NotFound + * @expectedExceptionMessage FolderA/test.txt does not exist + */ + public function testMoveSrcNotExist() { + $this->view->expects($this->once()) + ->method('getFileInfo') + ->with('FolderA/test.txt') + ->willReturn(false); + + $this->plugin->checkMove('FolderA/test.txt', 'test.txt'); + } } diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php b/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php index 9a067f230a3..a2a8326f4ff 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php @@ -8,7 +8,9 @@ namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; -use OC\AppFramework\Http; +use OC\Connector\Sabre\Exception\FileLocked; +use OCP\AppFramework\Http; +use OCP\Lock\ILockingProvider; class UploadTest extends RequestTest { public function testBasicUpload() { @@ -43,6 +45,34 @@ class UploadTest extends RequestTest { $this->assertEquals(3, $info->getSize()); } + /** + * @expectedException \OCA\DAV\Connector\Sabre\Exception\FileLocked + */ + public function testUploadOverWriteReadLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $view->file_put_contents('foo.txt', 'bar'); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_SHARED); + + $this->request($view, $user, 'pass', 'PUT', '/foo.txt', 'asd'); + } + + /** + * @expectedException \OCA\DAV\Connector\Sabre\Exception\FileLocked + */ + public function testUploadOverWriteWriteLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $view->file_put_contents('foo.txt', 'bar'); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_EXCLUSIVE); + + $this->request($view, $user, 'pass', 'PUT', '/foo.txt', 'asd'); + } + public function testChunkedUpload() { $user = $this->getUniqueID(); $view = $this->setupUser($user, 'pass'); @@ -107,4 +137,54 @@ class UploadTest extends RequestTest { $this->assertInstanceOf('\OC\Files\FileInfo', $info); $this->assertEquals(6, $info->getSize()); } + + /** + * @expectedException \OCA\DAV\Connector\Sabre\Exception\FileLocked + */ + public function testChunkedUploadOutOfOrderReadLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $this->assertFalse($view->file_exists('foo.txt')); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_SHARED); + + try { + $response = $this->request($view, $user, 'pass', 'PUT', '/foo.txt-chunking-123-2-1', 'bar', ['OC-Chunked' => '1']); + } catch (\OCA\DAV\Connector\Sabre\Exception\FileLocked $e) { + $this->fail('Didn\'t expect locked error for the first chunk on read lock'); + return; + } + + $this->assertEquals(Http::STATUS_CREATED, $response->getStatus()); + $this->assertFalse($view->file_exists('foo.txt')); + + // last chunk should trigger the locked error since it tries to assemble + $this->request($view, $user, 'pass', 'PUT', '/foo.txt-chunking-123-2-0', 'asd', ['OC-Chunked' => '1']); + } + + /** + * @expectedException \OCA\DAV\Connector\Sabre\Exception\FileLocked + */ + public function testChunkedUploadOutOfOrderWriteLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $this->assertFalse($view->file_exists('foo.txt')); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_EXCLUSIVE); + + try { + $response = $this->request($view, $user, 'pass', 'PUT', '/foo.txt-chunking-123-2-1', 'bar', ['OC-Chunked' => '1']); + } catch (\OCA\DAV\Connector\Sabre\Exception\FileLocked $e) { + $this->fail('Didn\'t expect locked error for the first chunk on write lock'); // maybe forbid this in the future for write locks only? + return; + } + + $this->assertEquals(Http::STATUS_CREATED, $response->getStatus()); + $this->assertFalse($view->file_exists('foo.txt')); + + // last chunk should trigger the locked error since it tries to assemble + $this->request($view, $user, 'pass', 'PUT', '/foo.txt-chunking-123-2-0', 'asd', ['OC-Chunked' => '1']); + } } diff --git a/apps/encryption/appinfo/application.php b/apps/encryption/appinfo/application.php index 812f1042a8f..6275047252e 100644 --- a/apps/encryption/appinfo/application.php +++ b/apps/encryption/appinfo/application.php @@ -201,7 +201,8 @@ class Application extends \OCP\AppFramework\App { $c->query('KeyManager'), $c->query('Crypt'), $c->query('Session'), - $server->getSession() + $server->getSession(), + $c->query('Util') ); }); diff --git a/apps/encryption/appinfo/routes.php b/apps/encryption/appinfo/routes.php index 8fa163d0751..260337361e8 100644 --- a/apps/encryption/appinfo/routes.php +++ b/apps/encryption/appinfo/routes.php @@ -36,6 +36,11 @@ namespace OCA\Encryption\AppInfo; 'verb' => 'POST' ], [ + 'name' => 'Settings#setEncryptHomeStorage', + 'url' => '/ajax/setEncryptHomeStorage', + 'verb' => 'POST' + ], + [ 'name' => 'Recovery#changeRecoveryPassword', 'url' => '/ajax/changeRecoveryPassword', 'verb' => 'POST' diff --git a/apps/encryption/controller/settingscontroller.php b/apps/encryption/controller/settingscontroller.php index e5bb79a1d40..59e23087b3a 100644 --- a/apps/encryption/controller/settingscontroller.php +++ b/apps/encryption/controller/settingscontroller.php @@ -25,6 +25,7 @@ namespace OCA\Encryption\Controller; use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\KeyManager; use OCA\Encryption\Session; +use OCA\Encryption\Util; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -57,6 +58,9 @@ class SettingsController extends Controller { /** @var ISession */ private $ocSession; + /** @var Util */ + private $util; + /** * @param string $AppName * @param IRequest $request @@ -67,6 +71,7 @@ class SettingsController extends Controller { * @param Crypt $crypt * @param Session $session * @param ISession $ocSession + * @param Util $util */ public function __construct($AppName, IRequest $request, @@ -76,7 +81,9 @@ class SettingsController extends Controller { KeyManager $keyManager, Crypt $crypt, Session $session, - ISession $ocSession) { + ISession $ocSession, + Util $util +) { parent::__construct($AppName, $request); $this->l = $l10n; $this->userSession = $userSession; @@ -85,6 +92,7 @@ class SettingsController extends Controller { $this->crypt = $crypt; $this->session = $session; $this->ocSession = $ocSession; + $this->util = $util; } @@ -143,4 +151,15 @@ class SettingsController extends Controller { } } + + /** + * @UseSession + * + * @param bool $encryptHomeStorage + * @return DataResponse + */ + public function setEncryptHomeStorage($encryptHomeStorage) { + $this->util->setEncryptHomeStorage($encryptHomeStorage); + return new DataResponse(); + } } diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js index 39923718c21..9b00a4ec627 100644 --- a/apps/encryption/js/settings-admin.js +++ b/apps/encryption/js/settings-admin.js @@ -76,4 +76,13 @@ $(document).ready(function () { }); }); + $('#encryptHomeStorage').change(function() { + $.post( + OC.generateUrl('/apps/encryption/ajax/setEncryptHomeStorage'), + { + encryptHomeStorage: this.checked + } + ); + }); + }); diff --git a/apps/encryption/l10n/fr.js b/apps/encryption/l10n/fr.js index f6016cc3ce6..59a36a73d7b 100644 --- a/apps/encryption/l10n/fr.js +++ b/apps/encryption/l10n/fr.js @@ -32,6 +32,8 @@ OC.L10N.register( "The share will expire on %s." : "Le partage expirera le %s.", "Cheers!" : "À bientôt !", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Bonjour,\n<br><br>\nL'administrateur a activé le chiffrement sur le serveur. Vos fichiers ont été chiffrés avec le mot de passe suivant :\n\n<p style=\"font-family: monospace;\"><b>%s</b></p>\n\n<p>\nVeuillez suivre ces instructions :\n<ol>\n<li>Connectez-vous à l'interface web et trouvez la section <em>\"Module de chiffrement de base d'ownCloud\"</em> dans vos paramètres personnels;</li>\n<li>Entrez le mot de passe fourni ci-dessus dans le champ <em>\"Ancien mot de passe de connexion\"</em>;</li>\n<li>Entrez le mot de passe que vous utilisez actuellement pour vous connecter dans le champ <em>\"Actuel mot de passe de connexion\"</em>;</li>\n<li>Validez en cliquant sur le bouton <em>\"Mettre à jour le mot de passe de votre clef privée\"</em>.</li>\n</ol>\n</p>", + "Encrypt the home storage" : "Chiffrer l'espace de stockage principal", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "L'activation de cette option chiffre tous les fichiers du stockage principal, sinon seuls les espaces de stockage externes seront chiffrés", "Enable recovery key" : "Activer la clé de récupération", "Disable recovery key" : "Désactiver la clé de récupération", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "La clé de récupération est une clé supplémentaire utilisée pour chiffrer les fichiers. Elle permet de récupérer les fichiers des utilisateurs s'ils oublient leur mot de passe.", diff --git a/apps/encryption/l10n/fr.json b/apps/encryption/l10n/fr.json index 54a7431db30..b1fcfb35b27 100644 --- a/apps/encryption/l10n/fr.json +++ b/apps/encryption/l10n/fr.json @@ -30,6 +30,8 @@ "The share will expire on %s." : "Le partage expirera le %s.", "Cheers!" : "À bientôt !", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Bonjour,\n<br><br>\nL'administrateur a activé le chiffrement sur le serveur. Vos fichiers ont été chiffrés avec le mot de passe suivant :\n\n<p style=\"font-family: monospace;\"><b>%s</b></p>\n\n<p>\nVeuillez suivre ces instructions :\n<ol>\n<li>Connectez-vous à l'interface web et trouvez la section <em>\"Module de chiffrement de base d'ownCloud\"</em> dans vos paramètres personnels;</li>\n<li>Entrez le mot de passe fourni ci-dessus dans le champ <em>\"Ancien mot de passe de connexion\"</em>;</li>\n<li>Entrez le mot de passe que vous utilisez actuellement pour vous connecter dans le champ <em>\"Actuel mot de passe de connexion\"</em>;</li>\n<li>Validez en cliquant sur le bouton <em>\"Mettre à jour le mot de passe de votre clef privée\"</em>.</li>\n</ol>\n</p>", + "Encrypt the home storage" : "Chiffrer l'espace de stockage principal", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "L'activation de cette option chiffre tous les fichiers du stockage principal, sinon seuls les espaces de stockage externes seront chiffrés", "Enable recovery key" : "Activer la clé de récupération", "Disable recovery key" : "Désactiver la clé de récupération", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "La clé de récupération est une clé supplémentaire utilisée pour chiffrer les fichiers. Elle permet de récupérer les fichiers des utilisateurs s'ils oublient leur mot de passe.", diff --git a/apps/encryption/l10n/it.js b/apps/encryption/l10n/it.js index 9f94b409f57..699e4babd01 100644 --- a/apps/encryption/l10n/it.js +++ b/apps/encryption/l10n/it.js @@ -32,6 +32,8 @@ OC.L10N.register( "The share will expire on %s." : "La condivisione scadrà il %s.", "Cheers!" : "Saluti!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Ciao,<br><br>l'amministratore ha abilitato la cifratura lato server. I tuoi file sono stati cifrati utilizzando la password <strong>%s</strong>.<br><br>Accedi all'interfaccia web, vai alla sezione \"modulo di cifratura base di ownCloud\" dalle nelle tue impostazioni personali e aggiorna la tua password di cifratura digitando la password nel campo \"vecchia password di accesso\" e la tua nuova password.", + "Encrypt the home storage" : "Cifra l'archiviazione principale", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "L'abilitazione di questa opzione cifra tutti i file memorizzati sull'archiviazione principale, altrimenti saranno cifrati solo i file sull'archiviazione esterna.", "Enable recovery key" : "Abilita chiave di ripristino", "Disable recovery key" : "Disabilita chiave di ripristino", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "La chiave di ripristino è una chiave di cifratura aggiuntiva utilizzata per cifrare i file. Consente di ripristinare i file di un utente se l'utente dimentica la propria password.", diff --git a/apps/encryption/l10n/it.json b/apps/encryption/l10n/it.json index a117af8a317..b86893303c2 100644 --- a/apps/encryption/l10n/it.json +++ b/apps/encryption/l10n/it.json @@ -30,6 +30,8 @@ "The share will expire on %s." : "La condivisione scadrà il %s.", "Cheers!" : "Saluti!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Ciao,<br><br>l'amministratore ha abilitato la cifratura lato server. I tuoi file sono stati cifrati utilizzando la password <strong>%s</strong>.<br><br>Accedi all'interfaccia web, vai alla sezione \"modulo di cifratura base di ownCloud\" dalle nelle tue impostazioni personali e aggiorna la tua password di cifratura digitando la password nel campo \"vecchia password di accesso\" e la tua nuova password.", + "Encrypt the home storage" : "Cifra l'archiviazione principale", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "L'abilitazione di questa opzione cifra tutti i file memorizzati sull'archiviazione principale, altrimenti saranno cifrati solo i file sull'archiviazione esterna.", "Enable recovery key" : "Abilita chiave di ripristino", "Disable recovery key" : "Disabilita chiave di ripristino", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "La chiave di ripristino è una chiave di cifratura aggiuntiva utilizzata per cifrare i file. Consente di ripristinare i file di un utente se l'utente dimentica la propria password.", diff --git a/apps/encryption/l10n/pt_BR.js b/apps/encryption/l10n/pt_BR.js index 09ed1910c1a..334bbf05282 100644 --- a/apps/encryption/l10n/pt_BR.js +++ b/apps/encryption/l10n/pt_BR.js @@ -32,6 +32,8 @@ OC.L10N.register( "The share will expire on %s." : "O compartilhamento irá expirar em %s.", "Cheers!" : "Saúde!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Olá,<br><br>o administrador habilitou criptografia-lado-servidor. Os seus arquivos foram criptografados usando a senha <strong>%s</strong>.<br><br>Por favor faça o login para a interface da Web, vá para a seção 'ownCloud módulo de criptografia básico' das suas definições pessoais e atualize sua senha de criptografia, inserindo esta senha no campo 'senha antiga de log-in' e sua atual senha-de-login..<br><br>", + "Encrypt the home storage" : "Criptografar a pasta de armazenamento home", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Ativar essa opção de criptografia para todos os arquivos armazenados no armazenamento principal, caso contrário, apenas arquivos no armazenamento externo serão criptografados", "Enable recovery key" : "Habilitar recuperação de chave", "Disable recovery key" : "Dasabilitar chave de recuperação", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "A chave de recuperação é uma chave de encriptação extra que é utilizada para encriptar arquivos. Ela permite a recuperação de arquivos de um usuário esquecer sua senha.", diff --git a/apps/encryption/l10n/pt_BR.json b/apps/encryption/l10n/pt_BR.json index 1682ec44b28..794eb478c74 100644 --- a/apps/encryption/l10n/pt_BR.json +++ b/apps/encryption/l10n/pt_BR.json @@ -30,6 +30,8 @@ "The share will expire on %s." : "O compartilhamento irá expirar em %s.", "Cheers!" : "Saúde!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Olá,<br><br>o administrador habilitou criptografia-lado-servidor. Os seus arquivos foram criptografados usando a senha <strong>%s</strong>.<br><br>Por favor faça o login para a interface da Web, vá para a seção 'ownCloud módulo de criptografia básico' das suas definições pessoais e atualize sua senha de criptografia, inserindo esta senha no campo 'senha antiga de log-in' e sua atual senha-de-login..<br><br>", + "Encrypt the home storage" : "Criptografar a pasta de armazenamento home", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Ativar essa opção de criptografia para todos os arquivos armazenados no armazenamento principal, caso contrário, apenas arquivos no armazenamento externo serão criptografados", "Enable recovery key" : "Habilitar recuperação de chave", "Disable recovery key" : "Dasabilitar chave de recuperação", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "A chave de recuperação é uma chave de encriptação extra que é utilizada para encriptar arquivos. Ela permite a recuperação de arquivos de um usuário esquecer sua senha.", diff --git a/apps/encryption/l10n/ru.js b/apps/encryption/l10n/ru.js index b326b71456d..ae2c1d1f4e0 100644 --- a/apps/encryption/l10n/ru.js +++ b/apps/encryption/l10n/ru.js @@ -32,6 +32,8 @@ OC.L10N.register( "The share will expire on %s." : "Доступ будет закрыт %s", "Cheers!" : "Всего наилучшего!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Привет,<br><br>администратор включил шифрование на стороне сервера. Ваши файлы были зашифрованы с помощью пароля <strong>%s</strong>.<br><br>Пожалуйста войдите в веб-приложение, в разделе \"ownCloud простой модуль шифрования\" в личных настройках вам нужно обновить пароль шифрования.<br><br>", + "Encrypt the home storage" : "Зашифровать домашнюю директорию", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Данный параметр позволяет зашифровать все файлы, хранящиеся в главном хранилище, иначе только файлы на внешних хранилищах будут зашифрованы", "Enable recovery key" : "Включить ключ восстановления", "Disable recovery key" : "Отключить ключ восстановления", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "Ключ восстановления это дополнительный ключ, который используется для шифрования файлов. Он позволяет восстановить пользовательские файлы в случае утери пароля.", diff --git a/apps/encryption/l10n/ru.json b/apps/encryption/l10n/ru.json index f4a14cb841f..87cb27d1e4a 100644 --- a/apps/encryption/l10n/ru.json +++ b/apps/encryption/l10n/ru.json @@ -30,6 +30,8 @@ "The share will expire on %s." : "Доступ будет закрыт %s", "Cheers!" : "Всего наилучшего!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Привет,<br><br>администратор включил шифрование на стороне сервера. Ваши файлы были зашифрованы с помощью пароля <strong>%s</strong>.<br><br>Пожалуйста войдите в веб-приложение, в разделе \"ownCloud простой модуль шифрования\" в личных настройках вам нужно обновить пароль шифрования.<br><br>", + "Encrypt the home storage" : "Зашифровать домашнюю директорию", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Данный параметр позволяет зашифровать все файлы, хранящиеся в главном хранилище, иначе только файлы на внешних хранилищах будут зашифрованы", "Enable recovery key" : "Включить ключ восстановления", "Disable recovery key" : "Отключить ключ восстановления", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "Ключ восстановления это дополнительный ключ, который используется для шифрования файлов. Он позволяет восстановить пользовательские файлы в случае утери пароля.", diff --git a/apps/encryption/l10n/sq.js b/apps/encryption/l10n/sq.js index d18e8bcbbfd..e608fb368f8 100644 --- a/apps/encryption/l10n/sq.js +++ b/apps/encryption/l10n/sq.js @@ -32,6 +32,8 @@ OC.L10N.register( "The share will expire on %s." : "Ndarja do të skadojë më %s.", "Cheers!" : "Gëzuar!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Njatjeta,<br><br>përgjegjësi aktivizoi fshehtëzim më anë shërbyesi. Kartelat tuaja qenë fshehtëzuar duke përdorur fjalëkalimin <strong>%s</strong>.<br><br>Ju lutemi, bëni hyrjen te ndërfaqja web, kaloni te ndarja \"modul i thjeshtë ownCloud për fshehtëzime\" e rregullimeve tuaja personale dhe përditësoni fjalëkalimin tuaj për fshehtëzime duke dhënë këtë fjalëkalim te fusha \"old log-in password\" dhe fjalëkalimin tuaj të tanishëm për hyrjet.<br><br>", + "Encrypt the home storage" : "Fshehtëzo depozitën bazë", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Aktivizimi i kësaj mundësie fshehtëzon krejt kartelat e depozituara në depon bazë, përndryshe do të fshehtëzohen vetëm kartelat në depozitën e jashtme", "Enable recovery key" : "Aktivizo kyç rimarrjesh", "Disable recovery key" : "Çaktivizo kyç rimarrjesh", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "Kyçi i rimarrjeve është një kyç ekstra fshehtëzimesh që përdoret për të fshehtëzuar kartela. Ai lejon rimarrjen e një kartele të përdoruesit, nëse përdoruesi harron fjalëkalimin e vet.", diff --git a/apps/encryption/l10n/sq.json b/apps/encryption/l10n/sq.json index 7415195f955..2319f03ae4f 100644 --- a/apps/encryption/l10n/sq.json +++ b/apps/encryption/l10n/sq.json @@ -30,6 +30,8 @@ "The share will expire on %s." : "Ndarja do të skadojë më %s.", "Cheers!" : "Gëzuar!", "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "Njatjeta,<br><br>përgjegjësi aktivizoi fshehtëzim më anë shërbyesi. Kartelat tuaja qenë fshehtëzuar duke përdorur fjalëkalimin <strong>%s</strong>.<br><br>Ju lutemi, bëni hyrjen te ndërfaqja web, kaloni te ndarja \"modul i thjeshtë ownCloud për fshehtëzime\" e rregullimeve tuaja personale dhe përditësoni fjalëkalimin tuaj për fshehtëzime duke dhënë këtë fjalëkalim te fusha \"old log-in password\" dhe fjalëkalimin tuaj të tanishëm për hyrjet.<br><br>", + "Encrypt the home storage" : "Fshehtëzo depozitën bazë", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "Aktivizimi i kësaj mundësie fshehtëzon krejt kartelat e depozituara në depon bazë, përndryshe do të fshehtëzohen vetëm kartelat në depozitën e jashtme", "Enable recovery key" : "Aktivizo kyç rimarrjesh", "Disable recovery key" : "Çaktivizo kyç rimarrjesh", "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "Kyçi i rimarrjeve është një kyç ekstra fshehtëzimesh që përdoret për të fshehtëzuar kartela. Ai lejon rimarrjen e një kartele të përdoruesit, nëse përdoruesi harron fjalëkalimin e vet.", diff --git a/apps/encryption/l10n/zh_TW.js b/apps/encryption/l10n/zh_TW.js index 17893b44b67..d0c1e3dfee8 100644 --- a/apps/encryption/l10n/zh_TW.js +++ b/apps/encryption/l10n/zh_TW.js @@ -1,21 +1,52 @@ OC.L10N.register( "encryption", { + "Missing recovery key password" : "遺失還原金鑰密碼", + "Please repeat the recovery key password" : "請您再輸入新的還原金鑰密碼一次", + "Repeated recovery key password does not match the provided recovery key password" : "輸入的還原金鑰密碼與設定的並不相符", "Recovery key successfully enabled" : "還原金鑰已成功開啟", "Could not enable recovery key. Please check your recovery key password!" : "無法啟用還原金鑰。請檢查您的還原金鑰密碼!", "Recovery key successfully disabled" : "還原金鑰已成功停用", "Could not disable recovery key. Please check your recovery key password!" : "無法停用還原金鑰。請檢查您的還原金鑰密碼!", + "Missing parameters" : "遺失參數", + "Please provide the old recovery password" : "請提供舊的還原密碼", + "Please provide a new recovery password" : "請提供新的還原密碼", + "Please repeat the new recovery password" : "請您再輸入新的還原密碼", "Password successfully changed." : "成功變更密碼。", "Could not change the password. Maybe the old password was not correct." : "無法變更密碼,或許是輸入的舊密碼不正確。", + "Recovery Key disabled" : "還原金鑰停用", + "Recovery Key enabled" : "還原金鑰啟用", + "Could not enable the recovery key, please try again or contact your administrator" : "無法啟用還原金鑰功能,請重試或聯絡系統管理員", + "Could not update the private key password." : "無法更新私人金鑰密碼", + "The old password was not correct, please try again." : "舊密碼不正確,請再試一次", + "The current log-in password was not correct, please try again." : "目前登入的密碼不正確,請再試一次", "Private key password successfully updated." : "私人金鑰密碼已成功更新。", + "You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run 'occ encryption:migrate' or contact your administrator" : "您需要搬移您的加密鑰匙從舊版的加密 (ownCloud <= 8.0) 到新版,請執行 'occ encryption:migrate' 或是聯絡系統管理員", "Invalid private key for Encryption App. Please update your private key password in your personal settings to recover access to your encrypted files." : "無效的檔案加密私鑰,請在個人設定中更新您的私鑰密語以存取加密的檔案。", "Encryption App is enabled but your keys are not initialized, please log-out and log-in again" : "檔案加密已啓用,但是您的金鑰尚未初始化,請重新登入一次", + "Encryption App is enabled and ready" : "加密應用程式已經被啟用", + "one-time password for server-side-encryption" : "一次性密碼用於伺服器端的加密", "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you." : "無法解密這個檔案,也許這是分享的檔案。請詢問檔案所有人重新分享檔案給您。", + "Can not read this file, probably this is a shared file. Please ask the file owner to reshare the file with you." : "無法檢視這個檔案,或許這是分享的檔案,請詢問這個檔案的擁有者並請他重新分享給您。", + "Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'ownCloud basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n" : "嗨,請看這裡,\n\n系管理員啟用了伺服器端的加密功能,您的檔案將會使用密碼 '%s' 加密\n\n請從網頁登入,到 'ownCloud basic encryption module' 設置您的個人設定並透過更新加密密碼,將這個組密碼設定在 'old log-in password' 以及您的目前登入密碼\n", "The share will expire on %s." : "這個分享將會於 %s 過期", "Cheers!" : "太棒了!", + "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "嗨,請看這裡,<br><br>系管理員啟用了伺服器端的加密功能,您的檔案將會使用密碼<strong> '%s' </strong>加密,請從網頁登入,到 'ownCloud basic encryption module' 設置您的個人設定並透過更新加密密碼,將這個組密碼設定在 'old log-in password' 以及您的目前登入密碼<br><br>", + "Encrypt the home storage" : "加密家目錄空間", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "請啟用這個功能以用來加密主要儲存空間的檔案,否則只有再外部儲存的檔案會加密", + "Enable recovery key" : "啟用還原金鑰", + "Disable recovery key" : "關閉還原金鑰", + "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "加密金鑰是另一種加密檔案方式,當使用者忘記密碼時,可以用還原金鑰來還原檔案", "Recovery key password" : "還原金鑰密碼", + "Repeat recovery key password" : "再輸入還原金鑰密碼一次", "Change recovery key password:" : "變更還原金鑰密碼:", + "Old recovery key password" : "舊的還原金鑰密碼", + "New recovery key password" : "新的還原金鑰密碼", + "Repeat new recovery key password" : "再輸入新的還原金鑰密碼一次", "Change Password" : "變更密碼", + "ownCloud basic encryption module" : "ownCloud 基本加密模組", + "Your private key password no longer matches your log-in password." : "您的私人金鑰密碼不符合您的登入密碼", + "Set your old private key password to your current log-in password:" : "設定您的舊私人金鑰密碼到您現在的登入密碼:", " If you don't remember your old password you can ask your administrator to recover your files." : "如果您忘記舊密碼,可以請求管理員協助取回檔案。", "Old log-in password" : "舊登入密碼", "Current log-in password" : "目前的登入密碼", diff --git a/apps/encryption/l10n/zh_TW.json b/apps/encryption/l10n/zh_TW.json index ce2e07228fc..feee736980f 100644 --- a/apps/encryption/l10n/zh_TW.json +++ b/apps/encryption/l10n/zh_TW.json @@ -1,19 +1,50 @@ { "translations": { + "Missing recovery key password" : "遺失還原金鑰密碼", + "Please repeat the recovery key password" : "請您再輸入新的還原金鑰密碼一次", + "Repeated recovery key password does not match the provided recovery key password" : "輸入的還原金鑰密碼與設定的並不相符", "Recovery key successfully enabled" : "還原金鑰已成功開啟", "Could not enable recovery key. Please check your recovery key password!" : "無法啟用還原金鑰。請檢查您的還原金鑰密碼!", "Recovery key successfully disabled" : "還原金鑰已成功停用", "Could not disable recovery key. Please check your recovery key password!" : "無法停用還原金鑰。請檢查您的還原金鑰密碼!", + "Missing parameters" : "遺失參數", + "Please provide the old recovery password" : "請提供舊的還原密碼", + "Please provide a new recovery password" : "請提供新的還原密碼", + "Please repeat the new recovery password" : "請您再輸入新的還原密碼", "Password successfully changed." : "成功變更密碼。", "Could not change the password. Maybe the old password was not correct." : "無法變更密碼,或許是輸入的舊密碼不正確。", + "Recovery Key disabled" : "還原金鑰停用", + "Recovery Key enabled" : "還原金鑰啟用", + "Could not enable the recovery key, please try again or contact your administrator" : "無法啟用還原金鑰功能,請重試或聯絡系統管理員", + "Could not update the private key password." : "無法更新私人金鑰密碼", + "The old password was not correct, please try again." : "舊密碼不正確,請再試一次", + "The current log-in password was not correct, please try again." : "目前登入的密碼不正確,請再試一次", "Private key password successfully updated." : "私人金鑰密碼已成功更新。", + "You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run 'occ encryption:migrate' or contact your administrator" : "您需要搬移您的加密鑰匙從舊版的加密 (ownCloud <= 8.0) 到新版,請執行 'occ encryption:migrate' 或是聯絡系統管理員", "Invalid private key for Encryption App. Please update your private key password in your personal settings to recover access to your encrypted files." : "無效的檔案加密私鑰,請在個人設定中更新您的私鑰密語以存取加密的檔案。", "Encryption App is enabled but your keys are not initialized, please log-out and log-in again" : "檔案加密已啓用,但是您的金鑰尚未初始化,請重新登入一次", + "Encryption App is enabled and ready" : "加密應用程式已經被啟用", + "one-time password for server-side-encryption" : "一次性密碼用於伺服器端的加密", "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you." : "無法解密這個檔案,也許這是分享的檔案。請詢問檔案所有人重新分享檔案給您。", + "Can not read this file, probably this is a shared file. Please ask the file owner to reshare the file with you." : "無法檢視這個檔案,或許這是分享的檔案,請詢問這個檔案的擁有者並請他重新分享給您。", + "Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'ownCloud basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n" : "嗨,請看這裡,\n\n系管理員啟用了伺服器端的加密功能,您的檔案將會使用密碼 '%s' 加密\n\n請從網頁登入,到 'ownCloud basic encryption module' 設置您的個人設定並透過更新加密密碼,將這個組密碼設定在 'old log-in password' 以及您的目前登入密碼\n", "The share will expire on %s." : "這個分享將會於 %s 過期", "Cheers!" : "太棒了!", + "Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section \"ownCloud basic encryption module\" of your personal settings and update your encryption password by entering this password into the \"old log-in password\" field and your current login-password.<br><br>" : "嗨,請看這裡,<br><br>系管理員啟用了伺服器端的加密功能,您的檔案將會使用密碼<strong> '%s' </strong>加密,請從網頁登入,到 'ownCloud basic encryption module' 設置您的個人設定並透過更新加密密碼,將這個組密碼設定在 'old log-in password' 以及您的目前登入密碼<br><br>", + "Encrypt the home storage" : "加密家目錄空間", + "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" : "請啟用這個功能以用來加密主要儲存空間的檔案,否則只有再外部儲存的檔案會加密", + "Enable recovery key" : "啟用還原金鑰", + "Disable recovery key" : "關閉還原金鑰", + "The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password." : "加密金鑰是另一種加密檔案方式,當使用者忘記密碼時,可以用還原金鑰來還原檔案", "Recovery key password" : "還原金鑰密碼", + "Repeat recovery key password" : "再輸入還原金鑰密碼一次", "Change recovery key password:" : "變更還原金鑰密碼:", + "Old recovery key password" : "舊的還原金鑰密碼", + "New recovery key password" : "新的還原金鑰密碼", + "Repeat new recovery key password" : "再輸入新的還原金鑰密碼一次", "Change Password" : "變更密碼", + "ownCloud basic encryption module" : "ownCloud 基本加密模組", + "Your private key password no longer matches your log-in password." : "您的私人金鑰密碼不符合您的登入密碼", + "Set your old private key password to your current log-in password:" : "設定您的舊私人金鑰密碼到您現在的登入密碼:", " If you don't remember your old password you can ask your administrator to recover your files." : "如果您忘記舊密碼,可以請求管理員協助取回檔案。", "Old log-in password" : "舊登入密碼", "Current log-in password" : "目前的登入密碼", diff --git a/apps/encryption/lib/crypto/crypt.php b/apps/encryption/lib/crypto/crypt.php index 53a78c216a3..c0dcc936bdf 100644 --- a/apps/encryption/lib/crypto/crypt.php +++ b/apps/encryption/lib/crypto/crypt.php @@ -2,6 +2,7 @@ /** * @author Björn Schießle <schiessle@owncloud.com> * @author Clark Tomlinson <fallen013@gmail.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 1a05277e20d..d1140ce7cde 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -378,6 +378,12 @@ class Encryption implements IEncryptionModule { * @return boolean */ public function shouldEncrypt($path) { + if ($this->util->shouldEncryptHomeStorage() === false) { + $storage = $this->util->getStorage($path); + if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { + return false; + } + } $parts = explode('/', $path); if (count($parts) < 4) { return false; diff --git a/apps/encryption/lib/util.php b/apps/encryption/lib/util.php index a162dcde305..62c9dc6dc5f 100644 --- a/apps/encryption/lib/util.php +++ b/apps/encryption/lib/util.php @@ -94,12 +94,41 @@ class Util { $recoveryMode = $this->config->getUserValue($uid, 'encryption', 'recoveryEnabled', - 0); + '0'); return ($recoveryMode === '1'); } /** + * check if the home storage should be encrypted + * + * @return bool + */ + public function shouldEncryptHomeStorage() { + $encryptHomeStorage = $this->config->getAppValue( + 'encryption', + 'encryptHomeStorage', + '1' + ); + + return ($encryptHomeStorage === '1'); + } + + /** + * check if the home storage should be encrypted + * + * @param bool $encryptHomeStorage + */ + public function setEncryptHomeStorage($encryptHomeStorage) { + $value = $encryptHomeStorage ? '1' : '0'; + $this->config->setAppValue( + 'encryption', + 'encryptHomeStorage', + $value + ); + } + + /** * check if master key is enabled * * @return bool @@ -157,4 +186,15 @@ class Util { return $owner; } + /** + * get storage of path + * + * @param string $path + * @return \OC\Files\Storage\Storage + */ + public function getStorage($path) { + $storage = $this->files->getMount($path)->getStorage(); + return $storage; + } + } diff --git a/apps/encryption/settings/settings-admin.php b/apps/encryption/settings/settings-admin.php index c7ac8c09c6b..8d55d587fed 100644 --- a/apps/encryption/settings/settings-admin.php +++ b/apps/encryption/settings/settings-admin.php @@ -25,12 +25,27 @@ $tmpl = new OCP\Template('encryption', 'settings-admin'); +$crypt = new \OCA\Encryption\Crypto\Crypt( + \OC::$server->getLogger(), + \OC::$server->getUserSession(), + \OC::$server->getConfig()); + +$util = new \OCA\Encryption\Util( + new \OC\Files\View(), + $crypt, + \OC::$server->getLogger(), + \OC::$server->getUserSession(), + \OC::$server->getConfig(), + \OC::$server->getUserManager()); + // Check if an adminRecovery account is enabled for recovering files after lost pwd $recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled', '0'); $session = new \OCA\Encryption\Session(\OC::$server->getSession()); +$encryptHomeStorage = $util->shouldEncryptHomeStorage($user); $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled); $tmpl->assign('initStatus', $session->getStatus()); +$tmpl->assign('encryptHomeStorage', $encryptHomeStorage); return $tmpl->fetchPage(); diff --git a/apps/encryption/templates/settings-admin.php b/apps/encryption/templates/settings-admin.php index 81c7f0607d8..e55aba6757c 100644 --- a/apps/encryption/templates/settings-admin.php +++ b/apps/encryption/templates/settings-admin.php @@ -9,56 +9,63 @@ style('encryption', 'settings-admin'); <?php if(!$_["initStatus"]): ?> <?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?> <?php else: ?> - <p id="encryptionSetRecoveryKey"> - <?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?> - <span class="msg"></span> - <br/> - <em> - <?php p($l->t("The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password.")) ?> - </em> - <br/> - <input type="password" - name="encryptionRecoveryPassword" - id="encryptionRecoveryPassword" - placeholder="<?php p($l->t("Recovery key password")); ?>"/> - <input type="password" - name="encryptionRecoveryPassword" - id="repeatEncryptionRecoveryPassword" - placeholder="<?php p($l->t("Repeat recovery key password")); ?>"/> - <input type="button" - name="enableRecoveryKey" - id="enableRecoveryKey" - status="<?php p($_["recoveryEnabled"]) ?>" - value="<?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>"/> - </p> - <br/><br/> - - <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> - <?php p($l->t("Change recovery key password:")); ?> - <span class="msg"></span> - <br/> - <input - type="password" - name="changeRecoveryPassword" - id="oldEncryptionRecoveryPassword" - placeholder="<?php p($l->t("Old recovery key password")); ?>"/> + <p id="encryptHomeStorageSetting"> + <input type="checkbox" class="checkbox" name="encrypt_home_storage" id="encryptHomeStorage" + value="1" <?php if ($_['encryptHomeStorage']) print_unescaped('checked="checked"'); ?> /> + <label for="encryptHomeStorage"><?php p($l->t('Encrypt the home storage'));?></label></br> + <em><?php p( $l->t( "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" ) ); ?></em> + </p> <br /> - <input - type="password" - name="changeRecoveryPassword" - id="newEncryptionRecoveryPassword" - placeholder="<?php p($l->t("New recovery key password")); ?>"/> - <input - type="password" - name="changeRecoveryPassword" - id="repeatedNewEncryptionRecoveryPassword" - placeholder="<?php p($l->t("Repeat new recovery key password")); ?>"/> + <p id="encryptionSetRecoveryKey"> + <?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?> + <span class="msg"></span> + <br/> + <em> + <?php p($l->t("The recovery key is an extra encryption key that is used to encrypt files. It allows recovery of a user's files if the user forgets his or her password.")) ?> + </em> + <br/> + <input type="password" + name="encryptionRecoveryPassword" + id="encryptionRecoveryPassword" + placeholder="<?php p($l->t("Recovery key password")); ?>"/> + <input type="password" + name="encryptionRecoveryPassword" + id="repeatEncryptionRecoveryPassword" + placeholder="<?php p($l->t("Repeat recovery key password")); ?>"/> + <input type="button" + name="enableRecoveryKey" + id="enableRecoveryKey" + status="<?php p($_["recoveryEnabled"]) ?>" + value="<?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>"/> + </p> + <br/><br/> + + <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> + <?php p($l->t("Change recovery key password:")); ?> + <span class="msg"></span> + <br/> + <input + type="password" + name="changeRecoveryPassword" + id="oldEncryptionRecoveryPassword" + placeholder="<?php p($l->t("Old recovery key password")); ?>"/> + <br /> + <input + type="password" + name="changeRecoveryPassword" + id="newEncryptionRecoveryPassword" + placeholder="<?php p($l->t("New recovery key password")); ?>"/> + <input + type="password" + name="changeRecoveryPassword" + id="repeatedNewEncryptionRecoveryPassword" + placeholder="<?php p($l->t("Repeat new recovery key password")); ?>"/> - <button - type="button" - name="submitChangeRecoveryKey"> + <button + type="button" + name="submitChangeRecoveryKey"> <?php p($l->t("Change Password")); ?> - </button> - </p> + </button> + </p> <?php endif; ?> </form> diff --git a/apps/encryption/tests/controller/SettingsControllerTest.php b/apps/encryption/tests/controller/SettingsControllerTest.php index 724a01522af..3b30e61a45b 100644 --- a/apps/encryption/tests/controller/SettingsControllerTest.php +++ b/apps/encryption/tests/controller/SettingsControllerTest.php @@ -56,6 +56,9 @@ class SettingsControllerTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $ocSessionMock; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + private $utilMock; + protected function setUp() { parent::setUp(); @@ -106,6 +109,10 @@ class SettingsControllerTest extends TestCase { $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') ->disableOriginalConstructor()->getMock(); + $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + ->disableOriginalConstructor() + ->getMock(); + $this->controller = new SettingsController( 'encryption', $this->requestMock, @@ -115,7 +122,8 @@ class SettingsControllerTest extends TestCase { $this->keyManagerMock, $this->cryptMock, $this->sessionMock, - $this->ocSessionMock + $this->ocSessionMock, + $this->utilMock ); } @@ -234,4 +242,10 @@ class SettingsControllerTest extends TestCase { $data['message']); } + function testSetEncryptHomeStorage() { + $value = true; + $this->utilMock->expects($this->once())->method('setEncryptHomeStorage')->with($value); + $this->controller->setEncryptHomeStorage($value); + } + } diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index be37020660c..65fefa262a7 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -2,6 +2,7 @@ /** * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/encryption/tests/lib/UtilTest.php b/apps/encryption/tests/lib/UtilTest.php index 723cc9fb910..d55b6b50b3e 100644 --- a/apps/encryption/tests/lib/UtilTest.php +++ b/apps/encryption/tests/lib/UtilTest.php @@ -39,6 +39,9 @@ class UtilTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $userManagerMock; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + private $mountMock; + /** @var Util */ private $instance; @@ -65,6 +68,7 @@ class UtilTest extends TestCase { protected function setUp() { parent::setUp(); + $this->mountMock = $this->getMock('\OCP\Files\Mount\IMountPoint'); $this->filesMock = $this->getMock('OC\Files\View'); $this->userManagerMock = $this->getMock('\OCP\IUserManager'); @@ -151,4 +155,52 @@ class UtilTest extends TestCase { ]; } + /** + * @dataProvider dataTestShouldEncryptHomeStorage + * @param $returnValue return value from getAppValue() + * @param $expected + */ + public function testShouldEncryptHomeStorage($returnValue, $expected) { + $this->configMock->expects($this->once())->method('getAppValue') + ->with('encryption', 'encryptHomeStorage', '1') + ->willReturn($returnValue); + + $this->assertSame($expected, + $this->instance->shouldEncryptHomeStorage()); + } + + public function dataTestShouldEncryptHomeStorage() { + return [ + ['1', true], + ['0', false] + ]; + } + + /** + * @dataProvider dataTestSetEncryptHomeStorage + * @param $value + * @param $expected + */ + public function testSetEncryptHomeStorage($value, $expected) { + $this->configMock->expects($this->once())->method('setAppValue') + ->with('encryption', 'encryptHomeStorage', $expected); + $this->instance->setEncryptHomeStorage($value); + } + + public function dataTestSetEncryptHomeStorage() { + return [ + [true, '1'], + [false, '0'] + ]; + } + + public function testGetStorage() { + $path = '/foo/bar.txt'; + $this->filesMock->expects($this->once())->method('getMount')->with($path) + ->willReturn($this->mountMock); + $this->mountMock->expects($this->once())->method('getStorage')->willReturn(true); + + $this->assertTrue($this->instance->getStorage($path)); + } + } diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php index f76bdfb6d61..138c1bc9446 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/lib/crypto/encryptionTest.php @@ -55,9 +55,14 @@ class EncryptionTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $l10nMock; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + private $storageMock; + public function setUp() { parent::setUp(); + $this->storageMock = $this->getMockBuilder('OCP\Files\Storage') + ->disableOriginalConstructor()->getMock(); $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') ->disableOriginalConstructor() ->getMock(); @@ -312,7 +317,17 @@ class EncryptionTest extends TestCase { * * @dataProvider dataTestShouldEncrypt */ - public function testShouldEncrypt($path, $expected) { + public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected) { + $this->utilMock->expects($this->once())->method('shouldEncryptHomeStorage') + ->willReturn($shouldEncryptHomeStorage); + + if ($shouldEncryptHomeStorage === false) { + $this->storageMock->expects($this->once())->method('instanceOfStorage') + ->with('\OCP\Files\IHomeStorage')->willReturn($isHomeStorage); + $this->utilMock->expects($this->once())->method('getStorage')->with($path) + ->willReturn($this->storageMock); + } + $this->assertSame($expected, $this->instance->shouldEncrypt($path) ); @@ -320,14 +335,17 @@ class EncryptionTest extends TestCase { public function dataTestShouldEncrypt() { return array( - array('/user1/files/foo.txt', true), - array('/user1/files_versions/foo.txt', true), - array('/user1/files_trashbin/foo.txt', true), - array('/user1/some_folder/foo.txt', false), - array('/user1/foo.txt', false), - array('/user1/files', false), - array('/user1/files_trashbin', false), - array('/user1/files_versions', false), + array('/user1/files/foo.txt', true, true, true), + array('/user1/files_versions/foo.txt', true, true, true), + array('/user1/files_trashbin/foo.txt', true, true, true), + array('/user1/some_folder/foo.txt', true, true, false), + array('/user1/foo.txt', true, true, false), + array('/user1/files', true, true, false), + array('/user1/files_trashbin', true, true, false), + array('/user1/files_versions', true, true, false), + // test if shouldEncryptHomeStorage is set to false + array('/user1/files/foo.txt', false, true, false), + array('/user1/files_versions/foo.txt', false, false, true), ); } diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php index 6ba77e09556..6aff517e17f 100644 --- a/apps/files/appinfo/application.php +++ b/apps/files/appinfo/application.php @@ -1,6 +1,6 @@ <?php /** - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tobias Kaminsky <tobias@kaminsky.me> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 41aeec6a152..d52dfaab21c 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -2,7 +2,7 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Lukas Reschke <lukas@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tobias Kaminsky <tobias@kaminsky.me> * @author Tom Needham <tom@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php index ea5ee81a9f6..1ecd5294c66 100644 --- a/apps/files/controller/apicontroller.php +++ b/apps/files/controller/apicontroller.php @@ -3,7 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tobias Kaminsky <tobias@kaminsky.me> * @author Vincent Petry <pvince81@owncloud.com> diff --git a/apps/files/js/favoritesfilelist.js b/apps/files/js/favoritesfilelist.js index 4e7db9f17ba..e6532ab188c 100644 --- a/apps/files/js/favoritesfilelist.js +++ b/apps/files/js/favoritesfilelist.js @@ -71,6 +71,10 @@ $(document).ready(function() { if (this._reloadCall) { this._reloadCall.abort(); } + + // there is only root + this._setCurrentDir('/', false); + this._reloadCall = $.ajax({ url: OC.generateUrl('/apps/files/api/v1/tags/{tagName}/files', {tagName: tagName}), type: 'GET', @@ -86,10 +90,9 @@ $(document).ready(function() { if (result.files) { this.setFiles(result.files.sort(this._sortComparator)); + return true; } - else { - // TODO: error handling - } + return false; } }); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c84d6c3c47d..99804b1b9be 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -767,7 +767,7 @@ */ elementToFile: function($el){ $el = $($el); - return { + var data = { id: parseInt($el.attr('data-id'), 10), name: $el.attr('data-file'), mimetype: $el.attr('data-mime'), @@ -777,6 +777,15 @@ etag: $el.attr('data-etag'), permissions: parseInt($el.attr('data-permissions'), 10) }; + var icon = $el.attr('data-icon'); + if (icon) { + data.icon = icon; + } + var mountType = $el.attr('data-mounttype'); + if (mountType) { + data.mountType = mountType; + } + return data; }, /** @@ -899,11 +908,12 @@ mtime = parseInt(fileData.mtime, 10), mime = fileData.mimetype, path = fileData.path, + dataIcon = null, linkUrl; options = options || {}; if (isNaN(mtime)) { - mtime = new Date().getTime() + mtime = new Date().getTime(); } if (type === 'dir') { @@ -911,6 +921,7 @@ if (fileData.mountType && fileData.mountType.indexOf('external') === 0) { icon = OC.MimeType.getIconUrl('dir-external'); + dataIcon = icon; } } @@ -926,6 +937,11 @@ "data-permissions": fileData.permissions || this.getDirectoryPermissions() }); + if (dataIcon) { + // icon override + tr.attr('data-icon', dataIcon); + } + if (fileData.mountType) { tr.attr('data-mounttype', fileData.mountType); } @@ -1177,7 +1193,7 @@ // display actions this.fileActions.display(filenameTd, !options.silent, this); - if (fileData.isPreviewAvailable) { + if (fileData.isPreviewAvailable && mime !== 'httpd/unix-directory') { var iconDiv = filenameTd.find('.thumbnail'); // lazy load / newly inserted td ? // the typeof check ensures that the default value of animate is true diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js index abf7da52ff4..69c796e492f 100644 --- a/apps/files/js/mainfileinfodetailview.js +++ b/apps/files/js/mainfileinfodetailview.js @@ -128,8 +128,8 @@ $iconDiv.addClass('icon-loading icon-32'); this.loadPreview(this.model.getFullPath(), this.model.get('mimetype'), this.model.get('etag'), $iconDiv, $container, this.model.isImage()); } else { - // TODO: special icons / shared / external - $iconDiv.css('background-image', 'url("' + OC.MimeType.getIconUrl('dir') + '")'); + var iconUrl = this.model.get('icon') || OC.MimeType.getIconUrl('dir'); + $iconDiv.css('background-image', 'url("' + iconUrl + '")'); OC.Util.scaleFixForIE8($iconDiv); } this.$el.find('[title]').tooltip({placement: 'bottom'}); diff --git a/apps/files/l10n/lv.js b/apps/files/l10n/lv.js index fa5ddf4f402..f0d5b4212b0 100644 --- a/apps/files/l10n/lv.js +++ b/apps/files/l10n/lv.js @@ -30,10 +30,10 @@ OC.L10N.register( "Favorites" : "Iecienītie", "Home" : "Mājas", "Close" : "Aizvērt", + "Upload cancelled." : "Augšupielāde ir atcelta.", "Unable to upload {filename} as it is a directory or has 0 bytes" : "Neizdodas augšupielādēt {filename}, jo tā ir vai nu mape vai 0 baitu saturošs fails.", "Total file size {size1} exceeds upload limit {size2}" : "Kopējais faila izmērs {size1} pārsniedz augšupielādes ierobežojumu {size2}", "Not enough free space, you are uploading {size1} but only {size2} is left" : "Nav pietiekami daudz brīvas vietas. Tiek augšupielādēti {size1}, bet pieejami tikai {size2}", - "Upload cancelled." : "Augšupielāde ir atcelta.", "Could not get result from server." : "Nevar saņemt rezultātus no servera", "File upload is in progress. Leaving the page now will cancel the upload." : "Notiek augšupielāde. Pametot lapu tagad, tiks atcelta augšupielāde.", "Actions" : "Darbības", diff --git a/apps/files/l10n/lv.json b/apps/files/l10n/lv.json index b164c88e381..14d0b4093df 100644 --- a/apps/files/l10n/lv.json +++ b/apps/files/l10n/lv.json @@ -28,10 +28,10 @@ "Favorites" : "Iecienītie", "Home" : "Mājas", "Close" : "Aizvērt", + "Upload cancelled." : "Augšupielāde ir atcelta.", "Unable to upload {filename} as it is a directory or has 0 bytes" : "Neizdodas augšupielādēt {filename}, jo tā ir vai nu mape vai 0 baitu saturošs fails.", "Total file size {size1} exceeds upload limit {size2}" : "Kopējais faila izmērs {size1} pārsniedz augšupielādes ierobežojumu {size2}", "Not enough free space, you are uploading {size1} but only {size2} is left" : "Nav pietiekami daudz brīvas vietas. Tiek augšupielādēti {size1}, bet pieejami tikai {size2}", - "Upload cancelled." : "Augšupielāde ir atcelta.", "Could not get result from server." : "Nevar saņemt rezultātus no servera", "File upload is in progress. Leaving the page now will cancel the upload." : "Notiek augšupielāde. Pametot lapu tagad, tiks atcelta augšupielāde.", "Actions" : "Darbības", diff --git a/apps/files/l10n/nb_NO.js b/apps/files/l10n/nb_NO.js index 3d27173708d..7fe475a6a22 100644 --- a/apps/files/l10n/nb_NO.js +++ b/apps/files/l10n/nb_NO.js @@ -30,10 +30,10 @@ OC.L10N.register( "Favorites" : "Favoritter", "Home" : "Hjem", "Close" : "Lukk", + "Upload cancelled." : "Opplasting avbrutt.", "Unable to upload {filename} as it is a directory or has 0 bytes" : "Kan ikke laste opp {filename} fordi det er en mappe eller har 0 bytes", "Total file size {size1} exceeds upload limit {size2}" : "Total filstørrelse {size1} overstiger grense for opplasting {size2}", "Not enough free space, you are uploading {size1} but only {size2} is left" : "Ikke nok ledig plass. Du laster opp size1} men bare {size2} er ledig", - "Upload cancelled." : "Opplasting avbrutt.", "Could not get result from server." : "Fikk ikke resultat fra serveren.", "File upload is in progress. Leaving the page now will cancel the upload." : "Filopplasting pågår. Forlater du siden nå avbrytes opplastingen.", "Actions" : "Handlinger", @@ -96,6 +96,9 @@ OC.L10N.register( "%2$s deleted %1$s" : "%2$s slettet %1$s", "You restored %1$s" : "Du gjenopprettet %1$s", "%2$s restored %1$s" : "%2$s gjenopprettet %1$s", + "Changed by %2$s" : "Endret av %2$s", + "Deleted by %2$s" : "Slettet av %2$s", + "Restored by %2$s" : "Gjenopprettet av %2$s", "%s could not be renamed as it has been deleted" : "%s kunne ikke gis nytt navn da den er blitt slettet", "%s could not be renamed" : "Kunne ikke gi nytt navn til %s", "Upload (max. %s)" : "Opplasting (maks. %s)", diff --git a/apps/files/l10n/nb_NO.json b/apps/files/l10n/nb_NO.json index a7e0cf33b83..69e8ca742aa 100644 --- a/apps/files/l10n/nb_NO.json +++ b/apps/files/l10n/nb_NO.json @@ -28,10 +28,10 @@ "Favorites" : "Favoritter", "Home" : "Hjem", "Close" : "Lukk", + "Upload cancelled." : "Opplasting avbrutt.", "Unable to upload {filename} as it is a directory or has 0 bytes" : "Kan ikke laste opp {filename} fordi det er en mappe eller har 0 bytes", "Total file size {size1} exceeds upload limit {size2}" : "Total filstørrelse {size1} overstiger grense for opplasting {size2}", "Not enough free space, you are uploading {size1} but only {size2} is left" : "Ikke nok ledig plass. Du laster opp size1} men bare {size2} er ledig", - "Upload cancelled." : "Opplasting avbrutt.", "Could not get result from server." : "Fikk ikke resultat fra serveren.", "File upload is in progress. Leaving the page now will cancel the upload." : "Filopplasting pågår. Forlater du siden nå avbrytes opplastingen.", "Actions" : "Handlinger", @@ -94,6 +94,9 @@ "%2$s deleted %1$s" : "%2$s slettet %1$s", "You restored %1$s" : "Du gjenopprettet %1$s", "%2$s restored %1$s" : "%2$s gjenopprettet %1$s", + "Changed by %2$s" : "Endret av %2$s", + "Deleted by %2$s" : "Slettet av %2$s", + "Restored by %2$s" : "Gjenopprettet av %2$s", "%s could not be renamed as it has been deleted" : "%s kunne ikke gis nytt navn da den er blitt slettet", "%s could not be renamed" : "Kunne ikke gi nytt navn til %s", "Upload (max. %s)" : "Opplasting (maks. %s)", diff --git a/apps/files/l10n/oc.js b/apps/files/l10n/oc.js index 4e1c7e0a011..6a0a05c782a 100644 --- a/apps/files/l10n/oc.js +++ b/apps/files/l10n/oc.js @@ -44,6 +44,8 @@ OC.L10N.register( "Select" : "Seleccionar", "Pending" : "En espèra", "Unable to determine date" : "Impossible de determinar la data", + "This operation is forbidden" : "L'operacion es interdicha", + "This directory is unavailable, please check the logs or contact the administrator" : "Aqueste repertòri es pas disponible. Consultatz los logs o contactatz vòstre administrator", "Error moving file." : "Error al moment del desplaçament del fichièr.", "Error moving file" : "Error al moment del desplaçament del fichièr", "Error" : "Error", @@ -64,11 +66,16 @@ OC.L10N.register( "New" : "Novèl", "\"{name}\" is an invalid file name." : "\"{name}\" es pas un nom de fichièr valid.", "File name cannot be empty." : "Lo nom de fichièr pòt pas èsser void.", + "Storage of {owner} is full, files can not be updated or synced anymore!" : "L'espaci d'emmagazinatge de {owner} es plen. Los fichièrs pòdon pas mai èsser meses a jorn o sincronizats !", "Your storage is full, files can not be updated or synced anymore!" : "Vòstre espaci d'emmagazinatge es plen, los fichièrs pòdon pas mai èsser aponduts o sincronizats !", + "Storage of {owner} is almost full ({usedSpacePercent}%)" : "L'espaci d'emmagazinatge de {owner} es gaireben plen ({usedSpacePercent}%)", "Your storage is almost full ({usedSpacePercent}%)" : "Vòstre espace d'emmagazinatge es gaireben plen ({usedSpacePercent}%)", "_matches '{filter}'_::_match '{filter}'_" : ["correspond a '{filter}'","correspondon a '{filter}'"], + "Path" : "Camin", + "_%n byte_::_%n bytes_" : ["%n octet","%n octets"], "Favorited" : "Marcat coma favorit", "Favorite" : "Favorit", + "{newname} already exists" : "{new_name} existís ja", "Upload" : "Cargament", "Text file" : "Fichièr tèxte", "New text file.txt" : "Novèl fichièr tèxte .txt", @@ -89,12 +96,16 @@ OC.L10N.register( "%2$s deleted %1$s" : "%2$s a suprimit %1$s", "You restored %1$s" : "Avètz restablit %1$s", "%2$s restored %1$s" : "%2$s a restablit %1$s", + "Changed by %2$s" : "Modificat per %2$s", + "Deleted by %2$s" : "Suprimit per %2$s", + "Restored by %2$s" : "Restablit per %2$s", "%s could not be renamed as it has been deleted" : "%s pòt pas èsser renomenat perque es estat suprimit ", "%s could not be renamed" : "%s pòt pas èsser renomenat", "Upload (max. %s)" : "Mandadís (max. %s)", "File handling" : "Gestion de fichièrs", "Maximum upload size" : "Talha max. de mandadís", "max. possible: " : "Max. possible :", + "With PHP-FPM this value may take up to 5 minutes to take effect after saving." : "Amb PHP-FPM, se pòdon passar fins a 5 minutas abans qu'aquesta valor siá aplicada.", "Save" : "Salvar", "Can not be edited from here due to insufficient permissions." : "Pòt pas èsser modificat aicí a causa de permissions insufisentas.", "Settings" : "Paramètres", diff --git a/apps/files/l10n/oc.json b/apps/files/l10n/oc.json index 108bc5d9de9..0577b75076a 100644 --- a/apps/files/l10n/oc.json +++ b/apps/files/l10n/oc.json @@ -42,6 +42,8 @@ "Select" : "Seleccionar", "Pending" : "En espèra", "Unable to determine date" : "Impossible de determinar la data", + "This operation is forbidden" : "L'operacion es interdicha", + "This directory is unavailable, please check the logs or contact the administrator" : "Aqueste repertòri es pas disponible. Consultatz los logs o contactatz vòstre administrator", "Error moving file." : "Error al moment del desplaçament del fichièr.", "Error moving file" : "Error al moment del desplaçament del fichièr", "Error" : "Error", @@ -62,11 +64,16 @@ "New" : "Novèl", "\"{name}\" is an invalid file name." : "\"{name}\" es pas un nom de fichièr valid.", "File name cannot be empty." : "Lo nom de fichièr pòt pas èsser void.", + "Storage of {owner} is full, files can not be updated or synced anymore!" : "L'espaci d'emmagazinatge de {owner} es plen. Los fichièrs pòdon pas mai èsser meses a jorn o sincronizats !", "Your storage is full, files can not be updated or synced anymore!" : "Vòstre espaci d'emmagazinatge es plen, los fichièrs pòdon pas mai èsser aponduts o sincronizats !", + "Storage of {owner} is almost full ({usedSpacePercent}%)" : "L'espaci d'emmagazinatge de {owner} es gaireben plen ({usedSpacePercent}%)", "Your storage is almost full ({usedSpacePercent}%)" : "Vòstre espace d'emmagazinatge es gaireben plen ({usedSpacePercent}%)", "_matches '{filter}'_::_match '{filter}'_" : ["correspond a '{filter}'","correspondon a '{filter}'"], + "Path" : "Camin", + "_%n byte_::_%n bytes_" : ["%n octet","%n octets"], "Favorited" : "Marcat coma favorit", "Favorite" : "Favorit", + "{newname} already exists" : "{new_name} existís ja", "Upload" : "Cargament", "Text file" : "Fichièr tèxte", "New text file.txt" : "Novèl fichièr tèxte .txt", @@ -87,12 +94,16 @@ "%2$s deleted %1$s" : "%2$s a suprimit %1$s", "You restored %1$s" : "Avètz restablit %1$s", "%2$s restored %1$s" : "%2$s a restablit %1$s", + "Changed by %2$s" : "Modificat per %2$s", + "Deleted by %2$s" : "Suprimit per %2$s", + "Restored by %2$s" : "Restablit per %2$s", "%s could not be renamed as it has been deleted" : "%s pòt pas èsser renomenat perque es estat suprimit ", "%s could not be renamed" : "%s pòt pas èsser renomenat", "Upload (max. %s)" : "Mandadís (max. %s)", "File handling" : "Gestion de fichièrs", "Maximum upload size" : "Talha max. de mandadís", "max. possible: " : "Max. possible :", + "With PHP-FPM this value may take up to 5 minutes to take effect after saving." : "Amb PHP-FPM, se pòdon passar fins a 5 minutas abans qu'aquesta valor siá aplicada.", "Save" : "Salvar", "Can not be edited from here due to insufficient permissions." : "Pòt pas èsser modificat aicí a causa de permissions insufisentas.", "Settings" : "Paramètres", diff --git a/apps/files/lib/capabilities.php b/apps/files/lib/capabilities.php index 2e19283e4d6..14fb07a9d86 100644 --- a/apps/files/lib/capabilities.php +++ b/apps/files/lib/capabilities.php @@ -1,7 +1,7 @@ <?php /** * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php index 00a62fa002d..859c7042b89 100644 --- a/apps/files/tests/ajax_rename.php +++ b/apps/files/tests/ajax_rename.php @@ -5,7 +5,6 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author tbartenstein <tbartenstein@users.noreply.github.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files/tests/command/deleteorphanedfilestest.php b/apps/files/tests/command/deleteorphanedfilestest.php index 3a1a541d8f1..a667dba99fc 100644 --- a/apps/files/tests/command/deleteorphanedfilestest.php +++ b/apps/files/tests/command/deleteorphanedfilestest.php @@ -1,6 +1,7 @@ <?php /** * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files/tests/controller/apicontrollertest.php b/apps/files/tests/controller/apicontrollertest.php index 7f34c0a5642..fb728d5eff0 100644 --- a/apps/files/tests/controller/apicontrollertest.php +++ b/apps/files/tests/controller/apicontrollertest.php @@ -1,9 +1,8 @@ <?php /** - * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 994e1d32844..05e6fcc6122 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1166,7 +1166,7 @@ describe('OCA.Files.FileList tests', function() { it('renders provided icon for file when provided', function() { var fileData = { type: 'file', - name: 'test dir', + name: 'test file', icon: OC.webroot + '/core/img/filetypes/application-pdf.svg', mimetype: 'application/pdf' }; @@ -1178,7 +1178,7 @@ describe('OCA.Files.FileList tests', function() { it('renders preview when no icon was provided and preview is available', function() { var fileData = { type: 'file', - name: 'test dir', + name: 'test file', isPreviewAvailable: true }; var $tr = fileList.add(fileData); @@ -1192,7 +1192,7 @@ describe('OCA.Files.FileList tests', function() { it('renders default file type icon when no icon was provided and no preview is available', function() { var fileData = { type: 'file', - name: 'test dir', + name: 'test file', isPreviewAvailable: false }; var $tr = fileList.add(fileData); @@ -1200,6 +1200,47 @@ describe('OCA.Files.FileList tests', function() { expect(OC.TestUtil.getImageUrl($imgDiv)).toEqual(OC.webroot + '/core/img/filetypes/file.svg'); expect(previewLoadStub.notCalled).toEqual(true); }); + it('does not render preview for directories', function() { + var fileData = { + type: 'dir', + mimetype: 'httpd/unix-directory', + name: 'test dir', + isPreviewAvailable: true + }; + var $tr = fileList.add(fileData); + var $td = $tr.find('td.filename'); + expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder.svg'); + expect(previewLoadStub.notCalled).toEqual(true); + }); + it('render external storage icon for external storage root', function() { + var fileData = { + type: 'dir', + mimetype: 'httpd/unix-directory', + name: 'test dir', + isPreviewAvailable: true, + mountType: 'external-root' + }; + var $tr = fileList.add(fileData); + var $td = $tr.find('td.filename'); + expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg'); + expect(previewLoadStub.notCalled).toEqual(true); + }); + it('render external storage icon for external storage subdir', function() { + var fileData = { + type: 'dir', + mimetype: 'httpd/unix-directory', + name: 'test dir', + isPreviewAvailable: true, + mountType: 'external' + }; + var $tr = fileList.add(fileData); + var $td = $tr.find('td.filename'); + expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg'); + expect(previewLoadStub.notCalled).toEqual(true); + // default icon override + expect($tr.attr('data-icon')).toEqual(OC.webroot + '/core/img/filetypes/folder-external.svg'); + }); + }); describe('viewer mode', function() { it('enabling viewer mode hides files table and action buttons', function() { diff --git a/apps/files/tests/js/mainfileinfodetailviewSpec.js b/apps/files/tests/js/mainfileinfodetailviewSpec.js index f4403196f2e..460629806c8 100644 --- a/apps/files/tests/js/mainfileinfodetailviewSpec.js +++ b/apps/files/tests/js/mainfileinfodetailviewSpec.js @@ -112,6 +112,20 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() { lazyLoadPreviewStub.restore(); }); + it('uses icon from model if present in model', function() { + var lazyLoadPreviewStub = sinon.stub(fileList, 'lazyLoadPreview'); + testFileInfo.set('mimetype', 'httpd/unix-directory'); + testFileInfo.set('icon', OC.MimeType.getIconUrl('dir-external')); + view.setFileInfo(testFileInfo); + + expect(lazyLoadPreviewStub.notCalled).toEqual(true); + + expect(view.$el.find('.thumbnail').hasClass('icon-loading')).toEqual(false); + expect(view.$el.find('.thumbnail').css('background-image')) + .toContain('filetypes/folder-external.svg'); + + lazyLoadPreviewStub.restore(); + }); it('displays thumbnail', function() { var lazyLoadPreviewStub = sinon.stub(fileList, 'lazyLoadPreview'); diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index aa39d79a85e..a7d8f4f668d 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -1,8 +1,8 @@ <?php /** * @author Christian Berendt <berendt@b1-systems.de> - * @author Jan-Christoph Borchardt <hey@jancborchardt.net> * @author j-ed <juergen@eisfair.org> + * @author Jan-Christoph Borchardt <hey@jancborchardt.net> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> diff --git a/apps/files_external/appinfo/application.php b/apps/files_external/appinfo/application.php index c7deaaf270e..1d6e0d03400 100644 --- a/apps/files_external/appinfo/application.php +++ b/apps/files_external/appinfo/application.php @@ -2,7 +2,7 @@ /** * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Ross Nicoll <jrn@jrn.me.uk> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_external/appinfo/routes.php b/apps/files_external/appinfo/routes.php index a98a63c711d..39ded1dc2ec 100644 --- a/apps/files_external/appinfo/routes.php +++ b/apps/files_external/appinfo/routes.php @@ -4,7 +4,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Ross Nicoll <jrn@jrn.me.uk> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php index f754565f628..048f3588ed7 100644 --- a/apps/files_external/controller/storagescontroller.php +++ b/apps/files_external/controller/storagescontroller.php @@ -237,9 +237,21 @@ abstract class StoragesController extends Controller { ) ); } catch (InsufficientDataForMeaningfulAnswerException $e) { - $storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE); + $storage->setStatus( + \OC_Mount_Config::STATUS_INDETERMINATE, + $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) + ); } catch (StorageNotAvailableException $e) { - $storage->setStatus(\OC_Mount_Config::STATUS_ERROR); + $storage->setStatus( + \OC_Mount_Config::STATUS_ERROR, + $e->getMessage() + ); + } catch (\Exception $e) { + // FIXME: convert storage exceptions to StorageNotAvailableException + $storage->setStatus( + \OC_Mount_Config::STATUS_ERROR, + get_class($e).': '.$e->getMessage() + ); } } diff --git a/apps/files_external/js/mountsfilelist.js b/apps/files_external/js/mountsfilelist.js index c45faafd9bf..35aef751fef 100644 --- a/apps/files_external/js/mountsfilelist.js +++ b/apps/files_external/js/mountsfilelist.js @@ -86,6 +86,10 @@ if (this._reloadCall) { this._reloadCall.abort(); } + + // there is only root + this._setCurrentDir('/', false); + this._reloadCall = $.ajax({ url: OC.linkToOCS('apps/files_external/api/v1') + 'mounts', data: { @@ -106,10 +110,9 @@ if (result.ocs && result.ocs.data) { this.setFiles(this._makeFiles(result.ocs.data)); + return true; } - else { - // TODO: error handling - } + return false; }, /** diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 5da34c52193..a839f396b9b 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -643,6 +643,10 @@ MountConfigListView.prototype = _.extend({ }); addSelect2(this.$el.find('tr:not(#addMountPoint) .applicableUsers'), this._userListLimit); + this.$el.tooltip({ + selector: '.status span', + container: 'body' + }); this._initEvents(); @@ -709,11 +713,12 @@ MountConfigListView.prototype = _.extend({ } highlightInput($target); var $tr = $target.closest('tr'); + this.updateStatus($tr, null); var timer = $tr.data('save-timer'); clearTimeout(timer); timer = setTimeout(function() { - self.saveStorageConfig($tr); + self.saveStorageConfig($tr, null, timer); }, 2000); $tr.data('save-timer', timer); }, @@ -931,8 +936,9 @@ MountConfigListView.prototype = _.extend({ * * @param $tr storage row * @param Function callback callback to call after save + * @param concurrentTimer only update if the timer matches this */ - saveStorageConfig:function($tr, callback) { + saveStorageConfig:function($tr, callback, concurrentTimer) { var self = this; var storage = this.getStorageConfig($tr); if (!storage.validate()) { @@ -942,15 +948,23 @@ MountConfigListView.prototype = _.extend({ this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS); storage.save({ success: function(result) { - self.updateStatus($tr, result.status); - $tr.attr('data-id', result.id); - - if (_.isFunction(callback)) { - callback(storage); + if (concurrentTimer === undefined + || $tr.data('save-timer') === concurrentTimer + ) { + self.updateStatus($tr, result.status, result.statusMessage); + $tr.attr('data-id', result.id); + + if (_.isFunction(callback)) { + callback(storage); + } } }, error: function() { - self.updateStatus($tr, StorageConfig.Status.ERROR); + if (concurrentTimer === undefined + || $tr.data('save-timer') === concurrentTimer + ) { + self.updateStatus($tr, StorageConfig.Status.ERROR); + } } }); }, @@ -971,7 +985,7 @@ MountConfigListView.prototype = _.extend({ this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS); storage.recheck({ success: function(result) { - self.updateStatus($tr, result.status); + self.updateStatus($tr, result.status, result.statusMessage); }, error: function() { self.updateStatus($tr, StorageConfig.Status.ERROR); @@ -984,11 +998,15 @@ MountConfigListView.prototype = _.extend({ * * @param {jQuery} $tr * @param {int} status + * @param {string} message */ - updateStatus: function($tr, status) { + updateStatus: function($tr, status, message) { var $statusSpan = $tr.find('.status span'); $statusSpan.removeClass('loading-small success indeterminate error'); switch (status) { + case null: + // remove status + break; case StorageConfig.Status.IN_PROGRESS: $statusSpan.addClass('loading-small'); break; @@ -1001,6 +1019,7 @@ MountConfigListView.prototype = _.extend({ default: $statusSpan.addClass('error'); } + $statusSpan.attr('data-original-title', (typeof message === 'string') ? message : ''); }, /** diff --git a/apps/files_external/l10n/fr.js b/apps/files_external/l10n/fr.js index 2ca3c2d2219..12738d841e4 100644 --- a/apps/files_external/l10n/fr.js +++ b/apps/files_external/l10n/fr.js @@ -83,7 +83,7 @@ OC.L10N.register( "Username as share" : "Nom d'utilisateur comme nom de partage", "OpenStack Object Storage" : "OpenStack Object Storage", "Service name" : "Nom du service", - "Request timeout (seconds)" : "Timeout des requêtes (en secondes)", + "Request timeout (seconds)" : "Délai d'expiration des requêtes (en secondes)", "<b>Note:</b> " : "<b>Attention :</b>", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>Attention :</b> La prise en charge de cURL par PHP n'est pas activée ou installée. Le montage de %s n'est pas possible. Contactez votre administrateur système pour l'installer.", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>Attention : </b> La prise en charge du FTP par PHP n'est pas activée ou installée. Le montage de %s n'est pas possible. Contactez votre administrateur système pour l'installer.", diff --git a/apps/files_external/l10n/fr.json b/apps/files_external/l10n/fr.json index 5b36ff92741..425413b7e8d 100644 --- a/apps/files_external/l10n/fr.json +++ b/apps/files_external/l10n/fr.json @@ -81,7 +81,7 @@ "Username as share" : "Nom d'utilisateur comme nom de partage", "OpenStack Object Storage" : "OpenStack Object Storage", "Service name" : "Nom du service", - "Request timeout (seconds)" : "Timeout des requêtes (en secondes)", + "Request timeout (seconds)" : "Délai d'expiration des requêtes (en secondes)", "<b>Note:</b> " : "<b>Attention :</b>", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>Attention :</b> La prise en charge de cURL par PHP n'est pas activée ou installée. Le montage de %s n'est pas possible. Contactez votre administrateur système pour l'installer.", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>Attention : </b> La prise en charge du FTP par PHP n'est pas activée ou installée. Le montage de %s n'est pas possible. Contactez votre administrateur système pour l'installer.", diff --git a/apps/files_external/l10n/ja.js b/apps/files_external/l10n/ja.js index b4401e0e344..ac5d1bfe6f8 100644 --- a/apps/files_external/l10n/ja.js +++ b/apps/files_external/l10n/ja.js @@ -8,6 +8,8 @@ OC.L10N.register( "Storage with id \"%i\" not found" : "ストレージID \"%i\" が見つかりません", "Invalid mount point" : "無効なマウントポイント", "Invalid storage backend \"%s\"" : "\"%s\" のストレージバックエンドが不正", + "Not permitted to use backend \"%s\"" : "バックエンド %s を使うための権限がありません", + "Unsatisfied authentication mechanism parameters" : "認証のためのパラメータが不十分です", "Personal" : "個人", "System" : "システム", "Grant access" : "アクセスを許可", @@ -69,6 +71,7 @@ OC.L10N.register( "Username as share" : "共有名", "OpenStack Object Storage" : "OpenStack ObjectStorage", "Service name" : "サービス名", + "Request timeout (seconds)" : "リクエストがタイムアウトするまでの秒数", "<b>Note:</b> " : "<b>注意:</b> ", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>注意:</b> PHPにcURLのエクステンションが入っていないか、有効ではありません。%s をマウントすることができません。このシステムの管理者にインストールをお願いしてください。", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>注意:</b> PHPにFTPのエクステンションが入っていないか、有効ではありません。%s をマウントすることができません。このシステムの管理者にインストールをお願いしてください。", diff --git a/apps/files_external/l10n/ja.json b/apps/files_external/l10n/ja.json index fbabe2eeb0f..6664b3d97db 100644 --- a/apps/files_external/l10n/ja.json +++ b/apps/files_external/l10n/ja.json @@ -6,6 +6,8 @@ "Storage with id \"%i\" not found" : "ストレージID \"%i\" が見つかりません", "Invalid mount point" : "無効なマウントポイント", "Invalid storage backend \"%s\"" : "\"%s\" のストレージバックエンドが不正", + "Not permitted to use backend \"%s\"" : "バックエンド %s を使うための権限がありません", + "Unsatisfied authentication mechanism parameters" : "認証のためのパラメータが不十分です", "Personal" : "個人", "System" : "システム", "Grant access" : "アクセスを許可", @@ -67,6 +69,7 @@ "Username as share" : "共有名", "OpenStack Object Storage" : "OpenStack ObjectStorage", "Service name" : "サービス名", + "Request timeout (seconds)" : "リクエストがタイムアウトするまでの秒数", "<b>Note:</b> " : "<b>注意:</b> ", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>注意:</b> PHPにcURLのエクステンションが入っていないか、有効ではありません。%s をマウントすることができません。このシステムの管理者にインストールをお願いしてください。", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>注意:</b> PHPにFTPのエクステンションが入っていないか、有効ではありません。%s をマウントすることができません。このシステムの管理者にインストールをお願いしてください。", diff --git a/apps/files_external/l10n/lv.js b/apps/files_external/l10n/lv.js index 7b4d94be6c7..6590706fa2a 100644 --- a/apps/files_external/l10n/lv.js +++ b/apps/files_external/l10n/lv.js @@ -5,6 +5,7 @@ OC.L10N.register( "Personal" : "Personīgi", "Grant access" : "Piešķirt pieeju", "Access granted" : "Piešķirta pieeja", + "Enable encryption" : "Ieslēgt šifrēšanu", "Saved" : "Saglabāts", "None" : "Nav", "Username" : "Lietotājvārds", diff --git a/apps/files_external/l10n/lv.json b/apps/files_external/l10n/lv.json index 7ad68595d73..4e27db77737 100644 --- a/apps/files_external/l10n/lv.json +++ b/apps/files_external/l10n/lv.json @@ -3,6 +3,7 @@ "Personal" : "Personīgi", "Grant access" : "Piešķirt pieeju", "Access granted" : "Piešķirta pieeja", + "Enable encryption" : "Ieslēgt šifrēšanu", "Saved" : "Saglabāts", "None" : "Nav", "Username" : "Lietotājvārds", diff --git a/apps/files_external/l10n/nb_NO.js b/apps/files_external/l10n/nb_NO.js index ecafac048c0..1859d5a7267 100644 --- a/apps/files_external/l10n/nb_NO.js +++ b/apps/files_external/l10n/nb_NO.js @@ -101,6 +101,7 @@ OC.L10N.register( "Advanced settings" : "Avanserte innstillinger", "Delete" : "Slett", "Add storage" : "Legg til lagringsplass", + "Allow users to mount external storages" : "Tillat at brukere kobler opp eksterne lagre", "Allow users to mount the following external storage" : "Tillat brukere å koble opp følgende eksterne lagring" }, "nplurals=2; plural=(n != 1);"); diff --git a/apps/files_external/l10n/nb_NO.json b/apps/files_external/l10n/nb_NO.json index 9a7a2ae6287..669751aa00f 100644 --- a/apps/files_external/l10n/nb_NO.json +++ b/apps/files_external/l10n/nb_NO.json @@ -99,6 +99,7 @@ "Advanced settings" : "Avanserte innstillinger", "Delete" : "Slett", "Add storage" : "Legg til lagringsplass", + "Allow users to mount external storages" : "Tillat at brukere kobler opp eksterne lagre", "Allow users to mount the following external storage" : "Tillat brukere å koble opp følgende eksterne lagring" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/apps/files_external/l10n/ru.js b/apps/files_external/l10n/ru.js index 5550ea780ab..dd8f5c9bdf5 100644 --- a/apps/files_external/l10n/ru.js +++ b/apps/files_external/l10n/ru.js @@ -101,6 +101,7 @@ OC.L10N.register( "Advanced settings" : "Расширенные настройки", "Delete" : "Удалить", "Add storage" : "Добавить хранилище", + "Allow users to mount external storages" : "Разрешить пользователям подключать внешние хранилища", "Allow users to mount the following external storage" : "Разрешить пользователям монтировать следующие сервисы хранения данных" }, "nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);"); diff --git a/apps/files_external/l10n/ru.json b/apps/files_external/l10n/ru.json index 52792a3f09a..04044274379 100644 --- a/apps/files_external/l10n/ru.json +++ b/apps/files_external/l10n/ru.json @@ -99,6 +99,7 @@ "Advanced settings" : "Расширенные настройки", "Delete" : "Удалить", "Add storage" : "Добавить хранилище", + "Allow users to mount external storages" : "Разрешить пользователям подключать внешние хранилища", "Allow users to mount the following external storage" : "Разрешить пользователям монтировать следующие сервисы хранения данных" },"pluralForm" :"nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);" }
\ No newline at end of file diff --git a/apps/files_external/l10n/zh_TW.js b/apps/files_external/l10n/zh_TW.js index d272f82f094..db7bf975017 100644 --- a/apps/files_external/l10n/zh_TW.js +++ b/apps/files_external/l10n/zh_TW.js @@ -1,38 +1,101 @@ OC.L10N.register( "files_external", { + "Fetching request tokens failed. Verify that your app key and secret are correct." : "請求失敗,請驗證您的應用程式金鑰及密碼是否正確", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "存取失敗,請驗證您的應用程式金鑰及密碼是否正確", + "Please provide a valid app key and secret." : "請提供有效的應用程式金鑰及密碼", + "Step 1 failed. Exception: %s" : "步驟 1 失敗,出現異常: %s", + "Step 2 failed. Exception: %s" : "步驟 2 失敗,出現異常: %s", "External storage" : "外部儲存", + "Storage with id \"%i\" not found" : "沒有找到編號 \"%i\" 的儲存空間 ", + "Invalid backend or authentication mechanism class" : "無效的後端處理或是驗證方式", + "Invalid mount point" : "無效的掛載點", + "Objectstore forbidden" : "物件儲存禁止存取", + "Invalid storage backend \"%s\"" : "無效的後端儲存 \"%s\"", + "Not permitted to use backend \"%s\"" : "不被允許使用後端儲存 \"%s\"", + "Not permitted to use authentication mechanism \"%s\"" : "不被允許使用驗證機制 \"%s\"", + "Unsatisfied backend parameters" : "無法滿足後端所需的參數條件", + "Unsatisfied authentication mechanism parameters" : "無法滿足驗證機制所需的參數條件", "Personal" : "個人", "System" : "系統", "Grant access" : "允許存取", "Access granted" : "允許存取", + "Error configuring OAuth1" : "設定 OAuth1 時發生錯誤", + "Error configuring OAuth2" : "設定 OAuth2 時發生錯誤", + "Generate keys" : "產生金鑰", + "Error generating key pair" : "產生金鑰對錯誤", + "Enable encryption" : "啟用加密", + "Enable previews" : "啟動預覽", + "Check for changes" : "檢查變動", + "Never" : "絕不", + "Every time the filesystem is used" : "每當檔案系統使用時", + "All users. Type to select user or group." : "所有人都可以使用,或者選擇特定使用者、群組", + "(group)" : "(群組)", "Saved" : "已儲存", + "Access key" : "存取金鑰", + "Secret key" : "私密金鑰", "None" : "無", + "App key" : "App 金鑰", + "App secret" : "App 密碼", + "Client ID" : "客戶端ID", + "Client secret" : "客戶端密碼", + "OpenStack" : "OpenStack", "Username" : "使用者名稱", "Password" : "密碼", + "Tenant name" : "租戶/專案名稱", + "Identity endpoint URL" : "身份識別終端點 URL", + "Rackspace" : "Rackspace", "API key" : "API金鑰", + "Username and password" : "使用者帳號和密碼", + "RSA public key" : "RSA 公開金鑰", + "Public key" : "公開金鑰", "Amazon S3" : "Amazon S3", + "Bucket" : "Bucket", + "Hostname" : "主機名稱", "Port" : "連接埠", "Region" : "地區", "Enable SSL" : "啟用 SSL", + "Enable Path Style" : "啟用路徑格式", "WebDAV" : "WebDAV", "URL" : "URL", + "Remote subfolder" : "遠端子資料夾", + "Secure https://" : "安全 https://", + "Dropbox" : "Dropbox", + "FTP" : "檔案傳輸協定-FTP", "Host" : "主機", + "Secure ftps://" : "安全 ftps://", + "Google Drive" : "Google 雲端硬碟", "Local" : "本地", "Location" : "地點", "ownCloud" : "ownCloud", + "SFTP" : "安全檔案傳輸協定-SFTP", + "SFTP with secret key login" : "以密碼金鑰登入SFTP", + "SMB / CIFS" : "伺服器訊息區塊-SMB/網路文件共享系統 (CIFS)", "Share" : "分享", + "Domain" : "網域名稱", + "SMB / CIFS using OC login" : "SMB / CIFS 使用 OC 登入", + "Username as share" : "以使用者名稱分享", + "OpenStack Object Storage" : "OpenStack 物件儲存", + "Service name" : "服務名稱", + "Request timeout (seconds)" : "請求超時 (秒)", "<b>Note:</b> " : "<b>警告:</b> ", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告:</b> PHP 並未啓用 Curl 的支援,因此無法掛載 %s 。請洽您的系統管理員將其安裝並啓用。", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告</b>:PHP 並未啓用 FTP 的支援,因此無法掛載 %s,請洽您的系統管理員將其安裝並啓用。", "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告</b>並未安裝 \"%s\",因此無法掛載 %s。請洽您的系統管理員將其安裝並啓用。", + "No external storage configured" : "目前尚未配置任何外部儲存", + "You can add external storages in the personal settings" : "在個人設定裡您可以自行加入外部儲存設定", "Name" : "名稱", + "Storage type" : "儲存類型", + "Scope" : "範圍", "External Storage" : "外部儲存", "Folder name" : "資料夾名稱", + "Authentication" : "驗證", "Configuration" : "設定", "Available for" : "可用的", + "Advanced settings" : "進階設定", "Delete" : "刪除", "Add storage" : "增加儲存區", + "Allow users to mount external storages" : "允許使用者能自行掛載外部儲存", "Allow users to mount the following external storage" : "允許使用者自行掛載以下的外部儲存" }, "nplurals=1; plural=0;"); diff --git a/apps/files_external/l10n/zh_TW.json b/apps/files_external/l10n/zh_TW.json index 3efd2fa691f..760ff7f5841 100644 --- a/apps/files_external/l10n/zh_TW.json +++ b/apps/files_external/l10n/zh_TW.json @@ -1,36 +1,99 @@ { "translations": { + "Fetching request tokens failed. Verify that your app key and secret are correct." : "請求失敗,請驗證您的應用程式金鑰及密碼是否正確", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "存取失敗,請驗證您的應用程式金鑰及密碼是否正確", + "Please provide a valid app key and secret." : "請提供有效的應用程式金鑰及密碼", + "Step 1 failed. Exception: %s" : "步驟 1 失敗,出現異常: %s", + "Step 2 failed. Exception: %s" : "步驟 2 失敗,出現異常: %s", "External storage" : "外部儲存", + "Storage with id \"%i\" not found" : "沒有找到編號 \"%i\" 的儲存空間 ", + "Invalid backend or authentication mechanism class" : "無效的後端處理或是驗證方式", + "Invalid mount point" : "無效的掛載點", + "Objectstore forbidden" : "物件儲存禁止存取", + "Invalid storage backend \"%s\"" : "無效的後端儲存 \"%s\"", + "Not permitted to use backend \"%s\"" : "不被允許使用後端儲存 \"%s\"", + "Not permitted to use authentication mechanism \"%s\"" : "不被允許使用驗證機制 \"%s\"", + "Unsatisfied backend parameters" : "無法滿足後端所需的參數條件", + "Unsatisfied authentication mechanism parameters" : "無法滿足驗證機制所需的參數條件", "Personal" : "個人", "System" : "系統", "Grant access" : "允許存取", "Access granted" : "允許存取", + "Error configuring OAuth1" : "設定 OAuth1 時發生錯誤", + "Error configuring OAuth2" : "設定 OAuth2 時發生錯誤", + "Generate keys" : "產生金鑰", + "Error generating key pair" : "產生金鑰對錯誤", + "Enable encryption" : "啟用加密", + "Enable previews" : "啟動預覽", + "Check for changes" : "檢查變動", + "Never" : "絕不", + "Every time the filesystem is used" : "每當檔案系統使用時", + "All users. Type to select user or group." : "所有人都可以使用,或者選擇特定使用者、群組", + "(group)" : "(群組)", "Saved" : "已儲存", + "Access key" : "存取金鑰", + "Secret key" : "私密金鑰", "None" : "無", + "App key" : "App 金鑰", + "App secret" : "App 密碼", + "Client ID" : "客戶端ID", + "Client secret" : "客戶端密碼", + "OpenStack" : "OpenStack", "Username" : "使用者名稱", "Password" : "密碼", + "Tenant name" : "租戶/專案名稱", + "Identity endpoint URL" : "身份識別終端點 URL", + "Rackspace" : "Rackspace", "API key" : "API金鑰", + "Username and password" : "使用者帳號和密碼", + "RSA public key" : "RSA 公開金鑰", + "Public key" : "公開金鑰", "Amazon S3" : "Amazon S3", + "Bucket" : "Bucket", + "Hostname" : "主機名稱", "Port" : "連接埠", "Region" : "地區", "Enable SSL" : "啟用 SSL", + "Enable Path Style" : "啟用路徑格式", "WebDAV" : "WebDAV", "URL" : "URL", + "Remote subfolder" : "遠端子資料夾", + "Secure https://" : "安全 https://", + "Dropbox" : "Dropbox", + "FTP" : "檔案傳輸協定-FTP", "Host" : "主機", + "Secure ftps://" : "安全 ftps://", + "Google Drive" : "Google 雲端硬碟", "Local" : "本地", "Location" : "地點", "ownCloud" : "ownCloud", + "SFTP" : "安全檔案傳輸協定-SFTP", + "SFTP with secret key login" : "以密碼金鑰登入SFTP", + "SMB / CIFS" : "伺服器訊息區塊-SMB/網路文件共享系統 (CIFS)", "Share" : "分享", + "Domain" : "網域名稱", + "SMB / CIFS using OC login" : "SMB / CIFS 使用 OC 登入", + "Username as share" : "以使用者名稱分享", + "OpenStack Object Storage" : "OpenStack 物件儲存", + "Service name" : "服務名稱", + "Request timeout (seconds)" : "請求超時 (秒)", "<b>Note:</b> " : "<b>警告:</b> ", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告:</b> PHP 並未啓用 Curl 的支援,因此無法掛載 %s 。請洽您的系統管理員將其安裝並啓用。", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告</b>:PHP 並未啓用 FTP 的支援,因此無法掛載 %s,請洽您的系統管理員將其安裝並啓用。", "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "<b>警告</b>並未安裝 \"%s\",因此無法掛載 %s。請洽您的系統管理員將其安裝並啓用。", + "No external storage configured" : "目前尚未配置任何外部儲存", + "You can add external storages in the personal settings" : "在個人設定裡您可以自行加入外部儲存設定", "Name" : "名稱", + "Storage type" : "儲存類型", + "Scope" : "範圍", "External Storage" : "外部儲存", "Folder name" : "資料夾名稱", + "Authentication" : "驗證", "Configuration" : "設定", "Available for" : "可用的", + "Advanced settings" : "進階設定", "Delete" : "刪除", "Add storage" : "增加儲存區", + "Allow users to mount external storages" : "允許使用者能自行掛載外部儲存", "Allow users to mount the following external storage" : "允許使用者自行掛載以下的外部儲存" },"pluralForm" :"nplurals=1; plural=0;" }
\ No newline at end of file diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 00915140bab..4b867c005a7 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -418,27 +418,6 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - public function getMimeType($path) { - $path = $this->normalizePath($path); - - if ($this->is_dir($path)) { - return 'httpd/unix-directory'; - } else if ($this->file_exists($path)) { - try { - $result = $this->getConnection()->headObject(array( - 'Bucket' => $this->bucket, - 'Key' => $path - )); - } catch (S3Exception $e) { - \OCP\Util::logException('files_external', $e); - return false; - } - - return $result['ContentType']; - } - return false; - } - public function touch($path, $mtime = null) { $path = $this->normalizePath($path); diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index d9fdb748fcd..56a7e547ec6 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -269,6 +269,7 @@ class OC_Mount_Config { } } catch (Exception $exception) { \OCP\Util::logException('files_external', $exception); + throw $e; } } return self::STATUS_ERROR; diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index 3b353b7777a..df8a0255134 100644 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -299,18 +299,6 @@ class Dropbox extends \OC\Files\Storage\Common { } } - public function getMimeType($path) { - if ($this->filetype($path) == 'dir') { - return 'httpd/unix-directory'; - } else { - $metaData = $this->getDropBoxMetaData($path); - if ($metaData) { - return $metaData['mime_type']; - } - } - return false; - } - public function free_space($path) { try { $info = $this->dropbox->getAccountInfo(); diff --git a/apps/files_external/lib/storageconfig.php b/apps/files_external/lib/storageconfig.php index 70aaa186783..86a7e6ffa12 100644 --- a/apps/files_external/lib/storageconfig.php +++ b/apps/files_external/lib/storageconfig.php @@ -73,6 +73,13 @@ class StorageConfig implements \JsonSerializable { private $status; /** + * Status message + * + * @var string + */ + private $statusMessage; + + /** * Priority * * @var int @@ -295,7 +302,7 @@ class StorageConfig implements \JsonSerializable { } /** - * Sets the storage status, whether the config worked last time + * Gets the storage status, whether the config worked last time * * @return int $status status */ @@ -304,12 +311,23 @@ class StorageConfig implements \JsonSerializable { } /** + * Gets the message describing the storage status + * + * @return string|null + */ + public function getStatusMessage() { + return $this->statusMessage; + } + + /** * Sets the storage status, whether the config worked last time * * @param int $status status + * @param string|null $message optional message */ - public function setStatus($status) { + public function setStatus($status, $message = null) { $this->status = $status; + $this->statusMessage = $message; } /** @@ -341,6 +359,9 @@ class StorageConfig implements \JsonSerializable { if (!is_null($this->status)) { $result['status'] = $this->status; } + if (!is_null($this->statusMessage)) { + $result['statusMessage'] = $this->statusMessage; + } return $result; } } diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index b9454b8d671..e946e7feb77 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -106,7 +106,10 @@ class Swift extends \OC\Files\Storage\Common { $this->getContainer()->getPartialObject($path); return true; } catch (ClientErrorResponseException $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + // Expected response is "404 Not Found", so only log if it isn't + if ($e->getResponse()->getStatusCode() !== 404) { + \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + } return false; } } @@ -361,18 +364,6 @@ class Swift extends \OC\Files\Storage\Common { } } - public function getMimeType($path) { - $path = $this->normalizePath($path); - - if ($this->is_dir($path)) { - return 'httpd/unix-directory'; - } else if ($this->file_exists($path)) { - $object = $this->getContainer()->getPartialObject($path); - return $object->getContentType(); - } - return false; - } - public function touch($path, $mtime = null) { $path = $this->normalizePath($path); if (is_null($mtime)) { diff --git a/apps/files_external/tests/service/userglobalstoragesservicetest.php b/apps/files_external/tests/service/userglobalstoragesservicetest.php index 1b902b6eee5..e88764d0f78 100644 --- a/apps/files_external/tests/service/userglobalstoragesservicetest.php +++ b/apps/files_external/tests/service/userglobalstoragesservicetest.php @@ -1,6 +1,7 @@ <?php /** * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index c80f0e0b288..0f8a3d56cf0 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -5,7 +5,7 @@ * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/ajax/list.php b/apps/files_sharing/ajax/list.php index 9819048b881..c7f0bde5d4a 100644 --- a/apps/files_sharing/ajax/list.php +++ b/apps/files_sharing/ajax/list.php @@ -3,7 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php index 62157e0ac0e..2902969b21f 100644 --- a/apps/files_sharing/ajax/publicpreview.php +++ b/apps/files_sharing/ajax/publicpreview.php @@ -4,7 +4,7 @@ * @author Georg Ehrke <georg@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php index 42e77570f95..bb5136a0c99 100644 --- a/apps/files_sharing/api/local.php +++ b/apps/files_sharing/api/local.php @@ -4,7 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php index d67920c3521..41ebb6e2eab 100644 --- a/apps/files_sharing/api/remote.php +++ b/apps/files_sharing/api/remote.php @@ -1,7 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php index 832193f2b99..93998ad774e 100644 --- a/apps/files_sharing/api/server2server.php +++ b/apps/files_sharing/api/server2server.php @@ -3,6 +3,7 @@ * @author Arthur Schiwon <blizzz@owncloud.com> * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php index b34aef72163..21f68d9b253 100644 --- a/apps/files_sharing/api/sharees.php +++ b/apps/files_sharing/api/sharees.php @@ -1,7 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php index 9dc0e0618b5..545a9425083 100644 --- a/apps/files_sharing/appinfo/application.php +++ b/apps/files_sharing/appinfo/application.php @@ -3,7 +3,8 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/appinfo/install.php b/apps/files_sharing/appinfo/install.php index 607e990346a..5185ae883f3 100644 --- a/apps/files_sharing/appinfo/install.php +++ b/apps/files_sharing/appinfo/install.php @@ -1,6 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index a466c4fc6cc..db7aa126c4e 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -5,7 +5,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index 03fb78a05af..8bff20cc442 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -2,6 +2,7 @@ /** * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 30a803f3207..63225a0d8ec 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -130,6 +130,13 @@ // remove icon, if applicable OC.Share.markFileAsShared($tr, false, false); } + var newIcon = $tr.attr('data-icon'); + // in case markFileAsShared decided to change the icon, + // we need to modify the model + // (FIXME: yes, this is hacky) + if (fileInfoModel.get('icon') !== newIcon) { + fileInfoModel.set('icon', newIcon); + } }); fileList.registerTabView(shareTab); }, diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index 2e798a92578..edf138b97ae 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -123,6 +123,9 @@ this._reloadCall.abort(); } + // there is only root + this._setCurrentDir('/', false); + var promises = []; var shares = $.ajax({ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares', @@ -173,17 +176,14 @@ if (shares[0].ocs && shares[0].ocs.data) { files = files.concat(this._makeFilesFromShares(shares[0].ocs.data)); - } else { - // TODO: error handling } if (remoteShares && remoteShares[0].ocs && remoteShares[0].ocs.data) { files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data)); - } else { - // TODO: error handling } this.setFiles(files); + return true; }, _makeFilesFromRemoteShares: function(data) { diff --git a/apps/files_sharing/l10n/ja.js b/apps/files_sharing/l10n/ja.js index d2e3bc9b263..b80be0c3315 100644 --- a/apps/files_sharing/l10n/ja.js +++ b/apps/files_sharing/l10n/ja.js @@ -38,10 +38,23 @@ OC.L10N.register( "Public shared file %1$s was downloaded" : "公開共有ファイル %1$s がダウンロードされました", "You shared %1$s with %2$s" : "あなたは %1$s を %2$s と共有しました", "You shared %1$s with group %2$s" : "あなたは %1$s をグループ %2$s と共有しました", + "%2$s shared %1$s with %3$s" : "%2$s は %1$s を %3$s と共有しました", + "%2$s shared %1$s with group %3$s" : "%2$s は %1$s をグループ %3$s と共有しました", + "%2$s shared %1$s via link" : "%2$s はリンク経由で %1$s を共有しました", "%2$s shared %1$s with you" : "%2$s は %1$s をあなたと共有しました", "You shared %1$s via link" : "リンク経由で %1$s を共有しています", + "Downloaded via public link" : "公開リンクからダウンロードしました", + "Shared with %2$s" : "%2$s と共有しました", + "Shared with group %2$s" : "%2$s グループと共有しました", + "Shared with %3$s by %2$s" : "%3$s と %2$s で共有しました", + "Shared with group %3$s by %2$s" : "%3$s グループと %2$s で共有しました", + "Shared via link by %2$s" : "リンク経由で %2$s が共有しました", + "Shared by %2$s" : "%2$s が共有", + "Shared via public link" : "公開リンク経由で共有中", "Shares" : "共有", + "You received %2$s as a remote share from %1$s" : "%1$s からリモート共有として %2$s を受け取りました。", "Accept" : "承諾", + "Decline" : "拒否《はてなキーワード》", "Share with me through my #ownCloud Federated Cloud ID, see %s" : "#ownCloud の「クラウド連携ID」で私と共有できます。こちらを見てください。%s", "Share with me through my #ownCloud Federated Cloud ID" : "#ownCloud の「クラウド連携ID」で私と共有できます。", "This share is password-protected" : "この共有はパスワードで保護されています", diff --git a/apps/files_sharing/l10n/ja.json b/apps/files_sharing/l10n/ja.json index 16ca792e33d..8f9efffb782 100644 --- a/apps/files_sharing/l10n/ja.json +++ b/apps/files_sharing/l10n/ja.json @@ -36,10 +36,23 @@ "Public shared file %1$s was downloaded" : "公開共有ファイル %1$s がダウンロードされました", "You shared %1$s with %2$s" : "あなたは %1$s を %2$s と共有しました", "You shared %1$s with group %2$s" : "あなたは %1$s をグループ %2$s と共有しました", + "%2$s shared %1$s with %3$s" : "%2$s は %1$s を %3$s と共有しました", + "%2$s shared %1$s with group %3$s" : "%2$s は %1$s をグループ %3$s と共有しました", + "%2$s shared %1$s via link" : "%2$s はリンク経由で %1$s を共有しました", "%2$s shared %1$s with you" : "%2$s は %1$s をあなたと共有しました", "You shared %1$s via link" : "リンク経由で %1$s を共有しています", + "Downloaded via public link" : "公開リンクからダウンロードしました", + "Shared with %2$s" : "%2$s と共有しました", + "Shared with group %2$s" : "%2$s グループと共有しました", + "Shared with %3$s by %2$s" : "%3$s と %2$s で共有しました", + "Shared with group %3$s by %2$s" : "%3$s グループと %2$s で共有しました", + "Shared via link by %2$s" : "リンク経由で %2$s が共有しました", + "Shared by %2$s" : "%2$s が共有", + "Shared via public link" : "公開リンク経由で共有中", "Shares" : "共有", + "You received %2$s as a remote share from %1$s" : "%1$s からリモート共有として %2$s を受け取りました。", "Accept" : "承諾", + "Decline" : "拒否《はてなキーワード》", "Share with me through my #ownCloud Federated Cloud ID, see %s" : "#ownCloud の「クラウド連携ID」で私と共有できます。こちらを見てください。%s", "Share with me through my #ownCloud Federated Cloud ID" : "#ownCloud の「クラウド連携ID」で私と共有できます。", "This share is password-protected" : "この共有はパスワードで保護されています", diff --git a/apps/files_sharing/l10n/lv.js b/apps/files_sharing/l10n/lv.js index 9c2f4d3fe48..f59a8d0b395 100644 --- a/apps/files_sharing/l10n/lv.js +++ b/apps/files_sharing/l10n/lv.js @@ -56,6 +56,7 @@ OC.L10N.register( "Download %s" : "Lejupielādēt %s", "Direct link" : "Tiešā saite", "Federated Cloud Sharing" : "Federatīva mākoņkoplietošana", + "Open documentation" : "Atvērt dokumentāciju", "Allow users on this server to send shares to other servers" : "Atļaut šī servera lietotājiem sūtīt koplietotnes uz citiem serveriem", "Allow users on this server to receive shares from other servers" : "Atļaut šī servera lietotājiem saņem koplietotnes no citiem serveriem" }, diff --git a/apps/files_sharing/l10n/lv.json b/apps/files_sharing/l10n/lv.json index abc16e3ad68..7c7e43cce4b 100644 --- a/apps/files_sharing/l10n/lv.json +++ b/apps/files_sharing/l10n/lv.json @@ -54,6 +54,7 @@ "Download %s" : "Lejupielādēt %s", "Direct link" : "Tiešā saite", "Federated Cloud Sharing" : "Federatīva mākoņkoplietošana", + "Open documentation" : "Atvērt dokumentāciju", "Allow users on this server to send shares to other servers" : "Atļaut šī servera lietotājiem sūtīt koplietotnes uz citiem serveriem", "Allow users on this server to receive shares from other servers" : "Atļaut šī servera lietotājiem saņem koplietotnes no citiem serveriem" },"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" diff --git a/apps/files_sharing/l10n/nb_NO.js b/apps/files_sharing/l10n/nb_NO.js index a8f7fbdbc9b..4f7fb08ef16 100644 --- a/apps/files_sharing/l10n/nb_NO.js +++ b/apps/files_sharing/l10n/nb_NO.js @@ -43,6 +43,14 @@ OC.L10N.register( "%2$s shared %1$s via link" : "%2$s delte %1$s via lenke", "%2$s shared %1$s with you" : "%2$s delte %1$s med deg", "You shared %1$s via link" : "Du delte %1$s via lenke", + "Downloaded via public link" : "Nedlastet via offentlig lenke", + "Shared with %2$s" : "Delt med %2$s", + "Shared with group %2$s" : "Delt med gruppe %2$s", + "Shared with %3$s by %2$s" : "Delt med %3$s av %2$s", + "Shared with group %3$s by %2$s" : "Delt med gruppe %3$s av %2$s", + "Shared via link by %2$s" : "Delt via lenke av %2$s", + "Shared by %2$s" : "Delt av %2$s", + "Shared via public link" : "Delt via offentlig lenke", "Shares" : "Delinger", "You received %2$s as a remote share from %1$s" : "Du mottok %2$s som en ekstern deling fra %1$s", "Accept" : "Aksepter", diff --git a/apps/files_sharing/l10n/nb_NO.json b/apps/files_sharing/l10n/nb_NO.json index e9c67955708..e75f095f354 100644 --- a/apps/files_sharing/l10n/nb_NO.json +++ b/apps/files_sharing/l10n/nb_NO.json @@ -41,6 +41,14 @@ "%2$s shared %1$s via link" : "%2$s delte %1$s via lenke", "%2$s shared %1$s with you" : "%2$s delte %1$s med deg", "You shared %1$s via link" : "Du delte %1$s via lenke", + "Downloaded via public link" : "Nedlastet via offentlig lenke", + "Shared with %2$s" : "Delt med %2$s", + "Shared with group %2$s" : "Delt med gruppe %2$s", + "Shared with %3$s by %2$s" : "Delt med %3$s av %2$s", + "Shared with group %3$s by %2$s" : "Delt med gruppe %3$s av %2$s", + "Shared via link by %2$s" : "Delt via lenke av %2$s", + "Shared by %2$s" : "Delt av %2$s", + "Shared via public link" : "Delt via offentlig lenke", "Shares" : "Delinger", "You received %2$s as a remote share from %1$s" : "Du mottok %2$s som en ekstern deling fra %1$s", "Accept" : "Aksepter", diff --git a/apps/files_sharing/l10n/zh_TW.js b/apps/files_sharing/l10n/zh_TW.js index b7e7ca4f91f..eecbbf1f92e 100644 --- a/apps/files_sharing/l10n/zh_TW.js +++ b/apps/files_sharing/l10n/zh_TW.js @@ -21,6 +21,7 @@ OC.L10N.register( "Cancel" : "取消", "Add remote share" : "加入遠端分享", "You can upload into this folder" : "你可以上傳內容到此資料夾", + "No ownCloud installation (7 or higher) found at {remote}" : "沒有在 {remote} 找到 ownCloud (本版7 或 更新版)", "Invalid ownCloud url" : "無效的 ownCloud URL", "Shared by" : "由...分享", "Sharing" : "分享", diff --git a/apps/files_sharing/l10n/zh_TW.json b/apps/files_sharing/l10n/zh_TW.json index 944014926d0..14be4c11d55 100644 --- a/apps/files_sharing/l10n/zh_TW.json +++ b/apps/files_sharing/l10n/zh_TW.json @@ -19,6 +19,7 @@ "Cancel" : "取消", "Add remote share" : "加入遠端分享", "You can upload into this folder" : "你可以上傳內容到此資料夾", + "No ownCloud installation (7 or higher) found at {remote}" : "沒有在 {remote} 找到 ownCloud (本版7 或 更新版)", "Invalid ownCloud url" : "無效的 ownCloud URL", "Shared by" : "由...分享", "Sharing" : "分享", diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 9f3bf6508b1..2e615e231f1 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -8,7 +8,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php index c8ba1273281..220878ec2aa 100644 --- a/apps/files_sharing/lib/capabilities.php +++ b/apps/files_sharing/lib/capabilities.php @@ -1,6 +1,6 @@ <?php /** - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/controllers/externalsharescontroller.php b/apps/files_sharing/lib/controllers/externalsharescontroller.php index 71cc956ec98..edf065ab476 100644 --- a/apps/files_sharing/lib/controllers/externalsharescontroller.php +++ b/apps/files_sharing/lib/controllers/externalsharescontroller.php @@ -3,7 +3,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index 8a4e67eccf6..4b446d79ada 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -7,6 +7,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/exceptions/s2sexception.php b/apps/files_sharing/lib/exceptions/s2sexception.php index d914e9e06db..fe2659d36ff 100644 --- a/apps/files_sharing/lib/exceptions/s2sexception.php +++ b/apps/files_sharing/lib/exceptions/s2sexception.php @@ -2,7 +2,7 @@ /** * @author Björn Schießle <schiessle@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php index 86b8904cc9a..93e2cdb540b 100644 --- a/apps/files_sharing/lib/external/manager.php +++ b/apps/files_sharing/lib/external/manager.php @@ -5,8 +5,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Vincent Petry <pvince81@owncloud.com> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index beb8c69c415..a804737c490 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -7,7 +7,7 @@ * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php index 9170c08b59d..22b9d32a275 100644 --- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php @@ -2,7 +2,7 @@ /** * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/lib/propagation/propagationmanager.php b/apps/files_sharing/lib/propagation/propagationmanager.php index 6ed70e93f84..aac9428240d 100644 --- a/apps/files_sharing/lib/propagation/propagationmanager.php +++ b/apps/files_sharing/lib/propagation/propagationmanager.php @@ -1,6 +1,7 @@ <?php /** * @author Robin Appelman <icewind@owncloud.com> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/propagation/recipientpropagator.php b/apps/files_sharing/lib/propagation/recipientpropagator.php index f0941ce6cb7..5eacf4c0f6e 100644 --- a/apps/files_sharing/lib/propagation/recipientpropagator.php +++ b/apps/files_sharing/lib/propagation/recipientpropagator.php @@ -1,5 +1,6 @@ <?php /** + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php index 67ef3937e6d..ffc417db2f4 100644 --- a/apps/files_sharing/lib/share/file.php +++ b/apps/files_sharing/lib/share/file.php @@ -3,10 +3,11 @@ * @author Andreas Fischer <bantu@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php index daa5b5e9eb8..5e7cd8099db 100644 --- a/apps/files_sharing/lib/share/folder.php +++ b/apps/files_sharing/lib/share/folder.php @@ -5,7 +5,7 @@ * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php index 85eb264ce09..a1387957867 100644 --- a/apps/files_sharing/lib/sharedmount.php +++ b/apps/files_sharing/lib/sharedmount.php @@ -4,7 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index b0e56f5f054..18e02844179 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -7,7 +7,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author scambra <sergio@entrecables.com> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index d70ed23b941..26044cc1c8e 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -5,7 +5,7 @@ * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index 3809b812051..760bc0591e5 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -5,7 +5,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/tests/api/shareestest.php b/apps/files_sharing/tests/api/shareestest.php index 923881d4569..8a35350aeb5 100644 --- a/apps/files_sharing/tests/api/shareestest.php +++ b/apps/files_sharing/tests/api/shareestest.php @@ -1,7 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php index b151f47a468..8bebde9f2d1 100644 --- a/apps/files_sharing/tests/capabilities.php +++ b/apps/files_sharing/tests/capabilities.php @@ -1,7 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/controller/externalsharecontroller.php b/apps/files_sharing/tests/controller/externalsharecontroller.php index 7bc11f7fb94..4913c7308ba 100644 --- a/apps/files_sharing/tests/controller/externalsharecontroller.php +++ b/apps/files_sharing/tests/controller/externalsharecontroller.php @@ -1,7 +1,7 @@ <?php /** * @author Lukas Reschke <lukas@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/etagpropagation.php b/apps/files_sharing/tests/etagpropagation.php index 9f9b65ed527..1abf04df84f 100644 --- a/apps/files_sharing/tests/etagpropagation.php +++ b/apps/files_sharing/tests/etagpropagation.php @@ -1,5 +1,7 @@ <?php /** + * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Lukas Reschke <lukas@owncloud.com> * @author Robin Appelman <icewind@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/tests/expiresharesjobtest.php b/apps/files_sharing/tests/expiresharesjobtest.php index 90da4011d8b..63a2c46f647 100644 --- a/apps/files_sharing/tests/expiresharesjobtest.php +++ b/apps/files_sharing/tests/expiresharesjobtest.php @@ -1,6 +1,6 @@ <?php /** - * @author Vincent Petry <pvince81@owncloud.com> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/external/managertest.php b/apps/files_sharing/tests/external/managertest.php index 7242779d455..5b93b7494e9 100644 --- a/apps/files_sharing/tests/external/managertest.php +++ b/apps/files_sharing/tests/external/managertest.php @@ -1,6 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_sharing/tests/grouppropagationmanager.php b/apps/files_sharing/tests/grouppropagationmanager.php index 6fc6ef7a532..ea32ca4f7ec 100644 --- a/apps/files_sharing/tests/grouppropagationmanager.php +++ b/apps/files_sharing/tests/grouppropagationmanager.php @@ -1,7 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php index 0269f77d0d5..031f8c1b970 100644 --- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php @@ -2,7 +2,7 @@ /** * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_sharing/tests/sharedmount.php b/apps/files_sharing/tests/sharedmount.php index 6f487892b8f..94c0ad448bc 100644 --- a/apps/files_sharing/tests/sharedmount.php +++ b/apps/files_sharing/tests/sharedmount.php @@ -4,7 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_sharing/tests/sizepropagation.php b/apps/files_sharing/tests/sizepropagation.php index c596003de76..1d09f69449f 100644 --- a/apps/files_sharing/tests/sizepropagation.php +++ b/apps/files_sharing/tests/sizepropagation.php @@ -1,5 +1,6 @@ <?php /** + * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 7ce8d632e4b..40d1811717c 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -4,7 +4,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php index 90add53f77f..49d6d93f574 100644 --- a/apps/files_trashbin/ajax/preview.php +++ b/apps/files_trashbin/ajax/preview.php @@ -3,7 +3,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Georg Ehrke <georg@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index 01dc91f9bac..f0e5ce6d889 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -4,7 +4,7 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_trashbin/appinfo/application.php b/apps/files_trashbin/appinfo/application.php index 08ab7cd5c1d..59553abfb14 100644 --- a/apps/files_trashbin/appinfo/application.php +++ b/apps/files_trashbin/appinfo/application.php @@ -1,6 +1,6 @@ <?php /** - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/appinfo/routes.php b/apps/files_trashbin/appinfo/routes.php index caa9f0864a1..f3b97d8687c 100644 --- a/apps/files_trashbin/appinfo/routes.php +++ b/apps/files_trashbin/appinfo/routes.php @@ -1,7 +1,7 @@ <?php /** * @author Lukas Reschke <lukas@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/l10n/zh_TW.js b/apps/files_trashbin/l10n/zh_TW.js index 85d0873eddf..e0ad6dbd723 100644 --- a/apps/files_trashbin/l10n/zh_TW.js +++ b/apps/files_trashbin/l10n/zh_TW.js @@ -5,13 +5,15 @@ OC.L10N.register( "Couldn't restore %s" : "無法還原 %s", "Deleted files" : "回收桶", "Restore" : "還原", + "Delete" : "刪除", "Delete permanently" : "永久刪除", "Error" : "錯誤", "restored" : "已還原", + "No deleted files" : "沒有已刪除的檔案", + "You will be able to recover deleted files from here" : "您可以從這裡還原已刪除的檔案", "No entries found in this folder" : "在此資料夾中沒有任何項目", "Select all" : "全選", "Name" : "名稱", - "Deleted" : "已刪除", - "Delete" : "刪除" + "Deleted" : "已刪除" }, "nplurals=1; plural=0;"); diff --git a/apps/files_trashbin/l10n/zh_TW.json b/apps/files_trashbin/l10n/zh_TW.json index 5c744f828c9..6a313220b58 100644 --- a/apps/files_trashbin/l10n/zh_TW.json +++ b/apps/files_trashbin/l10n/zh_TW.json @@ -3,13 +3,15 @@ "Couldn't restore %s" : "無法還原 %s", "Deleted files" : "回收桶", "Restore" : "還原", + "Delete" : "刪除", "Delete permanently" : "永久刪除", "Error" : "錯誤", "restored" : "已還原", + "No deleted files" : "沒有已刪除的檔案", + "You will be able to recover deleted files from here" : "您可以從這裡還原已刪除的檔案", "No entries found in this folder" : "在此資料夾中沒有任何項目", "Select all" : "全選", "Name" : "名稱", - "Deleted" : "已刪除", - "Delete" : "刪除" + "Deleted" : "已刪除" },"pluralForm" :"nplurals=1; plural=0;" }
\ No newline at end of file diff --git a/apps/files_trashbin/lib/capabilities.php b/apps/files_trashbin/lib/capabilities.php index c991cc8be65..d903066e676 100644 --- a/apps/files_trashbin/lib/capabilities.php +++ b/apps/files_trashbin/lib/capabilities.php @@ -2,7 +2,7 @@ /** * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/files_trashbin/lib/helper.php b/apps/files_trashbin/lib/helper.php index 3d6a02c7776..d14e97285c5 100644 --- a/apps/files_trashbin/lib/helper.php +++ b/apps/files_trashbin/lib/helper.php @@ -5,7 +5,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 9eada31f5df..8f0fe745a45 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -12,7 +12,7 @@ * @author Qingping Hou <dave2008713@gmail.com> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Sjors van der Pluijm <sjors@desjors.nl> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Victor Dubiniuk <dubiniuk@owncloud.com> diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php index d7bc44f17a2..0da518f3eaa 100644 --- a/apps/files_versions/ajax/preview.php +++ b/apps/files_versions/ajax/preview.php @@ -1,7 +1,7 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/apps/files_versions/appinfo/application.php b/apps/files_versions/appinfo/application.php index 00723e621ac..ba0a2ae74cb 100644 --- a/apps/files_versions/appinfo/application.php +++ b/apps/files_versions/appinfo/application.php @@ -1,6 +1,6 @@ <?php /** - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php index 9bab86d9224..b2ed477de68 100644 --- a/apps/files_versions/appinfo/routes.php +++ b/apps/files_versions/appinfo/routes.php @@ -4,7 +4,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tom Needham <tom@owncloud.com> * diff --git a/apps/files_versions/lib/capabilities.php b/apps/files_versions/lib/capabilities.php index 11b98038f46..ba4de906c70 100644 --- a/apps/files_versions/lib/capabilities.php +++ b/apps/files_versions/lib/capabilities.php @@ -2,7 +2,7 @@ /** * @author Christopher Schäpers <kondou@ts.unde.re> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/files_versions/tests/command/expiretest.php b/apps/files_versions/tests/command/expiretest.php index eb622689c33..eccc1f4c2ad 100644 --- a/apps/files_versions/tests/command/expiretest.php +++ b/apps/files_versions/tests/command/expiretest.php @@ -1,6 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Jörn Friedrich Dreyer <jfd@butonic.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/provisioning_api/appinfo/app.php b/apps/provisioning_api/appinfo/app.php deleted file mode 100644 index 40d8d5d04d3..00000000000 --- a/apps/provisioning_api/appinfo/app.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @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/> - * - */ diff --git a/apps/provisioning_api/appinfo/routes.php b/apps/provisioning_api/appinfo/routes.php index 17cfea26572..dcf18e0e53b 100644 --- a/apps/provisioning_api/appinfo/routes.php +++ b/apps/provisioning_api/appinfo/routes.php @@ -1,8 +1,10 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> + * @author michag86 <micha_g@arcor.de> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -31,7 +33,8 @@ $users = new \OCA\Provisioning_API\Users( \OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), - \OC::$server->getUserSession() + \OC::$server->getUserSession(), + \OC::$server->getLogger() ); API::register('get', '/cloud/users', [$users, 'getUsers'], 'provisioning_api', API::SUBADMIN_AUTH); API::register('post', '/cloud/users', [$users, 'addUser'], 'provisioning_api', API::ADMIN_AUTH); diff --git a/apps/provisioning_api/lib/apps.php b/apps/provisioning_api/lib/apps.php index ba920c7a9c9..e0fa63cca34 100644 --- a/apps/provisioning_api/lib/apps.php +++ b/apps/provisioning_api/lib/apps.php @@ -3,7 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php index 7e7515bc709..c28db35972f 100644 --- a/apps/provisioning_api/lib/groups.php +++ b/apps/provisioning_api/lib/groups.php @@ -3,7 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -26,7 +26,6 @@ namespace OCA\Provisioning_API; use \OC_OCS_Result; -use \OC_SubAdmin; use OCP\IGroup; use OCP\IUser; @@ -85,9 +84,16 @@ class Groups{ if(!$this->groupManager->groupExists($parameters['groupid'])) { return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested group could not be found'); } + + $isSubadminOfGroup = false; + $targetGroupObject =$this->groupManager->get($parameters['groupid']); + if($targetGroupObject !== null) { + $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $targetGroupObject); + } + // Check subadmin has access to this group if($this->groupManager->isAdmin($user->getUID()) - || in_array($parameters['groupid'], \OC_SubAdmin::getSubAdminsGroups($user->getUID()))){ + || $isSubadminOfGroup) { $users = $this->groupManager->get($parameters['groupid'])->getUsers(); $users = array_map(function($user) { /** @var IUser $user */ @@ -144,11 +150,21 @@ class Groups{ public function getSubAdminsOfGroup($parameters) { $group = $parameters['groupid']; // Check group exists - if(!$this->groupManager->groupExists($group)) { + $targetGroup = $this->groupManager->get($group); + if($targetGroup === null) { return new OC_OCS_Result(null, 101, 'Group does not exist'); } + + $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); + // New class returns IUser[] so convert back + $uids = []; + foreach ($subadmins as $user) { + $uids[] = $user->getUID(); + } + $subadmins = $uids; + // Go - if(!$subadmins = OC_Subadmin::getGroupsSubAdmins($group)) { + if(!$subadmins) { return new OC_OCS_Result(null, 102, 'Unknown error occured'); } else { return new OC_OCS_Result($subadmins); diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php index 0b529bcea2c..a9fafb48912 100644 --- a/apps/provisioning_api/lib/users.php +++ b/apps/provisioning_api/lib/users.php @@ -2,8 +2,9 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> + * @author michag86 <micha_g@arcor.de> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tom Needham <tom@owncloud.com> * @@ -27,39 +28,40 @@ namespace OCA\Provisioning_API; use \OC_OCS_Result; -use \OC_SubAdmin; use \OC_Helper; -use \OC_Group; use OCP\Files\NotFoundException; +use OCP\ILogger; class Users { /** @var \OCP\IUserManager */ private $userManager; - /** @var \OCP\IConfig */ private $config; - /** @var \OCP\IGroupManager */ private $groupManager; - /** @var \OCP\IUserSession */ private $userSession; + /** @var ILogger */ + private $logger; /** * @param \OCP\IUserManager $userManager * @param \OCP\IConfig $config * @param \OCP\IGroupManager $groupManager * @param \OCP\IUserSession $userSession + * @param ILogger $logger */ public function __construct(\OCP\IUserManager $userManager, \OCP\IConfig $config, \OCP\IGroupManager $groupManager, - \OCP\IUserSession $userSession) { + \OCP\IUserSession $userSession, + ILogger $logger) { $this->userManager = $userManager; $this->config = $config; $this->groupManager = $groupManager; $this->userSession = $userSession; + $this->logger = $logger; } /** @@ -79,10 +81,15 @@ class Users { } // Admin? Or SubAdmin? - if($this->groupManager->isAdmin($user->getUID())){ + $uid = $user->getUID(); + $subAdminManager = $this->groupManager->getSubAdmin(); + if($this->groupManager->isAdmin($uid)){ $users = $this->userManager->search($search, $limit, $offset); - } else if (\OC_SubAdmin::isSubAdmin($user->getUID())) { - $subAdminOfGroups = \OC_SubAdmin::getSubAdminsGroups($user->getUID()); + } else if ($subAdminManager->isSubAdmin($user)) { + $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); + foreach ($subAdminOfGroups as $key => $group) { + $subAdminOfGroups[$key] = $group->getGID(); + } if($offset === null) { $offset = 0; @@ -111,15 +118,15 @@ class Users { $userId = isset($_POST['userid']) ? $_POST['userid'] : null; $password = isset($_POST['password']) ? $_POST['password'] : null; if($this->userManager->userExists($userId)) { - \OCP\Util::writeLog('ocs_api', 'Failed addUser attempt: User already exists.', \OCP\Util::ERROR); + $this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']); return new OC_OCS_Result(null, 102, 'User already exists'); } else { try { $this->userManager->createUser($userId, $password); - \OCP\Util::writeLog('ocs_api', 'Successful addUser call with userid: '.$_POST['userid'], \OCP\Util::INFO); + $this->logger->info('Successful addUser call with userid: '.$_POST['userid'], ['app' => 'ocs_api']); return new OC_OCS_Result(null, 100); } catch (\Exception $e) { - \OCP\Util::writeLog('ocs_api', 'Failed addUser attempt with exception: '.$e->getMessage(), \OCP\Util::ERROR); + $this->logger->error('Failed addUser attempt with exception: '.$e->getMessage(), ['app' => 'ocs_api']); return new OC_OCS_Result(null, 101, 'Bad request'); } } @@ -131,35 +138,38 @@ class Users { * @param array $parameters * @return OC_OCS_Result */ - public function getUser($parameters){ + public function getUser($parameters) { $userId = $parameters['userid']; // Check if user is logged in - $user = $this->userSession->getUser(); - if ($user === null) { + $currentLoggedInUser = $this->userSession->getUser(); + if ($currentLoggedInUser === null) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } $data = []; + // Check if the target user exists + $targetUserObject = $this->userManager->get($userId); + if($targetUserObject === null) { + return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found'); + } + // Admin? Or SubAdmin? - if($this->groupManager->isAdmin($user->getUID()) || OC_SubAdmin::isUserAccessible($user->getUID(), $userId)) { - // Check they exist - if(!$this->userManager->userExists($userId)) { - return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found'); - } + if($this->groupManager->isAdmin($currentLoggedInUser->getUID()) + || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { $data['enabled'] = $this->config->getUserValue($userId, 'core', 'enabled', 'true'); } else { // Check they are looking up themselves - if($user->getUID() !== $userId) { + if($currentLoggedInUser->getUID() !== $userId) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } } // Find the data - $data['quota'] = self::fillStorageInfo($userId); + $data['quota'] = $this->fillStorageInfo($userId); $data['email'] = $this->config->getUserValue($userId, 'settings', 'email'); - $data['displayname'] = $this->userManager->get($userId)->getDisplayName(); + $data['displayname'] = $targetUserObject->getDisplayName(); return new OC_OCS_Result($data); } @@ -171,27 +181,34 @@ class Users { * @return OC_OCS_Result */ public function editUser($parameters) { - $userId = $parameters['userid']; + /** @var string $targetUserId */ + $targetUserId = $parameters['userid']; // Check if user is logged in - $user = $this->userSession->getUser(); - if ($user === null) { + $currentLoggedInUser = $this->userSession->getUser(); + if ($currentLoggedInUser === null) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - if($userId === $user->getUID()) { + $targetUser = $this->userManager->get($targetUserId); + if($targetUser === null) { + return new OC_OCS_Result(null, 997); + } + + if($targetUserId === $currentLoggedInUser->getUID()) { // Editing self (display, email) $permittedFields[] = 'display'; $permittedFields[] = 'email'; $permittedFields[] = 'password'; // If admin they can edit their own quota - if($this->groupManager->isAdmin($user->getUID())) { + if($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { $permittedFields[] = 'quota'; } } else { // Check if admin / subadmin - if(OC_SubAdmin::isUserAccessible($user->getUID(), $userId) - || $this->groupManager->isAdmin($user->getUID())) { + $subAdminManager = $this->groupManager->getSubAdmin(); + if($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) + || $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { // They have permissions over the user $permittedFields[] = 'display'; $permittedFields[] = 'quota'; @@ -207,9 +224,9 @@ class Users { return new OC_OCS_Result(null, 997); } // Process the edit - switch($parameters['_put']['key']){ + switch($parameters['_put']['key']) { case 'display': - $this->userManager->get($userId)->setDisplayName($parameters['_put']['value']); + $targetUser->setDisplayName($parameters['_put']['value']); break; case 'quota': $quota = $parameters['_put']['value']; @@ -224,20 +241,20 @@ class Users { } if($quota === 0) { $quota = 'default'; - }else if($quota === -1){ + }else if($quota === -1) { $quota = 'none'; } else { $quota = \OCP\Util::humanFileSize($quota); } } - $this->config->setUserValue($userId, 'files', 'quota', $quota); + $this->config->setUserValue($targetUserId, 'files', 'quota', $quota); break; case 'password': - $this->userManager->get($userId)->setPassword($parameters['_put']['value']); + $targetUser->setPassword($parameters['_put']['value']); break; case 'email': if(filter_var($parameters['_put']['value'], FILTER_VALIDATE_EMAIL)) { - $this->config->setUserValue($userId, 'settings', 'email', $parameters['_put']['value']); + $this->config->setUserValue($targetUserId, 'settings', 'email', $parameters['_put']['value']); } else { return new OC_OCS_Result(null, 102); } @@ -255,21 +272,25 @@ class Users { */ public function deleteUser($parameters) { // Check if user is logged in - $user = $this->userSession->getUser(); - if ($user === null) { + $currentLoggedInUser = $this->userSession->getUser(); + if ($currentLoggedInUser === null) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - if(!$this->userManager->userExists($parameters['userid']) - || $parameters['userid'] === $user->getUID()) { + $targetUser = $this->userManager->get($parameters['userid']); + + if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { return new OC_OCS_Result(null, 101); } + // If not permitted - if(!$this->groupManager->isAdmin($user->getUID()) && !OC_SubAdmin::isUserAccessible($user->getUID(), $parameters['userid'])) { + $subAdminManager = $this->groupManager->getSubAdmin(); + if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { return new OC_OCS_Result(null, 997); } + // Go ahead with the delete - if($this->userManager->get($parameters['userid'])->delete()) { + if($targetUser->delete()) { return new OC_OCS_Result(null, 100); } else { return new OC_OCS_Result(null, 101); @@ -282,27 +303,34 @@ class Users { */ public function getUsersGroups($parameters) { // Check if user is logged in - $user = $this->userSession->getUser(); - if ($user === null) { + $loggedInUser = $this->userSession->getUser(); + if ($loggedInUser === null) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - if($parameters['userid'] === $user->getUID() || $this->groupManager->isAdmin($user->getUID())) { + $targetUser = $this->userManager->get($parameters['userid']); + if($targetUser === null) { + return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND); + } + + if($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) { // Self lookup or admin lookup return new OC_OCS_Result([ - 'groups' => $this->groupManager->getUserGroupIds( - $this->userManager->get($parameters['userid']) - ) + 'groups' => $this->groupManager->getUserGroupIds($targetUser) ]); } else { + $subAdminManager = $this->groupManager->getSubAdmin(); + // Looking up someone else - if(OC_SubAdmin::isUserAccessible($user->getUID(), $parameters['userid'])) { + if($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { // Return the group that the method caller is subadmin of for the user in question + $getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); + foreach ($getSubAdminsGroups as $key => $group) { + $getSubAdminsGroups[$key] = $group->getGID(); + } $groups = array_intersect( - OC_SubAdmin::getSubAdminsGroups($user->getUID()), - $this->groupManager->getUserGroupIds( - $this->userManager->get($parameters['userid']) - ) + $getSubAdminsGroups, + $this->groupManager->getUserGroupIds($targetUser) ); return new OC_OCS_Result(array('groups' => $groups)); } else { @@ -324,27 +352,28 @@ class Users { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - $group = !empty($_POST['groupid']) ? $_POST['groupid'] : null; - if(is_null($group)){ - return new OC_OCS_Result(null, 101); - } // Check they're an admin - if(!$this->groupManager->isInGroup($user->getUID(), 'admin')){ + if(!$this->groupManager->isAdmin($user->getUID())) { // This user doesn't have rights to add a user to this group return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - // Check if the group exists - if(!$this->groupManager->groupExists($group)){ + + $groupId = !empty($_POST['groupid']) ? $_POST['groupid'] : null; + if($groupId === null) { + return new OC_OCS_Result(null, 101); + } + + $group = $this->groupManager->get($groupId); + $targetUser = $this->userManager->get($parameters['userid']); + if($group === null) { return new OC_OCS_Result(null, 102); } - // Check if the user exists - if(!$this->userManager->userExists($parameters['userid'])){ + if($targetUser === null) { return new OC_OCS_Result(null, 103); } + // Add user to group - $this->groupManager->get($group)->addUser( - $this->userManager->get($parameters['userid']) - ); + $group->addUser($targetUser); return new OC_OCS_Result(null, 100); } @@ -354,44 +383,47 @@ class Users { */ public function removeFromGroup($parameters) { // Check if user is logged in - $user = $this->userSession->getUser(); - if ($user === null) { + $loggedInUser = $this->userSession->getUser(); + if ($loggedInUser === null) { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - $group = !empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null; - if(is_null($group)){ + $group = $this->groupManager->get(!empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null); + if($group === null) { return new OC_OCS_Result(null, 101); } + + $targetUser = $this->userManager->get($parameters['userid']); + if($targetUser === null) { + return new OC_OCS_Result(null, 103); + } + // If they're not an admin, check they are a subadmin of the group in question - if(!$this->groupManager->isInGroup($user->getUID(), 'admin') && !OC_SubAdmin::isSubAdminofGroup($user->getUID(), $group)){ + $subAdminManager = $this->groupManager->getSubAdmin(); + if(!$this->groupManager->isAdmin($loggedInUser->getUID()) && !$subAdminManager->isSubAdminofGroup($loggedInUser, $group)) { return new OC_OCS_Result(null, 104); } // Check they aren't removing themselves from 'admin' or their 'subadmin; group - if($parameters['userid'] === $user->getUID()){ - if($this->groupManager->isInGroup($user->getUID(), 'admin')){ - if($group === 'admin'){ + if($parameters['userid'] === $loggedInUser->getUID()) { + if($this->groupManager->isAdmin($loggedInUser->getUID())) { + if($group->getGID() === 'admin') { return new OC_OCS_Result(null, 105, 'Cannot remove yourself from the admin group'); } } else { // Not an admin, check they are not removing themself from their subadmin group - if(in_array($group, OC_SubAdmin::getSubAdminsGroups($user->getUID()))){ + $subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); + foreach ($subAdminGroups as $key => $group) { + $subAdminGroups[$key] = $group->getGID(); + } + + if(in_array($group->getGID(), $subAdminGroups, true)) { return new OC_OCS_Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin'); } } } - // Check if the group exists - if(!$this->groupManager->groupExists($group)){ - return new OC_OCS_Result(null, 102); - } - // Check if the user exists - if(!$this->userManager->userExists($parameters['userid'])){ - return new OC_OCS_Result(null, 103); - } + // Remove user from group - $this->groupManager->get($group)->removeUser( - $this->userManager->get($parameters['userid']) - ); + $group->removeUser($targetUser); return new OC_OCS_Result(null, 100); } @@ -402,31 +434,34 @@ class Users { * @return OC_OCS_Result */ public function addSubAdmin($parameters) { - $group = $_POST['groupid']; - $user = $parameters['userid']; + $group = $this->groupManager->get($_POST['groupid']); + $user = $this->userManager->get($parameters['userid']); + // Check if the user exists - if(!$this->userManager->userExists($user)) { + if($user === null) { return new OC_OCS_Result(null, 101, 'User does not exist'); } // Check if group exists - if(!$this->groupManager->groupExists($group)) { - return new OC_OCS_Result(null, 102, 'Group:'.$group.' does not exist'); + if($group === null) { + return new OC_OCS_Result(null, 102, 'Group:'.$_POST['groupid'].' does not exist'); } // Check if trying to make subadmin of admin group - if(strtolower($group) === 'admin') { + if(strtolower($_POST['groupid']) === 'admin') { return new OC_OCS_Result(null, 103, 'Cannot create subadmins for admin group'); } + + $subAdminManager = $this->groupManager->getSubAdmin(); + // We cannot be subadmin twice - if (OC_Subadmin::isSubAdminOfGroup($user, $group)) { + if ($subAdminManager->isSubAdminofGroup($user, $group)) { return new OC_OCS_Result(null, 100); } // Go - if(OC_Subadmin::createSubAdmin($user, $group)) { + if($subAdminManager->createSubAdmin($user, $group)) { return new OC_OCS_Result(null, 100); } else { - return new OC_OCS_Result(null, 103, 'Unknown error occured'); + return new OC_OCS_Result(null, 103, 'Unknown error occurred'); } - } /** @@ -436,18 +471,25 @@ class Users { * @return OC_OCS_Result */ public function removeSubAdmin($parameters) { - $group = $parameters['_delete']['groupid']; - $user = $parameters['userid']; + $group = $this->groupManager->get($parameters['_delete']['groupid']); + $user = $this->userManager->get($parameters['userid']); + $subAdminManager = $this->groupManager->getSubAdmin(); + // Check if the user exists - if(!$this->userManager->userExists($user)) { + if($user === null) { return new OC_OCS_Result(null, 101, 'User does not exist'); } + // Check if the group exists + if($group === null) { + return new OC_OCS_Result(null, 101, 'Group does not exist'); + } // Check if they are a subadmin of this said group - if(!OC_SubAdmin::isSubAdminofGroup($user, $group)) { + if(!$subAdminManager->isSubAdminofGroup($user, $group)) { return new OC_OCS_Result(null, 102, 'User is not a subadmin of this group'); } + // Go - if(OC_Subadmin::deleteSubAdmin($user, $group)) { + if($subAdminManager->deleteSubAdmin($user, $group)) { return new OC_OCS_Result(null, 100); } else { return new OC_OCS_Result(null, 103, 'Unknown error occurred'); @@ -461,13 +503,19 @@ class Users { * @return OC_OCS_Result */ public function getUserSubAdminGroups($parameters) { - $user = $parameters['userid']; + $user = $this->userManager->get($parameters['userid']); // Check if the user exists - if(!$this->userManager->userExists($user)) { + if($user === null) { return new OC_OCS_Result(null, 101, 'User does not exist'); } + // Get the subadmin groups - if(!$groups = OC_SubAdmin::getSubAdminsGroups($user)) { + $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); + foreach ($groups as $key => $group) { + $groups[$key] = $group->getGID(); + } + + if(!$groups) { return new OC_OCS_Result(null, 102, 'Unknown error occurred'); } else { return new OC_OCS_Result($groups); @@ -476,12 +524,10 @@ class Users { /** * @param string $userId - * @param array $data - * @return mixed + * @return array * @throws \OCP\Files\NotFoundException */ - private static function fillStorageInfo($userId) { - $data = []; + protected function fillStorageInfo($userId) { try { \OC_Util::tearDownFS(); \OC_Util::setupFS($userId); diff --git a/apps/provisioning_api/tests/appstest.php b/apps/provisioning_api/tests/appstest.php index 2baea5bbc8c..2e1a86025c2 100644 --- a/apps/provisioning_api/tests/appstest.php +++ b/apps/provisioning_api/tests/appstest.php @@ -2,7 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/provisioning_api/tests/groupstest.php b/apps/provisioning_api/tests/groupstest.php index 4afd246abcd..f67ed1c36ae 100644 --- a/apps/provisioning_api/tests/groupstest.php +++ b/apps/provisioning_api/tests/groupstest.php @@ -1,8 +1,9 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -29,15 +30,14 @@ use OCP\IGroupManager; use OCP\IUserSession; class GroupsTest extends TestCase { - /** @var IUserManager */ protected $userManager; - /** @var IGroupManager */ protected $groupManager; - /** @var IUserSession */ protected $userSession; + /** @var \OCA\Provisioning_API\Groups */ + protected $api; protected function setup() { parent::setup(); @@ -114,7 +114,7 @@ class GroupsTest extends TestCase { $group->addUser($users[0]); $group->addUser($users[1]); - \OC_SubAdmin::createSubAdmin($users[0]->getUID(), $group->getGID()); + $this->groupManager->getSubAdmin()->createSubAdmin($users[0], $group); $result = $this->api->getGroup([ 'groupid' => $group->getGID(), @@ -147,7 +147,7 @@ class GroupsTest extends TestCase { $group1->addUser($users[1]); $group2->addUser($users[0]); - \OC_SubAdmin::createSubAdmin($users[0]->getUID(), $group2->getGID()); + $this->groupManager->getSubAdmin()->createSubAdmin($users[0], $group2); $result = $this->api->getGroup([ 'groupid' => $group1->getGID(), @@ -196,7 +196,7 @@ class GroupsTest extends TestCase { $this->userSession->setUser($user1); $this->groupManager->get('admin')->addUser($user1); $group1 = $this->groupManager->createGroup($this->getUniqueID()); - \OC_SubAdmin::createSubAdmin($user2->getUID(), $group1->getGID()); + $this->groupManager->getSubAdmin()->createSubAdmin($user2, $group1); $result = $this->api->getSubAdminsOfGroup([ 'groupid' => $group1->getGID(), ]); diff --git a/apps/provisioning_api/tests/testcase.php b/apps/provisioning_api/tests/testcase.php index 6135a6d2f96..113bc512243 100644 --- a/apps/provisioning_api/tests/testcase.php +++ b/apps/provisioning_api/tests/testcase.php @@ -2,7 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php index b43041bbbf9..c5a1ac3061e 100644 --- a/apps/provisioning_api/tests/userstest.php +++ b/apps/provisioning_api/tests/userstest.php @@ -1,11 +1,11 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tom Needham <tom@owncloud.com> - * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -26,1248 +26,1886 @@ namespace OCA\Provisioning_API\Tests; +use OCA\Provisioning_API\Users; use OCP\IUserManager; use OCP\IConfig; use OCP\IGroupManager; use OCP\IUserSession; +use Test\TestCase as OriginalTest; +use OCP\ILogger; -class UsersTest extends TestCase { +class UsersTest extends OriginalTest { /** @var IUserManager */ protected $userManager; - /** @var IConfig */ protected $config; - - /** @var IGroupManager */ + /** @var \OC\Group\Manager */ protected $groupManager; - /** @var IUserSession */ protected $userSession; + /** @var ILogger */ + protected $logger; + /** @var Users */ + protected $api; - protected function resetParams() { + protected function tearDown() { $_GET = null; $_POST = null; + parent::tearDown(); } protected function setup() { parent::setup(); - $this->userManager = \OC::$server->getUserManager(); - $this->config = \OC::$server->getConfig(); - $this->groupManager = \OC::$server->getGroupManager(); - $this->userSession = \OC::$server->getUserSession(); - $this->api = new \OCA\Provisioning_Api\Users( - $this->userManager, - $this->config, - $this->groupManager, - $this->userSession - ); + $this->userManager = $this->getMock('\OCP\IUserManager'); + $this->config = $this->getMock('\OCP\IConfig'); + $this->groupManager = $this->getMockBuilder('\OC\Group\Manager') + ->disableOriginalConstructor()->getMock(); + $this->userSession = $this->getMock('\OCP\IUserSession'); + $this->logger = $this->getMock('\OCP\ILogger'); + $this->api = $this->getMockBuilder('\OCA\Provisioning_API\Users') + ->setConstructorArgs([ + $this->userManager, + $this->config, + $this->groupManager, + $this->userSession, + $this->logger, + ] + ) + ->setMethods(['fillStorageInfo']) + ->getMock(); + } - $this->userSession->setUser(null); + public function testGetUsersNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $this->assertEquals($expected, $this->api->getUsers()); } - // Test getting the list of users public function testGetUsersAsAdmin() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - - $result = $this->api->getUsers(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $count = $result->getData(); - $count = count($count['users']); - $this->assertEquals(count($this->userManager->search('', null, null)), $count); - - $user = $this->generateUsers(); - $_GET['search'] = $user->getUID(); - $result = $this->api->getUsers(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals($user->getUID(), reset($data['users'])); - - // Add several users - $this->generateUsers(10); - $this->resetParams(); - $_GET['limit'] = 2; - $result = $this->api->getUsers(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $count = $result->getData(); - $count = count($count['users']); - $this->assertEquals(2, $count); - - $this->resetParams(); - $_GET['limit'] = 1; - $_GET['offset'] = 1; - $result = $this->api->getUsers(array()); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals(array_keys($this->userManager->search('', 1, 1)), $data['users']); + $_GET['search'] = 'MyCustomSearch'; + + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->will($this->returnValue(true)); + $this->userManager + ->expects($this->once()) + ->method('search') + ->with('MyCustomSearch', null, null) + ->will($this->returnValue(['Admin' => [], 'Foo' => [], 'Bar' => []])); + + $expected = new \OC_OCS_Result([ + 'users' => [ + 'Admin', + 'Foo', + 'Bar', + ], + ]); + $this->assertEquals($expected, $this->api->getUsers()); } public function testGetUsersAsSubAdmin() { - $user = $this->generateUsers(10); - $this->userSession->setUser($user[0]); - $group = $this->groupManager->createGroup($this->getUniqueID()); - \OC_SubAdmin::createSubAdmin($user[0]->getUID(), $group->getGID()); - - //Empty list - $result = $this->api->getUsers([]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertEquals(['users' => []], $result->getData()); - - //Some users in group - $group->addUser($user[1]); - $group->addUser($user[2]); - $group->addUser($user[3]); - $group->addUser($user[4]); - - $result = $this->api->getUsers([]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertArrayHasKey('users', $result->getData()); - - $this->assertContains($user[1]->getUID(), $result->getData()['users']); - $this->assertContains($user[2]->getUID(), $result->getData()['users']); - $this->assertContains($user[3]->getUID(), $result->getData()['users']); - $this->assertContains($user[4]->getUID(), $result->getData()['users']); - - $uids = [ - $user[1]->getUID(), - $user[2]->getUID(), - $user[3]->getUID(), - $user[4]->getUID() - ]; - sort($uids); - - $_GET['limit'] = 2; - $_GET['offset'] = 1; - $result = $this->api->getUsers([]); - - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - - // Disable this test for now since sorting is not done the same on all backends - //$this->assertEquals(['users' => array_slice($uids, 1, 2)], $result->getData()); - - $this->assertCount(2, $result->getData()['users']); - - $counter = 0; - foreach ($uids as $uid) { - if (in_array($uid, $result->getData()['users'], true)) { - $counter += 1; - } - } - - $this->assertEquals(2, $counter); - } - - public function testGetUsersNoUser() { - $result = $this->api->getUsers([]); - - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode()); - } - - public function testGetUsersAsUser() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - - $result = $this->api->getUsers(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode()); - - } - - public function testAddUser() { - $this->resetParams(); - $_POST['userid'] = $this->getUniqueID(); - $_POST['password'] = 'password'; - $result = $this->api->addUser(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertTrue($this->userManager->userExists($_POST['userid'])); - $this->assertEquals($_POST['userid'], $this->userManager->checkPassword($_POST['userid'], $_POST['password'])->getUID()); - $this->users[] = $this->userManager->get($_POST['userid']); - } - - public function testAddUserTwice() { - $this->resetParams(); - $_POST['userid'] = $this->getUniqueID(); - $_POST['password'] = 'password'; - $this->api->addUser(); - $result = $this->api->addUser(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); - $this->assertEquals('User already exists', $result->getMeta()['message']); - } - - public function testAddUserFails() { - $uid = $this->getUniqueID(); + $_GET['search'] = 'MyCustomSearch'; - $userManager = $this->getMockBuilder('\OCP\IUserManager') - ->disableOriginalConstructor() - ->getMock(); + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->will($this->returnValue(false)); + $firstGroup = $this->getMock('\OCP\IGroup'); + $firstGroup + ->expects($this->once()) + ->method('getGID') + ->will($this->returnValue('FirstGroup')); + $secondGroup = $this->getMock('\OCP\IGroup'); + $secondGroup + ->expects($this->once()) + ->method('getGID') + ->will($this->returnValue('SecondGroup')); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdmin') + ->with($loggedInUser) + ->will($this->returnValue(true)); + $subAdminManager + ->expects($this->once()) + ->method('getSubAdminsGroups') + ->with($loggedInUser) + ->will($this->returnValue([$firstGroup, $secondGroup])); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->any()) + ->method('displayNamesInGroup') + ->will($this->onConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []])); + + $expected = new \OC_OCS_Result([ + 'users' => [ + 'AnotherUserInTheFirstGroup', + 'UserInTheSecondGroup', + ], + ]); + $this->assertEquals($expected, $this->api->getUsers()); + } + + public function testGetUsersAsRegularUser() { + $_GET['search'] = 'MyCustomSearch'; + + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('regularUser')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdmin') + ->with($loggedInUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $this->assertEquals($expected, $this->api->getUsers()); + } + + public function testAddUserAlreadyExisting() { + $_POST['userid'] = 'AlreadyExistingUser'; + $this->userManager + ->expects($this->once()) + ->method('userExists') + ->with('AlreadyExistingUser') + ->will($this->returnValue(true)); + $this->logger + ->expects($this->once()) + ->method('error') + ->with('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']); + + $expected = new \OC_OCS_Result(null, 102, 'User already exists'); + $this->assertEquals($expected, $this->api->addUser()); + } - $userManager->expects($this->once()) + public function testAddUserSuccessful() { + $_POST['userid'] = 'NewUser'; + $_POST['password'] = 'PasswordOfTheNewUser'; + $this->userManager + ->expects($this->once()) ->method('userExists') - ->with($uid) - ->willReturn(false); - $userManager->expects($this->once()) + ->with('NewUser') + ->will($this->returnValue(false)); + $this->userManager + ->expects($this->once()) ->method('createUser') - ->with($uid, 'password') - ->will($this->throwException(new \Exception)); - - $api = new \OCA\Provisioning_Api\Users( - $userManager, - $this->config, - $this->groupManager, - $this->userSession - ); + ->with('NewUser', 'PasswordOfTheNewUser'); + $this->logger + ->expects($this->once()) + ->method('info') + ->with('Successful addUser call with userid: NewUser', ['app' => 'ocs_api']); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->addUser()); + } - $this->resetParams(); - $_POST['userid'] = $uid; - $_POST['password'] = 'password'; - $result = $api->addUser(); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); - $this->assertEquals('Bad request', $result->getMeta()['message']); - } - - public function testGetUserOnSelf() { - $user = $this->generateUsers(); - $user->setDisplayName('foobar'); - $this->userSession->setUser($user); - $params = ['userid' => $user->getUID()]; - $result = $this->api->getUser($params); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - - $this->assertEquals('foobar', $data['displayname']); - } - - public function testGetUserOnNonExistingUser() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $params = array(); - $params['userid'] = $this->getUniqueID(); - while($this->userManager->userExists($params['userid'])) { - $params['userid'] = $this->getUniqueID(); - } - $result = $this->api->getUser($params); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(\OCP\API::RESPOND_NOT_FOUND, $result->getStatusCode()); - - } - - public function testGetUserOnOtherUser() { - $users = $this->generateUsers(2); - $params = ['userid' => $users[0]->getUID()]; - $this->userSession->setUser($users[1]); - $result = $this->api->getUser($params); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - - // Now as as admin - $users = $this->generateUsers(2); - $params['userid'] = $users[0]->getUID(); - // login to generate home - $this->userSession->setUser($users[0]); - $this->groupManager->get('admin')->addUser($users[1]); - $this->userSession->setUser($users[1]); - $result = $this->api->getUser($params); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals(\OC::$server->getConfig()->getUserValue($users[0]->getUID(), 'core', 'enabled', 'true'), $data['enabled']); - } - - public function testEditOwnDisplayName() { - // Test editing own name - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $result = $this->api->editUser( - array( - 'userid' => $user->getUID(), - '_put' => array( - 'key' => 'display', - 'value' => 'newname', - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertEquals('newname', $user->getDisplayName()); - - } - - public function testAdminEditDisplayNameOfUser() { - // Test admin editing users name - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->editUser( - [ - 'userid' => $user2->getUID(), - '_put' => [ - 'key' => 'display', - 'value' => 'newname', - ], - ] - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertEquals('newname', $user2->getDisplayName()); - - } - - public function testUserEditOtherUserDisplayName() { - // Test editing other users name - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->editUser( - array( - 'userid' => $user2->getUID(), - '_put' => array( - 'key' => 'display', - 'value' => 'newname', - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - - } - - /** - * @dataProvider providesQuotas - * @param $expected - * @param $quota - */ - public function testEditOwnQuota($expected, $quota) { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $result = $this->api->editUser( + public function testAddUserUnsuccessful() { + $_POST['userid'] = 'NewUser'; + $_POST['password'] = 'PasswordOfTheNewUser'; + $this->userManager + ->expects($this->once()) + ->method('userExists') + ->with('NewUser') + ->will($this->returnValue(false)); + $this->userManager + ->expects($this->once()) + ->method('createUser') + ->with('NewUser', 'PasswordOfTheNewUser') + ->will($this->throwException(new \Exception('User backend not found.'))); + $this->logger + ->expects($this->once()) + ->method('error') + ->with('Failed addUser attempt with exception: User backend not found.', ['app' => 'ocs_api']); + + $expected = new \OC_OCS_Result(null, 101, 'Bad request'); + $this->assertEquals($expected, $this->api->addUser()); + } + + public function testGetUserNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); + } + + public function testGetUserTargetDoesNotExist() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToGet') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found'); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); + } + + public function testGetUserAsAdmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToGet') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + $this->config + ->expects($this->at(0)) + ->method('getUserValue') + ->with('UserToGet', 'core', 'enabled', 'true') + ->will($this->returnValue('true')); + $this->api + ->expects($this->once()) + ->method('fillStorageInfo') + ->with('UserToGet') + ->will($this->returnValue(['DummyValue'])); + $this->config + ->expects($this->at(1)) + ->method('getUserValue') + ->with('UserToGet', 'settings', 'email') + ->will($this->returnValue('demo@owncloud.org')); + $targetUser + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('Demo User')); + + $expected = new \OC_OCS_Result( [ - 'userid' => $user->getUID(), - '_put' => [ - 'key' => 'quota', - 'value' => $quota, - ], + 'enabled' => 'true', + 'quota' => ['DummyValue'], + 'email' => 'demo@owncloud.org', + 'displayname' => 'Demo User', ] - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(997, $result->getStatusCode()); - } - - /** - * @dataProvider providesQuotas - * @param $expected - * @param $quota - */ - public function testEditOwnQuotaAsAdmin($expected, $quota) { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $result = $this->api->editUser( + ); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); + } + + public function testGetUserAsSubAdminAndUserIsAccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToGet') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor() + ->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->config + ->expects($this->at(0)) + ->method('getUserValue') + ->with('UserToGet', 'core', 'enabled', 'true') + ->will($this->returnValue('true')); + $this->api + ->expects($this->once()) + ->method('fillStorageInfo') + ->with('UserToGet') + ->will($this->returnValue(['DummyValue'])); + $this->config + ->expects($this->at(1)) + ->method('getUserValue') + ->with('UserToGet', 'settings', 'email') + ->will($this->returnValue('demo@owncloud.org')); + $targetUser + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('Demo User')); + + $expected = new \OC_OCS_Result( [ - 'userid' => $user->getUID(), - '_put' => [ - 'key' => 'quota', - 'value' => $quota, - ], + 'enabled' => 'true', + 'quota' => ['DummyValue'], + 'email' => 'demo@owncloud.org', + 'displayname' => 'Demo User', ] - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertEquals($expected, $result->succeeded()); - } - - public function providesQuotas() { - return [ - [true, '20G'], - [true, '1234567'], - [true, 'none'], - [true, 'default'], - [false, 'qwertzu'], - [true, 0], - [true, -1] - ]; - } - - public function testAdminEditOwnQuota() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $result = $this->api->editUser( - array( - 'userid' => $user->getUID(), - '_put' => array( - 'key' => 'quota', - 'value' => '20G', - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - } - - public function testAdminEditOtherUserQuota() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->editUser( - array( - 'userid' => $user2->getUID(), - '_put' => array( - 'key' => 'quota', - 'value' => '20G', - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - } - - public function testUserEditOtherUserQuota() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->editUser( - array( - 'userid' => $user2->getUID(), - '_put' => array( - 'key' => 'quota', - 'value' => '20G', - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testUserEditOwnEmail() { - $user = $this->generateUsers(); - $email = 'test@example.com'; - $this->userSession->setUser($user); - $result = $this->api->editUser( - array( - 'userid' => $user->getUID(), - '_put' => array( - 'key' => 'email', - 'value' => $email, - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertEquals($email, \OC::$server->getConfig()->getUserValue($user->getUID(), 'settings', 'email', null)); - } - - public function testUserEditOwnEmailInvalid() { - $user = $this->generateUsers(); - $email = 'test@example'; - $this->userSession->setUser($user); - $result = $this->api->editUser([ - 'userid' => $user->getUID(), - '_put' => [ - 'key' => 'email', - 'value' => $email, - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); - } - - public function testUserEditOtherUserEmailAsUser() { - $users = $this->generateUsers(2); - $email = 'test@example.com'; - $this->userSession->setUser($users[0]); - $result = $this->api->editUser( - array( - 'userid' => $users[1]->getUID(), - '_put' => array( - 'key' => 'email', - 'value' => $email, - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testUserEditOtherUserEmailAsAdmin() { - $users = $this->generateUsers(2); - $email = 'test@example.com'; - $this->userSession->setUser($users[0]); - $this->groupManager->get('admin')->addUser($users[0]); - $result = $this->api->editUser( - array( - 'userid' => $users[1]->getUID(), - '_put' => array( - 'key' => 'email', - 'value' => $email, - ), - ) - ); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertEquals($email, \OC::$server->getConfig()->getUserValue($users[1]->getUID(), 'settings', 'email', null)); - } - - public function testUserEditOwnPassword() { - $user = $this->generateUsers(); - $password = 'foo'; - $this->userSession->setUser($user); - $result = $this->api->editUser([ - 'userid' => $user->getUID(), - '_put' => [ - 'key' => 'password', - 'value' => $password, - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - } - - public function testUserEditOtherUserPasswordAsUser() { - $users = $this->generateUsers(2); - $password = 'foo'; - $this->userSession->setUser($users[0]); - $result = $this->api->editUser([ - 'userid' => $users[1]->getUID(), - '_put' => [ - 'key' => 'password', - 'value' => $password, - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testUserEditOtherUserPasswordAsAdmin() { - $users = $this->generateUsers(2); - $password = 'foo'; - $this->userSession->setUser($users[0]); - $this->groupManager->get('admin')->addUser($users[0]); - $result = $this->api->editUser([ - 'userid' => $users[1]->getUID(), - '_put' => [ - 'key' => 'password', - 'value' => $password, - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - } - - public function testDeleteSelf() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $result = $this->api->deleteUser(array( - 'userid' => $user->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testDeleteOtherAsUser() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->deleteUser(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testDeleteOtherAsSubAdmin() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $group = $this->groupManager->createGroup($this->getUniqueID()); - $group->addUser($user); - $group->addUser($user2); - \OC_SubAdmin::createSubAdmin($user->getUID(), $group->getGID()); - $result = $this->api->deleteUser(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $group->delete(); - } - - public function testDeleteOtherAsIrelevantSubAdmin() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $group = $this->groupManager->createGroup($this->getUniqueID()); - $group2 = $this->groupManager->createGroup($this->getUniqueID()); - $group->addUser($user); - $group2->addUser($user2); - \OC_SubAdmin::createSubAdmin($user->getUID(), $group->getGID()); - $result = $this->api->deleteUser(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $group->delete(); - $group2->delete(); - } - - public function testDeleteOtherAsAdmin() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $user2 = $this->generateUsers(); - $result = $this->api->deleteUser(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - } - - public function testDeleteSelfAsAdmin() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); - $result = $this->api->deleteUser(array( - 'userid' => $user->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - } - - public function testDeleteFails() { - $user = $this->getMockBuilder('\OCP\IUser') + ); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); + } + + public function testGetUserAsSubAdminAndUserIsNotAccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->exactly(2)) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToGet') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') ->disableOriginalConstructor() ->getMock(); - $user->expects($this->once()) - ->method('delete') - ->willReturn(false); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); + } - $user2 = $this->getMockBuilder('\OCP\IUser') + public function testGetUserAsSubAdminSelfLookup() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->exactly(2)) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('subadmin') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') ->disableOriginalConstructor() ->getMock(); - $user2->expects($this->any()) + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->api + ->expects($this->once()) + ->method('fillStorageInfo') + ->with('subadmin') + ->will($this->returnValue(['DummyValue'])); + $this->config + ->expects($this->once()) + ->method('getUserValue') + ->with('subadmin', 'settings', 'email') + ->will($this->returnValue('subadmin@owncloud.org')); + $targetUser + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('Subadmin User')); + + $expected = new \OC_OCS_Result([ + 'quota' => ['DummyValue'], + 'email' => 'subadmin@owncloud.org', + 'displayname' => 'Subadmin User', + ]); + $this->assertEquals($expected, $this->api->getUser(['userid' => 'subadmin'])); + } + + public function testEditUserNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit'])); + } + + public function testEditUserRegularUserSelfEditChangeDisplayName() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $targetUser + ->expects($this->once()) + ->method('setDisplayName') + ->with('NewDisplayName'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'display', 'value' => 'NewDisplayName']])); + } + + public function testEditUserRegularUserSelfEditChangeEmailValid() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $this->config + ->expects($this->once()) + ->method('setUserValue') + ->with('UserToEdit', 'settings', 'email', 'demo@owncloud.org'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'email', 'value' => 'demo@owncloud.org']])); + } + + public function testEditUserRegularUserSelfEditChangeEmailInvalid() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + + $expected = new \OC_OCS_Result(null, 102); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'email', 'value' => 'demo.org']])); + } + + public function testEditUserRegularUserSelfEditChangePassword() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $targetUser + ->expects($this->once()) + ->method('setPassword') + ->with('NewPassword'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'password', 'value' => 'NewPassword']])); + } + + public function testEditUserRegularUserSelfEditChangeQuota() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => 'NewQuota']])); + } + + public function testEditUserAdminUserSelfEditChangeValidQuota() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('UserToEdit') + ->will($this->returnValue(true)); + $this->config + ->expects($this->once()) + ->method('setUserValue') + ->with('UserToEdit', 'files', 'quota', '2.9 MB'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']])); + } + + public function testEditUserAdminUserSelfEditChangeInvalidQuota() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) ->method('getUID') - ->willReturn('user2'); + ->will($this->returnValue('UserToEdit')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('UserToEdit') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 103, 'Invalid quota value ABC'); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => 'ABC']])); + } - $userManager = $this->getMockBuilder('\OCP\IUserManager') + public function testEditUserAdminUserEditChangeValidQuota() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') ->disableOriginalConstructor() ->getMock(); - $userManager->expects($this->once()) - ->method('userExists') - ->with('user') - ->willReturn(true); - $userManager->expects($this->once()) - ->method('get') - ->with('user') - ->willReturn($user); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->config + ->expects($this->once()) + ->method('setUserValue') + ->with('UserToEdit', 'files', 'quota', '2.9 MB'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']])); + } - $userSession = $this->getMockBuilder('\OCP\IUserSession') + public function testEditUserSubadminUserAccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') ->disableOriginalConstructor() ->getMock(); - $userSession->expects($this->once()) + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->config + ->expects($this->once()) + ->method('setUserValue') + ->with('UserToEdit', 'files', 'quota', '2.9 MB'); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']])); + } + + public function testEditUserSubadminUserInaccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) ->method('getUser') - ->willReturn($user2); - - $groupManager = $this->getMockBuilder('\OCP\IGroupManager') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToEdit') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') ->disableOriginalConstructor() ->getMock(); - $groupManager->expects($this->once()) + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']])); + } + + public function testDeleteUserNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); + } + + public function testDeleteUserNotExistingUser() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToEdit')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); + } + + public function testDeleteUserSelf() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); + } + + public function testDeleteSuccessfulUserAsAdmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) ->method('isAdmin') - ->with('user2') - ->willReturn(true); - - $api = new \OCA\Provisioning_Api\Users( - $userManager, - $this->config, - $groupManager, - $userSession - ); + ->with('admin') + ->will($this->returnValue(true)); + $targetUser + ->expects($this->once()) + ->method('delete') + ->will($this->returnValue(true)); - $result = $api->deleteUser([ - 'userid' => 'user', - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); - } - - public function testGetUsersGroupsOnSelf() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $group = $this->getUniqueID(); - $group = $this->groupManager->createGroup($group); - $group->addUser($user); - $result = $this->api->getUsersGroups(array( - 'userid' => $user->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals($group->getGID(), reset($data['groups'])); - $this->assertEquals(1, count($data['groups'])); - $group->delete(); - } - - public function testGetUsersGroupOnOther() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group = $this->getUniqueID(); - $group = $this->groupManager->createGroup($group); - $group->addUser($user2); - $result = $this->api->getUsersGroups(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $group->delete(); - } - - public function testGetUsersGroupOnOtherAsAdmin() { - $user1 = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user1); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group = $this->getUniqueID(); - $group = $this->groupManager->createGroup($group); - $group->addUser($user2); - $result = $this->api->getUsersGroups(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals($group->getGID(), reset($data['groups'])); - $this->assertEquals(1, count($data['groups'])); - $group->delete(); - } - - public function testGetUsersGroupsOnOtherAsSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group2 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group2 = $this->groupManager->createGroup($group2); - $group1->addUser($user2); - $group2->addUser($user2); - $group1->addUser($user1); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $result = $this->api->getUsersGroups(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals($group1->getGID(), reset($data['groups'])); - $this->assertEquals(1, count($data['groups'])); - $group1->delete(); - $group2->delete(); - } - - public function testGetUsersGroupsOnOtherAsIrelevantSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group2 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group2 = $this->groupManager->createGroup($group2); - $group2->addUser($user2); - $group1->addUser($user1); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $result = $this->api->getUsersGroups(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $group1->delete(); - $group2->delete(); - } - - public function testAddToGroup() { - $user = $this->generateUsers(); - $group = $this->getUniqueID(); - $group = $this->groupManager->createGroup($group); - $this->userSession->setUser($user); - $_POST['groupid'] = $group->getGID(); - $result = $this->api->addToGroup(array( - 'userid' => $user->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertFalse($group->inGroup($user)); - $group->delete(); - } - - public function testAddToGroupAsAdmin() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $group = $this->getUniqueID(); - $group = $this->groupManager->createGroup($group); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user); - $_POST['groupid'] = $group->getGID(); - $result = $this->api->addToGroup(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertTrue($group->inGroup($user2)); - $group->delete(); - } - - public function testAddToGroupAsSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->addToGroup(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertFalse($group1->inGroup($user2)); - $group1->delete(); - } - - public function testAddToGroupAsIrelevantSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group2 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group2 = $this->groupManager->createGroup($group2); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $_POST['groupid'] = $group2->getGID(); - $result = $this->api->addToGroup(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertFalse($group2->inGroup($user2)); - $group1->delete(); - $group2->delete(); - } - - public function testAddToGroupNoGroupId() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - - $_POST['groupid'] = ''; - $result = $this->api->addToGroup([ - 'userid' => $this->getUniqueID(), - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); } - public function testAddToNonExistingGroup() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); + public function testDeleteUnsuccessfulUserAsAdmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + $targetUser + ->expects($this->once()) + ->method('delete') + ->will($this->returnValue(false)); - $group = $this->groupManager->createGroup($this->getUniqueID()); - $_POST['groupid'] = $group->getGID(); - $result = $this->api->addToGroup([ - 'userid' => $this->getUniqueID(), - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(103, $result->getStatusCode()); + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); } - public function testAddNonExistingUserToGroup() { - $user = $this->generateUsers(); - $this->groupManager->get('admin')->addUser($user); - $this->userSession->setUser($user); + public function testDeleteSuccessfulUserAsSubadmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $targetUser + ->expects($this->once()) + ->method('delete') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); + } - $_POST['groupid'] = $this->getUniqueID(); - $result = $this->api->addToGroup([ - 'userid' => $this->getUniqueID(), - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); - } - - // test delete /cloud/users/{userid}/groups - public function testRemoveFromGroupAsSelf() { - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group1->addUser($user1); - $result = $this->api->removeFromGroup(array( - 'userid' => $user1->getUID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertTrue($group1->inGroup($user1)); - $group1->delete(); - } - - public function testRemoveFromGroupAsAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group1->addUser($user2); - $this->groupManager->get('admin')->addUser($user1); - $result = $this->api->removeFromGroup(array( - 'userid' => $user2->getUID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertFalse($group1->inGroup($user2)); - $group1->delete(); - } - - public function testRemoveSelfFromGroupAsAdmin() { - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group1 = $this->groupManager->createGroup($this->getUniqueID()); - $group1->addUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $result = $this->api->removeFromGroup([ - 'userid' => $user1->getUID(), - '_delete' => [ - 'groupid' => $group1->getGID(), - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertFalse($group1->inGroup($user1)); - $group1->delete(); - } - - public function testRemoveFromGroupAsSubAdmin() { - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $user2 = $this->generateUsers(); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group1->addUser($user1); - $group1->addUser($user2); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $result = $this->api->removeFromGroup(array( - 'userid' => $user2->getUID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertFalse($group1->inGroup($user2)); - $group1->delete(); - } - - public function testRemoveFromGroupAsIrelevantSubAdmin() { - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $user2 = $this->generateUsers(); - $group1 = $this->getUniqueID(); - $group2 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $group2 = $this->groupManager->createGroup($group2); - $group1->addUser($user1); - $group2->addUser($user2); - \OC_SubAdmin::createSubAdmin($user1->getUID(), $group1->getGID()); - $result = $this->api->removeFromGroup(array( - 'userid' => $user2->getUID(), - '_delete' => array( - 'groupid' => $group2->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertTrue($group2->inGroup($user2)); - $group1->delete(); - $group2->delete(); - } - - public function testRemoveFromGroupNoGroupId() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - - $result = $this->api->removeFromGroup([ - '_delete' => [ - 'groupid' => '' - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); + public function testDeleteUnsuccessfulUserAsSubadmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $targetUser + ->expects($this->once()) + ->method('delete') + ->will($this->returnValue(false)); + + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); } - public function testRemoveSelfFromAdminAsAdmin() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $this->groupManager->get('admin')->addUser($user); + public function testDeleteUserAsSubAdminAndUserIsNotAccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToDelete')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToDelete') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete'])); + } - $result = $this->api->removeFromGroup([ - 'userid' => $user->getUID(), - '_delete' => [ - 'groupid' => 'admin' - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(105, $result->getStatusCode()); - $this->assertEquals('Cannot remove yourself from the admin group', $result->getMeta()['message']); - } - - public function testRemoveSelfFromSubAdminGroupAsSubAdmin() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $group = $this->groupManager->createGroup($this->getUniqueID()); - \OC_SubAdmin::createSubAdmin($user->getUID(), $group->getGID()); - - $result = $this->api->removeFromGroup([ - 'userid' => $user->getUID(), - '_delete' => [ - 'groupid' => $group->getGID() - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(105, $result->getStatusCode()); - $this->assertEquals('Cannot remove yourself from this group as you are a SubAdmin', $result->getMeta()['message']); - $group->delete(); - } - - public function testRemoveFromNonExistingGroup() { - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - - $user2 = $this->generateUsers(); - $result = $this->api->removeFromGroup([ - 'userid' => $user2->getUID(), - '_delete' => [ - 'groupid' => $this->getUniqueID() - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); + public function testGetUsersGroupsNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); } - public function testRemoveFromNonGroupNonExistingUser() { - $user = $this->generateUsers(); - $this->userSession->setUser($user); - $this->groupManager->get('admin')->addUser($user); + public function testGetUsersGroupsTargetUserNotExisting() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); - $group = $this->groupManager->createGroup($this->getUniqueID()); + $expected = new \OC_OCS_Result(null, 998); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); + } - $result = $this->api->removeFromGroup([ - 'userid' => $this->getUniqueID(), - '_delete' => [ - 'groupid' => $group->getGID() - ], - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(103, $result->getStatusCode()); - } - - - public function testCreateSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->addSubAdmin(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertTrue(\OC_SubAdmin::isSubAdminofGroup($user2->getUID(), $group1->getGID())); - $group1->delete(); - - $this->resetParams(); - - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $_POST['groupid'] = 'admin'; - $result = $this->api->addSubAdmin(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertEquals(103, $result->getStatusCode()); - $this->assertFalse($result->succeeded()); - - $this->resetParams(); - - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->addSubAdmin(array( - 'userid' => $this->getUniqueID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); - $group1->delete(); - - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $group = $this->getUniqueID(); - $_POST['groupid'] = $group; - $result = $this->api->addSubAdmin([ - 'userid' => $user1->getUID() - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); - $this->assertEquals('Group:'.$group.' does not exist', $result->getMeta()['message']); - } - - public function testRemoveSubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - \OC_SubAdmin::createSubAdmin($user2->getUID(), $group1->getGID()); - $result = $this->api->removeSubAdmin(array( - 'userid' => $user2->getUID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $this->assertTrue(!\OC_SubAdmin::isSubAdminofGroup($user2->getUID(), $group1->getGID())); - $group1->delete(); - - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $result = $this->api->removeSubAdmin(array( - 'userid' => $this->getUniqueID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertEquals(101, $result->getStatusCode()); - $this->assertFalse($result->succeeded()); - - $this->resetParams(); - - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->removeSubAdmin(array( - 'userid' => $user2->getUID(), - '_delete' => array( - 'groupid' => $group1->getGID(), - ), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(102, $result->getStatusCode()); - $group1->delete(); - } - - public function testGetSubAdminGroups() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->getUniqueID(); - $group1 = $this->groupManager->createGroup($group1); - \OC_SubAdmin::createSubAdmin($user2->getUID(), $group1->getGID()); - $result = $this->api->getUserSubAdminGroups(array( - 'userid' => $user2->getUID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $data = $result->getData(); - $this->assertEquals($group1->getGID(), reset($data)); - $group1->delete(); - - $user1 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $result = $this->api->getUserSubAdminGroups(array( - 'userid' => $this->getUniqueID(), - )); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); - } - - public function testSubAdminOfGroupAlreadySubAdmin() { - $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); - $this->userSession->setUser($user1); - $this->groupManager->get('admin')->addUser($user1); - $group1 = $this->groupManager->createGroup($this->getUniqueID()); - - //Make user2 subadmin of group1 - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->addSubAdmin([ - 'userid' => $user2->getUID(), - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); + public function testGetUsersGroupsSelfTargetted() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToLookup')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToLookup')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToLookup') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('getUserGroupIds') + ->with($targetUser) + ->will($this->returnValue(['DummyValue'])); + + $expected = new \OC_OCS_Result(['groups' => ['DummyValue']]); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); + } - //Make user2 subadmin of group1 again - $_POST['groupid'] = $group1->getGID(); - $result = $this->api->addSubAdmin([ - 'userid' => $user2->getUID(), - ]); - $this->assertInstanceOf('OC_OCS_Result', $result); - $this->assertTrue($result->succeeded()); - $group1->delete(); + public function testGetUsersGroupsForAdminUser() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->exactly(2)) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToLookup')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToLookup') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('getUserGroupIds') + ->with($targetUser) + ->will($this->returnValue(['DummyValue'])); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(['groups' => ['DummyValue']]); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); + } + + public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->exactly(2)) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToLookup')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToLookup') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $group1 = $this->getMock('\OCP\IGroup'); + $group1 + ->expects($this->any()) + ->method('getGID') + ->will($this->returnValue('Group1')); + $group2 = $this->getMock('\OCP\IGroup'); + $group2 + ->expects($this->any()) + ->method('getGID') + ->will($this->returnValue('Group2')); + $subAdminManager + ->expects($this->once()) + ->method('getSubAdminsGroups') + ->with($loggedInUser) + ->will($this->returnValue([$group1, $group2])); + $this->groupManager + ->expects($this->any()) + ->method('getUserGroupIds') + ->with($targetUser) + ->will($this->returnValue(['Group1'])); + + $expected = new \OC_OCS_Result(['groups' => ['Group1']]); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); + } + + + public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->exactly(2)) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToLookup')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('UserToLookup') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isUserAccessible') + ->with($loggedInUser, $targetUser) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->any()) + ->method('getUserGroupIds') + ->with($targetUser) + ->will($this->returnValue(['Group1'])); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup'])); + } + + public function testAddToGroupNotLoggedIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->addToGroup([])); + } + + public function testAddToGroupWithTargetGroupNotExisting() { + $_POST['groupid'] = 'GroupToAddTo'; + + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToAddTo') + ->will($this->returnValue(null)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 102); + $this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser'])); + } + + public function testAddToGroupWithNoGroupSpecified() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser'])); + } + + public function testAddToGroupWithTargetUserNotExisting() { + $_POST['groupid'] = 'GroupToAddTo'; + + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToAddTo') + ->will($this->returnValue($targetGroup)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 103); + $this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser'])); + } + + public function testAddToGroupWithoutPermission() { + $_POST['groupid'] = 'GroupToAddTo'; + + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('admin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(false)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser'])); + } + + public function testRemoveFromGroupWithoutLogIn() { + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 997); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); + } + + public function testRemoveFromGroupWithNotExistingTargetGroup() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); + } + + public function testRemoveFromGroupWithNotExistingTargetUser() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue($targetGroup)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('TargetUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 103); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); + } + + public function testRemoveFromGroupWithoutPermission() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('unauthorizedUser')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue($targetGroup)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('TargetUser') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->once()) + ->method('isAdmin') + ->with('unauthorizedUser') + ->will($this->returnValue(false)); + + $expected = new \OC_OCS_Result(null, 104); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); + } + + public function testRemoveFromGroupAsAdminFromAdmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $targetGroup + ->expects($this->once()) + ->method('getGID') + ->will($this->returnValue('admin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('admin') + ->will($this->returnValue($targetGroup)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('admin') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->any()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + + $expected = new \OC_OCS_Result(null, 105, 'Cannot remove yourself from the admin group'); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'admin', '_delete' => ['groupid' => 'admin']])); + } + + public function testRemoveFromGroupAsSubAdminFromSubAdmin() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('subadmin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $targetGroup + ->expects($this->any()) + ->method('getGID') + ->will($this->returnValue('subadmin')); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('subadmin') + ->will($this->returnValue($targetGroup)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('subadmin') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminofGroup') + ->with($loggedInUser, $targetGroup) + ->will($this->returnValue(true)); + $subAdminManager + ->expects($this->once()) + ->method('getSubAdminsGroups') + ->with($loggedInUser) + ->will($this->returnValue([$targetGroup])); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->any()) + ->method('isAdmin') + ->with('subadmin') + ->will($this->returnValue(false)); + + $expected = new \OC_OCS_Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin'); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'subadmin', '_delete' => ['groupid' => 'subadmin']])); + } + + public function testRemoveFromGroupSuccessful() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $loggedInUser + ->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('admin')); + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('admin') + ->will($this->returnValue($targetGroup)); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('AnotherUser') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + $this->groupManager + ->expects($this->any()) + ->method('isAdmin') + ->with('admin') + ->will($this->returnValue(true)); + $targetGroup + ->expects($this->once()) + ->method('removeUser') + ->with($targetUser); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'AnotherUser', '_delete' => ['groupid' => 'admin']])); + } + + public function testAddSubAdminWithNotExistingTargetUser() { + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101, 'User does not exist'); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'NotExistingUser'])); + } + + public function testAddSubAdminWithNotExistingTargetGroup() { + $_POST['groupid'] = 'NotExistingGroup'; + + $targetUser = $this->getMock('\OCP\IUser'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingGroup') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 102, 'Group:NotExistingGroup does not exist'); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser'])); + } + + public function testAddSubAdminToAdminGroup() { + $_POST['groupid'] = 'ADmiN'; + + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('ADmiN') + ->will($this->returnValue($targetGroup)); + + $expected = new \OC_OCS_Result(null, 103, 'Cannot create subadmins for admin group'); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser'])); + } + + public function testAddSubAdminTwice() { + $_POST['groupid'] = 'TargetGroup'; + + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser'])); + } + + public function testAddSubAdminSuccessful() { + $_POST['groupid'] = 'TargetGroup'; + + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(false)); + $subAdminManager + ->expects($this->once()) + ->method('createSubAdmin') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser'])); + } + + public function testAddSubAdminUnsuccessful() { + $_POST['groupid'] = 'TargetGroup'; + + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('TargetGroup') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(false)); + $subAdminManager + ->expects($this->once()) + ->method('createSubAdmin') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 103, 'Unknown error occurred'); + $this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser'])); + } + + public function testRemoveSubAdminNotExistingTargetUser() { + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101, 'User does not exist'); + $this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'NotExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']])); + } + + public function testRemoveSubAdminNotExistingTargetGroup() { + $targetUser = $this->getMock('\OCP\IUser'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToDeleteFrom') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101, 'Group does not exist'); + $this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']])); + } + + public function testRemoveSubAdminFromNotASubadmin() { + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToDeleteFrom') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 102, 'User is not a subadmin of this group'); + $this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']])); + } + + public function testRemoveSubAdminSuccessful() { + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToDeleteFrom') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(true)); + $subAdminManager + ->expects($this->once()) + ->method('deleteSubAdmin') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(true)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 100); + $this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']])); + } + + public function testRemoveSubAdminUnsuccessful() { + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->will($this->returnValue($targetUser)); + $this->groupManager + ->expects($this->once()) + ->method('get') + ->with('GroupToDeleteFrom') + ->will($this->returnValue($targetGroup)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('isSubAdminOfGroup') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(true)); + $subAdminManager + ->expects($this->once()) + ->method('deleteSubAdmin') + ->with($targetUser, $targetGroup) + ->will($this->returnValue(false)); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 103, 'Unknown error occurred'); + $this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']])); + } + + public function testGetUserSubAdminGroupsNotExistingTargetUser() { + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('RequestedUser') + ->will($this->returnValue(null)); + + $expected = new \OC_OCS_Result(null, 101, 'User does not exist'); + $this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser'])); + } + + public function testGetUserSubAdminGroupsWithGroups() { + $targetUser = $this->getMock('\OCP\IUser'); + $targetGroup = $this->getMock('\OCP\IGroup'); + $targetGroup + ->expects($this->once()) + ->method('getGID') + ->will($this->returnValue('TargetGroup')); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('RequestedUser') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('getSubAdminsGroups') + ->with($targetUser) + ->will($this->returnValue([$targetGroup])); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(['TargetGroup'], 100); + $this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser'])); + } + + public function testGetUserSubAdminGroupsWithoutGroups() { + $targetUser = $this->getMock('\OCP\IUser'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('RequestedUser') + ->will($this->returnValue($targetUser)); + $subAdminManager = $this->getMockBuilder('\OC\Subadmin') + ->disableOriginalConstructor()->getMock(); + $subAdminManager + ->expects($this->once()) + ->method('getSubAdminsGroups') + ->with($targetUser) + ->will($this->returnValue([])); + $this->groupManager + ->expects($this->once()) + ->method('getSubAdmin') + ->will($this->returnValue($subAdminManager)); + + $expected = new \OC_OCS_Result(null, 102, 'Unknown error occurred'); + $this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser'])); } } diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index 4fd029c74da..d7ca786a439 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -6,6 +6,7 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Christopher Schäpers <kondou@ts.unde.re> * @author Frédéric Fortier <frederic.fortier@oronospolytechnique.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Nicolas Grekas <nicolas.grekas@gmail.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> diff --git a/apps/user_ldap/l10n/fr.js b/apps/user_ldap/l10n/fr.js index 3bf26f0e3ea..9e863ada3b5 100644 --- a/apps/user_ldap/l10n/fr.js +++ b/apps/user_ldap/l10n/fr.js @@ -39,7 +39,7 @@ OC.L10N.register( "Select attributes" : "Sélectionner les attributs", "User not found. Please check your login attributes and username. Effective filter (to copy-and-paste for command line validation): <br/>" : "Utilisateur introuvable. Veuillez vérifier les attributs de login et le nom d'utilisateur. Filtre effectif (à copier-coller pour valider en ligne de commande):<br/>", "User found and settings verified." : "Utilisateur trouvé et paramètres vérifiés.", - "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter." : "Paramètres vérifiés, mais seul le premier utilisateur pourra se connecter. Utilisez plutôt un filtre moins restrictif.", + "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter." : "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter.", "An unspecified error occurred. Please check the settings and the log." : "Une erreur inconnue s'est produite. Veuillez vérifier les paramètres et le log.", "The search filter is invalid, probably due to syntax issues like uneven number of opened and closed brackets. Please revise." : "Le filtre de recherche n'est pas valide, probablement à cause de problèmes de syntaxe tels que des parenthèses manquantes. Veuillez le corriger.", "A connection error to LDAP / AD occurred, please check host, port and credentials." : "Une erreur s'est produite lors de la connexion au LDAP / AD. Veuillez vérifier l'hôte, le port et les informations d'identification.", diff --git a/apps/user_ldap/l10n/fr.json b/apps/user_ldap/l10n/fr.json index 87cf780e825..a26710c340b 100644 --- a/apps/user_ldap/l10n/fr.json +++ b/apps/user_ldap/l10n/fr.json @@ -37,7 +37,7 @@ "Select attributes" : "Sélectionner les attributs", "User not found. Please check your login attributes and username. Effective filter (to copy-and-paste for command line validation): <br/>" : "Utilisateur introuvable. Veuillez vérifier les attributs de login et le nom d'utilisateur. Filtre effectif (à copier-coller pour valider en ligne de commande):<br/>", "User found and settings verified." : "Utilisateur trouvé et paramètres vérifiés.", - "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter." : "Paramètres vérifiés, mais seul le premier utilisateur pourra se connecter. Utilisez plutôt un filtre moins restrictif.", + "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter." : "Settings verified, but one user found. Only the first will be able to login. Consider a more narrow filter.", "An unspecified error occurred. Please check the settings and the log." : "Une erreur inconnue s'est produite. Veuillez vérifier les paramètres et le log.", "The search filter is invalid, probably due to syntax issues like uneven number of opened and closed brackets. Please revise." : "Le filtre de recherche n'est pas valide, probablement à cause de problèmes de syntaxe tels que des parenthèses manquantes. Veuillez le corriger.", "A connection error to LDAP / AD occurred, please check host, port and credentials." : "Une erreur s'est produite lors de la connexion au LDAP / AD. Veuillez vérifier l'hôte, le port et les informations d'identification.", diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 32472c13b03..dd8ffe14bca 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -691,8 +691,9 @@ class Access extends LDAPUtility implements user\IUserTools { * @param array $ldapRecords */ public function batchApplyUserAttributes(array $ldapRecords){ + $displayNameAttribute = strtolower($this->connection->ldapUserDisplayName); foreach($ldapRecords as $userRecord) { - $ocName = $this->dn2ocname($userRecord['dn'][0], $userRecord[$this->connection->ldapUserDisplayName]); + $ocName = $this->dn2ocname($userRecord['dn'][0], $userRecord[$displayNameAttribute]); $this->cacheUserExists($ocName); $user = $this->userManager->get($ocName); $user->processAttributes($userRecord); diff --git a/apps/user_ldap/lib/configuration.php b/apps/user_ldap/lib/configuration.php index 4a6263de9aa..e1ca624af95 100644 --- a/apps/user_ldap/lib/configuration.php +++ b/apps/user_ldap/lib/configuration.php @@ -3,6 +3,7 @@ * @author Alexander Bergolth <leo@strike.wu.ac.at> * @author Arthur Schiwon <blizzz@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Lennart Rosam <hello@takuto.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> diff --git a/apps/user_ldap/lib/filesystemhelper.php b/apps/user_ldap/lib/filesystemhelper.php index 6d431f6cb43..ee8c26d2f59 100644 --- a/apps/user_ldap/lib/filesystemhelper.php +++ b/apps/user_ldap/lib/filesystemhelper.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/user_ldap/lib/user/deletedusersindex.php b/apps/user_ldap/lib/user/deletedusersindex.php index f8c1406d77e..6b58595cce6 100644 --- a/apps/user_ldap/lib/user/deletedusersindex.php +++ b/apps/user_ldap/lib/user/deletedusersindex.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php index 89bbc849887..4a687c0832a 100644 --- a/apps/user_ldap/lib/user/manager.php +++ b/apps/user_ldap/lib/user/manager.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * diff --git a/apps/user_ldap/lib/user/offlineuser.php b/apps/user_ldap/lib/user/offlineuser.php index 8177e84346f..72c02427928 100644 --- a/apps/user_ldap/lib/user/offlineuser.php +++ b/apps/user_ldap/lib/user/offlineuser.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/user_ldap/lib/user/user.php b/apps/user_ldap/lib/user/user.php index 756b923e7e5..0dc3c8c0c26 100644 --- a/apps/user_ldap/lib/user/user.php +++ b/apps/user_ldap/lib/user/user.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -416,9 +417,9 @@ class User { } //can be null $quotaDefault = $this->connection->ldapQuotaDefault; - $quota = !is_null($valueFromLDAP) - ? $valueFromLDAP - : $quotaDefault !== '' ? $quotaDefault : null; + $quota = $quotaDefault !== '' ? $quotaDefault : null; + $quota = !is_null($valueFromLDAP) ? $valueFromLDAP : $quota; + if(is_null($valueFromLDAP)) { $quotaAttribute = $this->connection->ldapQuotaAttribute; if(!empty($quotaAttribute)) { diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index cb6dbf0cd5d..25e871d9b3d 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -230,24 +230,34 @@ class Test_Access extends \Test\TestCase { $mapperMock = $this->getMockBuilder('\OCA\User_LDAP\Mapping\UserMapping') ->disableOriginalConstructor() ->getMock(); + + $mapperMock->expects($this->any()) + ->method('getNameByDN') + ->will($this->returnValue('a_username')); + $userMock = $this->getMockBuilder('\OCA\user_ldap\lib\user\User') ->disableOriginalConstructor() ->getMock(); + $access->connection->expects($this->any()) + ->method('__get') + ->will($this->returnValue('displayName')); + $access->setUserMapper($mapperMock); + $displayNameAttribute = strtolower($access->connection->ldapUserDisplayName); $data = array( array( 'dn' => 'foobar', - $con->ldapUserDisplayName => 'barfoo' + $displayNameAttribute => 'barfoo' ), array( 'dn' => 'foo', - $con->ldapUserDisplayName => 'bar' + $displayNameAttribute => 'bar' ), array( 'dn' => 'raboof', - $con->ldapUserDisplayName => 'oofrab' + $displayNameAttribute => 'oofrab' ) ); diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index 49af5e3fe34..6a6d5bc7ca1 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -3,6 +3,7 @@ * @author Arthur Schiwon <blizzz@owncloud.com> * @author Frédéric Fortier <frederic.fortier@oronospolytechnique.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php index 1c41eb71ec2..19581d835d1 100644 --- a/apps/user_ldap/tests/user/user.php +++ b/apps/user_ldap/tests/user/user.php @@ -370,6 +370,45 @@ class Test_User_User extends \Test\TestCase { $user->updateQuota(); } + public function testUpdateQuotaFromValue() { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $readQuota = '19 GB'; + + $connection->expects($this->at(0)) + ->method('__get') + ->with($this->equalTo('ldapQuotaDefault')) + ->will($this->returnValue('')); + + $connection->expects($this->once(1)) + ->method('__get') + ->with($this->equalTo('ldapQuotaDefault')) + ->will($this->returnValue(null)); + + $access->expects($this->never()) + ->method('readAttribute'); + + $config->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('alice'), + $this->equalTo('files'), + $this->equalTo('quota'), + $this->equalTo($readQuota)) + ->will($this->returnValue(true)); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + + $user->updateQuota($readQuota); + } + //the testUpdateAvatar series also implicitely tests getAvatarImage public function testUpdateAvatarJpegPhotoProvided() { list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = |