aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/ajax/upload.php16
-rw-r--r--apps/files/css/files.css25
-rw-r--r--apps/files_encryption/ajax/getMigrationStatus.php8
-rw-r--r--apps/files_encryption/appinfo/app.php1
-rw-r--r--apps/files_encryption/hooks/hooks.php29
-rw-r--r--apps/files_encryption/js/detect-migration.js6
-rw-r--r--apps/files_encryption/js/encryption.js12
-rw-r--r--apps/files_encryption/lib/proxy.php8
-rw-r--r--apps/files_encryption/lib/stream.php2
-rw-r--r--apps/files_encryption/lib/util.php91
-rw-r--r--apps/files_encryption/tests/hooks.php2
-rwxr-xr-xapps/files_encryption/tests/share.php14
-rwxr-xr-xapps/files_encryption/tests/util.php89
-rw-r--r--apps/files_sharing/ajax/publicpreview.php2
-rw-r--r--apps/files_sharing/css/public.css5
-rw-r--r--apps/files_sharing/templates/public.php2
-rw-r--r--apps/files_trashbin/ajax/preview.php2
-rw-r--r--apps/files_trashbin/lib/trashbin.php2
-rw-r--r--apps/user_ldap/templates/part.wizard-groupfilter.php2
-rw-r--r--apps/user_ldap/templates/part.wizard-loginfilter.php2
-rw-r--r--apps/user_ldap/templates/part.wizard-userfilter.php2
-rw-r--r--core/ajax/preview.php2
-rw-r--r--core/img/filetypes/application-x-cbr.pngbin0 -> 1205 bytes
-rw-r--r--core/img/filetypes/application-x-cbr.svg771
-rw-r--r--core/js/config.php2
-rw-r--r--core/js/js.js4
-rw-r--r--cron.php4
-rw-r--r--issue_template.md39
-rw-r--r--lib/private/allconfig.php4
-rw-r--r--lib/private/backgroundjob/job.php4
-rw-r--r--lib/private/backgroundjob/joblist.php74
-rw-r--r--lib/private/config.php4
-rw-r--r--lib/private/db.php2
-rw-r--r--lib/private/db/mdb2schemareader.php3
-rw-r--r--lib/private/files/fileinfo.php185
-rw-r--r--lib/private/files/view.php42
-rw-r--r--lib/private/group/manager.php14
-rw-r--r--lib/private/helper.php1
-rw-r--r--lib/private/migrate.php105
-rw-r--r--lib/private/migration/content.php36
-rw-r--r--lib/private/mimetypes.list.php7
-rw-r--r--lib/private/preview/office.php2
-rw-r--r--lib/private/preview/pdf.php2
-rw-r--r--lib/private/preview/svg.php2
-rw-r--r--lib/private/preview/unknown.php2
-rw-r--r--lib/private/server.php16
-rw-r--r--lib/public/backgroundjob.php14
-rw-r--r--lib/public/backgroundjob/ijob.php42
-rw-r--r--lib/public/backgroundjob/ijoblist.php77
-rw-r--r--lib/public/config.php4
-rw-r--r--lib/public/files/fileinfo.php138
-rw-r--r--lib/public/iconfig.php4
-rw-r--r--lib/public/iservercontainer.php7
-rw-r--r--lib/public/util.php2
-rw-r--r--ocs/providers.php2
-rw-r--r--settings/ajax/decryptall.php9
-rw-r--r--tests/lib/backgroundjob/dummyjoblist.php2
-rw-r--r--tests/lib/backgroundjob/job.php25
-rw-r--r--tests/lib/backgroundjob/joblist.php203
-rw-r--r--tests/lib/backgroundjob/testjob.php34
-rw-r--r--tests/lib/db.php2
-rw-r--r--tests/lib/dbschema.php2
-rw-r--r--tests/lib/group/manager.php37
-rw-r--r--tests/lib/migrate.php89
64 files changed, 2013 insertions, 329 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 754c34ef088..145f40c50da 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -22,6 +22,7 @@ if (empty($_POST['dirToken'])) {
} else {
// return only read permissions for public upload
$allowedPermissions = OCP\PERMISSION_READ;
+ $public_directory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/';
$linkItem = OCP\Share::getShareByToken($_POST['dirToken']);
if ($linkItem === false) {
@@ -45,7 +46,7 @@ if (empty($_POST['dirToken'])) {
$dir = sprintf(
"/%s/%s",
$path,
- isset($_POST['subdir']) ? $_POST['subdir'] : ''
+ $public_directory
);
if (!$dir || empty($dir) || $dir === false) {
@@ -112,7 +113,14 @@ if (strpos($dir, '..') === false) {
} else {
$target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]);
}
-
+
+ $directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
+ if (isset($public_directory)) {
+ // If we are uploading from the public app,
+ // we want to send the relative path in the ajax request.
+ $directory = $public_directory;
+ }
+
if ( ! \OC\Files\Filesystem::file_exists($target)
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
) {
@@ -140,7 +148,7 @@ if (strpos($dir, '..') === false) {
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+ 'directory' => $directory,
);
}
@@ -168,7 +176,7 @@ if (strpos($dir, '..') === false) {
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+ 'directory' => $directory,
);
}
}
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 5526abaf6e2..3ad167054c2 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -84,9 +84,26 @@
background-color: rgb(240,240,240);
}
tbody a { color:#000; }
-span.extension, span.uploading, td.date { color:#999; }
-span.extension { text-transform:lowercase; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; }
-tr:hover span.extension { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; color:#777; }
+
+span.extension, span.uploading, td.date {
+ color: #999;
+}
+span.extension {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
+ filter: alpha(opacity=70);
+ opacity: .7;
+ -webkit-transition: opacity 300ms;
+ -moz-transition: opacity 300ms;
+ -o-transition: opacity 300ms;
+ transition: opacity 300ms;
+}
+tr:hover span.extension {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+ filter: alpha(opacity=100);
+ opacity: 1;
+ color: #777;
+}
+
table tr.mouseOver td { background-color:#eee; }
table th { height:24px; padding:0 8px; color:#999; }
table th .name {
@@ -302,7 +319,7 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; }
#fileList a.action {
display: inline;
margin: -8px 0;
- padding: 18px 8px !important;
+ padding: 18px 8px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php
index 17469a1af0c..7c9e0dcc51c 100644
--- a/apps/files_encryption/ajax/getMigrationStatus.php
+++ b/apps/files_encryption/ajax/getMigrationStatus.php
@@ -13,16 +13,14 @@ use OCA\Encryption\Util;
$loginname = isset($_POST['user']) ? $_POST['user'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
-$migrationCompleted = true;
+$migrationStatus = Util::MIGRATION_COMPLETED;
if ($loginname !== '' && $password !== '') {
$username = \OCP\User::checkPassword($loginname, $password);
if ($username) {
$util = new Util(new \OC_FilesystemView('/'), $username);
- if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
- $migrationCompleted = false;
- }
+ $migrationStatus = $util->getMigrationStatus();
}
}
-\OCP\JSON::success(array('data' => array('migrationCompleted' => $migrationCompleted)));
+\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus)));
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index fd9aa429b01..21de421c195 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -10,6 +10,7 @@ OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php';
OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php';
OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php';
+\OCP\Util::addscript('files_encryption', 'encryption');
\OCP\Util::addscript('files_encryption', 'detect-migration');
if (!OC_Config::getValue('maintenance', false)) {
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 83abf3ba9de..50f322ddef4 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -85,10 +85,9 @@ class Hooks {
$ready = $util->beginMigration();
} elseif ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
// refuse login as long as the initial encryption is running
- while ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
- sleep(60);
- $migrationStatus = $util->getMigrationStatus();
- }
+ sleep(5);
+ \OCP\User::logout();
+ return false;
}
// If migration not yet done
@@ -109,21 +108,27 @@ class Hooks {
}
- // Encrypt existing user files:
- if (
- $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])
- ) {
+ // Encrypt existing user files
+ try {
+ $result = $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']);
+ } catch (\Exception $ex) {
+ \OCP\Util::writeLog('Encryption library', 'Initial encryption failed! Error: ' . $ex->getMessage(), \OCP\Util::FATAL);
+ $util->resetMigrationStatus();
+ \OCP\User::logout();
+ $result = false;
+ }
+
+ if ($result) {
\OC_Log::write(
'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed'
, \OC_Log::INFO
);
- }
-
- // Register successful migration in DB
- $util->finishMigration();
+ // Register successful migration in DB
+ $util->finishMigration();
+ }
}
return true;
diff --git a/apps/files_encryption/js/detect-migration.js b/apps/files_encryption/js/detect-migration.js
index 301e77f24f7..f5627edf4e4 100644
--- a/apps/files_encryption/js/detect-migration.js
+++ b/apps/files_encryption/js/detect-migration.js
@@ -17,10 +17,14 @@ $(document).ready(function(){
data: {user: user, password: password},
async: false,
success: function(response) {
- if (response.data.migrationCompleted === false) {
+ if (response.data.migrationStatus === OC.Encryption.MIGRATION_OPEN) {
var message = t('files_encryption', 'Initial encryption started... This can take some time. Please wait.');
$('#messageText').text(message);
$('#message').removeClass('hidden').addClass('update');
+ } else if (response.data.migrationStatus === OC.Encryption.MIGRATION_IN_PROGRESS) {
+ var message = t('files_encryption', 'Initial encryption running... Please try again later.');
+ $('#messageText').text(message);
+ $('#message').removeClass('hidden').addClass('update');
}
}
});
diff --git a/apps/files_encryption/js/encryption.js b/apps/files_encryption/js/encryption.js
new file mode 100644
index 00000000000..65ffabe55e6
--- /dev/null
+++ b/apps/files_encryption/js/encryption.js
@@ -0,0 +1,12 @@
+/**
+ * Copyright (c) 2014
+ * Bjoern Schiessle <schiessle@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ */
+
+OC.Encryption={
+ MIGRATION_OPEN:0,
+ MIGRATION_COMPLETED:1,
+ MIGRATION_IN_PROGRESS:-1,
+};
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 11048005969..9d456f6c517 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -262,7 +262,7 @@ class Proxy extends \OC_FileProxy {
} elseif (
self::shouldEncrypt($path)
- and $meta ['mode'] !== 'r'
+ and $meta['mode'] !== 'r'
and $meta['mode'] !== 'rb'
) {
$result = fopen('crypt://' . $path, $meta['mode']);
@@ -283,7 +283,7 @@ class Proxy extends \OC_FileProxy {
public function postGetFileInfo($path, $data) {
// if path is a folder do nothing
- if (\OCP\App::isEnabled('files_encryption') && is_array($data) && array_key_exists('size', $data)) {
+ if (\OCP\App::isEnabled('files_encryption') && $data !== false && array_key_exists('size', $data)) {
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
@@ -341,7 +341,7 @@ class Proxy extends \OC_FileProxy {
}
// if file is encrypted return real file size
- if (is_array($fileInfo) && $fileInfo['encrypted'] === true) {
+ if ($fileInfo && $fileInfo['encrypted'] === true) {
// try to fix unencrypted file size if it doesn't look plausible
if ((int)$fileInfo['size'] > 0 && (int)$fileInfo['unencrypted_size'] === 0 ) {
$fixSize = $util->getFileSize($path);
@@ -354,7 +354,7 @@ class Proxy extends \OC_FileProxy {
$size = $fileInfo['unencrypted_size'];
} else {
// self healing if file was removed from file cache
- if (!is_array($fileInfo)) {
+ if (!$fileInfo) {
$fileInfo = array();
}
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index b3bf34ddb82..88eacc6f136 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -567,7 +567,7 @@ class Stream {
// get file info
$fileInfo = $this->rootView->getFileInfo($path);
- if (is_array($fileInfo)) {
+ if ($fileInfo) {
// set encryption data
$fileInfo['encrypted'] = true;
$fileInfo['size'] = $this->size;
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 13184b50dbf..a338f90c8be 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -318,7 +318,8 @@ class Util {
$found = array(
'plain' => array(),
'encrypted' => array(),
- 'legacy' => array()
+ 'legacy' => array(),
+ 'broken' => array(),
);
}
@@ -329,10 +330,7 @@ class Util {
if(is_resource($handle)) {
while (false !== ($file = readdir($handle))) {
- if (
- $file !== "."
- && $file !== ".."
- ) {
+ if ($file !== "." && $file !== "..") {
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
@@ -359,15 +357,23 @@ class Util {
// NOTE: This is inefficient;
// scanning every file like this
// will eat server resources :(
- if (
- Keymanager::getFileKey($this->view, $this, $relPath)
- && $isEncryptedPath
- ) {
-
- $found['encrypted'][] = array(
- 'name' => $file,
- 'path' => $filePath
- );
+ if ($isEncryptedPath) {
+
+ $fileKey = Keymanager::getFileKey($this->view, $this, $relPath);
+ $shareKey = Keymanager::getShareKey($this->view, $this->userId, $this, $relPath);
+ // if file is encrypted but now file key is available, throw exception
+ if ($fileKey === false || $shareKey === false) {
+ \OCP\Util::writeLog('encryption library', 'No keys available to decrypt the file: ' . $filePath, \OCP\Util::ERROR);
+ $found['broken'][] = array(
+ 'name' => $file,
+ 'path' => $filePath,
+ );
+ } else {
+ $found['encrypted'][] = array(
+ 'name' => $file,
+ 'path' => $filePath,
+ );
+ }
// If the file uses old
// encryption system
@@ -773,6 +779,12 @@ class Util {
$successful = false;
}
+ // if there are broken encrypted files than the complete decryption
+ // was not successful
+ if (!empty($found['broken'])) {
+ $successful = false;
+ }
+
if ($successful) {
$this->view->deleteAll($this->keyfilesPath);
$this->view->deleteAll($this->shareKeysPath);
@@ -1190,26 +1202,48 @@ class Util {
}
/**
- * @brief start migration mode to initially encrypt users data
+ * @brief set migration status
+ * @param int $status
* @return boolean
*/
- public function beginMigration() {
+ private function setMigrationStatus($status) {
- $return = false;
-
- $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ? and `migration_status` = ?';
- $args = array(self::MIGRATION_IN_PROGRESS, $this->userId, self::MIGRATION_OPEN);
+ $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?';
+ $args = array($status, $this->userId);
$query = \OCP\DB::prepare($sql);
$manipulatedRows = $query->execute($args);
if ($manipulatedRows === 1) {
- $return = true;
+ $result = true;
+ \OCP\Util::writeLog('Encryption library', "Migration status set to " . self::MIGRATION_OPEN, \OCP\Util::INFO);
+ } else {
+ $result = false;
+ \OCP\Util::writeLog('Encryption library', "Could not set migration status to " . self::MIGRATION_OPEN, \OCP\Util::WARN);
+ }
+
+ return $result;
+ }
+
+ /**
+ * @brief start migration mode to initially encrypt users data
+ * @return boolean
+ */
+ public function beginMigration() {
+
+ $result = $this->setMigrationStatus(self::MIGRATION_IN_PROGRESS);
+
+ if ($result) {
\OCP\Util::writeLog('Encryption library', "Start migration to encryption mode for " . $this->userId, \OCP\Util::INFO);
} else {
\OCP\Util::writeLog('Encryption library', "Could not activate migration mode for " . $this->userId . ". Probably another process already started the initial encryption", \OCP\Util::WARN);
}
- return $return;
+ return $result;
+ }
+
+ public function resetMigrationStatus() {
+ return $this->setMigrationStatus(self::MIGRATION_OPEN);
+
}
/**
@@ -1217,22 +1251,15 @@ class Util {
* @return boolean
*/
public function finishMigration() {
+ $result = $this->setMigrationStatus(self::MIGRATION_COMPLETED);
- $return = false;
-
- $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ? and `migration_status` = ?';
- $args = array(self::MIGRATION_COMPLETED, $this->userId, self::MIGRATION_IN_PROGRESS);
- $query = \OCP\DB::prepare($sql);
- $manipulatedRows = $query->execute($args);
-
- if ($manipulatedRows === 1) {
- $return = true;
+ if ($result) {
\OCP\Util::writeLog('Encryption library', "Finish migration successfully for " . $this->userId, \OCP\Util::INFO);
} else {
\OCP\Util::writeLog('Encryption library', "Could not deactivate migration mode for " . $this->userId, \OCP\Util::WARN);
}
- return $return;
+ return $result;
}
/**
diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php
index 44525791743..7d926caea1b 100644
--- a/apps/files_encryption/tests/hooks.php
+++ b/apps/files_encryption/tests/hooks.php
@@ -203,7 +203,7 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
$fileInfo = $this->user1View->getFileInfo($this->filename);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// share the file with user2
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, OCP\PERMISSION_ALL);
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index 076459c562e..46a21dd55cd 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -150,7 +150,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@@ -310,7 +310,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// re-enable the file proxy
\OC_FileProxy::$enabled = $proxyStatus;
@@ -388,7 +388,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
. $this->subfolder);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfoSubFolder));
+ $this->assertTrue($fileInfoSubFolder instanceof \OC\Files\FileInfo);
// re-enable the file proxy
\OC_FileProxy::$enabled = $proxyStatus;
@@ -422,7 +422,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
. $this->subsubfolder . '/' . $this->filename);
// check if we have fileInfos
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// share the file with user3
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, OCP\PERMISSION_ALL);
@@ -517,7 +517,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@@ -595,7 +595,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@@ -888,7 +888,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
- $this->assertTrue(is_array($fileInfo));
+ $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 97e3c518dac..321bdc76f8b 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -64,6 +64,8 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
function setUp() {
+ // login user
+ \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
\OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
$this->userId = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
$this->pass = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
@@ -328,7 +330,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
- $this->assertTrue(is_array($fileInfoUnencrypted));
+ $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo);
// enable file encryption again
\OC_App::enable('files_encryption');
@@ -338,7 +340,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
- $this->assertTrue(is_array($fileInfoEncrypted));
+ $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo);
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
@@ -357,23 +359,98 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
- $this->assertTrue(is_array($fileInfoEncrypted));
+ $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo);
+ $this->assertEquals($fileInfoEncrypted['encrypted'], 1);
- // encrypt all unencrypted files
- $util->decryptAll('/' . $this->userId . '/' . 'files');
+ // decrypt all encrypted files
+ $result = $util->decryptAll('/' . $this->userId . '/' . 'files');
+
+ $this->assertTrue($result);
$fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
- $this->assertTrue(is_array($fileInfoUnencrypted));
+ $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo);
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
$this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
+ // file should no longer be encrypted
+ $this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
$this->view->unlink($this->userId . '/files/' . $filename);
}
+ function testDescryptAllWithBrokenFiles() {
+
+ $file1 = "/decryptAll1" . uniqid() . ".txt";
+ $file2 = "/decryptAll2" . uniqid() . ".txt";
+
+ $util = new Encryption\Util($this->view, $this->userId);
+
+ $this->view->file_put_contents($this->userId . '/files/' . $file1, $this->dataShort);
+ $this->view->file_put_contents($this->userId . '/files/' . $file2, $this->dataShort);
+
+ $fileInfoEncrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
+ $fileInfoEncrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
+
+ $this->assertTrue($fileInfoEncrypted1 instanceof \OC\Files\FileInfo);
+ $this->assertTrue($fileInfoEncrypted2 instanceof \OC\Files\FileInfo);
+ $this->assertEquals($fileInfoEncrypted1['encrypted'], 1);
+ $this->assertEquals($fileInfoEncrypted2['encrypted'], 1);
+
+ // rename keyfile for file1 so that the decryption for file1 fails
+ // Expected behaviour: decryptAll() returns false, file2 gets decrypted anyway
+ $this->view->rename($this->userId . '/files_encryption/keyfiles/' . $file1 . '.key',
+ $this->userId . '/files_encryption/keyfiles/' . $file1 . '.key.moved');
+
+ // decrypt all encrypted files
+ $result = $util->decryptAll('/' . $this->userId . '/' . 'files');
+
+ $this->assertFalse($result);
+
+ $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
+ $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
+
+ $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo);
+ $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo);
+
+ // file1 should be still encrypted; file2 should be decrypted
+ $this->assertEquals(1, $fileInfoUnencrypted1['encrypted']);
+ $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']);
+
+ // keyfiles and share keys should still exist
+ $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/keyfiles/'));
+ $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/share-keys/'));
+
+ // rename the keyfile for file1 back
+ $this->view->rename($this->userId . '/files_encryption/keyfiles/' . $file1 . '.key.moved',
+ $this->userId . '/files_encryption/keyfiles/' . $file1 . '.key');
+
+ // try again to decrypt all encrypted files
+ $result = $util->decryptAll('/' . $this->userId . '/' . 'files');
+
+ $this->assertTrue($result);
+
+ $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
+ $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
+
+ $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo);
+ $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo);
+
+ // now both files should be decrypted
+ $this->assertEquals(0, $fileInfoUnencrypted1['encrypted']);
+ $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']);
+
+ // keyfiles and share keys should be deleted
+ $this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/keyfiles/'));
+ $this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/share-keys/'));
+
+ $this->view->unlink($this->userId . '/files/' . $file1);
+ $this->view->unlink($this->userId . '/files/' . $file2);
+
+ }
+
/**
* @large
*/
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index a52f522afac..d12d212a2e6 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -11,7 +11,7 @@ if(!\OC_App::isEnabled('files_sharing')){
\OC_User::setIncognitoMode(true);
-$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index 21f0c82b829..5246a4b2fec 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -66,7 +66,8 @@ p.info a {
margin:0 auto;
}
-#imgframe img {
+#imgframe img,
+#imgframe video {
max-height:100%;
max-width:100%;
}
@@ -76,6 +77,8 @@ p.info a {
margin-top: 10%;
}
+
+
thead {
padding-left: 0 !important; /* fixes multiselect bar offset on shared page */
}
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 3ddaf4446df..3eb84ce1672 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -35,7 +35,7 @@
<?php else: ?>
<div id="imgframe">
<?php $size = \OC\Preview::isMimeSupported($_['mimetype']) ? 500 : 128 ?>
- <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => urlencode($_['directory_path']), 't' => $_['dirToken']))); ?>" class="publicpreview"/>
+ <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => $_['directory_path'], 't' => $_['dirToken']))); ?>" class="publicpreview"/>
</div>
<?php endif; ?>
<div class="directDownload">
diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php
index 44738734b19..ce64d9ecc9f 100644
--- a/apps/files_trashbin/ajax/preview.php
+++ b/apps/files_trashbin/ajax/preview.php
@@ -11,7 +11,7 @@ if(!\OC_App::isEnabled('files_trashbin')){
exit;
}
-$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 6cef7fa3d25..250cfd54cad 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -996,6 +996,6 @@ class Trashbin {
}
public static function preview_icon($path) {
- return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) ));
+ return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => $path ));
}
}
diff --git a/apps/user_ldap/templates/part.wizard-groupfilter.php b/apps/user_ldap/templates/part.wizard-groupfilter.php
index 0cc4dfa572a..e460997b1bf 100644
--- a/apps/user_ldap/templates/part.wizard-groupfilter.php
+++ b/apps/user_ldap/templates/part.wizard-groupfilter.php
@@ -1,7 +1,7 @@
<fieldset id="ldapWizard4">
<div>
<p>
- <?php p($l->t('Limit the access to %s to groups meeting this criteria:', $theme->getName()));?>
+ <?php p($l->t('Groups meeting these criteria are available in %s:', $theme->getName()));?>
</p>
<p>
<label for="ldap_groupfilter_objectclass">
diff --git a/apps/user_ldap/templates/part.wizard-loginfilter.php b/apps/user_ldap/templates/part.wizard-loginfilter.php
index dc5d61e9f77..3dde46fa979 100644
--- a/apps/user_ldap/templates/part.wizard-loginfilter.php
+++ b/apps/user_ldap/templates/part.wizard-loginfilter.php
@@ -1,7 +1,7 @@
<fieldset id="ldapWizard3">
<div>
<p>
- <?php p($l->t('What attribute shall be used as login name:'));?>
+ <?php p($l->t('Users login with this attribute:'));?>
</p>
<p>
<label for="ldap_loginfilter_username">
diff --git a/apps/user_ldap/templates/part.wizard-userfilter.php b/apps/user_ldap/templates/part.wizard-userfilter.php
index c1d522ce2a6..eff9f89ce2c 100644
--- a/apps/user_ldap/templates/part.wizard-userfilter.php
+++ b/apps/user_ldap/templates/part.wizard-userfilter.php
@@ -1,7 +1,7 @@
<fieldset id="ldapWizard2">
<div>
<p>
- <?php p($l->t('Limit the access to %s to users meeting this criteria:', $theme->getName()));?>
+ <?php p($l->t('Limit %s access to users meeting these criteria:', $theme->getName()));?>
</p>
<p>
<label for="ldap_userfilter_objectclass">
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index af0f0493f4c..a1267d6f5cf 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -7,7 +7,7 @@
*/
\OC_Util::checkLoggedIn();
-$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
diff --git a/core/img/filetypes/application-x-cbr.png b/core/img/filetypes/application-x-cbr.png
new file mode 100644
index 00000000000..c61130cda31
--- /dev/null
+++ b/core/img/filetypes/application-x-cbr.png
Binary files differ
diff --git a/core/img/filetypes/application-x-cbr.svg b/core/img/filetypes/application-x-cbr.svg
new file mode 100644
index 00000000000..9e3fc11d39d
--- /dev/null
+++ b/core/img/filetypes/application-x-cbr.svg
@@ -0,0 +1,771 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32px"
+ height="32px"
+ id="svg3194"
+ version="1.1"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="application-cbr.svg"
+ inkscape:export-filename="application-cbr.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs3196">
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3195"
+ id="linearGradient3066"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.502671,0,0,0.64629877,3.711822,0.79617735)"
+ x1="23.99999"
+ y1="14.915504"
+ x2="23.99999"
+ y2="32.595779" />
+ <linearGradient
+ id="linearGradient3195">
+ <stop
+ id="stop3197"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3199"
+ style="stop-color:#ffffff;stop-opacity:0.23529412"
+ offset="0.12291458" />
+ <stop
+ id="stop3201"
+ style="stop-color:#ffffff;stop-opacity:0.15686275"
+ offset="0.93706012" />
+ <stop
+ id="stop3203"
+ style="stop-color:#ffffff;stop-opacity:0.39215687"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-7"
+ id="radialGradient3069"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,0.96917483,-0.82965977,0,24.014205,-1.7852207)"
+ cx="10.90426"
+ cy="8.4497671"
+ fx="10.90426"
+ fy="8.4497671"
+ r="19.99999" />
+ <linearGradient
+ id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-7">
+ <stop
+ id="stop5430-8-6"
+ style="stop-color:#5f5f5f;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5432-3-5"
+ style="stop-color:#4f4f4f;stop-opacity:1"
+ offset="0.26238" />
+ <stop
+ id="stop5434-1-6"
+ style="stop-color:#3b3b3b;stop-opacity:1"
+ offset="0.704952" />
+ <stop
+ id="stop5436-8-9"
+ style="stop-color:#2b2b2b;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-7"
+ id="linearGradient3071"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.65627449,0,0,0.6892852,1.2531134,-0.21112011)"
+ x1="24"
+ y1="44"
+ x2="24"
+ y2="3.8990016" />
+ <linearGradient
+ id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-7">
+ <stop
+ id="stop5440-4-4"
+ style="stop-color:#272727;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5442-3-5"
+ style="stop-color:#454545;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3731"
+ id="linearGradient3075"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.56756757,0,0,0.67567567,2.3783793,-0.21620881)"
+ x1="23.99999"
+ y1="4.999989"
+ x2="23.99999"
+ y2="43" />
+ <linearGradient
+ id="linearGradient3731">
+ <stop
+ id="stop3733"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3735"
+ style="stop-color:#ffffff;stop-opacity:0.23529412"
+ offset="0.02706478" />
+ <stop
+ id="stop3737"
+ style="stop-color:#ffffff;stop-opacity:0.15686275"
+ offset="0.97377032" />
+ <stop
+ id="stop3739"
+ style="stop-color:#ffffff;stop-opacity:0.39215687"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8"
+ id="radialGradient3078"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.165708e-8,1.6179162,-1.483354,-2.9808191e-8,28.734063,-9.2240923)"
+ cx="7.4956832"
+ cy="8.4497671"
+ fx="7.4956832"
+ fy="8.4497671"
+ r="19.99999" />
+ <linearGradient
+ id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8">
+ <stop
+ id="stop5430-8"
+ style="stop-color:#5f5f5f;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5432-3"
+ style="stop-color:#4f4f4f;stop-opacity:1"
+ offset="0.26238" />
+ <stop
+ id="stop5434-1"
+ style="stop-color:#3b3b3b;stop-opacity:1"
+ offset="0.704952" />
+ <stop
+ id="stop5436-8"
+ style="stop-color:#2b2b2b;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6"
+ id="linearGradient3080"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.60000001,0,0,0.69230771,1.8000008,-0.61538474)"
+ x1="24"
+ y1="44"
+ x2="24"
+ y2="3.8990016" />
+ <linearGradient
+ id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6">
+ <stop
+ id="stop5440-4"
+ style="stop-color:#272727;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5442-3"
+ style="stop-color:#454545;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient8967-1"
+ id="radialGradient3083"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,1.8069473,-2.0594306,0,30.190262,-41.983847)"
+ cx="24.501682"
+ cy="6.6475959"
+ fx="24.501682"
+ fy="6.6475959"
+ r="17.49832" />
+ <linearGradient
+ id="linearGradient8967">
+ <stop
+ id="stop8969"
+ style="stop-color:#ddcfbd;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop8971"
+ style="stop-color:#856f50;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3319-1"
+ id="linearGradient3085"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.45330736,0,0,0.48530928,1.9941631,0.11705426)"
+ x1="32.901409"
+ y1="4.6481781"
+ x2="32.901409"
+ y2="61.481758" />
+ <linearGradient
+ id="linearGradient3319">
+ <stop
+ id="stop3321"
+ style="stop-color:#a79071;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3323"
+ style="stop-color:#6f5d45;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2346"
+ id="linearGradient3088"
+ gradientUnits="userSpaceOnUse"
+ x1="10.654308"
+ y1="1"
+ x2="10.654308"
+ y2="3"
+ gradientTransform="matrix(0.60000001,0,0,0.75000464,0.6000147,0.12497942)" />
+ <linearGradient
+ id="linearGradient2346">
+ <stop
+ id="stop2348"
+ style="stop-color:#eeeeee;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop2350"
+ style="stop-color:#d9d9da;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2"
+ id="linearGradient3090"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.60000001,0,0,0.07692307,1.8001714,0.15384638)"
+ x1="24"
+ y1="44"
+ x2="24"
+ y2="3.8990016" />
+ <linearGradient
+ id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2">
+ <stop
+ id="stop5440-4-8"
+ style="stop-color:#272727;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5442-3-8"
+ style="stop-color:#454545;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3101">
+ <stop
+ offset="0"
+ style="stop-color:#9b876c;stop-opacity:1"
+ id="stop3103" />
+ <stop
+ offset="0.95429963"
+ style="stop-color:#9b876c;stop-opacity:1"
+ id="stop3105" />
+ <stop
+ offset="0.95717829"
+ style="stop-color:#c2c2c2;stop-opacity:1"
+ id="stop3107" />
+ <stop
+ offset="1"
+ style="stop-color:#c2c2c2;stop-opacity:1"
+ id="stop3109" />
+ </linearGradient>
+ <linearGradient
+ y2="4.882647"
+ x2="24.640038"
+ y1="3.1234391"
+ x1="24.62738"
+ gradientTransform="matrix(0.69041563,0,0,1.0164576,0.2501926,-2.4916513)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient3190"
+ xlink:href="#linearGradient2346"
+ inkscape:collect="always" />
+ <linearGradient
+ y2="0.065301567"
+ x2="54.887218"
+ y1="0.065301567"
+ x1="5.2122574"
+ gradientTransform="matrix(0.49253714,0,0,0.4937733,0.8902917,0.14413039)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient3192"
+ xlink:href="#linearGradient3911"
+ inkscape:collect="always" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3688-166-749"
+ id="radialGradient2976"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.003784,0,0,1.4,27.98813,-17.4)"
+ cx="4.9929786"
+ cy="43.5"
+ fx="4.9929786"
+ fy="43.5"
+ r="2.5" />
+ <linearGradient
+ id="linearGradient3688-166-749">
+ <stop
+ id="stop2883"
+ style="stop-color:#181818;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop2885"
+ style="stop-color:#181818;stop-opacity:0"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3688-464-309"
+ id="radialGradient2978"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.003784,0,0,1.4,-20.01187,-104.4)"
+ cx="4.9929786"
+ cy="43.5"
+ fx="4.9929786"
+ fy="43.5"
+ r="2.5" />
+ <linearGradient
+ id="linearGradient3688-464-309">
+ <stop
+ id="stop2889"
+ style="stop-color:#181818;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop2891"
+ style="stop-color:#181818;stop-opacity:0"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3702-501-757"
+ id="linearGradient2980"
+ gradientUnits="userSpaceOnUse"
+ x1="25.058096"
+ y1="47.027729"
+ x2="25.058096"
+ y2="39.999443" />
+ <linearGradient
+ id="linearGradient3702-501-757">
+ <stop
+ id="stop2895"
+ style="stop-color:#181818;stop-opacity:0"
+ offset="0" />
+ <stop
+ id="stop2897"
+ style="stop-color:#181818;stop-opacity:1"
+ offset="0.5" />
+ <stop
+ id="stop2899"
+ style="stop-color:#181818;stop-opacity:0"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3100"
+ id="linearGradient3072"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.40540539,0,0,0.45945944,-21.967425,1.9253706)"
+ x1="23.99999"
+ y1="4.431067"
+ x2="24.107431"
+ y2="43.758408" />
+ <linearGradient
+ id="linearGradient3100">
+ <stop
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1"
+ id="stop3102" />
+ <stop
+ offset="0.06169702"
+ style="stop-color:#ffffff;stop-opacity:0.23529412"
+ id="stop3104" />
+ <stop
+ offset="0.93279684"
+ style="stop-color:#ffffff;stop-opacity:0.15686275"
+ id="stop3106" />
+ <stop
+ offset="1"
+ style="stop-color:#ffffff;stop-opacity:0.39215687"
+ id="stop3108" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-3"
+ id="radialGradient3075"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,1.1385335,-0.98890268,-2.0976135e-8,-4.5816524,-4.7978939)"
+ cx="7.4956832"
+ cy="8.4497671"
+ fx="7.4956832"
+ fy="8.4497671"
+ r="19.99999" />
+ <linearGradient
+ id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-3">
+ <stop
+ id="stop5430-8-4"
+ style="stop-color:#5f5f5f;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5432-3-0"
+ style="stop-color:#4f4f4f;stop-opacity:1"
+ offset="0.26238" />
+ <stop
+ id="stop5434-1-7"
+ style="stop-color:#3b3b3b;stop-opacity:1"
+ offset="0.704952" />
+ <stop
+ id="stop5436-8-7"
+ style="stop-color:#2b2b2b;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-77"
+ id="linearGradient3077"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.40000001,0,0,0.48717951,-22.537695,1.2600855)"
+ x1="24"
+ y1="44"
+ x2="24"
+ y2="3.8990016" />
+ <linearGradient
+ id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-77">
+ <stop
+ id="stop5440-4-82"
+ style="stop-color:#272727;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5442-3-9"
+ style="stop-color:#454545;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient8967-1"
+ id="radialGradient3080"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,1.2711776,-1.4972812,0,-1.7843744,-27.838648)"
+ cx="24.501682"
+ cy="6.6475959"
+ fx="24.501682"
+ fy="6.6475959"
+ r="17.49832" />
+ <linearGradient
+ id="linearGradient8967-1">
+ <stop
+ id="stop8969-2"
+ style="stop-color:#c4ea71;stop-opacity:1;"
+ offset="0" />
+ <stop
+ id="stop8971-2"
+ style="stop-color:#7c9d35;stop-opacity:1;"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3319-1"
+ id="linearGradient3082"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.32957099,0,0,0.34141245,-22.283968,1.7791087)"
+ x1="32.901409"
+ y1="4.6481781"
+ x2="32.901409"
+ y2="61.481758" />
+ <linearGradient
+ id="linearGradient3319-1">
+ <stop
+ id="stop3321-3"
+ style="stop-color:#96bf3e;stop-opacity:1;"
+ offset="0" />
+ <stop
+ id="stop3323-6"
+ style="stop-color:#4d6b0d;stop-opacity:1;"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2346-4"
+ id="linearGradient3085-0"
+ gradientUnits="userSpaceOnUse"
+ x1="10.654308"
+ y1="1"
+ x2="10.654308"
+ y2="3"
+ gradientTransform="matrix(0.39999999,0,0,0.50000335,-23.337674,1.202378)" />
+ <linearGradient
+ id="linearGradient2346-4">
+ <stop
+ id="stop2348-6"
+ style="stop-color:#eeeeee;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop2350-4"
+ style="stop-color:#d9d9da;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2-9"
+ id="linearGradient3087"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.39999999,0,0,0.05128207,-22.537569,1.2216233)"
+ x1="24"
+ y1="44"
+ x2="24"
+ y2="3.8990016" />
+ <linearGradient
+ id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2-9">
+ <stop
+ id="stop5440-4-8-9"
+ style="stop-color:#272727;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop5442-3-8-1"
+ style="stop-color:#454545;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2346-4"
+ id="linearGradient3090-0"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.52589466,0,0,1.0164584,-24.496147,-1.5392617)"
+ x1="24.640038"
+ y1="3.3805361"
+ x2="24.640038"
+ y2="4.4969802" />
+ <linearGradient
+ id="linearGradient3159">
+ <stop
+ id="stop3161"
+ style="stop-color:#eeeeee;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3163"
+ style="stop-color:#d9d9da;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3911"
+ id="linearGradient3092"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.37516915,0,0,0.49377366,-24.008579,1.096522)"
+ x1="10.199131"
+ y1="0.065301567"
+ x2="54.887218"
+ y2="0.065301567" />
+ <linearGradient
+ id="linearGradient3911">
+ <stop
+ id="stop3913"
+ style="stop-color:#96bf3e;stop-opacity:1;"
+ offset="0" />
+ <stop
+ id="stop3915"
+ style="stop-color:#4d6b0d;stop-opacity:1;"
+ offset="1" />
+ </linearGradient>
+ <radialGradient
+ r="2.5"
+ fy="43.5"
+ fx="4.9929786"
+ cy="43.5"
+ cx="4.9929786"
+ gradientTransform="matrix(2.003784,0,0,1.4,27.98813,-17.4)"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient3082-993"
+ xlink:href="#linearGradient3688-166-749-49"
+ inkscape:collect="always" />
+ <linearGradient
+ id="linearGradient3688-166-749-49">
+ <stop
+ offset="0"
+ style="stop-color:#181818;stop-opacity:1"
+ id="stop3079" />
+ <stop
+ offset="1"
+ style="stop-color:#181818;stop-opacity:0"
+ id="stop3081" />
+ </linearGradient>
+ <radialGradient
+ r="2.5"
+ fy="43.5"
+ fx="4.9929786"
+ cy="43.5"
+ cx="4.9929786"
+ gradientTransform="matrix(2.003784,0,0,1.4,-20.01187,-104.4)"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient3084-992"
+ xlink:href="#linearGradient3688-464-309-276"
+ inkscape:collect="always" />
+ <linearGradient
+ id="linearGradient3688-464-309-276">
+ <stop
+ offset="0"
+ style="stop-color:#181818;stop-opacity:1"
+ id="stop3085" />
+ <stop
+ offset="1"
+ style="stop-color:#181818;stop-opacity:0"
+ id="stop3087" />
+ </linearGradient>
+ <linearGradient
+ y2="39.999443"
+ x2="25.058096"
+ y1="47.027729"
+ x1="25.058096"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient3086-631"
+ xlink:href="#linearGradient3702-501-757-979"
+ inkscape:collect="always" />
+ <linearGradient
+ id="linearGradient3702-501-757-979">
+ <stop
+ offset="0"
+ style="stop-color:#181818;stop-opacity:0"
+ id="stop3091" />
+ <stop
+ offset="0.5"
+ style="stop-color:#181818;stop-opacity:1"
+ id="stop3093" />
+ <stop
+ offset="1"
+ style="stop-color:#181818;stop-opacity:0"
+ id="stop3095" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.1523438"
+ inkscape:cx="-47.81249"
+ inkscape:cy="58.888102"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="1366"
+ inkscape:window-height="744"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata3199">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <g
+ style="display:inline"
+ id="g2036"
+ transform="matrix(0.64999974,0,0,0.3333336,0.39999974,15.33333)">
+ <g
+ style="opacity:0.4"
+ id="g3712"
+ transform="matrix(1.052632,0,0,1.285713,-1.263158,-13.42854)">
+ <rect
+ style="fill:url(#radialGradient2976);fill-opacity:1;stroke:none"
+ id="rect2801"
+ y="40"
+ x="38"
+ height="7"
+ width="5" />
+ <rect
+ style="fill:url(#radialGradient2978);fill-opacity:1;stroke:none"
+ id="rect3696"
+ transform="scale(-1,-1)"
+ y="-47"
+ x="-10"
+ height="7"
+ width="5" />
+ <rect
+ style="fill:url(#linearGradient2980);fill-opacity:1;stroke:none"
+ id="rect3700"
+ y="40"
+ x="10"
+ height="7.0000005"
+ width="28" />
+ </g>
+ </g>
+ <path
+ inkscape:connector-curvature="0"
+ style="fill:url(#linearGradient3190);fill-opacity:1;stroke:url(#linearGradient3192);stroke-width:1.01739752;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
+ id="path2723"
+ d="M 27.491301,2.3043778 C 27.288172,1.6493136 27.414776,1.1334476 27.302585,0.5086989 l -20.7938863,0 0.1227276,1.9826025" />
+ <path
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:url(#linearGradient3088);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3090);stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect5505-21-3-9"
+ d="m 7.5001709,3.5 -2.4000002,0 C 4.7576618,3.5 4.5001708,3.46825 4.5001708,3.426829 l 0,-2.0973288 c 0,-0.66594375 0.3354193,-0.82950023 0.7745366,-0.82950023 l 2.2254635,0" />
+ <rect
+ ry="0.5"
+ style="fill:url(#radialGradient3083);fill-opacity:1.0;stroke:url(#linearGradient3085);stroke-width:1.01904130000000004;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
+ id="rect2719"
+ y="2.5095644"
+ x="5.5095205"
+ rx="0.5"
+ height="26.980959"
+ width="21.980959" />
+ <path
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:url(#radialGradient3078);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3080);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect5505-21-3"
+ d="m 7.5,2.5000001 c 0,0 0,18.7742959 0,26.9999999 l -2.4,0 c -0.3425089,0 -0.6,-0.285772 -0.6,-0.658537 l 0,-26.3414629 z" />
+ <rect
+ style="opacity:0.5;fill:none;stroke:url(#linearGradient3075);stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+ id="rect6741-0"
+ y="3.5000002"
+ x="5.5"
+ height="25"
+ width="21" />
+ <g
+ style="fill:#000000;fill-opacity:1;opacity:0.2"
+ id="g3230"
+ transform="matrix(-0.17865757,0,0,0.17865757,25.443696,7.0670321)">
+ <path
+ style="fill:#000000;fill-opacity:1"
+ id="path3232"
+ d="m 50.463,22.014 c -19.869,0 -35.984,11.045 -35.984,24.674 0,6.475 3.667,12.342 9.612,16.748 l -4.027,14.551 20.54,-7.582 c 3.132,0.615 6.438,0.967 9.859,0.967 19.873,0 35.98,-11.049 35.98,-24.684 0,-13.629 -16.107,-24.674 -35.98,-24.674 z"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="matrix(-0.17865757,0,0,0.17865757,25.443696,6.0670321)"
+ id="Layer_5"
+ style="fill:#ffffff">
+ <path
+ inkscape:connector-curvature="0"
+ d="m 50.463,22.014 c -19.869,0 -35.984,11.045 -35.984,24.674 0,6.475 3.667,12.342 9.612,16.748 l -4.027,14.551 20.54,-7.582 c 3.132,0.615 6.438,0.967 9.859,0.967 19.873,0 35.98,-11.049 35.98,-24.684 0,-13.629 -16.107,-24.674 -35.98,-24.674 z"
+ id="path3196"
+ style="fill:#ffffff" />
+ </g>
+ </g>
+</svg>
diff --git a/core/js/config.php b/core/js/config.php
index 517ea1615a8..b6875fb73f9 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -57,7 +57,7 @@ $array = array(
"firstDay" => json_encode($l->l('firstday', 'firstday')) ,
"oc_config" => json_encode(
array(
- 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', 60 * 60 * 24),
+ 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')),
'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true)
)
)
diff --git a/core/js/js.js b/core/js/js.js
index cb177712a3a..d4d2583f1e5 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -884,11 +884,7 @@ function initCore() {
$('a.action.delete').tipsy({gravity:'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
-
$('input').tipsy({gravity:'w', fade:true});
- $('input[type=text]').focus(function(){
- this.select();
- });
}
$(document).ready(initCore);
diff --git a/cron.php b/cron.php
index 0d2c07b2d95..44ca421328b 100644
--- a/cron.php
+++ b/cron.php
@@ -97,7 +97,7 @@ try {
touch(TemporaryCronClass::$lockfile);
// Work
- $jobList = new \OC\BackgroundJob\JobList();
+ $jobList = \OC::$server->getJobList();
$jobs = $jobList->getAll();
foreach ($jobs as $job) {
$job->execute($jobList, $logger);
@@ -109,7 +109,7 @@ try {
OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
} else {
// Work and success :-)
- $jobList = new \OC\BackgroundJob\JobList();
+ $jobList = \OC::$server->getJobList();
$job = $jobList->getNext();
$job->execute($jobList, $logger);
$jobList->setLastJob($job);
diff --git a/issue_template.md b/issue_template.md
index 0ddc7667bf3..ec14a8b3463 100644
--- a/issue_template.md
+++ b/issue_template.md
@@ -1,37 +1,44 @@
+### Steps to reproduce
+1.
+2.
+3.
+
### Expected behaviour
Tell us what should happen
### Actual behaviour
Tell us what happens instead
-### Steps to reproduce
-1.
-2.
-3.
-
### Server configuration
-Operating system:
+**Operating system**:
-Web server:
+**Web server:**
-Database:
+**Database:**
-PHP version:
+**PHP version:**
-ownCloud version: (see ownCloud admin page)
+**ownCloud version:** (see ownCloud admin page)
-Updated from an older ownCloud or fresh install:
+**Updated from an older ownCloud or fresh install:**
-List of activated app:
+**List of activated apps:**
+
+**The content of config/config.php:**
+
+```
+Insert your config.php content here
+(Without the database password and passwordsalt)
+```
-The content of config/config.php: (Without the database password and passwordsalt)
+**Are you using external storage, if yes which one:** local/smb/sftp/...
-Are you using external storage, if yes which one:
+**Are you using encryption:** yes/no
### Client configuration
-Browser:
+**Browser:**
-Operating system:
+**Operating system:**
### Logs
#### Web server error log
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
index a4aa69d43fb..de3ac973637 100644
--- a/lib/private/allconfig.php
+++ b/lib/private/allconfig.php
@@ -17,7 +17,7 @@ class AllConfig implements \OCP\IConfig {
* Sets a new system wide value
*
* @param string $key the key of the value, under which will be saved
- * @param string $value the value that should be stored
+ * @param mixed $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value) {
@@ -28,7 +28,7 @@ class AllConfig implements \OCP\IConfig {
* Looks up a system wide defined value
*
* @param string $key the key of the value, under which it was saved
- * @param string $default the default value to be returned if the value isn't set
+ * @param mixed $default the default value to be returned if the value isn't set
* @return string the saved value
*/
public function getSystemValue($key, $default = '') {
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 92bd0f8fdbd..0cef401bc24 100644
--- a/lib/private/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
@@ -8,7 +8,9 @@
namespace OC\BackgroundJob;
-abstract class Job {
+use OCP\BackgroundJob\IJob;
+
+abstract class Job implements IJob {
/**
* @var int $id
*/
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index 99743a70c77..586e99a3cbc 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@@ -8,14 +8,28 @@
namespace OC\BackgroundJob;
-/**
- * Class QueuedJob
- *
- * create a background job that is to be executed once
- *
- * @package OC\BackgroundJob
- */
-class JobList {
+use OCP\BackgroundJob\IJobList;
+
+class JobList implements IJobList {
+ /**
+ * @var \OCP\IDBConnection
+ */
+ private $conn;
+
+ /**
+ * @var \OCP\IConfig $config
+ */
+ private $config;
+
+ /**
+ * @param \OCP\IDBConnection $conn
+ * @param \OCP\IConfig $config
+ */
+ public function __construct($conn, $config) {
+ $this->conn = $conn;
+ $this->config = $config;
+ }
+
/**
* @param Job|string $job
* @param mixed $argument
@@ -28,7 +42,7 @@ class JobList {
$class = $job;
}
$argument = json_encode($argument);
- $query = \OC_DB::prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)');
+ $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)');
$query->execute(array($class, $argument));
}
}
@@ -45,10 +59,10 @@ class JobList {
}
if (!is_null($argument)) {
$argument = json_encode($argument);
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
+ $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
$query->execute(array($class, $argument));
} else {
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ?');
+ $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ?');
$query->execute(array($class));
}
}
@@ -67,9 +81,9 @@ class JobList {
$class = $job;
}
$argument = json_encode($argument);
- $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
- $result = $query->execute(array($class, $argument));
- return (bool)$result->fetchRow();
+ $query = $this->conn->prepare('SELECT `id` FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
+ $query->execute(array($class, $argument));
+ return (bool)$query->fetch();
}
/**
@@ -78,10 +92,10 @@ class JobList {
* @return Job[]
*/
public function getAll() {
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs`');
- $result = $query->execute();
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs`');
+ $query->execute();
$jobs = array();
- while ($row = $result->fetchRow()) {
+ while ($row = $query->fetch()) {
$jobs[] = $this->buildJob($row);
}
return $jobs;
@@ -94,15 +108,15 @@ class JobList {
*/
public function getNext() {
$lastId = $this->getLastJob();
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1);
- $result = $query->execute(array($lastId));
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1);
+ $query->execute(array($lastId));
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
//begin at the start of the queue
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1);
- $result = $query->execute();
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1);
+ $query->execute();
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
return null; //empty job list
@@ -115,9 +129,9 @@ class JobList {
* @return Job
*/
public function getById($id) {
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` = ?');
- $result = $query->execute(array($id));
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` = ?');
+ $query->execute(array($id));
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
return null;
@@ -148,7 +162,7 @@ class JobList {
* @param Job $job
*/
public function setLastJob($job) {
- \OC_Appconfig::setValue('backgroundjob', 'lastjob', $job->getId());
+ $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId());
}
/**
@@ -157,7 +171,7 @@ class JobList {
* @return int
*/
public function getLastJob() {
- return \OC_Appconfig::getValue('backgroundjob', 'lastjob', 0);
+ return $this->config->getAppValue('backgroundjob', 'lastjob', 0);
}
/**
@@ -166,7 +180,7 @@ class JobList {
* @param Job $job
*/
public function setLastRun($job) {
- $query = \OC_DB::prepare('UPDATE `*PREFIX*jobs` SET `last_run` = ? WHERE `id` = ?');
+ $query = $this->conn->prepare('UPDATE `*PREFIX*jobs` SET `last_run` = ? WHERE `id` = ?');
$query->execute(array(time(), $job->getId()));
}
}
diff --git a/lib/private/config.php b/lib/private/config.php
index 8a9d5ca6158..8399d0defbd 100644
--- a/lib/private/config.php
+++ b/lib/private/config.php
@@ -77,7 +77,7 @@ class Config {
/**
* @brief Gets a value from config.php
* @param string $key key
- * @param string $default = null default value
+ * @param mixed $default = null default value
* @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
@@ -94,7 +94,7 @@ class Config {
/**
* @brief Sets a value
* @param string $key key
- * @param string $value value
+ * @param mixed $value value
*
* This function sets the value and writes the config.php.
*
diff --git a/lib/private/db.php b/lib/private/db.php
index 562065259fa..723c1ee07a3 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -44,7 +44,7 @@ class OC_DB {
/**
* @var \OC\DB\Connection $connection
*/
- static private $connection; //the prefered connection to use, only Doctrine
+ static private $connection; //the preferred connection to use, only Doctrine
static private $prefix=null;
static private $type=null;
diff --git a/lib/private/db/mdb2schemareader.php b/lib/private/db/mdb2schemareader.php
index b1fd2454cb0..f9a76786c3e 100644
--- a/lib/private/db/mdb2schemareader.php
+++ b/lib/private/db/mdb2schemareader.php
@@ -288,12 +288,13 @@ class MDB2SchemaReader {
if (!empty($fields)) {
if (isset($primary) && $primary) {
$table->setPrimaryKey($fields, $name);
- } else
+ } else {
if (isset($unique) && $unique) {
$table->addUniqueIndex($fields, $name);
} else {
$table->addIndex($fields, $name);
}
+ }
} else {
throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true));
}
diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php
new file mode 100644
index 00000000000..c77571cd2a7
--- /dev/null
+++ b/lib/private/files/fileinfo.php
@@ -0,0 +1,185 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files;
+
+class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
+ /**
+ * @var array $data
+ */
+ private $data;
+
+ /**
+ * @var string $path
+ */
+ private $path;
+
+ /**
+ * @var \OC\Files\Storage\Storage $storage
+ */
+ private $storage;
+
+ /**
+ * @var string $internalPath
+ */
+ private $internalPath;
+
+ public function __construct($path, $storage, $internalPath, $data) {
+ $this->path = $path;
+ $this->storage = $storage;
+ $this->internalPath = $internalPath;
+ $this->data = $data;
+ }
+
+ public function offsetSet($offset, $value) {
+ $this->data[$offset] = $value;
+ }
+
+ public function offsetExists($offset) {
+ return isset($this->data[$offset]);
+ }
+
+ public function offsetUnset($offset) {
+ unset($this->data[$offset]);
+ }
+
+ public function offsetGet($offset) {
+ return $this->data[$offset];
+ }
+
+ /**
+ * @return string
+ */
+ public function getPath() {
+ return $this->path;
+ }
+
+ /**
+ * @return \OCP\Files\Storage
+ */
+ public function getStorage() {
+ return $this->storage;
+ }
+
+ /**
+ * @return string
+ */
+ public function getInternalPath() {
+ return $this->internalPath;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId() {
+ return $this->data['fileid'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getMimetype() {
+ return $this->data['mimetype'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getMimePart() {
+ return $this->data['mimepart'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getName() {
+ return $this->data['name'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getEtag() {
+ return $this->data['etag'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getSize() {
+ return $this->data['size'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getMTime() {
+ return $this->data['mtime'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function isEncrypted() {
+ return $this->data['encrypted'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getPermissions() {
+ return $this->data['permissions'];
+ }
+
+ /**
+ * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER
+ */
+ public function getType() {
+ return $this->data['type'];
+ }
+
+ public function getData(){
+ return $this->data;
+ }
+
+ /**
+ * @param int $permissions
+ * @return bool
+ */
+ protected function checkPermissions($permissions) {
+ return ($this->getPermissions() & $permissions) === $permissions;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isReadable() {
+ return $this->checkPermissions(\OCP\PERMISSION_READ);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isUpdateable() {
+ return $this->checkPermissions(\OCP\PERMISSION_UPDATE);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isDeletable() {
+ return $this->checkPermissions(\OCP\PERMISSION_DELETE);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isShareable() {
+ return $this->checkPermissions(\OCP\PERMISSION_SHARE);
+ }
+}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index d97544b865e..6fc534757b2 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -781,14 +781,7 @@ class View {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo | false
*/
public function getFileInfo($path, $includeMountPoints = true) {
$data = array();
@@ -841,10 +834,13 @@ class View {
$data['permissions'] = $permissions;
}
}
+ if (!$data) {
+ return false;
+ }
$data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
- return $data;
+ return new FileInfo($path, $storage, $internalPath, $data);
}
/**
@@ -852,7 +848,7 @@ class View {
*
* @param string $directory path under datadirectory
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
- * @return array
+ * @return FileInfo[]
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
$result = array();
@@ -878,7 +874,11 @@ class View {
$watcher->checkUpdate($internalPath);
}
- $files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ $files = array();
+ $contents = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ foreach ($contents as $content) {
+ $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
+ }
$permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user);
$ids = array();
@@ -936,7 +936,7 @@ class View {
break;
}
}
- $files[] = $rootEntry;
+ $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry);
}
}
}
@@ -958,6 +958,7 @@ class View {
$result = $files;
}
}
+
return $result;
}
@@ -965,12 +966,15 @@ class View {
* change file metadata
*
* @param string $path
- * @param array $data
+ * @param array | \OCP\Files\FileInfo $data
* @return int
*
* returns the fileid of the updated file
*/
public function putFileInfo($path, $data) {
+ if ($data instanceof FileInfo) {
+ $data = $data->getData();
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -995,7 +999,7 @@ class View {
* search for files with the name matching $query
*
* @param string $query
- * @return array
+ * @return FileInfo[]
*/
public function search($query) {
return $this->searchCommon('%' . $query . '%', 'search');
@@ -1005,7 +1009,7 @@ class View {
* search for files by mimetype
*
* @param string $mimetype
- * @return array
+ * @return FileInfo[]
*/
public function searchByMime($mimetype) {
return $this->searchCommon($mimetype, 'searchByMime');
@@ -1014,7 +1018,7 @@ class View {
/**
* @param string $query
* @param string $method
- * @return array
+ * @return FileInfo[]
*/
private function searchCommon($query, $method) {
$files = array();
@@ -1028,8 +1032,9 @@ class View {
$results = $cache->$method($query);
foreach ($results as $result) {
if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
+ $internalPath = $result['path'];
$result['path'] = substr($mountPoint . $result['path'], $rootLength);
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
@@ -1043,8 +1048,9 @@ class View {
$results = $cache->$method($query);
if ($results) {
foreach ($results as $result) {
+ $internalPath = $result['path'];
$result['path'] = $relativeMountPoint . $result['path'];
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
}
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index bf469d51d12..9b433b64fd4 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -76,12 +76,7 @@ class Manager extends PublicEmitter {
if (isset($this->cachedGroups[$gid])) {
return $this->cachedGroups[$gid];
}
- foreach ($this->backends as $backend) {
- if ($backend->groupExists($gid)) {
- return $this->getGroupObject($gid);
- }
- }
- return null;
+ return $this->getGroupObject($gid);
}
protected function getGroupObject($gid) {
@@ -91,6 +86,9 @@ class Manager extends PublicEmitter {
$backends[] = $backend;
}
}
+ if (count($backends) === 0) {
+ return null;
+ }
$this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this);
return $this->cachedGroups[$gid];
}
@@ -110,8 +108,8 @@ class Manager extends PublicEmitter {
public function createGroup($gid) {
if (!$gid) {
return false;
- } else if ($this->groupExists($gid)) {
- return $this->get($gid);
+ } else if ($group = $this->get($gid)) {
+ return $group;
} else {
$this->emit('\OC\Group', 'preCreate', array($gid));
foreach ($this->backends as $backend) {
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 58cb1b88d66..e5d1fa9b513 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -151,6 +151,7 @@ class OC_Helper {
*/
public static function mimetypeIcon($mimetype) {
$alias = array(
+ 'application/octet-stream' => 'file', // use file icon as fallback
'application/xml' => 'code/xml',
'application/msword' => 'x-office/document',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document',
diff --git a/lib/private/migrate.php b/lib/private/migrate.php
index 0b319177400..948b3d4572d 100644
--- a/lib/private/migrate.php
+++ b/lib/private/migrate.php
@@ -35,12 +35,8 @@ class OC_Migrate{
static private $zip=false;
// Stores the type of export
static private $exporttype=false;
- // Array of temp files to be deleted after zip creation
- static private $tmpfiles=array();
// Holds the db object
- static private $MDB2=false;
- // Schema db object
- static private $schema=false;
+ static private $migration_database=false;
// Path to the sqlite db
static private $dbpath=false;
// Holds the path to the zip file
@@ -131,7 +127,7 @@ class OC_Migrate{
if( !self::connectDB() ) {
return json_encode( array( 'success' => false ) );
}
- self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 );
+ self::$content = new OC_Migration_Content( self::$zip, self::$migration_database );
// Export the app info
$exportdata = self::exportAppData();
// Add the data dir to the zip
@@ -257,7 +253,7 @@ class OC_Migrate{
$userfolder = $extractpath . $json->exporteduser;
$newuserfolder = $datadir . '/' . self::$uid;
foreach(scandir($userfolder) as $file){
- if($file !== '.' && $file !== '..' && is_dir($file)) {
+ if($file !== '.' && $file !== '..' && is_dir($userfolder.'/'.$file)) {
$file = str_replace(array('/', '\\'), '', $file);
// Then copy the folder over
@@ -359,24 +355,6 @@ class OC_Migrate{
}
/**
- * @brief connects to a MDB2 database scheme
- * @returns bool
- */
- static private function connectScheme() {
- // We need a mdb2 database connection
- self::$MDB2->loadModule( 'Manager' );
- self::$MDB2->loadModule( 'Reverse' );
-
- // Connect if this did not happen before
- if( !self::$schema ) {
- require_once 'MDB2/Schema.php';
- self::$schema=MDB2_Schema::factory( self::$MDB2 );
- }
-
- return true;
- }
-
- /**
* @brief creates a migration.db in the users data dir with their app data in
* @return bool whether operation was successfull
*/
@@ -463,47 +441,18 @@ class OC_Migrate{
return false;
}
// Already connected
- if(!self::$MDB2) {
- require_once 'MDB2.php';
-
+ if(!self::$migration_database) {
$datadir = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
-
- // DB type
- if( class_exists( 'SQLite3' ) ) {
- $dbtype = 'sqlite3';
- } else if( is_callable( 'sqlite_open' ) ) {
- $dbtype = 'sqlite';
- } else {
- OC_Log::write( 'migration', 'SQLite not found', OC_Log::ERROR );
- return false;
- }
-
- // Prepare options array
- $options = array(
- 'portability' => MDB2_PORTABILITY_ALL & (!MDB2_PORTABILITY_FIX_CASE),
- 'log_line_break' => '<br>',
- 'idxname_format' => '%s',
- 'debug' => true,
- 'quote_identifier' => true
- );
- $dsn = array(
- 'phptype' => $dbtype,
- 'database' => self::$dbpath,
- 'mode' => '0644'
+ $connectionParams = array(
+ 'path' => self::$dbpath,
+ 'driver' => 'pdo_sqlite',
);
+ $connectionParams['adapter'] = '\OC\DB\AdapterSqlite';
+ $connectionParams['wrapperClass'] = 'OC\DB\Connection';
+ $connectionParams['tablePrefix'] = '';
// Try to establish connection
- self::$MDB2 = MDB2::factory( $dsn, $options );
- // Die if we could not connect
- if( PEAR::isError( self::$MDB2 ) ) {
- die( self::$MDB2->getMessage() );
- OC_Log::write( 'migration', 'Failed to create/connect to migration.db', OC_Log::FATAL );
- OC_Log::write( 'migration', self::$MDB2->getUserInfo(), OC_Log::FATAL );
- OC_Log::write( 'migration', self::$MDB2->getMessage(), OC_Log::FATAL );
- return false;
- }
- // We always, really always want associative arrays
- self::$MDB2->setFetchMode(MDB2_FETCHMODE_ASSOC);
+ self::$migration_database = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
}
return true;
@@ -515,10 +464,7 @@ class OC_Migrate{
* @return bool whether the operation was successful
*/
static private function createAppTables( $appid ) {
-
- if( !self::connectScheme() ) {
- return false;
- }
+ $schema_manager = new OC\DB\MDB2SchemaManager(self::$migration_database);
// There is a database.xml file
$content = file_get_contents(OC_App::getAppPath($appid) . '/appinfo/database.xml' );
@@ -538,29 +484,16 @@ class OC_Migrate{
file_put_contents( $file2, $content );
// Try to create tables
- $definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
-
- unlink( $file2 );
-
- // Die in case something went wrong
- if( $definition instanceof MDB2_Schema_Error ) {
- OC_Log::write( 'migration', 'Failed to parse database.xml for: '.$appid, OC_Log::FATAL );
- OC_Log::write( 'migration', $definition->getMessage().': '.$definition->getUserInfo(), OC_Log::FATAL );
- return false;
- }
-
- $definition['overwrite'] = true;
-
- $ret = self::$schema->createDatabase( $definition );
-
- // Die in case something went wrong
- if( $ret instanceof MDB2_Error ) {
+ try {
+ $schema_manager->createDbFromStructure($file2);
+ } catch(Exception $e) {
+ unlink( $file2 );
OC_Log::write( 'migration', 'Failed to create tables for: '.$appid, OC_Log::FATAL );
- OC_Log::write( 'migration', $ret->getMessage().': '.$ret->getUserInfo(), OC_Log::FATAL );
+ OC_Log::write( 'migration', $e->getMessage(), OC_Log::FATAL );
return false;
}
- return $tables;
+ return $tables;
}
/**
@@ -646,7 +579,7 @@ class OC_Migrate{
if( !self::connectDB( $db ) ) {
return false;
}
- $content = new OC_Migration_Content( self::$zip, self::$MDB2 );
+ $content = new OC_Migration_Content( self::$zip, self::$migration_database );
$provider->setData( self::$uid, $content, $info );
// Then do the import
if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ) {
diff --git a/lib/private/migration/content.php b/lib/private/migration/content.php
index 4413d722731..d6eee40786e 100644
--- a/lib/private/migration/content.php
+++ b/lib/private/migration/content.php
@@ -27,7 +27,7 @@
class OC_Migration_Content{
private $zip=false;
- // Holds the MDB2 object
+ // Holds the database object
private $db=null;
// Holds an array of tmpfiles to delete after zip creation
private $tmpfiles=array();
@@ -35,7 +35,7 @@ class OC_Migration_Content{
/**
* @brief sets up the
* @param $zip ZipArchive object
- * @param optional $db a MDB2 database object (required for exporttype user)
+ * @param optional $db a database object (required for exporttype user)
* @return bool
*/
public function __construct( $zip, $db=null ) {
@@ -63,17 +63,9 @@ class OC_Migration_Content{
// Optimize the query
$query = $this->db->prepare( $query );
+ $query = new OC_DB_StatementWrapper($query, false);
- // Die if we have an error (error means: bad query, not 0 results!)
- if( PEAR::isError( $query ) ) {
- $entry = 'DB Error: "'.$query->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
- OC_Log::write( 'migration', $entry, OC_Log::FATAL );
- return false;
- } else {
- return $query;
- }
-
+ return $query;
}
/**
@@ -156,20 +148,14 @@ class OC_Migration_Content{
$sql .= $valuessql . " )";
// Make the query
$query = $this->prepare( $sql );
- if( !$query ) {
- OC_Log::write( 'migration', 'Invalid sql produced: '.$sql, OC_Log::FATAL );
- return false;
- exit();
+ $query->execute( $values );
+ // Do we need to return some values?
+ if( array_key_exists( 'idcol', $options ) ) {
+ // Yes we do
+ $return[] = $row[$options['idcol']];
} else {
- $query->execute( $values );
- // Do we need to return some values?
- if( array_key_exists( 'idcol', $options ) ) {
- // Yes we do
- $return[] = $row[$options['idcol']];
- } else {
- // Take a guess and return the first field :)
- $return[] = reset($row);
- }
+ // Take a guess and return the first field :)
+ $return[] = reset($row);
}
$fields = '';
$values = '';
diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php
index 40fb1d2d97d..174877d623b 100644
--- a/lib/private/mimetypes.list.php
+++ b/lib/private/mimetypes.list.php
@@ -29,10 +29,17 @@ return array(
'avi'=>'video/x-msvideo',
'bash' => 'text/x-shellscript',
'blend'=>'application/x-blender',
+ 'cb7' => 'application/x-cbr',
+ 'cba' => 'application/x-cbr',
+ 'cbr' => 'application/x-cbr',
+ 'cbt' => 'application/x-cbr',
+ 'cbtc' => 'application/x-cbr',
+ 'cbz' => 'application/x-cbr',
'cc' => 'text/x-c',
'cdr' => 'application/coreldraw',
'cpp' => 'text/x-c++src',
'css'=>'text/css',
+ 'cvbdl' => 'application/x-cbr',
'c' => 'text/x-c',
'c++' => 'text/x-c++src',
'doc'=>'application/msword',
diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php
index 884b6e7dc9b..02bb22e9b94 100644
--- a/lib/private/preview/office.php
+++ b/lib/private/preview/office.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
//both, libreoffice backend and php fallback, need imagick
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("PDF")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
$isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec');
// LibreOffice preview is currently not supported on Windows
diff --git a/lib/private/preview/pdf.php b/lib/private/preview/pdf.php
index 572b8788ac9..d390b4fc677 100644
--- a/lib/private/preview/pdf.php
+++ b/lib/private/preview/pdf.php
@@ -7,7 +7,7 @@
*/
namespace OC\Preview;
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("PDF")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
class PDF extends Provider {
diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php
index 07a37e8f8c1..9a73fff9467 100644
--- a/lib/private/preview/svg.php
+++ b/lib/private/preview/svg.php
@@ -7,7 +7,7 @@
*/
namespace OC\Preview;
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("SVG")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("SVG")) === 1) {
class SVG extends Provider {
diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php
index 8145c826149..2d3b5c5655e 100644
--- a/lib/private/preview/unknown.php
+++ b/lib/private/preview/unknown.php
@@ -22,7 +22,7 @@ class Unknown extends Provider {
$svgPath = substr_replace($path, 'svg', -3);
- if (extension_loaded('imagick') && file_exists($svgPath) && count(\Imagick::queryFormats("SVG")) === 1) {
+ if (extension_loaded('imagick') && file_exists($svgPath) && count(@\Imagick::queryFormats("SVG")) === 1) {
// http://www.php.net/manual/de/imagick.setresolution.php#85284
$svg = new \Imagick();
diff --git a/lib/private/server.php b/lib/private/server.php
index fc8f170dc4a..7696fc207fd 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -151,6 +151,13 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('AvatarManager', function($c) {
return new AvatarManager();
});
+ $this->registerService('JobList', function ($c) {
+ /**
+ * @var Server $c
+ */
+ $config = $c->getConfig();
+ return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
+ });
}
/**
@@ -348,4 +355,13 @@ class Server extends SimpleContainer implements IServerContainer {
function getActivityManager() {
return $this->query('ActivityManager');
}
+
+ /**
+ * Returns an job list for controlling background jobs
+ *
+ * @return \OCP\BackgroundJob\IJobList
+ */
+ function getJobList(){
+ return $this->query('JobList');
+ }
}
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index a7f54491dfa..bcaf6e35454 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -33,7 +33,7 @@ use \OC\BackgroundJob\JobList;
/**
* This class provides functions to register backgroundjobs in ownCloud
*
- * To create a new backgroundjob create a new class that inharits from either \OC\BackgroundJob\Job,
+ * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job,
* \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using
* \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function
* of the job when the job is executed.
@@ -73,7 +73,7 @@ class BackgroundJob {
* @param mixed $argument
*/
public static function registerJob($job, $argument = null) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$jobList->add($job, $argument);
}
@@ -99,7 +99,7 @@ class BackgroundJob {
* key is string "$klass-$method", value is array( $klass, $method )
*/
static public function allRegularTasks() {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$regularJobs = array();
foreach ($allJobs as $job) {
@@ -118,7 +118,7 @@ class BackgroundJob {
* @return associative array
*/
public static function findQueuedTask($id) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
return $jobList->getById($id);
}
@@ -128,7 +128,7 @@ class BackgroundJob {
* @return array with associative arrays
*/
public static function allQueuedTasks() {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$queuedJobs = array();
foreach ($allJobs as $job) {
@@ -148,7 +148,7 @@ class BackgroundJob {
* @return array with associative arrays
*/
public static function queuedTaskWhereAppIs($app) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$allJobs = $jobList->getAll();
$queuedJobs = array();
foreach ($allJobs as $job) {
@@ -186,7 +186,7 @@ class BackgroundJob {
* Deletes a report
*/
public static function deleteQueuedTask($id) {
- $jobList = new JobList();
+ $jobList = \OC::$server->getJobList();
$job = $jobList->getById($id);
if ($job) {
$jobList->remove($job);
diff --git a/lib/public/backgroundjob/ijob.php b/lib/public/backgroundjob/ijob.php
new file mode 100644
index 00000000000..5231e9537a9
--- /dev/null
+++ b/lib/public/backgroundjob/ijob.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\BackgroundJob;
+
+interface IJob {
+ /**
+ * Run the background job with the registered argument
+ *
+ * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job
+ * @param \OC\Log $logger
+ */
+ public function execute($jobList, $logger = null);
+
+ /**
+ * Get the id of the background job
+ * This id is determined by the job list when a job is added to the list
+ *
+ * @return int
+ */
+ public function getId();
+
+ /**
+ * Get the last time this job was run as unix timestamp
+ *
+ * @return int
+ */
+ public function getLastRun();
+
+ /**
+ * Get the argument associated with the background job
+ * This is the argument that will be passed to the background job
+ *
+ * @return mixed
+ */
+ public function getArgument();
+}
diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php
new file mode 100644
index 00000000000..72f3fe863da
--- /dev/null
+++ b/lib/public/backgroundjob/ijoblist.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\BackgroundJob;
+
+interface IJobList {
+ /**
+ * Add a job to the list
+ *
+ * @param \OCP\BackgroundJob\IJob |string $job
+ * @param mixed $argument The argument to be passed to $job->run() when the job is exectured
+ */
+ public function add($job, $argument = null);
+
+ /**
+ * Remove a job from the list
+ *
+ * @param \OCP\BackgroundJob\IJob|string $job
+ * @param mixed $argument
+ */
+ public function remove($job, $argument = null);
+
+ /**
+ * check if a job is in the list
+ *
+ * @param $job
+ * @param mixed $argument
+ * @return bool
+ */
+ public function has($job, $argument);
+
+ /**
+ * get all jobs in the list
+ *
+ * @return \OCP\BackgroundJob\IJob[]
+ */
+ public function getAll();
+
+ /**
+ * get the next job in the list
+ *
+ * @return \OCP\BackgroundJob\IJob
+ */
+ public function getNext();
+
+ /**
+ * @param int $id
+ * @return \OCP\BackgroundJob\IJob
+ */
+ public function getById($id);
+
+ /**
+ * set the job that was last ran to the current time
+ *
+ * @param \OCP\BackgroundJob\IJob $job
+ */
+ public function setLastJob($job);
+
+ /**
+ * get the id of the last ran job
+ *
+ * @return int
+ */
+ public function getLastJob();
+
+ /**
+ * set the lastRun of $job to now
+ *
+ * @param \OCP\BackgroundJob\IJob $job
+ */
+ public function setLastRun($job);
+}
diff --git a/lib/public/config.php b/lib/public/config.php
index d9355a0605f..c1cc1034878 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -42,7 +42,7 @@ class Config {
/**
* Gets a value from config.php
* @param string $key key
- * @param string $default = null default value
+ * @param mixed $default = null default value
* @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
@@ -55,7 +55,7 @@ class Config {
/**
* Sets a value
* @param string $key key
- * @param string $value value
+ * @param mixed $value value
* @return bool
*
* This function sets the value and writes the config.php. If the file can
diff --git a/lib/public/files/fileinfo.php b/lib/public/files/fileinfo.php
new file mode 100644
index 00000000000..68ce45d3fa1
--- /dev/null
+++ b/lib/public/files/fileinfo.php
@@ -0,0 +1,138 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+namespace OCP\Files;
+
+interface FileInfo {
+ const TYPE_FILE = 'file';
+ const TYPE_FOLDER = 'folder';
+
+ /**
+ * Get the Etag of the file or folder
+ *
+ * @return string
+ */
+ public function getEtag();
+
+ /**
+ * Get the size in bytes for the file or folder
+ *
+ * @return int
+ */
+ public function getSize();
+
+ /**
+ * Get the last modified date as timestamp for the file or folder
+ *
+ * @return int
+ */
+ public function getMtime();
+
+ /**
+ * Get the name of the file or folder
+ *
+ * @return string
+ */
+ public function getName();
+
+ /**
+ * Get the path relative to the storage
+ *
+ * @return string
+ */
+ public function getInternalPath();
+
+ /**
+ * Get the absolute path
+ *
+ * @return string
+ */
+ public function getPath();
+
+ /**
+ * Get the full mimetype of the file or folder i.e. 'image/png'
+ *
+ * @return string
+ */
+ public function getMimetype();
+
+ /**
+ * Get the first part of the mimetype of the file or folder i.e. 'image'
+ *
+ * @return string
+ */
+ public function getMimePart();
+
+ /**
+ * Get the storage the file or folder is storage on
+ *
+ * @return \OCP\Files\Storage
+ */
+ public function getStorage();
+
+ /**
+ * Get the file id of the file or folder
+ *
+ * @return int
+ */
+ public function getId();
+
+ /**
+ * Check whether the file is encrypted
+ *
+ * @return bool
+ */
+ public function isEncrypted();
+
+ /**
+ * Get the permissions of the file or folder as bitmasked combination of the following constants
+ * \OCP\PERMISSION_CREATE
+ * \OCP\PERMISSION_READ
+ * \OCP\PERMISSION_UPDATE
+ * \OCP\PERMISSION_DELETE
+ * \OCP\PERMISSION_SHARE
+ * \OCP\PERMISSION_ALL
+ *
+ * @return int
+ */
+ public function getPermissions();
+
+ /**
+ * Check whether this is a file or a folder
+ *
+ * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER
+ */
+ public function getType();
+
+ /**
+ * Check if the file or folder is readable
+ *
+ * @return bool
+ */
+ public function isReadable();
+
+ /**
+ * Check if a file is writable
+ *
+ * @return bool
+ */
+ public function isUpdateable();
+
+ /**
+ * Check if a file or folder can be deleted
+ *
+ * @return bool
+ */
+ public function isDeletable();
+
+ /**
+ * Check if a file or folder can be shared
+ *
+ * @return bool
+ */
+ public function isShareable();
+}
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
index 1d0f8e0015c..585ee2812dc 100644
--- a/lib/public/iconfig.php
+++ b/lib/public/iconfig.php
@@ -38,7 +38,7 @@ interface IConfig {
* Sets a new system wide value
*
* @param string $key the key of the value, under which will be saved
- * @param string $value the value that should be stored
+ * @param mixed $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value);
@@ -47,7 +47,7 @@ interface IConfig {
* Looks up a system wide defined value
*
* @param string $key the key of the value, under which it was saved
- * @param string $default the default value to be returned if the value isn't set
+ * @param mixed $default the default value to be returned if the value isn't set
* @return string the saved value
*/
public function getSystemValue($key, $default = '');
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index dcb00caf496..5fb51f9ecd5 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -183,4 +183,11 @@ interface IServerContainer {
*/
function getAvatarManager();
+ /**
+ * Returns an job list for controlling background jobs
+ *
+ * @return \OCP\BackgroundJob\IJobList
+ */
+ function getJobList();
+
}
diff --git a/lib/public/util.php b/lib/public/util.php
index 4611e5e2650..570283e2a8a 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -121,7 +121,7 @@ class Util {
/**
* get l10n object
* @param string $application
- * @return OC_L10N
+ * @return \OC_L10N
*/
public static function getL10N( $application ) {
return \OC_L10N::get( $application );
diff --git a/ocs/providers.php b/ocs/providers.php
index bf94b85dcfb..2c62f767ad3 100644
--- a/ocs/providers.php
+++ b/ocs/providers.php
@@ -23,6 +23,8 @@
require_once '../lib/base.php';
+header('Content-type: application/xml');
+
$url=OCP\Util::getServerProtocol().'://'.substr(OCP\Util::getServerHost().OCP\Util::getRequestUri(), 0, -17).'ocs/v1.php/';
echo('
diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php
index ebc17aacfaa..d7c104ab151 100644
--- a/settings/ajax/decryptall.php
+++ b/settings/ajax/decryptall.php
@@ -16,7 +16,14 @@ $util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
$result = $util->initEncryption($params);
if ($result !== false) {
- $successful = $util->decryptAll();
+
+ try {
+ $successful = $util->decryptAll();
+ } catch (\Exception $ex) {
+ \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR);
+ $successful = false;
+ }
+
if ($successful === true) {
\OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
} else {
diff --git a/tests/lib/backgroundjob/dummyjoblist.php b/tests/lib/backgroundjob/dummyjoblist.php
index e1579c273bb..7801269b27e 100644
--- a/tests/lib/backgroundjob/dummyjoblist.php
+++ b/tests/lib/backgroundjob/dummyjoblist.php
@@ -21,6 +21,8 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
private $last = 0;
+ public function __construct(){}
+
/**
* @param \OC\BackgroundJob\Job|string $job
* @param mixed $argument
diff --git a/tests/lib/backgroundjob/job.php b/tests/lib/backgroundjob/job.php
index 7d66fa772d2..10a8f46462e 100644
--- a/tests/lib/backgroundjob/job.php
+++ b/tests/lib/backgroundjob/job.php
@@ -8,31 +8,6 @@
namespace Test\BackgroundJob;
-
-class TestJob extends \OC\BackgroundJob\Job {
- private $testCase;
-
- /**
- * @var callable $callback
- */
- private $callback;
-
- /**
- * @param Job $testCase
- * @param callable $callback
- */
- public function __construct($testCase, $callback) {
- $this->testCase = $testCase;
- $this->callback = $callback;
- }
-
- public function run($argument) {
- $this->testCase->markRun();
- $callback = $this->callback;
- $callback($argument);
- }
-}
-
class Job extends \PHPUnit_Framework_TestCase {
private $run = false;
diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php
new file mode 100644
index 00000000000..c3318f80cb2
--- /dev/null
+++ b/tests/lib/backgroundjob/joblist.php
@@ -0,0 +1,203 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\BackgroundJob;
+
+class JobList extends \PHPUnit_Framework_TestCase {
+ /**
+ * @var \OC\BackgroundJob\JobList
+ */
+ protected $instance;
+
+ /**
+ * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject $config
+ */
+ protected $config;
+
+ public function setUp() {
+ $conn = \OC::$server->getDatabaseConnection();
+ $this->config = $this->getMock('\OCP\IConfig');
+ $this->instance = new \OC\BackgroundJob\JobList($conn, $this->config);
+ }
+
+ public function argumentProvider() {
+ return array(
+ array(null),
+ array(false),
+ array('foobar'),
+ array(12),
+ array(array(
+ 'asd' => 5,
+ 'foo' => 'bar'
+ ))
+ );
+ }
+
+ /**
+ * @dataProvider argumentProvider
+ * @param $argument
+ */
+ public function testAddRemove($argument) {
+ $existingJobs = $this->instance->getAll();
+ $job = new TestJob();
+ $this->instance->add($job, $argument);
+
+ $jobs = $this->instance->getAll();
+
+ $this->assertCount(count($existingJobs) + 1, $jobs);
+ $addedJob = $jobs[count($jobs) - 1];
+ $this->assertInstanceOf('\Test\BackgroundJob\TestJob', $addedJob);
+ $this->assertEquals($argument, $addedJob->getArgument());
+
+ $this->instance->remove($job, $argument);
+
+ $jobs = $this->instance->getAll();
+ $this->assertEquals($existingJobs, $jobs);
+ }
+
+ /**
+ * @dataProvider argumentProvider
+ * @param $argument
+ */
+ public function testRemoveDifferentArgument($argument) {
+ $existingJobs = $this->instance->getAll();
+ $job = new TestJob();
+ $this->instance->add($job, $argument);
+
+ $jobs = $this->instance->getAll();
+ $this->instance->remove($job, 10);
+ $jobs2 = $this->instance->getAll();
+
+ $this->assertEquals($jobs, $jobs2);
+
+ $this->instance->remove($job, $argument);
+
+ $jobs = $this->instance->getAll();
+ $this->assertEquals($existingJobs, $jobs);
+ }
+
+ /**
+ * @dataProvider argumentProvider
+ * @param $argument
+ */
+ public function testHas($argument) {
+ $job = new TestJob();
+ $this->assertFalse($this->instance->has($job, $argument));
+ $this->instance->add($job, $argument);
+
+ $this->assertTrue($this->instance->has($job, $argument));
+
+ $this->instance->remove($job, $argument);
+
+ $this->assertFalse($this->instance->has($job, $argument));
+ }
+
+ /**
+ * @dataProvider argumentProvider
+ * @param $argument
+ */
+ public function testHasDifferentArgument($argument) {
+ $job = new TestJob();
+ $this->instance->add($job, $argument);
+
+ $this->assertFalse($this->instance->has($job, 10));
+
+ $this->instance->remove($job, $argument);
+ }
+
+ public function testGetLastJob() {
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with('backgroundjob', 'lastjob', 0)
+ ->will($this->returnValue(15));
+
+ $this->assertEquals(15, $this->instance->getLastJob());
+ }
+
+ public function testGetNext() {
+ $job = new TestJob();
+ $this->instance->add($job, 1);
+ $this->instance->add($job, 2);
+
+ $jobs = $this->instance->getAll();
+
+ $savedJob1 = $jobs[count($jobs) - 2];
+ $savedJob2 = $jobs[count($jobs) - 1];
+
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with('backgroundjob', 'lastjob', 0)
+ ->will($this->returnValue($savedJob1->getId()));
+
+ $nextJob = $this->instance->getNext();
+
+ $this->assertEquals($savedJob2, $nextJob);
+
+ $this->instance->remove($job, 1);
+ $this->instance->remove($job, 2);
+ }
+
+ public function testGetNextWrapAround() {
+ $job = new TestJob();
+ $this->instance->add($job, 1);
+ $this->instance->add($job, 2);
+
+ $jobs = $this->instance->getAll();
+
+ $savedJob2 = $jobs[count($jobs) - 1];
+
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with('backgroundjob', 'lastjob', 0)
+ ->will($this->returnValue($savedJob2->getId()));
+
+ $nextJob = $this->instance->getNext();
+
+ $this->assertEquals($jobs[0], $nextJob);
+
+ $this->instance->remove($job, 1);
+ $this->instance->remove($job, 2);
+ }
+
+ /**
+ * @dataProvider argumentProvider
+ * @param $argument
+ */
+ public function testGetById($argument) {
+ $job = new TestJob();
+ $this->instance->add($job, $argument);
+
+ $jobs = $this->instance->getAll();
+
+ $addedJob = $jobs[count($jobs) - 1];
+
+ $this->assertEquals($addedJob, $this->instance->getById($addedJob->getId()));
+
+ $this->instance->remove($job, $argument);
+ }
+
+ public function testSetLastRun() {
+ $job = new TestJob();
+ $this->instance->add($job);
+
+ $jobs = $this->instance->getAll();
+
+ $addedJob = $jobs[count($jobs) - 1];
+
+ $timeStart = time();
+ $this->instance->setLastRun($addedJob);
+ $timeEnd = time();
+
+ $addedJob = $this->instance->getById($addedJob->getId());
+
+ $this->assertGreaterThanOrEqual($timeStart, $addedJob->getLastRun());
+ $this->assertLessThanOrEqual($timeEnd, $addedJob->getLastRun());
+
+ $this->instance->remove($job);
+ }
+}
diff --git a/tests/lib/backgroundjob/testjob.php b/tests/lib/backgroundjob/testjob.php
new file mode 100644
index 00000000000..23fc4268d1a
--- /dev/null
+++ b/tests/lib/backgroundjob/testjob.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\BackgroundJob;
+
+
+class TestJob extends \OC\BackgroundJob\Job {
+ private $testCase;
+
+ /**
+ * @var callable $callback
+ */
+ private $callback;
+
+ /**
+ * @param Job $testCase
+ * @param callable $callback
+ */
+ public function __construct($testCase = null, $callback = null) {
+ $this->testCase = $testCase;
+ $this->callback = $callback;
+ }
+
+ public function run($argument) {
+ $this->testCase->markRun();
+ $callback = $this->callback;
+ $callback($argument);
+ }
+}
diff --git a/tests/lib/db.php b/tests/lib/db.php
index f0b271a36f1..2fca67b5638 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -30,7 +30,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
public function setUp() {
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
- $r = '_'.OC_Util::generateRandomBytes('4').'_';
+ $r = '_'.OC_Util::generateRandomBytes(4).'_';
$content = file_get_contents( $dbfile );
$content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content );
file_put_contents( self::$schema_file, $content );
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index 4a7b7f7aac0..e8a43538004 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -16,7 +16,7 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
$dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml';
- $r = '_'.OC_Util::generateRandomBytes('4').'_';
+ $r = '_'.OC_Util::generateRandomBytes(4).'_';
$content = file_get_contents( $dbfile );
$content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content );
file_put_contents( $this->schema_file, $content );
diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php
index 9d3adf51a0c..90f0e1b35e2 100644
--- a/tests/lib/group/manager.php
+++ b/tests/lib/group/manager.php
@@ -116,16 +116,22 @@ class Manager extends \PHPUnit_Framework_TestCase {
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend
*/
+ $backendGroupCreated = false;
$backend = $this->getMock('\OC_Group_Database');
$backend->expects($this->any())
->method('groupExists')
->with('group1')
- ->will($this->returnValue(false));
+ ->will($this->returnCallback(function () use (&$backendGroupCreated) {
+ return $backendGroupCreated;
+ }));
$backend->expects($this->once())
->method('implementsActions')
->will($this->returnValue(true));
$backend->expects($this->once())
- ->method('createGroup');
+ ->method('createGroup')
+ ->will($this->returnCallback(function () use (&$backendGroupCreated) {
+ $backendGroupCreated = true;
+ }));;
/**
* @var \OC\User\Manager $userManager
@@ -170,6 +176,10 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getGroups')
->with('1')
->will($this->returnValue(array('group1')));
+ $backend->expects($this->once())
+ ->method('groupExists')
+ ->with('group1')
+ ->will($this->returnValue(true));
/**
* @var \OC\User\Manager $userManager
@@ -193,6 +203,9 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getGroups')
->with('1')
->will($this->returnValue(array('group1')));
+ $backend1->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2
@@ -202,6 +215,9 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getGroups')
->with('1')
->will($this->returnValue(array('group12', 'group1')));
+ $backend2->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
/**
* @var \OC\User\Manager $userManager
@@ -228,6 +244,9 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getGroups')
->with('1', 2, 1)
->will($this->returnValue(array('group1')));
+ $backend1->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2
@@ -237,6 +256,9 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getGroups')
->with('1', 1, 0)
->will($this->returnValue(array('group12')));
+ $backend2->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
/**
* @var \OC\User\Manager $userManager
@@ -263,6 +285,10 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getUserGroups')
->with('user1')
->will($this->returnValue(array('group1')));
+ $backend->expects($this->any())
+ ->method('groupExists')
+ ->with('group1')
+ ->will($this->returnValue(true));
/**
* @var \OC\User\Manager $userManager
@@ -286,6 +312,10 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getUserGroups')
->with('user1')
->will($this->returnValue(array('group1')));
+ $backend1->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
+
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2
*/
@@ -294,6 +324,9 @@ class Manager extends \PHPUnit_Framework_TestCase {
->method('getUserGroups')
->with('user1')
->will($this->returnValue(array('group1', 'group2')));
+ $backend1->expects($this->any())
+ ->method('groupExists')
+ ->will($this->returnValue(true));
/**
* @var \OC\User\Manager $userManager
diff --git a/tests/lib/migrate.php b/tests/lib/migrate.php
new file mode 100644
index 00000000000..39a9bfc8d5a
--- /dev/null
+++ b/tests/lib/migrate.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Copyright (c) 2014 Tom Needham <tom@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class Test_Migrate extends PHPUnit_Framework_TestCase {
+
+ public $users;
+ public $tmpfiles = array();
+
+ /**
+ * @brief Generates a test user and sets up their file system
+ * @return string the test users id
+ */
+ public function generateUser() {
+ $username = uniqid();
+ \OC_User::createUser($username, 'password');
+ \OC_Util::tearDownFS();
+ \OC_User::setUserId('');
+ \OC\Files\Filesystem::tearDown();
+ \OC_Util::setupFS($username);
+ $this->users[] = $username;
+ return $username;
+ }
+
+ /**
+ * @brief validates an export for a user
+ * @brief checks for existence of export_info.json and file folder
+ * @param string $exportedUser the user that was exported
+ * @param string $path the path to the .zip export
+ */
+ public function validateUserExport($exportedBy, $exportedUser, $path) {
+ $this->assertTrue(file_exists($path));
+ // Extract
+ $extract = get_temp_dir() . '/oc_import_' . uniqid();
+ //mkdir($extract);
+ $this->tmpfiles[] = $extract;
+ $zip = new ZipArchive;
+ $zip->open($path);
+ $zip->extractTo($extract);
+ $zip->close();
+ $this->assertTrue(file_exists($extract.'/export_info.json'));
+ $exportInfo = file_get_contents($extract.'/export_info.json');
+ $exportInfo = json_decode($exportInfo);
+ $this->assertNotNull($exportInfo);
+ $this->assertEquals($exportedUser, $exportInfo->exporteduser);
+ $this->assertEquals($exportedBy, $exportInfo->exportedby);
+ $this->assertTrue(file_exists($extract.'/'.$exportedUser.'/files'));
+ }
+
+ public function testUserSelfExport() {
+ // Create a user
+ $user = $this->generateUser();
+ \OC_User::setUserId($user);
+ $export = \OC_Migrate::export($user);
+ // Check it succeeded and exists
+ $this->assertTrue(json_decode($export)->success);
+ // Validate the export
+ $this->validateUserExport($user, $user, json_decode($export)->data);
+ }
+
+ public function testUserOtherExport() {
+ $user = $this->generateUser();
+ $user2 = $this->generateUser();
+ \OC_User::setUserId($user2);
+ $export = \OC_Migrate::export($user);
+ // Check it succeeded and exists
+ $this->assertTrue(json_decode($export)->success);
+ // Validate the export
+ $this->validateUserExport($user2, $user, json_decode($export)->data);
+ }
+
+ public function tearDown() {
+ $u = new OC_User();
+ foreach($this->users as $user) {
+ $u->deleteUser($user);
+ }
+ foreach($this->tmpfiles as $file) {
+ \OC_Helper::rmdirr($file);
+ }
+ }
+
+
+
+
+}