aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_external/appinfo/app.php12
-rwxr-xr-xapps/files_external/lib/config.php103
-rw-r--r--apps/files_external/tests/mountconfig.php165
-rw-r--r--console.php45
-rw-r--r--core/command/maintenance/repair.php2
-rw-r--r--core/js/oc-dialogs.js6
-rw-r--r--l10n/templates/core.pot2
-rw-r--r--l10n/templates/files.pot20
-rw-r--r--l10n/templates/files_encryption.pot4
-rw-r--r--l10n/templates/files_external.pot2
-rw-r--r--l10n/templates/files_sharing.pot4
-rw-r--r--l10n/templates/files_trashbin.pot2
-rw-r--r--l10n/templates/files_versions.pot2
-rw-r--r--l10n/templates/lib.pot6
-rw-r--r--l10n/templates/private.pot2
-rw-r--r--l10n/templates/settings.pot2
-rw-r--r--l10n/templates/user_ldap.pot2
-rw-r--r--l10n/templates/user_webdavauth.pot2
-rw-r--r--lib/private/preferences.php37
-rw-r--r--tests/lib/preferences.php37
20 files changed, 403 insertions, 54 deletions
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index e8ed8950c3a..ca164784fb0 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -32,11 +32,13 @@ OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login
OC_Mount_Config::registerBackend('\OC\Files\Storage\Local', array(
'backend' => (string)$l->t('Local'),
+ 'priority' => 150,
'configuration' => array(
'datadir' => (string)$l->t('Location'))));
OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
'backend' => (string)$l->t('Amazon S3'),
+ 'priority' => 100,
'configuration' => array(
'key' => (string)$l->t('Key'),
'secret' => '*'.$l->t('Secret'),
@@ -45,6 +47,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
'backend' => (string)$l->t('Amazon S3 and compliant'),
+ 'priority' => 100,
'configuration' => array(
'key' => (string)$l->t('Access Key'),
'secret' => '*'.$l->t('Secret Key'),
@@ -58,6 +61,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', array(
'backend' => 'Dropbox',
+ 'priority' => 100,
'configuration' => array(
'configured' => '#configured',
'app_key' => (string)$l->t('App key'),
@@ -69,6 +73,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\FTP', array(
'backend' => 'FTP',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
@@ -79,6 +84,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\FTP', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', array(
'backend' => 'Google Drive',
+ 'priority' => 100,
'configuration' => array(
'configured' => '#configured',
'client_id' => (string)$l->t('Client ID'),
@@ -90,6 +96,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', array(
'backend' => (string)$l->t('OpenStack Object Storage'),
+ 'priority' => 100,
'configuration' => array(
'user' => (string)$l->t('Username (required)'),
'bucket' => (string)$l->t('Bucket (required)'),
@@ -107,6 +114,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', array(
if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB', array(
'backend' => 'SMB / CIFS',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
@@ -117,6 +125,7 @@ if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB_OC', array(
'backend' => (string)$l->t('SMB / CIFS using OC login'),
+ 'priority' => 90,
'configuration' => array(
'host' => (string)$l->t('Host'),
'username_as_share' => '!'.$l->t('Username as share'),
@@ -127,6 +136,7 @@ if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', array(
'backend' => 'WebDAV',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('URL'),
'user' => (string)$l->t('Username'),
@@ -137,6 +147,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\OwnCloud', array(
'backend' => 'ownCloud',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('URL'),
'user' => (string)$l->t('Username'),
@@ -147,6 +158,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\OwnCloud', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', array(
'backend' => 'SFTP',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 7a651239cb4..21f63bf439d 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -35,6 +35,7 @@ class OC_Mount_Config {
const MOUNT_TYPE_GLOBAL = 'global';
const MOUNT_TYPE_GROUP = 'group';
const MOUNT_TYPE_USER = 'user';
+ const MOUNT_TYPE_PERSONAL = 'personal';
// whether to skip backend test (for unit tests, as this static class is not mockable)
public static $skipTest = false;
@@ -126,6 +127,8 @@ class OC_Mount_Config {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
$mount_file = \OC_Config::getValue("mount_file", $datadir . "/mount.json");
+ $backends = self::getBackends();
+
//move config file to it's new position
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
rename(\OC::$SERVERROOT . '/config/mount.json', $mount_file);
@@ -133,12 +136,45 @@ class OC_Mount_Config {
// Load system mount points
$mountConfig = self::readData();
+
+ // Global mount points (is this redundant?)
if (isset($mountConfig[self::MOUNT_TYPE_GLOBAL])) {
foreach ($mountConfig[self::MOUNT_TYPE_GLOBAL] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ // Override if priority greater
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
+ $options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
+ // All user mount points
+ if (isset($mountConfig[self::MOUNT_TYPE_USER]) && isset($mountConfig[self::MOUNT_TYPE_USER]['all'])) {
+ $mounts = $mountConfig[self::MOUNT_TYPE_USER]['all'];
+ foreach ($mounts as $mountPoint => $options) {
+ $mountPoint = self::setUserVars($user, $mountPoint);
+ foreach ($options as &$option) {
+ $option = self::setUserVars($user, $option);
+ }
+ $options['options'] = self::decryptPasswords($options['options']);
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ // Override if priority greater
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
+ $options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
+ $mountPoints[$mountPoint] = $options;
+ }
+ }
+ }
+ // Group mount points
if (isset($mountConfig[self::MOUNT_TYPE_GROUP])) {
foreach ($mountConfig[self::MOUNT_TYPE_GROUP] as $group => $mounts) {
if (\OC_Group::inGroup($user, $group)) {
@@ -148,21 +184,42 @@ class OC_Mount_Config {
$option = self::setUserVars($user, $option);
}
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ // Override if priority greater or if priority type different
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
+ || ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_GROUP) ) {
+ $options['priority_type'] = self::MOUNT_TYPE_GROUP;
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
}
}
+ // User mount points
if (isset($mountConfig[self::MOUNT_TYPE_USER])) {
foreach ($mountConfig[self::MOUNT_TYPE_USER] as $mountUser => $mounts) {
- if ($mountUser === 'all' or strtolower($mountUser) === strtolower($user)) {
+ if (strtolower($mountUser) === strtolower($user)) {
foreach ($mounts as $mountPoint => $options) {
$mountPoint = self::setUserVars($user, $mountPoint);
foreach ($options as &$option) {
$option = self::setUserVars($user, $option);
}
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ // Override if priority greater or if priority type different
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
+ || ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_USER) ) {
+ $options['priority_type'] = self::MOUNT_TYPE_USER;
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
}
@@ -173,6 +230,9 @@ class OC_Mount_Config {
if (isset($mountConfig[self::MOUNT_TYPE_USER][$user])) {
foreach ($mountConfig[self::MOUNT_TYPE_USER][$user] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
+
+ // Always override previous config
+ $options['priority_type'] = self::MOUNT_TYPE_PERSONAL;
$mountPoints[$mountPoint] = $options;
}
}
@@ -244,6 +304,9 @@ class OC_Mount_Config {
$mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
}
$mount['options'] = self::decryptPasswords($mount['options']);
+ if (!isset($mount['priority'])) {
+ $mount['priority'] = $backends[$mount['class']]['priority'];
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
@@ -251,6 +314,7 @@ class OC_Mount_Config {
'class' => $mount['class'],
'mountpoint' => $mountPoint,
'backend' => $backends[$mount['class']]['backend'],
+ 'priority' => $mount['priority'],
'options' => $mount['options'],
'applicable' => array('groups' => array($group), 'users' => array()),
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
@@ -275,12 +339,16 @@ class OC_Mount_Config {
$mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
}
$mount['options'] = self::decryptPasswords($mount['options']);
+ if (!isset($mount['priority'])) {
+ $mount['priority'] = $backends[$mount['class']]['priority'];
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
$config = array(
'class' => $mount['class'],
'mountpoint' => $mountPoint,
'backend' => $backends[$mount['class']]['backend'],
+ 'priority' => $mount['priority'],
'options' => $mount['options'],
'applicable' => array('groups' => array(), 'users' => array($user)),
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
@@ -363,6 +431,7 @@ class OC_Mount_Config {
* @param string $mountType MOUNT_TYPE_GROUP | MOUNT_TYPE_USER
* @param string $applicable User or group to apply mount to
* @param bool $isPersonal Personal or system mount point i.e. is this being called from the personal or admin page
+ * @param int|null $priority Mount point priority, null for default
* @return boolean
*/
public static function addMountPoint($mountPoint,
@@ -370,7 +439,8 @@ class OC_Mount_Config {
$classOptions,
$mountType,
$applicable,
- $isPersonal = false) {
+ $isPersonal = false,
+ $priority = null) {
$backends = self::getBackends();
$mountPoint = OC\Files\Filesystem::normalizePath($mountPoint);
if ($mountPoint === '' || $mountPoint === '/') {
@@ -400,9 +470,24 @@ class OC_Mount_Config {
'options' => self::encryptPasswords($classOptions))
)
);
+ if (! $isPersonal && !is_null($priority)) {
+ $mount[$applicable][$mountPoint]['priority'] = $priority;
+ }
$mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
$mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType);
+
+ // Set default priority if none set
+ if (!isset($mountPoints[$mountType][$applicable][$mountPoint]['priority'])) {
+ if (isset($backends[$class]['priority'])) {
+ $mountPoints[$mountType][$applicable][$mountPoint]['priority']
+ = $backends[$class]['priority'];
+ } else {
+ $mountPoints[$mountType][$applicable][$mountPoint]['priority']
+ = 100;
+ }
+ }
+
self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
return self::getBackendStatus($class, $classOptions, $isPersonal);
@@ -690,8 +775,16 @@ class OC_Mount_Config {
*/
private static function mergeMountPoints($data, $mountPoint, $mountType) {
$applicable = key($mountPoint);
+ $mountPath = key($mountPoint[$applicable]);
if (isset($data[$mountType])) {
if (isset($data[$mountType][$applicable])) {
+ // Merge priorities
+ if (isset($data[$mountType][$applicable][$mountPath])
+ && isset($data[$mountType][$applicable][$mountPath]['priority'])
+ && !isset($mountPoint[$applicable][$mountPath]['priority'])) {
+ $mountPoint[$applicable][$mountPath]['priority']
+ = $data[$mountType][$applicable][$mountPath]['priority'];
+ }
$data[$mountType][$applicable]
= array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
} else {
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php
index 14fe1d90b7a..9b04e200e2b 100644
--- a/apps/files_external/tests/mountconfig.php
+++ b/apps/files_external/tests/mountconfig.php
@@ -41,16 +41,22 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
const TEST_USER1 = 'user1';
const TEST_USER2 = 'user2';
const TEST_GROUP1 = 'group1';
+ const TEST_GROUP1B = 'group1b';
const TEST_GROUP2 = 'group2';
+ const TEST_GROUP2B = 'group2b';
public function setUp() {
\OC_User::createUser(self::TEST_USER1, self::TEST_USER1);
\OC_User::createUser(self::TEST_USER2, self::TEST_USER2);
\OC_Group::createGroup(self::TEST_GROUP1);
+ \OC_Group::createGroup(self::TEST_GROUP1B);
\OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1);
+ \OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1B);
\OC_Group::createGroup(self::TEST_GROUP2);
+ \OC_Group::createGroup(self::TEST_GROUP2B);
\OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2);
+ \OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2B);
\OC_User::setUserId(self::TEST_USER1);
$this->userHome = \OC_User::getHome(self::TEST_USER1);
@@ -81,7 +87,9 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
\OC_User::deleteUser(self::TEST_USER2);
\OC_User::deleteUser(self::TEST_USER1);
\OC_Group::deleteGroup(self::TEST_GROUP1);
+ \OC_Group::deleteGroup(self::TEST_GROUP1B);
\OC_Group::deleteGroup(self::TEST_GROUP2);
+ \OC_Group::deleteGroup(self::TEST_GROUP2B);
@unlink($this->dataDir . '/mount.json');
@@ -635,4 +643,161 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
$this->assertEquals('ext', $config[1]['mountpoint']);
$this->assertEquals($options2, $config[1]['options']);
}
+
+ public function priorityDataProvider() {
+ return array(
+
+ // test 1 - group vs group
+ array(
+ array(
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_GROUP,
+ 'applicable' => self::TEST_GROUP1,
+ 'priority' => 50
+ ),
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_GROUP,
+ 'applicable' => self::TEST_GROUP1B,
+ 'priority' => 60
+ )
+ ),
+ 1
+ ),
+ // test 2 - user vs personal
+ array(
+ array(
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_USER,
+ 'applicable' => self::TEST_USER1,
+ 'priority' => 2000
+ ),
+ array(
+ 'isPersonal' => true,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_USER,
+ 'applicable' => self::TEST_USER1,
+ 'priority' => null
+ )
+ ),
+ 1
+ ),
+ // test 3 - all vs group vs user
+ array(
+ array(
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_USER,
+ 'applicable' => 'all',
+ 'priority' => 70
+ ),
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_GROUP,
+ 'applicable' => self::TEST_GROUP1,
+ 'priority' => 60
+ ),
+ array(
+ 'isPersonal' => false,
+ 'mountType' => OC_Mount_Config::MOUNT_TYPE_USER,
+ 'applicable' => self::TEST_USER1,
+ 'priority' => 50
+ )
+ ),
+ 2
+ )
+
+ );
+ }
+
+ /**
+ * Ensure priorities are being respected
+ * Test user is self::TEST_USER1
+ *
+ * @dataProvider priorityDataProvider
+ * @param array[] $mounts array of associative array of mount parameters:
+ * bool $isPersonal
+ * string $mountType
+ * string $applicable
+ * int|null $priority null for personal
+ * @param int $expected index of expected visible mount
+ */
+ public function testPriority($mounts, $expected) {
+ $mountConfig = array(
+ 'host' => 'somehost',
+ 'user' => 'someuser',
+ 'password' => 'somepassword',
+ 'root' => 'someroot'
+ );
+
+ // Add mount points
+ foreach($mounts as $i => $mount) {
+ $this->assertTrue(
+ OC_Mount_Config::addMountPoint(
+ '/ext',
+ '\OC\Files\Storage\SMB',
+ $mountConfig + array('id' => $i),
+ $mount['mountType'],
+ $mount['applicable'],
+ $mount['isPersonal'],
+ $mount['priority']
+ )
+ );
+ }
+
+ // Get mount points for user
+ $mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+
+ $this->assertEquals(1, count($mountPoints));
+ $this->assertEquals($expected, $mountPoints['/'.self::TEST_USER1.'/files/ext']['options']['id']);
+ }
+
+ /**
+ * Test for persistence of priority when changing mount options
+ */
+ public function testPriorityPersistence() {
+ $class = '\OC\Files\Storage\SMB';
+ $priority = 123;
+ $mountConfig = array(
+ 'host' => 'somehost',
+ 'user' => 'someuser',
+ 'password' => 'somepassword',
+ 'root' => 'someroot'
+ );
+
+ $this->assertTrue(
+ OC_Mount_Config::addMountPoint(
+ '/ext',
+ $class,
+ $mountConfig,
+ OC_Mount_Config::MOUNT_TYPE_USER,
+ self::TEST_USER1,
+ false,
+ $priority
+ )
+ );
+
+ // Check for correct priority
+ $mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+ $this->assertEquals($priority,
+ $mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+
+ // Simulate changed mount options (without priority set)
+ $this->assertTrue(
+ OC_Mount_Config::addMountPoint(
+ '/ext',
+ $class,
+ $mountConfig,
+ OC_Mount_Config::MOUNT_TYPE_USER,
+ self::TEST_USER1,
+ false
+ )
+ );
+
+ // Check for correct priority
+ $mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+ $this->assertEquals($priority,
+ $mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+ }
}
diff --git a/console.php b/console.php
index dd2c1026e47..55bae7a6b38 100644
--- a/console.php
+++ b/console.php
@@ -8,29 +8,34 @@
use Symfony\Component\Console\Application;
-require_once 'lib/base.php';
+try {
+ require_once 'lib/base.php';
-// Don't do anything if ownCloud has not been installed yet
-if (!OC_Config::getValue('installed', false)) {
- echo "Console can only be used once ownCloud has been installed" . PHP_EOL;
- exit(0);
-}
+ // Don't do anything if ownCloud has not been installed yet
+ if (!\OC::$server->getConfig()->getSystemValue('installed', false)) {
+ echo "Console can only be used once ownCloud has been installed" . PHP_EOL;
+ exit(0);
+ }
-if (!OC::$CLI) {
- echo "This script can be run from the command line only" . PHP_EOL;
- exit(0);
-}
+ if (!OC::$CLI) {
+ echo "This script can be run from the command line only" . PHP_EOL;
+ exit(0);
+ }
-// load all apps to get all api routes properly setup
-OC_App::loadApps();
+ // load all apps to get all api routes properly setup
+ OC_App::loadApps();
-$defaults = new OC_Defaults;
-$application = new Application($defaults->getName(), \OC_Util::getVersionString());
-require_once 'core/register_command.php';
-foreach(OC_App::getAllApps() as $app) {
- $file = OC_App::getAppPath($app).'/appinfo/register_command.php';
- if(file_exists($file)) {
- require $file;
+ $defaults = new OC_Defaults;
+ $application = new Application($defaults->getName(), \OC_Util::getVersionString());
+ require_once 'core/register_command.php';
+ foreach(OC_App::getAllApps() as $app) {
+ $file = OC_App::getAppPath($app).'/appinfo/register_command.php';
+ if(file_exists($file)) {
+ require $file;
+ }
}
+ $application->run();
+} catch (Exception $ex) {
+ echo "An unhandled exception has been thrown:" . PHP_EOL;
+ echo $ex;
}
-$application->run();
diff --git a/core/command/maintenance/repair.php b/core/command/maintenance/repair.php
index c5ef0c55cc0..310c01fbe2a 100644
--- a/core/command/maintenance/repair.php
+++ b/core/command/maintenance/repair.php
@@ -29,7 +29,7 @@ class Repair extends Command {
protected function configure() {
$this
->setName('maintenance:repair')
- ->setDescription('set single user mode');
+ ->setDescription('repair this installation');
}
protected function execute(InputInterface $input, OutputInterface $output) {
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index f6c17122d7d..54b9442af27 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -351,7 +351,7 @@ var OCdialogs = {
conflict.find('.filename').text(original.name);
conflict.find('.original .size').text(humanFileSize(original.size));
- conflict.find('.original .mtime').text(formatDate(original.mtime*1000));
+ conflict.find('.original .mtime').text(formatDate(original.mtime));
// ie sucks
if (replacement.size && replacement.lastModifiedDate) {
conflict.find('.replacement .size').text(humanFileSize(replacement.size));
@@ -374,9 +374,9 @@ var OCdialogs = {
//set more recent mtime bold
// ie sucks
- if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() > original.mtime*1000) {
+ if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() > original.mtime) {
conflict.find('.replacement .mtime').css('font-weight', 'bold');
- } else if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() < original.mtime*1000) {
+ } else if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() < original.mtime) {
conflict.find('.original .mtime').css('font-weight', 'bold');
} else {
//TODO add to same mtime collection?
diff --git a/l10n/templates/core.pot b/l10n/templates/core.pot
index c6565eb862d..f1ab23fc580 100644
--- a/l10n/templates/core.pot
+++ b/l10n/templates/core.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/files.pot b/l10n/templates/files.pot
index da3a068b7f7..03cae133d8a 100644
--- a/l10n/templates/files.pot
+++ b/l10n/templates/files.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -211,7 +211,7 @@ msgid ""
"big."
msgstr ""
-#: js/filelist.js:602 js/filelist.js:1672
+#: js/filelist.js:602 js/filelist.js:1671
msgid "Pending"
msgstr ""
@@ -227,39 +227,39 @@ msgstr ""
msgid "Error"
msgstr ""
-#: js/filelist.js:1201
+#: js/filelist.js:1213
msgid "Could not rename file"
msgstr ""
-#: js/filelist.js:1335
+#: js/filelist.js:1334
msgid "Error deleting file."
msgstr ""
-#: js/filelist.js:1438 templates/list.php:62
+#: js/filelist.js:1437 templates/list.php:62
msgid "Name"
msgstr ""
-#: js/filelist.js:1439 templates/list.php:75
+#: js/filelist.js:1438 templates/list.php:75
msgid "Size"
msgstr ""
-#: js/filelist.js:1440 templates/list.php:78
+#: js/filelist.js:1439 templates/list.php:78
msgid "Modified"
msgstr ""
-#: js/filelist.js:1450 js/filesummary.js:141 js/filesummary.js:168
+#: js/filelist.js:1449 js/filesummary.js:141 js/filesummary.js:168
msgid "%n folder"
msgid_plural "%n folders"
msgstr[0] ""
msgstr[1] ""
-#: js/filelist.js:1456 js/filesummary.js:142 js/filesummary.js:169
+#: js/filelist.js:1455 js/filesummary.js:142 js/filesummary.js:169
msgid "%n file"
msgid_plural "%n files"
msgstr[0] ""
msgstr[1] ""
-#: js/filelist.js:1580 js/filelist.js:1619
+#: js/filelist.js:1579 js/filelist.js:1618
msgid "Uploading %n file"
msgid_plural "Uploading %n files"
msgstr[0] ""
diff --git a/l10n/templates/files_encryption.pot b/l10n/templates/files_encryption.pot
index 051793af8e9..73f8b5c863a 100644
--- a/l10n/templates/files_encryption.pot
+++ b/l10n/templates/files_encryption.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -89,7 +89,7 @@ msgid ""
"the encryption app has been disabled."
msgstr ""
-#: hooks/hooks.php:295
+#: hooks/hooks.php:299
msgid "Following users are not set up for encryption:"
msgstr ""
diff --git a/l10n/templates/files_external.pot b/l10n/templates/files_external.pot
index 4794ed8e20d..73e8c59268f 100644
--- a/l10n/templates/files_external.pot
+++ b/l10n/templates/files_external.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/files_sharing.pot b/l10n/templates/files_sharing.pot
index 8ed864c657c..8be713c64a2 100644
--- a/l10n/templates/files_sharing.pot
+++ b/l10n/templates/files_sharing.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: js/share.js:33
+#: js/share.js:35
msgid "Shared by {owner}"
msgstr ""
diff --git a/l10n/templates/files_trashbin.pot b/l10n/templates/files_trashbin.pot
index 23356738375..289e2e88369 100644
--- a/l10n/templates/files_trashbin.pot
+++ b/l10n/templates/files_trashbin.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/files_versions.pot b/l10n/templates/files_versions.pot
index 5ab74dc02a6..304ce12e92c 100644
--- a/l10n/templates/files_versions.pot
+++ b/l10n/templates/files_versions.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/lib.pot b/l10n/templates/lib.pot
index d544c5e5f73..6574e0383cf 100644
--- a/l10n/templates/lib.pot
+++ b/l10n/templates/lib.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,11 +18,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-#: base.php:694
+#: base.php:695
msgid "You are accessing the server from an untrusted domain."
msgstr ""
-#: base.php:695
+#: base.php:696
msgid ""
"Please contact your administrator. If you are an administrator of this "
"instance, configure the \"trusted_domain\" setting in config/config.php. An "
diff --git a/l10n/templates/private.pot b/l10n/templates/private.pot
index 0421990090c..f5a58d6f69f 100644
--- a/l10n/templates/private.pot
+++ b/l10n/templates/private.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/settings.pot b/l10n/templates/settings.pot
index f6539cae89e..f113a096426 100644
--- a/l10n/templates/settings.pot
+++ b/l10n/templates/settings.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/user_ldap.pot b/l10n/templates/user_ldap.pot
index 61114718e61..45238cc4881 100644
--- a/l10n/templates/user_ldap.pot
+++ b/l10n/templates/user_ldap.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/l10n/templates/user_webdavauth.pot b/l10n/templates/user_webdavauth.pot
index 10bd03976a2..0f65c10e0f0 100644
--- a/l10n/templates/user_webdavauth.pot
+++ b/l10n/templates/user_webdavauth.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud Core 6.0.0\n"
"Report-Msgid-Bugs-To: translations@owncloud.org\n"
-"POT-Creation-Date: 2014-05-20 01:54-0400\n"
+"POT-Creation-Date: 2014-05-22 01:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/lib/private/preferences.php b/lib/private/preferences.php
index e6d9f28b1d6..a4bfc650d08 100644
--- a/lib/private/preferences.php
+++ b/lib/private/preferences.php
@@ -206,6 +206,43 @@ class Preferences {
}
/**
+ * Gets the preference for an array of users
+ * @param string $app
+ * @param string $key
+ * @param array $users
+ * @return array Mapped values: userid => value
+ */
+ public function getValueForUsers($app, $key, $users) {
+ if (empty($users) || !is_array($users)) {
+ return array();
+ }
+
+ $chunked_users = array_chunk($users, 50, true);
+ $placeholders_50 = implode(',', array_fill(0, 50, '?'));
+
+ $userValues = array();
+ foreach ($chunked_users as $chunk) {
+ $queryParams = $chunk;
+ array_unshift($queryParams, $key);
+ array_unshift($queryParams, $app);
+
+ $placeholders = (sizeof($chunk) == 50) ? $placeholders_50 : implode(',', array_fill(0, sizeof($chunk), '?'));
+
+ $query = 'SELECT `userid`, `configvalue` '
+ . ' FROM `*PREFIX*preferences` '
+ . ' WHERE `appid` = ? AND `configkey` = ?'
+ . ' AND `userid` IN (' . $placeholders . ')';
+ $result = $this->conn->executeQuery($query, $queryParams);
+
+ while ($row = $result->fetch()) {
+ $userValues[$row['userid']] = $row['configvalue'];
+ }
+ }
+
+ return $userValues;
+ }
+
+ /**
* Deletes a key
* @param string $user user
* @param string $app app
diff --git a/tests/lib/preferences.php b/tests/lib/preferences.php
index f1f6ed08003..499be914fb7 100644
--- a/tests/lib/preferences.php
+++ b/tests/lib/preferences.php
@@ -184,6 +184,43 @@ class Test_Preferences_Object extends PHPUnit_Framework_TestCase {
$preferences->setValue('grg', 'bar', 'foo', 'v2');
}
+ public function testGetUserValues()
+ {
+ $query = \OC_DB::prepare('INSERT INTO `*PREFIX*preferences` VALUES(?, ?, ?, ?)');
+ $query->execute(array('SomeUser', 'testGetUserValues', 'somekey', 'somevalue'));
+ $query->execute(array('AnotherUser', 'testGetUserValues', 'somekey', 'someothervalue'));
+ $query->execute(array('AUser', 'testGetUserValues', 'somekey', 'somevalue'));
+
+ $preferences = new OC\Preferences(\OC_DB::getConnection());
+ $users = array('SomeUser', 'AnotherUser', 'NoValueSet');
+
+ $values = $preferences->getValueForUsers('testGetUserValues', 'somekey', $users);
+ $this->assertUserValues($values);
+
+ // Add a lot of users so the array is chunked
+ for ($i = 1; $i <= 75; $i++) {
+ array_unshift($users, 'NoValueBefore#' . $i);
+ array_push($users, 'NoValueAfter#' . $i);
+ }
+
+ $values = $preferences->getValueForUsers('testGetUserValues', 'somekey', $users);
+ $this->assertUserValues($values);
+
+ // Clean DB after the test
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?');
+ $query->execute(array('testGetUserValues'));
+ }
+
+ protected function assertUserValues($values) {
+ $this->assertEquals(2, sizeof($values));
+
+ $this->assertArrayHasKey('SomeUser', $values);
+ $this->assertEquals('somevalue', $values['SomeUser']);
+
+ $this->assertArrayHasKey('AnotherUser', $values);
+ $this->assertEquals('someothervalue', $values['AnotherUser']);
+ }
+
public function testDeleteKey()
{
$connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false);