Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 734fdbddea | |||
| 33144941a9 | |||
| f309920bef | |||
| e78a309111 | |||
| 46a4ad4f3c | |||
| 3842c0d766 | |||
| 8369c1f05b | |||
| cadf1c232e | |||
| 713651738c | |||
| 1475245465 | |||
| 281bbf4bd4 | |||
| a2bbbb1448 | |||
| 87a28957aa | |||
| 01de6c565a | |||
| f3e341edac | |||
| c5d6af3c5a | |||
| cc1577054d | |||
| 3e6b18b2d0 | |||
| 7eb505e6dd | |||
| 91ca1cf985 | |||
| f8a4bcdd50 | |||
| 418d401bf9 | |||
| d0afd774b7 | |||
| 0af65cae37 | |||
| 4d50fe5f12 | |||
| f24aca61a9 | |||
| d3e2226b38 | |||
| 73fa6259be | |||
| dffc2a8b1c | |||
| fd634fdec8 | |||
| 328ebaefde | |||
| 4de8c4e5db | |||
| 8dc3cb2ffb | |||
| c67ece0f6b | |||
| 6640e120b7 | |||
| 6f7b394d99 | |||
| 91f47645b0 | |||
| 18903cc8f7 | |||
| 7e467484a8 | |||
| 21bf6abd41 | |||
| 401728b2a2 | |||
| bfd0dc3314 | |||
| ad92b12559 | |||
| 4391992b8c | |||
| 728e6d735a | |||
| 66df8c3bb3 | |||
| ca08d21da0 | |||
| 7d0f458f11 | |||
| f15aeb3bbc | |||
| 9333244925 | |||
| 50f5ab8515 | |||
| 4df0d2e7e8 | |||
| f2e17a0b68 | |||
| e372971f2b | |||
| 3bf30377b8 | |||
| 67b67b6d66 | |||
| b8390f15d4 | |||
| 5ac3f9bfa5 | |||
| 02fe013d2f | |||
| 5e5e4fe3a4 | |||
| d49e4e53fd | |||
| 2d11290121 | |||
| 1a197292da | |||
| 3b59979746 | |||
| 259d619af3 |
@@ -69,20 +69,11 @@
|
||||
<th <?php if (!$_['fileHeader']):?>class="hidden"<?php endif; ?> id="headerDate">
|
||||
<span id="modified"><?php p($l->t( 'Modified' )); ?></span>
|
||||
<?php if ($_['permissions'] & OCP\PERMISSION_DELETE): ?>
|
||||
<!-- NOTE: Temporary fix to allow unsharing of files in root of Shared folder -->
|
||||
<?php if ($_['dir'] == '/Shared'): ?>
|
||||
<span class="selectedActions"><a href="" class="delete-selected">
|
||||
<?php p($l->t('Unshare'))?>
|
||||
<img class="svg" alt="<?php p($l->t('Unshare'))?>"
|
||||
src="<?php print_unescaped(OCP\image_path("core", "actions/delete.svg")); ?>" />
|
||||
</a></span>
|
||||
<?php else: ?>
|
||||
<span class="selectedActions"><a href="" class="delete-selected">
|
||||
<?php p($l->t('Delete'))?>
|
||||
<img class="svg" alt="<?php p($l->t('Delete'))?>"
|
||||
src="<?php print_unescaped(OCP\image_path("core", "actions/delete.svg")); ?>" />
|
||||
</a></span>
|
||||
<?php endif; ?>
|
||||
<span class="selectedActions"><a href="" class="delete-selected">
|
||||
<?php p($l->t('Delete'))?>
|
||||
<img class="svg" alt="<?php p($l->t('Delete'))?>"
|
||||
src="<?php print_unescaped(OCP\image_path("core", "actions/delete.svg")); ?>" />
|
||||
</a></span>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@@ -179,9 +179,9 @@ class Hooks {
|
||||
// the necessary keys)
|
||||
if (Crypt::mode() === 'server') {
|
||||
|
||||
if ($params['uid'] === \OCP\User::getUser()) {
|
||||
$view = new \OC_FilesystemView('/');
|
||||
|
||||
$view = new \OC_FilesystemView('/');
|
||||
if ($params['uid'] === \OCP\User::getUser()) {
|
||||
|
||||
$session = new \OCA\Encryption\Session($view);
|
||||
|
||||
@@ -202,36 +202,41 @@ class Hooks {
|
||||
} else { // admin changed the password for a different user, create new keys and reencrypt file keys
|
||||
|
||||
$user = $params['uid'];
|
||||
$recoveryPassword = $params['recoveryPassword'];
|
||||
$newUserPassword = $params['password'];
|
||||
$util = new Util($view, $user);
|
||||
$recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null;
|
||||
|
||||
$view = new \OC_FilesystemView('/');
|
||||
if (($util->recoveryEnabledForUser() && $recoveryPassword)
|
||||
|| !$util->userKeysExists()) {
|
||||
|
||||
// make sure that the users home is mounted
|
||||
\OC\Files\Filesystem::initMountPoints($user);
|
||||
$recoveryPassword = $params['recoveryPassword'];
|
||||
$newUserPassword = $params['password'];
|
||||
|
||||
$keypair = Crypt::createKeypair();
|
||||
// make sure that the users home is mounted
|
||||
\OC\Files\Filesystem::initMountPoints($user);
|
||||
|
||||
// Disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
$keypair = Crypt::createKeypair();
|
||||
|
||||
// Save public key
|
||||
$view->file_put_contents('/public-keys/' . $user . '.public.key', $keypair['publicKey']);
|
||||
// Disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
// Encrypt private key empty passphrase
|
||||
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword);
|
||||
// Save public key
|
||||
$view->file_put_contents('/public-keys/' . $user . '.public.key', $keypair['publicKey']);
|
||||
|
||||
// Save private key
|
||||
$view->file_put_contents(
|
||||
'/' . $user . '/files_encryption/' . $user . '.private.key', $encryptedPrivateKey);
|
||||
// Encrypt private key empty passphrase
|
||||
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword);
|
||||
|
||||
if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
|
||||
$util = new Util($view, $user);
|
||||
$util->recoverUsersFiles($recoveryPassword);
|
||||
// Save private key
|
||||
$view->file_put_contents(
|
||||
'/' . $user . '/files_encryption/' . $user . '.private.key', $encryptedPrivateKey);
|
||||
|
||||
if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
|
||||
$util = new Util($view, $user);
|
||||
$util->recoverUsersFiles($recoveryPassword);
|
||||
}
|
||||
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
}
|
||||
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,14 @@ class Helper {
|
||||
* @return bool true if requirements are met
|
||||
*/
|
||||
public static function checkRequirements() {
|
||||
return extension_loaded('openssl');
|
||||
$result = true;
|
||||
|
||||
//openssl extension needs to be loaded
|
||||
$result &= extension_loaded("openssl");
|
||||
// we need php >= 5.3.3
|
||||
$result &= version_compare(phpversion(), '5.3.3', '>=');
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,15 +101,24 @@ class Util {
|
||||
or !$this->view->file_exists($this->publicKeyPath)
|
||||
or !$this->view->file_exists($this->privateKeyPath)
|
||||
) {
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check if the users private & public key exists
|
||||
* @return boolean
|
||||
*/
|
||||
public function userKeysExists() {
|
||||
if (
|
||||
$this->view->file_exists($this->privateKeyPath) &&
|
||||
$this->view->file_exists($this->publicKeyPath)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -761,7 +770,7 @@ class Util {
|
||||
\OC\Files\Filesystem::putFileInfo($relPath, array(
|
||||
'encrypted' => false,
|
||||
'size' => $size,
|
||||
'unencrypted_size' => $size,
|
||||
'unencrypted_size' => 0,
|
||||
'etag' => $fileInfo['etag']
|
||||
));
|
||||
|
||||
@@ -831,32 +840,35 @@ class Util {
|
||||
// Open enc file handle for binary writing, with same filename as original plain file
|
||||
$encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
|
||||
|
||||
// Move plain file to a temporary location
|
||||
$size = stream_copy_to_stream($plainHandle, $encHandle);
|
||||
if (is_resource($encHandle)) {
|
||||
// Move plain file to a temporary location
|
||||
$size = stream_copy_to_stream($plainHandle, $encHandle);
|
||||
|
||||
fclose($encHandle);
|
||||
fclose($plainHandle);
|
||||
fclose($encHandle);
|
||||
fclose($plainHandle);
|
||||
|
||||
$fakeRoot = $this->view->getRoot();
|
||||
$this->view->chroot('/' . $this->userId . '/files');
|
||||
$fakeRoot = $this->view->getRoot();
|
||||
$this->view->chroot('/' . $this->userId . '/files');
|
||||
|
||||
$this->view->rename($relPath . '.part', $relPath);
|
||||
$this->view->rename($relPath . '.part', $relPath);
|
||||
|
||||
// set timestamp
|
||||
$this->view->touch($relPath, $timestamp);
|
||||
// set timestamp
|
||||
$this->view->touch($relPath, $timestamp);
|
||||
|
||||
$this->view->chroot($fakeRoot);
|
||||
$encSize = $this->view->filesize($relPath);
|
||||
|
||||
// Add the file to the cache
|
||||
\OC\Files\Filesystem::putFileInfo($relPath, array(
|
||||
'encrypted' => true,
|
||||
'size' => $size,
|
||||
'unencrypted_size' => $size,
|
||||
'etag' => $fileInfo['etag']
|
||||
));
|
||||
$this->view->chroot($fakeRoot);
|
||||
|
||||
$encryptedFiles[] = $relPath;
|
||||
// Add the file to the cache
|
||||
\OC\Files\Filesystem::putFileInfo($relPath, array(
|
||||
'encrypted' => true,
|
||||
'size' => $encSize,
|
||||
'unencrypted_size' => $size,
|
||||
'etag' => $fileInfo['etag']
|
||||
));
|
||||
|
||||
$encryptedFiles[] = $relPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Encrypt legacy encrypted files
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<fieldset class="personalblock">
|
||||
<h2><?php p( $l->t( 'Encryption' ) ); ?></h2>
|
||||
|
||||
<?php if ( ! $_["privateKeySet"] && $_["initialized"] ): ?>
|
||||
<?php if ( $_["initialized"] === '1' ): ?>
|
||||
<p>
|
||||
<a name="changePKPasswd" />
|
||||
<label for="changePrivateKeyPasswd">
|
||||
|
||||
@@ -81,9 +81,9 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
||||
$scheme = ($params['use_ssl'] === 'false') ? 'http' : 'https';
|
||||
$this->test = isset($params['test']);
|
||||
$this->timeout = ( ! isset($params['timeout'])) ? 15 : $params['timeout'];
|
||||
$params['region'] = ( ! isset($params['region'])) ? 'eu-west-1' : $params['region'];
|
||||
$params['hostname'] = ( !isset($params['hostname'])) ? 's3.amazonaws.com' : $params['hostname'];
|
||||
if (!isset($params['port'])) {
|
||||
$params['region'] = ( ! isset($params['region']) || $params['region'] === '' ) ? 'eu-west-1' : $params['region'];
|
||||
$params['hostname'] = ( !isset($params['hostname']) || $params['hostname'] === '' ) ? 's3.amazonaws.com' : $params['hostname'];
|
||||
if (!isset($params['port']) || $params['port'] === '') {
|
||||
$params['port'] = ($params['use_ssl'] === 'false') ? 80 : 443;
|
||||
}
|
||||
$base_url = $scheme.'://'.$params['hostname'].':'.$params['port'].'/';
|
||||
@@ -507,8 +507,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
||||
}
|
||||
|
||||
public function test() {
|
||||
$test = $this->s3->get_canonical_user_id();
|
||||
if (isset($test['id']) && $test['id'] != '') {
|
||||
$test = $this->connection->getBucketAcl(array(
|
||||
'Bucket' => $this->bucket,
|
||||
));
|
||||
if (isset($test) && !is_null($test->getPath('Owner/ID'))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -50,9 +50,9 @@ class OC_Mount_Config {
|
||||
'key' => 'Access Key',
|
||||
'secret' => '*Secret Key',
|
||||
'bucket' => 'Bucket',
|
||||
'hostname' => 'Hostname (optional)',
|
||||
'port' => 'Port (optional)',
|
||||
'region' => 'Region (optional)',
|
||||
'hostname' => '&Hostname (optional)',
|
||||
'port' => '&Port (optional)',
|
||||
'region' => '&Region (optional)',
|
||||
'use_ssl' => '!Enable SSL',
|
||||
'use_path_style' => '!Enable Path Style'));
|
||||
|
||||
@@ -244,6 +244,7 @@ class OC_Mount_Config {
|
||||
$storage = new $class($options);
|
||||
return $storage->test();
|
||||
} catch (Exception $exception) {
|
||||
\OCP\Util::logException('files_external', $exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
class="optional"
|
||||
data-parameter="<?php p($parameter); ?>"
|
||||
value="<?php p($value); ?>"
|
||||
placeholder="<?php p(substr($placeholder, 5)); ?>" />
|
||||
placeholder="<?php p(substr($placeholder, 1)); ?>" />
|
||||
<?php elseif (strpos($placeholder, '#') !== false): ?>
|
||||
<input type="hidden"
|
||||
data-parameter="<?php p($parameter); ?>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
body {
|
||||
background:#ddd;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
#header {
|
||||
@@ -22,7 +22,7 @@ body {
|
||||
#public_upload,
|
||||
#download {
|
||||
font-weight:700;
|
||||
margin: 0 0.4em 0 0;
|
||||
margin: 0 0 0 .4em;
|
||||
padding: 0 5px;
|
||||
height: 32px;
|
||||
float: left;
|
||||
@@ -49,12 +49,14 @@ body {
|
||||
vertical-align:text-bottom;
|
||||
}
|
||||
|
||||
#controls {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#preview {
|
||||
background:#eee;
|
||||
border-bottom:1px solid #f8f8f8;
|
||||
min-height:30em;
|
||||
text-align:center;
|
||||
margin:45px auto;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
margin: 45px auto 0;
|
||||
}
|
||||
|
||||
#noPreview {
|
||||
@@ -62,11 +64,16 @@ body {
|
||||
padding-top:5em;
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 45px;
|
||||
}
|
||||
|
||||
p.info {
|
||||
color:#777;
|
||||
text-align:center;
|
||||
width:22em;
|
||||
margin:2em auto;
|
||||
color: #777;
|
||||
text-align: center;
|
||||
width: 22em;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
p.info a {
|
||||
|
||||
@@ -112,8 +112,12 @@ class Shared_Updater {
|
||||
*/
|
||||
static public function shareHook($params) {
|
||||
if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
|
||||
$uidOwner = \OCP\User::getUser();
|
||||
$users = \OCP\Share::getUsersItemShared($params['itemType'], $params['fileSource'], $uidOwner, true);
|
||||
if (isset($params['uidOwner'])) {
|
||||
$uidOwner = $params['uidOwner'];
|
||||
} else {
|
||||
$uidOwner = \OCP\User::getUser();
|
||||
}
|
||||
$users = \OCP\Share::getUsersItemShared($params['itemType'], $params['fileSource'], $uidOwner, true, false);
|
||||
if (!empty($users)) {
|
||||
while (!empty($users)) {
|
||||
$reshareUsers = array();
|
||||
|
||||
@@ -4,14 +4,24 @@ OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
// "empty trash" command
|
||||
$deleteAll = false;
|
||||
if (isset($_POST['allfiles']) and $_POST['allfiles'] === 'true'){
|
||||
$user = \OCP\User::getUser();
|
||||
$list = OCA\Files_Trashbin\Helper::getTrashFiles('/');
|
||||
$deleteAll = true;
|
||||
$dirlisting = '0';
|
||||
$folder = isset($_POST['dir']) ? $_POST['dir'] : '/';
|
||||
if ($folder === '/' || $folder === '') {
|
||||
OCA\Files_Trashbin\Trashbin::deleteAll();
|
||||
$list = array();
|
||||
} else {
|
||||
$dirname = dirname($folder);
|
||||
if ( $dirname !== '/' && $dirname !== '.' ) {
|
||||
$dirlisting = '1';
|
||||
} else {
|
||||
$dirlisting = '0';
|
||||
}
|
||||
$list[] = $folder;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$deleteAll = false;
|
||||
$files = $_POST['files'];
|
||||
$dirlisting = $_POST['dirlisting'];
|
||||
$list = json_decode($files);
|
||||
@@ -19,19 +29,13 @@ else {
|
||||
$error = array();
|
||||
$success = array();
|
||||
|
||||
|
||||
$i = 0;
|
||||
foreach ($list as $file) {
|
||||
if ( $dirlisting === '0') {
|
||||
if ($deleteAll) {
|
||||
$filename = $file['name'];
|
||||
$timestamp = $file['timestamp'];
|
||||
}
|
||||
else {
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$filename = substr($file, 0, $delimiter);
|
||||
$timestamp = substr($file, $delimiter+2);
|
||||
}
|
||||
$file = ltrim($file, '/');
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$filename = substr($file, 0, $delimiter);
|
||||
$timestamp = substr($file, $delimiter+2);
|
||||
} else {
|
||||
$filename = $file;
|
||||
$timestamp = null;
|
||||
|
||||
@@ -13,6 +13,7 @@ $success = array();
|
||||
$i = 0;
|
||||
foreach ($list as $file) {
|
||||
if ( $dirlisting === '0') {
|
||||
$file = ltrim($file, '/');
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$filename = substr($file, 0, $delimiter);
|
||||
$timestamp = substr($file, $delimiter+2);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#fileList td a.file, #fileList td a.file span {
|
||||
cursor: default;
|
||||
}
|
||||
@@ -10,6 +10,7 @@ OCP\Util::addScript('files', 'fileactions');
|
||||
$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
|
||||
|
||||
OCP\Util::addStyle('files', 'files');
|
||||
OCP\Util::addStyle('files_trashbin', 'trash');
|
||||
OCP\Util::addScript('files', 'filelist');
|
||||
// filelist overrides
|
||||
OCP\Util::addScript('files_trashbin', 'filelist');
|
||||
|
||||
@@ -8,7 +8,7 @@ $(document).ready(function() {
|
||||
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||
disableActions();
|
||||
$.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
|
||||
{files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||
{files: JSON.stringify([$('#dir').val() + '/' + filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||
function(result) {
|
||||
for (var i = 0; i < result.data.success.length; i++) {
|
||||
var row = document.getElementById(result.data.success[i].filename);
|
||||
@@ -35,7 +35,7 @@ $(document).ready(function() {
|
||||
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||
disableActions();
|
||||
$.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
|
||||
{files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||
{files: JSON.stringify([$('#dir').val() + '/' +filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||
function(result) {
|
||||
for (var i = 0; i < result.data.success.length; i++) {
|
||||
var row = document.getElementById(result.data.success[i].filename);
|
||||
@@ -66,41 +66,6 @@ $(document).ready(function() {
|
||||
procesSelection();
|
||||
});
|
||||
|
||||
$('#fileList').on('click', 'td.filename a', function(event) {
|
||||
if (event.shiftKey) {
|
||||
event.preventDefault();
|
||||
var last = $(lastChecked).parent().parent().prevAll().length;
|
||||
var first = $(this).parent().parent().prevAll().length;
|
||||
var start = Math.min(first, last);
|
||||
var end = Math.max(first, last);
|
||||
var rows = $(this).parent().parent().parent().children('tr');
|
||||
for (var i = start; i < end; i++) {
|
||||
$(rows).each(function(index) {
|
||||
if (index == i) {
|
||||
var checkbox = $(this).children().children('input:checkbox');
|
||||
$(checkbox).attr('checked', 'checked');
|
||||
$(checkbox).parent().parent().addClass('selected');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var checkbox = $(this).parent().children('input:checkbox');
|
||||
lastChecked = checkbox;
|
||||
if ($(checkbox).attr('checked')) {
|
||||
$(checkbox).removeAttr('checked');
|
||||
$(checkbox).parent().parent().removeClass('selected');
|
||||
$('#select_all').removeAttr('checked');
|
||||
} else {
|
||||
$(checkbox).attr('checked', 'checked');
|
||||
$(checkbox).parent().parent().toggleClass('selected');
|
||||
var selectedCount = $('td.filename input:checkbox:checked').length;
|
||||
if (selectedCount == $('td.filename input:checkbox').length) {
|
||||
$('#select_all').attr('checked', 'checked');
|
||||
}
|
||||
}
|
||||
procesSelection();
|
||||
});
|
||||
|
||||
$('.undelete').click('click', function(event) {
|
||||
event.preventDefault();
|
||||
var files = getSelectedFiles('file');
|
||||
@@ -136,7 +101,8 @@ $(document).ready(function() {
|
||||
var params = {};
|
||||
if (allFiles) {
|
||||
params = {
|
||||
allfiles: true
|
||||
allfiles: true,
|
||||
dir: $('#dir').val()
|
||||
};
|
||||
}
|
||||
else {
|
||||
@@ -183,6 +149,12 @@ $(document).ready(function() {
|
||||
|
||||
});
|
||||
|
||||
$('#fileList').on('click', 'td.filename input', function() {
|
||||
var checkbox = $(this).parent().children('input:checkbox');
|
||||
$(checkbox).parent().parent().toggleClass('selected');
|
||||
procesSelection();
|
||||
});
|
||||
|
||||
$('#fileList').on('click', 'td.filename a', function(event) {
|
||||
var mime = $(this).parent().parent().data('mime');
|
||||
if (mime !== 'httpd/unix-directory') {
|
||||
@@ -229,7 +201,7 @@ function getSelectedFiles(property){
|
||||
elements.each(function(i,element){
|
||||
var file={
|
||||
name:$(element).attr('data-filename'),
|
||||
file:$(element).attr('data-file'),
|
||||
file:$('#dir').val() + "/" + $(element).attr('data-file'),
|
||||
timestamp:$(element).attr('data-timestamp'),
|
||||
type:$(element).attr('data-type'),
|
||||
dirlisting:$(element).attr('data-dirlisting')
|
||||
|
||||
@@ -44,8 +44,10 @@ class Helper
|
||||
}
|
||||
|
||||
$files = array();
|
||||
$id = 0;
|
||||
foreach ($result as $r) {
|
||||
$i = array();
|
||||
$i['id'] = $id++;
|
||||
$i['name'] = $r['id'];
|
||||
$i['date'] = \OCP\Util::formatDate($r['timestamp']);
|
||||
$i['timestamp'] = $r['timestamp'];
|
||||
|
||||
@@ -564,6 +564,21 @@ class Trashbin {
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete all files from the trash
|
||||
*/
|
||||
public static function deleteAll() {
|
||||
$user = \OCP\User::getUser();
|
||||
$view = new \OC\Files\View('/' . $user);
|
||||
$view->deleteAll('files_trashbin');
|
||||
self::setTrashbinSize($user, 0);
|
||||
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?');
|
||||
$query->execute(array($user));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief delete file from trash bin permanently
|
||||
*
|
||||
@@ -763,8 +778,13 @@ class Trashbin {
|
||||
*/
|
||||
private static function expire($trashbinSize, $user) {
|
||||
|
||||
// let the admin disable auto expire
|
||||
$autoExpire = \OC_Config::getValue('trashbin_auto_expire', true);
|
||||
if ($autoExpire === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$user = \OCP\User::getUser();
|
||||
$view = new \OC\Files\View('/' . $user);
|
||||
$availableSpace = self::calculateFreeSpace($trashbinSize);
|
||||
$size = 0;
|
||||
|
||||
|
||||
@@ -35,18 +35,21 @@
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
>
|
||||
<?php if(!isset($_['readonly']) || !$_['readonly']): ?><input type="checkbox" /><?php endif; ?>
|
||||
<?php if(!isset($_['readonly']) || !$_['readonly']): ?>
|
||||
<input id="select-<?php p($file['id']); ?>" type="checkbox" />
|
||||
<label for="select-<?php p($file['id']); ?>"></label>
|
||||
<?php endif; ?>
|
||||
<?php if($file['type'] === 'dir'): ?>
|
||||
<?php if( $_['dirlisting'] ): ?>
|
||||
<a class="name" href="<?php p($_['baseURL'].'/'.$name); ?>" title="">
|
||||
<a class="name dir" href="<?php p($_['baseURL'].'/'.$name); ?>" title="">
|
||||
<?php else: ?>
|
||||
<a class="name" href="<?php p($_['baseURL'].'/'.$name.'.d'.$file['timestamp']); ?>" title="">
|
||||
<a class="name dir" href="<?php p($_['baseURL'].'/'.$name.'.d'.$file['timestamp']); ?>" title="">
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php if( $_['dirlisting'] ): ?>
|
||||
<a class="name" href="<?php p($_['downloadURL'].'/'.$name); ?>" title="">
|
||||
<a class="name file" href="<?php p($_['downloadURL'].'/'.$name); ?>" title="">
|
||||
<?php else: ?>
|
||||
<a class="name" href="<?php p($_['downloadURL'].'/'.$name.'.d'.$file['timestamp']);?>" title="">
|
||||
<a class="name file" href="<?php p($_['downloadURL'].'/'.$name.'.d'.$file['timestamp']);?>" title="">
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<span class="nametext">
|
||||
|
||||
@@ -27,6 +27,18 @@ OCP\JSON::checkAppEnabled('user_ldap');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$prefix = $_POST['ldap_serverconfig_chooser'];
|
||||
|
||||
// Checkboxes are not submitted, when they are unchecked. Set them manually.
|
||||
// only legacy checkboxes (Advanced and Expert tab) need to be handled here,
|
||||
// the Wizard-like tabs handle it on their own
|
||||
$chkboxes = array('ldap_configuration_active', 'ldap_override_main_server',
|
||||
'ldap_nocase', 'ldap_turn_off_cert_check');
|
||||
foreach($chkboxes as $boxid) {
|
||||
if(!isset($_POST[$boxid])) {
|
||||
$_POST[$boxid] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
|
||||
$connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix);
|
||||
$connection->setConfiguration($_POST);
|
||||
|
||||
@@ -30,6 +30,8 @@ $l=OC_L10N::get('user_ldap');
|
||||
|
||||
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
|
||||
$connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null);
|
||||
//needs to be true, otherwise it will also fail with an irritating message
|
||||
$_POST['ldap_configuration_active'] = 1;
|
||||
if($connection->setConfiguration($_POST)) {
|
||||
//Configuration is okay
|
||||
if($connection->bind()) {
|
||||
|
||||
@@ -407,6 +407,7 @@ var LdapWizard = {
|
||||
if($('#rawLoginFilterContainer').hasClass('invisible')) {
|
||||
$('#ldap_loginfilter_attributes').multiselect('enable');
|
||||
}
|
||||
LdapWizard.postInitLoginFilter();
|
||||
},
|
||||
function (result) {
|
||||
//deactivate if no attributes found
|
||||
@@ -443,10 +444,24 @@ var LdapWizard = {
|
||||
//enable only when raw filter editing is not turned on
|
||||
$('#'+multisel).multiselect('enable');
|
||||
}
|
||||
if(type === 'Users') {
|
||||
//required for initial save
|
||||
filter = $('#ldap_userlist_filter').val();
|
||||
if(!filter) {
|
||||
LdapWizard.saveMultiSelect(multisel,
|
||||
$('#'+multisel).multiselect("getChecked"));
|
||||
}
|
||||
LdapWizard.userFilterAvailableGroupsHasRun = true;
|
||||
LdapWizard.postInitUserFilter();
|
||||
}
|
||||
},
|
||||
function (result) {
|
||||
LdapWizard.hideSpinner('#'+multisel);
|
||||
$('#'+multisel).multiselect('disable');
|
||||
if(type == 'Users') {
|
||||
LdapWizard.userFilterAvailableGroupsHasRun = true;
|
||||
LdapWizard.postInitUserFilter();
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
@@ -471,9 +486,23 @@ var LdapWizard = {
|
||||
LdapWizard.hideSpinner('#'+multisel);
|
||||
LdapWizard.applyChanges(result);
|
||||
$('#'+multisel).multiselect('refresh');
|
||||
if(type === 'User') {
|
||||
//required for initial save
|
||||
filter = $('#ldap_userlist_filter').val();
|
||||
if(!filter) {
|
||||
LdapWizard.saveMultiSelect(multisel,
|
||||
$('#'+multisel).multiselect("getChecked"));
|
||||
}
|
||||
LdapWizard.userFilterObjectClassesHasRun = true;
|
||||
LdapWizard.postInitUserFilter();
|
||||
}
|
||||
},
|
||||
function (result) {
|
||||
LdapWizard.hideSpinner('#'+multisel);
|
||||
if(type == 'User') {
|
||||
LdapWizard.userFilterObjectClassesHasRun = true;
|
||||
LdapWizard.postInitUserFilter();
|
||||
}
|
||||
//TODO: error handling
|
||||
}
|
||||
);
|
||||
@@ -489,13 +518,17 @@ var LdapWizard = {
|
||||
loginfilter = $('#ldap_login_filter').val();
|
||||
|
||||
//FIXME: activates a manually deactivated configuration.
|
||||
if(host && port && base && userfilter && loginfilter) {
|
||||
if(host && port && base && userfilter && loginfilter) {
|
||||
LdapWizard.updateStatusIndicator(true);
|
||||
if($('#ldap_configuration_active').is(':checked')) {
|
||||
return;
|
||||
}
|
||||
$('#ldap_configuration_active').prop('checked', true);
|
||||
LdapWizard.save($('#ldap_configuration_active')[0]);
|
||||
if(!LdapWizard.isConfigurationActiveControlLocked) {
|
||||
//avoids a manually deactivated connection will be activated
|
||||
//upon opening the admin page
|
||||
$('#ldap_configuration_active').prop('checked', true);
|
||||
LdapWizard.save($('#ldap_configuration_active')[0]);
|
||||
}
|
||||
} else {
|
||||
if($('#ldap_configuration_active').is(':checked')) {
|
||||
$('#ldap_configuration_active').prop('checked', false);
|
||||
@@ -517,9 +550,12 @@ var LdapWizard = {
|
||||
$(id + " + button").css('display', 'inline');
|
||||
},
|
||||
|
||||
isConfigurationActiveControlLocked: true,
|
||||
|
||||
init: function() {
|
||||
LdapWizard.basicStatusCheck();
|
||||
LdapWizard.functionalityCheck();
|
||||
LdapWizard.isConfigurationActiveControlLocked = false;
|
||||
},
|
||||
|
||||
initGroupFilter: function() {
|
||||
@@ -529,11 +565,21 @@ var LdapWizard = {
|
||||
LdapWizard.countGroups();
|
||||
},
|
||||
|
||||
/** init login filter tab section **/
|
||||
|
||||
initLoginFilter: function() {
|
||||
LdapWizard.regardFilterMode('Login');
|
||||
LdapWizard.findAttributes();
|
||||
},
|
||||
|
||||
postInitLoginFilter: function() {
|
||||
if($('#rawLoginFilterContainer').hasClass('invisible')) {
|
||||
LdapWizard.composeFilter('login');
|
||||
}
|
||||
},
|
||||
|
||||
/** end of init user filter tab section **/
|
||||
|
||||
initMultiSelect: function(object, id, caption) {
|
||||
object.multiselect({
|
||||
header: false,
|
||||
@@ -546,13 +592,29 @@ var LdapWizard = {
|
||||
});
|
||||
},
|
||||
|
||||
/** init user filter tab section **/
|
||||
|
||||
userFilterObjectClassesHasRun: false,
|
||||
userFilterAvailableGroupsHasRun: false,
|
||||
|
||||
initUserFilter: function() {
|
||||
LdapWizard.userFilterObjectClassesHasRun = false;
|
||||
LdapWizard.userFilterAvailableGroupsHasRun = false;
|
||||
LdapWizard.regardFilterMode('User');
|
||||
LdapWizard.findObjectClasses('ldap_userfilter_objectclass', 'User');
|
||||
LdapWizard.findAvailableGroups('ldap_userfilter_groups', 'Users');
|
||||
LdapWizard.countUsers();
|
||||
},
|
||||
|
||||
postInitUserFilter: function() {
|
||||
if(LdapWizard.userFilterObjectClassesHasRun
|
||||
&& LdapWizard.userFilterAvailableGroupsHasRun) {
|
||||
LdapWizard.composeFilter('user');
|
||||
LdapWizard.countUsers();
|
||||
}
|
||||
},
|
||||
|
||||
/** end of init user filter tab section **/
|
||||
|
||||
onTabChange: function(event, ui) {
|
||||
newTabIndex = 0;
|
||||
if(ui.newTab[0].id === '#ldapWizard2') {
|
||||
@@ -619,8 +681,6 @@ var LdapWizard = {
|
||||
} else if(mode == LdapWizard.filterModeAssisted
|
||||
&& !$('#raw'+subject+'FilterContainer').hasClass('invisible')) {
|
||||
LdapWizard['toggleRaw'+subject+'Filter']();
|
||||
} else {
|
||||
c = $('#raw'+subject+'FilterContainer').hasClass('invisible');
|
||||
}
|
||||
},
|
||||
function (result) {
|
||||
|
||||
@@ -308,7 +308,7 @@ class Configuration {
|
||||
'ldap_user_filter_mode' => 0,
|
||||
'ldap_userfilter_objectclass' => '',
|
||||
'ldap_userfilter_groups' => '',
|
||||
'ldap_login_filter' => 'uid=%uid',
|
||||
'ldap_login_filter' => '',
|
||||
'ldap_login_filter_mode' => 0,
|
||||
'ldap_loginfilter_email' => 0,
|
||||
'ldap_loginfilter_username' => 1,
|
||||
|
||||
@@ -91,7 +91,7 @@ class LDAP implements ILDAPWrapper {
|
||||
}
|
||||
|
||||
public function setOption($link, $option, $value) {
|
||||
$this->invokeLDAPMethod('set_option', $link, $option, $value);
|
||||
return $this->invokeLDAPMethod('set_option', $link, $option, $value);
|
||||
}
|
||||
|
||||
public function sort($link, $result, $sortfilter) {
|
||||
|
||||
@@ -432,7 +432,6 @@ class Wizard extends LDAPUtility {
|
||||
$this->configuration->setConfiguration($config);
|
||||
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '. $p, \OCP\Util::DEBUG);
|
||||
$this->result->addChange('ldap_port', $p);
|
||||
$this->result->addChange('ldap_tls', intval($t));
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
@@ -1001,7 +1000,7 @@ class Wizard extends LDAPUtility {
|
||||
|
||||
private function getConnection() {
|
||||
if(!is_null($this->cr)) {
|
||||
return $cr;
|
||||
return $this->cr;
|
||||
}
|
||||
$cr = $this->ldap->connect(
|
||||
$this->configuration->ldapHost.':'.$this->configuration->ldapPort,
|
||||
|
||||
Regular → Executable
+5
-2
@@ -117,6 +117,9 @@ $CONFIG = array(
|
||||
/* How long should ownCloud keep deleted files in the trash bin, default value: 30 days */
|
||||
'trashbin_retention_obligation' => 30,
|
||||
|
||||
/* Disable/Enable auto expire for the trash bin, by default auto expire is enabled */
|
||||
'trashbin_auto_expire' => true,
|
||||
|
||||
/* allow user to change his display name, if it is supported by the back-end */
|
||||
'allow_user_to_change_display_name' => true,
|
||||
|
||||
@@ -185,8 +188,8 @@ $CONFIG = array(
|
||||
// "datadirectory" => "",
|
||||
|
||||
/* Enable maintenance mode to disable ownCloud
|
||||
If you want to prevent users to login to ownCloud before you start doing some maintenance work,
|
||||
you need to set the value of the maintenance parameter to true.
|
||||
If you want to prevent users to login to ownCloud before you start doing some maintenance work,
|
||||
you need to set the value of the maintenance parameter to true.
|
||||
Please keep in mind that users who are already logged-in are kicked out of ownCloud instantly.
|
||||
*/
|
||||
"maintenance" => false,
|
||||
|
||||
+10
-3
@@ -105,8 +105,8 @@ textarea:hover, textarea:focus, textarea:active {
|
||||
input[type="checkbox"] { margin:0; padding:0; height:auto; width:auto; }
|
||||
input[type="checkbox"]:hover+label, input[type="checkbox"]:focus+label { color:#111 !important; }
|
||||
input[type="time"] {
|
||||
width: 110px;
|
||||
height: 30px;
|
||||
width: initial;
|
||||
height: 31px;
|
||||
-moz-box-sizing: border-box; box-sizing: border-box;
|
||||
}
|
||||
#quota {
|
||||
@@ -202,13 +202,20 @@ input[type="submit"].enabled {
|
||||
box-sizing: border-box;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 80px;
|
||||
left: 0;
|
||||
height: 44px;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: #eee;
|
||||
border-bottom: 1px solid #e7e7e7;
|
||||
z-index: 50;
|
||||
}
|
||||
/* account for shift of controls bar due to app navigation */
|
||||
#body-user #controls,
|
||||
#body-settings #controls {
|
||||
padding-left: 80px;
|
||||
}
|
||||
#controls .button,
|
||||
#controls button,
|
||||
#controls input[type='submit'],
|
||||
|
||||
@@ -6,18 +6,19 @@
|
||||
<form action="index.php" method="post">
|
||||
<input type="hidden" name="install" value="true" />
|
||||
<?php if(count($_['errors']) > 0): ?>
|
||||
<ul class="errors">
|
||||
<fieldset class="warning">
|
||||
<legend><strong><?php p($l->t('Error'));?></strong></legend>
|
||||
<?php foreach($_['errors'] as $err): ?>
|
||||
<li>
|
||||
<p>
|
||||
<?php if(is_array($err)):?>
|
||||
<?php print_unescaped($err['error']); ?>
|
||||
<p class='hint'><?php print_unescaped($err['hint']); ?></p>
|
||||
<span class='hint'><?php print_unescaped($err['hint']); ?></span>
|
||||
<?php else: ?>
|
||||
<?php print_unescaped($err); ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</p>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<?php if($_['vulnerableToNullByte']): ?>
|
||||
<fieldset class="warning">
|
||||
|
||||
@@ -50,6 +50,8 @@ try {
|
||||
|
||||
session_write_close();
|
||||
|
||||
$logger = \OC_Log::$object;
|
||||
|
||||
// Don't do anything if ownCloud has not been installed
|
||||
if (!OC_Config::getValue('installed', false)) {
|
||||
exit(0);
|
||||
@@ -98,7 +100,7 @@ try {
|
||||
$jobList = new \OC\BackgroundJob\JobList();
|
||||
$jobs = $jobList->getAll();
|
||||
foreach ($jobs as $job) {
|
||||
$job->execute($jobList);
|
||||
$job->execute($jobList, $logger);
|
||||
}
|
||||
} else {
|
||||
// We call cron.php from some website
|
||||
@@ -109,7 +111,7 @@ try {
|
||||
// Work and success :-)
|
||||
$jobList = new \OC\BackgroundJob\JobList();
|
||||
$job = $jobList->getNext();
|
||||
$job->execute($jobList);
|
||||
$job->execute($jobList, $logger);
|
||||
$jobList->setLastJob($job);
|
||||
OC_JSON::success();
|
||||
}
|
||||
|
||||
@@ -866,7 +866,6 @@ class OC {
|
||||
OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
|
||||
// login
|
||||
OC_User::setUserId($_COOKIE['oc_username']);
|
||||
OC_User::setDisplayName($_COOKIE['oc_username'], $_COOKIE['display_name']);
|
||||
OC_Util::redirectToDefaultPage();
|
||||
// doesn't return
|
||||
}
|
||||
|
||||
@@ -9,16 +9,35 @@
|
||||
namespace OC\BackgroundJob;
|
||||
|
||||
abstract class Job {
|
||||
/**
|
||||
* @var int $id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var int $lastRun
|
||||
*/
|
||||
protected $lastRun;
|
||||
|
||||
/**
|
||||
* @var mixed $argument
|
||||
*/
|
||||
protected $argument;
|
||||
|
||||
/**
|
||||
* @param JobList $jobList
|
||||
* @param \OC\Log $logger
|
||||
*/
|
||||
public function execute($jobList) {
|
||||
public function execute($jobList, $logger = null) {
|
||||
$jobList->setLastRun($this);
|
||||
$this->run($this->argument);
|
||||
try {
|
||||
$this->run($this->argument);
|
||||
} catch (\Exception $e) {
|
||||
if ($logger) {
|
||||
$logger->error('Error while running background job: ' . $e->getMessage());
|
||||
}
|
||||
$jobList->remove($this, $this->argument);
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected function run($argument);
|
||||
|
||||
@@ -20,9 +20,10 @@ abstract class QueuedJob extends Job {
|
||||
* run the job, then remove it from the joblist
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param \OC\Log $logger
|
||||
*/
|
||||
public function execute($jobList) {
|
||||
public function execute($jobList, $logger = null) {
|
||||
$jobList->remove($this);
|
||||
$this->run($this->argument);
|
||||
parent::execute($jobList, $logger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ abstract class TimedJob extends Job {
|
||||
* run the job if
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param \OC\Log $logger
|
||||
*/
|
||||
public function execute($jobList) {
|
||||
public function execute($jobList, $logger = null) {
|
||||
if ((time() - $this->lastRun) > $this->interval) {
|
||||
$jobList->setLastRun($this);
|
||||
$this->run($this->argument);
|
||||
parent::execute($jobList, $logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,9 @@ class OC_Files {
|
||||
$zip = false;
|
||||
$filename = $dir . '/' . $files;
|
||||
$name = $files;
|
||||
if ($xsendfile && OC_App::isEnabled('files_encryption')) {
|
||||
$xsendfile = false;
|
||||
}
|
||||
}
|
||||
OC_Util::obEnd();
|
||||
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
|
||||
|
||||
Vendored
+4
@@ -178,6 +178,10 @@ class Cache {
|
||||
if ($file['storage_mtime'] == 0) {
|
||||
$file['storage_mtime'] = $file['mtime'];
|
||||
}
|
||||
if ($file['encrypted']) {
|
||||
$file['encrypted_size'] = $file['size'];
|
||||
$file['size'] = $file['unencrypted_size'];
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
@@ -286,7 +286,7 @@ class Scanner extends BasicEmitter {
|
||||
public function backgroundScan() {
|
||||
$lastPath = null;
|
||||
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
|
||||
$this->scan($path);
|
||||
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
|
||||
$this->cache->correctFolderSize($path);
|
||||
$lastPath = $path;
|
||||
}
|
||||
|
||||
@@ -424,4 +424,12 @@ class Wrapper implements \OC\Files\Storage\Storage {
|
||||
public function getETag($path) {
|
||||
return $this->storage->getETag($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true
|
||||
* @return true
|
||||
*/
|
||||
public function test() {
|
||||
return $this->storage->test();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,11 @@ class View {
|
||||
}
|
||||
|
||||
public function rmdir($path) {
|
||||
return $this->basicOperation('rmdir', $path, array('delete'));
|
||||
if ($this->is_dir($path)) {
|
||||
return $this->basicOperation('rmdir', $path, array('delete'));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function opendir($path) {
|
||||
@@ -712,7 +716,7 @@ class View {
|
||||
return false;
|
||||
}
|
||||
$defaultRoot = Filesystem::getRoot();
|
||||
if($this->fakeRoot === $defaultRoot){
|
||||
if ($this->fakeRoot === $defaultRoot) {
|
||||
return true;
|
||||
}
|
||||
return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
namespace OC\Setup;
|
||||
|
||||
abstract class AbstractDatabase {
|
||||
|
||||
/**
|
||||
* @var \OC_L10N
|
||||
*/
|
||||
protected $trans;
|
||||
protected $dbDefinitionFile;
|
||||
protected $dbuser;
|
||||
|
||||
+39
-24
@@ -29,10 +29,10 @@ class OCI extends AbstractDatabase {
|
||||
\OC_Log::write('setup oracle', 'connect string: ' . $easy_connect_string, \OC_Log::DEBUG);
|
||||
$connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string);
|
||||
if(!$connection) {
|
||||
$e = oci_error();
|
||||
if (is_array ($e) && isset ($e['message'])) {
|
||||
$errorMessage = $this->getLastError();
|
||||
if ($errorMessage) {
|
||||
throw new \DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
|
||||
$e['message'].' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
|
||||
$errorMessage.' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
|
||||
.' ORACLE_SID='.getenv('ORACLE_SID')
|
||||
.' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
|
||||
.' NLS_LANG='.getenv('NLS_LANG')
|
||||
@@ -51,7 +51,7 @@ class OCI extends AbstractDatabase {
|
||||
." WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
|
||||
$stmt = oci_parse($connection, $query);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
@@ -68,25 +68,25 @@ class OCI extends AbstractDatabase {
|
||||
$this->dbpassword=\OC_Util::generateRandomBytes(30);
|
||||
|
||||
//oracle passwords are treated as identifiers:
|
||||
// must start with aphanumeric char
|
||||
// must start with alphanumeric char
|
||||
// needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
|
||||
$this->dbpassword=substr($this->dbpassword, 0, 30);
|
||||
|
||||
$this->createDBUser($connection);
|
||||
|
||||
\OC_Config::setValue('dbuser', $this->dbusername);
|
||||
\OC_Config::setValue('dbname', $this->dbusername);
|
||||
\OC_Config::setValue('dbuser', $this->dbuser);
|
||||
\OC_Config::setValue('dbname', $this->dbuser);
|
||||
\OC_Config::setValue('dbpassword', $this->dbpassword);
|
||||
|
||||
//create the database not neccessary, oracle implies user = schema
|
||||
//$this->createDatabase($this->dbname, $this->dbusername, $connection);
|
||||
//create the database not necessary, oracle implies user = schema
|
||||
//$this->createDatabase($this->dbname, $this->dbuser, $connection);
|
||||
} else {
|
||||
|
||||
\OC_Config::setValue('dbuser', $this->dbuser);
|
||||
\OC_Config::setValue('dbname', $this->dbname);
|
||||
\OC_Config::setValue('dbpassword', $this->dbpassword);
|
||||
|
||||
//create the database not neccessary, oracle implies user = schema
|
||||
//create the database not necessary, oracle implies user = schema
|
||||
//$this->createDatabase($this->dbname, $this->dbuser, $connection);
|
||||
}
|
||||
|
||||
@@ -115,10 +115,10 @@ class OCI extends AbstractDatabase {
|
||||
}
|
||||
$query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
|
||||
$stmt = oci_parse($connection, $query);
|
||||
$un = $this->dbtableprefix.'users';
|
||||
$un = $this->tableprefix.'users';
|
||||
oci_bind_by_name($stmt, ':un', $un);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
@@ -133,25 +133,22 @@ class OCI extends AbstractDatabase {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param String $name
|
||||
* @param String $password
|
||||
* @param resource $connection
|
||||
*/
|
||||
private function createDBUser($connection) {
|
||||
$name = $this->dbuser;
|
||||
$password = $this->password;
|
||||
$password = $this->dbpassword;
|
||||
$query = "SELECT * FROM all_users WHERE USERNAME = :un";
|
||||
$stmt = oci_parse($connection, $query);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
oci_bind_by_name($stmt, ':un', $name);
|
||||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
@@ -162,14 +159,14 @@ class OCI extends AbstractDatabase {
|
||||
$query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$this->dbtablespace;
|
||||
$stmt = oci_parse($connection, $query);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
//oci_bind_by_name($stmt, ':un', $name);
|
||||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
|
||||
array($query, $name, $password)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
@@ -178,7 +175,7 @@ class OCI extends AbstractDatabase {
|
||||
$query = "ALTER USER :un IDENTIFIED BY :pw";
|
||||
$stmt = oci_parse($connection, $query);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
@@ -186,7 +183,7 @@ class OCI extends AbstractDatabase {
|
||||
oci_bind_by_name($stmt, ':pw', $password);
|
||||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
@@ -195,16 +192,34 @@ class OCI extends AbstractDatabase {
|
||||
$query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
|
||||
$stmt = oci_parse($connection, $query);
|
||||
if (!$stmt) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
|
||||
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
|
||||
array($query, $name, $password)) . '<br />';
|
||||
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $connection
|
||||
* @return string
|
||||
*/
|
||||
protected function getLastError($connection = null) {
|
||||
if ($connection) {
|
||||
$error = oci_error($connection);
|
||||
} else {
|
||||
$error = oci_error();
|
||||
}
|
||||
foreach (array('message', 'code') as $key) {
|
||||
if (isset($error[$key])) {
|
||||
return $error[$key];
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -437,9 +437,9 @@ class OC_Util {
|
||||
);
|
||||
$webServerRestart = true;
|
||||
}
|
||||
if(version_compare(phpversion(), '5.3.8', '<')) {
|
||||
if(version_compare(phpversion(), '5.3.3', '<')) {
|
||||
$errors[] = array(
|
||||
'error'=>'PHP 5.3.8 or higher is required.',
|
||||
'error'=>'PHP 5.3.3 or higher is required.',
|
||||
'hint'=>'Please ask your server administrator to update PHP to the latest version.'
|
||||
.' Your PHP version is no longer supported by ownCloud and the PHP community.'
|
||||
);
|
||||
@@ -874,6 +874,14 @@ class OC_Util {
|
||||
return function_exists('finfo_open');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a PHP version older then 5.3.8 is installed.
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPHPoutdated() {
|
||||
return version_compare(phpversion(), '5.3.8', '<');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the ownCloud server can connect to the internet
|
||||
* @return bool
|
||||
|
||||
+21
-14
@@ -423,11 +423,13 @@ class Share {
|
||||
* @param string Item source
|
||||
* @param string Owner
|
||||
* @param bool Include collections
|
||||
* @praram bool check expire date
|
||||
* @return Return array of users
|
||||
*/
|
||||
public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) {
|
||||
public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false, $checkExpireDate = true) {
|
||||
|
||||
$users = array();
|
||||
$items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections);
|
||||
$items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections, false, $checkExpireDate);
|
||||
if ($items) {
|
||||
foreach ($items as $item) {
|
||||
if ((int)$item['share_type'] === self::SHARE_TYPE_USER) {
|
||||
@@ -866,12 +868,14 @@ class Share {
|
||||
protected static function unshareItem(array $item) {
|
||||
// Pass all the vars we have for now, they may be useful
|
||||
$hookParams = array(
|
||||
'itemType' => $item['item_type'],
|
||||
'itemSource' => $item['item_source'],
|
||||
'shareType' => $item['share_type'],
|
||||
'shareWith' => $item['share_with'],
|
||||
'itemParent' => $item['parent'],
|
||||
'itemType' => $item['item_type'],
|
||||
'itemSource' => $item['item_source'],
|
||||
'shareType' => $item['share_type'],
|
||||
'shareWith' => $item['share_with'],
|
||||
'itemParent' => $item['parent'],
|
||||
'uidOwner' => $item['uid_owner'],
|
||||
);
|
||||
|
||||
\OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams + array(
|
||||
'fileSource' => $item['file_source'],
|
||||
));
|
||||
@@ -961,6 +965,7 @@ class Share {
|
||||
* @param int Number of items to return, -1 to return all matches (optional)
|
||||
* @param bool Include collection item types (optional)
|
||||
* @param bool TODO (optional)
|
||||
* @prams bool check expire date
|
||||
* @return mixed
|
||||
*
|
||||
* See public functions getItem(s)... for parameter usage
|
||||
@@ -968,7 +973,7 @@ class Share {
|
||||
*/
|
||||
private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null,
|
||||
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
|
||||
$includeCollections = false, $itemShareWithBySource = false) {
|
||||
$includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) {
|
||||
if (!self::isEnabled()) {
|
||||
if ($limit == 1 || (isset($uidOwner) && isset($item))) {
|
||||
return false;
|
||||
@@ -1108,19 +1113,19 @@ class Share {
|
||||
if ($format == self::FORMAT_STATUSES) {
|
||||
if ($itemType == 'file' || $itemType == 'folder') {
|
||||
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,'
|
||||
.' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`';
|
||||
.' `share_type`, `file_source`, `path`, `expiration`, `storage`, `share_with`, `mail_send`, `uid_owner`';
|
||||
} else {
|
||||
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`';
|
||||
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `expiration`, `mail_send`, `uid_owner`';
|
||||
}
|
||||
} else {
|
||||
if (isset($uidOwner)) {
|
||||
if ($itemType == 'file' || $itemType == 'folder') {
|
||||
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,'
|
||||
.' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,'
|
||||
.' `expiration`, `token`, `storage`, `mail_send`';
|
||||
.' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`';
|
||||
} else {
|
||||
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,'
|
||||
.' `stime`, `file_source`, `expiration`, `token`, `mail_send`';
|
||||
.' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`';
|
||||
}
|
||||
} else {
|
||||
if ($fileDependent) {
|
||||
@@ -1234,8 +1239,10 @@ class Share {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self::expireItem($row)) {
|
||||
continue;
|
||||
if($checkExpireDate) {
|
||||
if (self::expireItem($row)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Check if resharing is allowed, if not remove share permission
|
||||
if (isset($row['permissions']) && !self::isResharingAllowed()) {
|
||||
|
||||
@@ -28,6 +28,7 @@ $tmpl->assign('internetconnectionworking', OC_Util::isInternetConnectionEnabled(
|
||||
$tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
|
||||
$tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
|
||||
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
|
||||
$tmpl->assign('old_php', OC_Util::isPHPoutdated());
|
||||
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
|
||||
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
|
||||
|
||||
|
||||
@@ -72,6 +72,20 @@ if (!$_['has_fileinfo']) {
|
||||
<?php
|
||||
}
|
||||
|
||||
// is PHP at least at 5.3.8?
|
||||
if ($_['old_php']) {
|
||||
?>
|
||||
<fieldset class="personalblock">
|
||||
<h2><?php p($l->t('Your PHP version is outdated'));?></h2>
|
||||
|
||||
<span class="connectionwarning">
|
||||
<?php p($l->t('Your PHP version is outdated. We strongly recommend to update to 5.3.8 or newer because older versions are known to be broken. It is possible that this installation is not working correctly.')); ?>
|
||||
</span>
|
||||
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
// is locale working ?
|
||||
if (!$_['isLocaleWorking']) {
|
||||
?>
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
class JobRun extends \Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Class DummyJobList
|
||||
*
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 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, $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;
|
||||
|
||||
public function setUp() {
|
||||
$this->run = false;
|
||||
}
|
||||
|
||||
public function testRemoveAfterException() {
|
||||
$jobList = new DummyJobList();
|
||||
$job = new TestJob($this, function () {
|
||||
throw new \Exception();
|
||||
});
|
||||
$jobList->add($job);
|
||||
|
||||
$this->assertCount(1, $jobList->getAll());
|
||||
$job->execute($jobList);
|
||||
$this->assertTrue($this->run);
|
||||
$this->assertCount(0, $jobList->getAll());
|
||||
}
|
||||
|
||||
public function markRun() {
|
||||
$this->run = true;
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,17 @@
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
|
||||
private $testCase;
|
||||
|
||||
/**
|
||||
* @param QueuedJob $testCase
|
||||
*/
|
||||
public function __construct($testCase) {
|
||||
$this->testCase = $testCase;
|
||||
}
|
||||
|
||||
public function run($argument) {
|
||||
throw new JobRun(); //throw an exception so we can detect if this function is called
|
||||
$this->testCase->markRun();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +33,22 @@ class QueuedJob extends \PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
private $job;
|
||||
|
||||
private $jobRun = false;
|
||||
|
||||
public function markRun() {
|
||||
$this->jobRun = true;
|
||||
}
|
||||
|
||||
public function setup() {
|
||||
$this->jobList = new DummyJobList();
|
||||
$this->job = new TestQueuedJob();
|
||||
$this->job = new TestQueuedJob($this);
|
||||
$this->jobList->add($this->job);
|
||||
$this->jobRun = false;
|
||||
}
|
||||
|
||||
public function testJobShouldBeRemoved() {
|
||||
try {
|
||||
$this->assertTrue($this->jobList->has($this->job, null));
|
||||
$this->job->execute($this->jobList);
|
||||
$this->fail("job should have been run");
|
||||
} catch (JobRun $e) {
|
||||
$this->assertFalse($this->jobList->has($this->job, null));
|
||||
}
|
||||
$this->assertTrue($this->jobList->has($this->job, null));
|
||||
$this->job->execute($this->jobList);
|
||||
$this->assertTrue($this->jobRun);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,18 @@
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
class TestTimedJob extends \OC\BackgroundJob\TimedJob {
|
||||
public function __construct() {
|
||||
private $testCase;
|
||||
|
||||
/**
|
||||
* @param TimedJob $testCase
|
||||
*/
|
||||
public function __construct($testCase) {
|
||||
$this->setInterval(10);
|
||||
$this->testCase = $testCase;
|
||||
}
|
||||
|
||||
public function run($argument) {
|
||||
throw new JobRun(); //throw an exception so we can detect if this function is called
|
||||
$this->testCase->markRun();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,44 +34,37 @@ class TimedJob extends \PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
private $job;
|
||||
|
||||
private $jobRun = false;
|
||||
|
||||
public function markRun() {
|
||||
$this->jobRun = true;
|
||||
}
|
||||
|
||||
public function setup() {
|
||||
$this->jobList = new DummyJobList();
|
||||
$this->job = new TestTimedJob();
|
||||
$this->job = new TestTimedJob($this);
|
||||
$this->jobList->add($this->job);
|
||||
$this->jobRun = false;
|
||||
}
|
||||
|
||||
public function testShouldRunAfterInterval() {
|
||||
$this->job->setLastRun(time() - 12);
|
||||
try {
|
||||
$this->job->execute($this->jobList);
|
||||
$this->fail("job should have run");
|
||||
} catch (JobRun $e) {
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
$this->job->execute($this->jobList);
|
||||
$this->assertTrue($this->jobRun);
|
||||
}
|
||||
|
||||
public function testShouldNotRunWithinInterval() {
|
||||
$this->job->setLastRun(time() - 5);
|
||||
try {
|
||||
$this->job->execute($this->jobList);
|
||||
} catch (JobRun $e) {
|
||||
$this->fail("job should not have run");
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
$this->job->execute($this->jobList);
|
||||
$this->assertFalse($this->jobRun);
|
||||
}
|
||||
|
||||
public function testShouldNotTwice() {
|
||||
$this->job->setLastRun(time() - 15);
|
||||
try {
|
||||
$this->job->execute($this->jobList);
|
||||
$this->fail("job should have run the first time");
|
||||
} catch (JobRun $e) {
|
||||
try {
|
||||
$this->job->execute($this->jobList);
|
||||
} catch (JobRun $e) {
|
||||
$this->fail("job should not have run the second time");
|
||||
}
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
$this->job->execute($this->jobList);
|
||||
$this->assertTrue($this->jobRun);
|
||||
$this->jobRun = false;
|
||||
$this->job->execute($this->jobList);
|
||||
$this->assertFalse($this->jobRun);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 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\Files;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OCP\Share;
|
||||
|
||||
class EtagTest extends \PHPUnit_Framework_TestCase {
|
||||
private $datadir;
|
||||
|
||||
private $tmpDir;
|
||||
|
||||
private $uid;
|
||||
|
||||
/**
|
||||
* @var \OC_User_Dummy $userBackend
|
||||
*/
|
||||
private $userBackend;
|
||||
|
||||
public function setUp() {
|
||||
\OC_Hook::clear('OC_Filesystem', 'setup');
|
||||
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
||||
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
||||
\OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
|
||||
|
||||
$this->datadir = \OC_Config::getValue('datadirectory');
|
||||
$this->tmpDir = \OC_Helper::tmpFolder();
|
||||
\OC_Config::setValue('datadirectory', $this->tmpDir);
|
||||
$this->uid = \OC_User::getUser();
|
||||
\OC_User::setUserId(null);
|
||||
|
||||
$this->userBackend = new \OC_User_Dummy();
|
||||
\OC_User::useBackend($this->userBackend);
|
||||
\OC_Util::tearDownFS();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
\OC_Config::setValue('datadirectory', $this->datadir);
|
||||
\OC_User::setUserId($this->uid);
|
||||
\OC_Util::setupFS($this->uid);
|
||||
}
|
||||
|
||||
public function testNewUser() {
|
||||
$user1 = uniqid('user_');
|
||||
$this->userBackend->createUser($user1, '');
|
||||
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId($user1);
|
||||
\OC_Util::setupFS($user1);
|
||||
Filesystem::mkdir('/folder');
|
||||
Filesystem::mkdir('/folder/subfolder');
|
||||
Filesystem::file_put_contents('/foo.txt', 'asd');
|
||||
Filesystem::file_put_contents('/folder/bar.txt', 'fgh');
|
||||
Filesystem::file_put_contents('/folder/subfolder/qwerty.txt', 'jkl');
|
||||
|
||||
$files = array('/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt');
|
||||
$originalEtags = $this->getEtags($files);
|
||||
|
||||
$scanner = new \OC\Files\Utils\Scanner($user1);
|
||||
$scanner->backgroundScan('/');
|
||||
|
||||
$this->assertEquals($originalEtags, $this->getEtags($files));
|
||||
}
|
||||
|
||||
private function getEtags($files) {
|
||||
$etags = array();
|
||||
foreach ($files as $file) {
|
||||
$info = Filesystem::getFileInfo($file);
|
||||
$etags[$file] = $info['etag'];
|
||||
}
|
||||
return $etags;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* @var array tmpDirs
|
||||
*/
|
||||
private $tmpDirs=array();
|
||||
private $tmpDirs = array();
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@@ -51,21 +51,21 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
public function testMount() {
|
||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local',self::getStorageData(),'/');
|
||||
$this->assertEquals('/',\OC\Files\Filesystem::getMountPoint('/'));
|
||||
$this->assertEquals('/',\OC\Files\Filesystem::getMountPoint('/some/folder'));
|
||||
list( , $internalPath)=\OC\Files\Filesystem::resolvePath('/');
|
||||
$this->assertEquals('',$internalPath);
|
||||
list( , $internalPath)=\OC\Files\Filesystem::resolvePath('/some/folder');
|
||||
$this->assertEquals('some/folder',$internalPath);
|
||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/');
|
||||
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/'));
|
||||
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/some/folder'));
|
||||
list(, $internalPath) = \OC\Files\Filesystem::resolvePath('/');
|
||||
$this->assertEquals('', $internalPath);
|
||||
list(, $internalPath) = \OC\Files\Filesystem::resolvePath('/some/folder');
|
||||
$this->assertEquals('some/folder', $internalPath);
|
||||
|
||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local',self::getStorageData(),'/some');
|
||||
$this->assertEquals('/',\OC\Files\Filesystem::getMountPoint('/'));
|
||||
$this->assertEquals('/some/',\OC\Files\Filesystem::getMountPoint('/some/folder'));
|
||||
$this->assertEquals('/some/',\OC\Files\Filesystem::getMountPoint('/some/'));
|
||||
$this->assertEquals('/some/',\OC\Files\Filesystem::getMountPoint('/some'));
|
||||
list( , $internalPath)=\OC\Files\Filesystem::resolvePath('/some/folder');
|
||||
$this->assertEquals('folder',$internalPath);
|
||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/some');
|
||||
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/'));
|
||||
$this->assertEquals('/some/', \OC\Files\Filesystem::getMountPoint('/some/folder'));
|
||||
$this->assertEquals('/some/', \OC\Files\Filesystem::getMountPoint('/some/'));
|
||||
$this->assertEquals('/some/', \OC\Files\Filesystem::getMountPoint('/some'));
|
||||
list(, $internalPath) = \OC\Files\Filesystem::resolvePath('/some/folder');
|
||||
$this->assertEquals('folder', $internalPath);
|
||||
}
|
||||
|
||||
public function testNormalize() {
|
||||
@@ -136,20 +136,20 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
public function testHooks() {
|
||||
if(\OC\Files\Filesystem::getView()){
|
||||
if (\OC\Files\Filesystem::getView()) {
|
||||
$user = \OC_User::getUser();
|
||||
}else{
|
||||
$user=uniqid();
|
||||
\OC\Files\Filesystem::init($user, '/'.$user.'/files');
|
||||
} else {
|
||||
$user = uniqid();
|
||||
\OC\Files\Filesystem::init($user, '/' . $user . '/files');
|
||||
}
|
||||
\OC_Hook::clear('OC_Filesystem');
|
||||
\OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
|
||||
|
||||
\OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/');
|
||||
|
||||
$rootView=new \OC\Files\View('');
|
||||
$rootView->mkdir('/'.$user);
|
||||
$rootView->mkdir('/'.$user.'/files');
|
||||
$rootView = new \OC\Files\View('');
|
||||
$rootView->mkdir('/' . $user);
|
||||
$rootView->mkdir('/' . $user . '/files');
|
||||
|
||||
// \OC\Files\Filesystem::file_put_contents('/foo', 'foo');
|
||||
\OC\Files\Filesystem::mkdir('/bar');
|
||||
@@ -215,7 +215,7 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
|
||||
$homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/');
|
||||
|
||||
$this->assertInstanceOf('\OC\Files\Storage\Home', $homeMount);
|
||||
$this->assertEquals('local::' . $datadir. '/' . $userId . '/', $homeMount->getId());
|
||||
$this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId());
|
||||
|
||||
\OC_User::deleteUser($userId);
|
||||
// delete storage entry
|
||||
|
||||
@@ -42,6 +42,13 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
||||
$this->assertTrue($this->instance->isUpdatable('/'), 'Root folder is not writable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the test() function works
|
||||
*/
|
||||
public function testTestFunction() {
|
||||
$this->assertTrue($this->instance->test());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider directoryProvider
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel when updating major/minor version number.
|
||||
$OC_Version=array(6, 00, 0, 10);
|
||||
$OC_Version=array(6, 00, 0, 12);
|
||||
|
||||
// The human readable string
|
||||
$OC_VersionString='6.0 RC2';
|
||||
$OC_VersionString='6.0 RC4';
|
||||
|
||||
// The ownCloud edition
|
||||
$OC_Edition='';
|
||||
|
||||
Reference in New Issue
Block a user