Merge branch 'master' into fix_privatedata

This commit is contained in:
Thomas Müller 2013-10-31 09:05:35 +01:00
commit 64bfd21ccd
8 changed files with 81 additions and 61 deletions

View File

@ -465,7 +465,11 @@ $(document).ready(function() {
crumb.text(text);
}
$(document).click(function() {
$(document).click(function(ev) {
// do not close when clicking in the dropdown
if ($(ev.target).closest('#new').length){
return;
}
$('#new>ul').hide();
$('#new').removeClass('active');
if ($('#new .error').length > 0) {

View File

@ -593,18 +593,19 @@ var FileList={
var fileSize = '<td class="filesize">'+humanFileSize(totalSize)+'</td>';
}
$('#fileList').append('<tr class="summary"><td><span class="info">'+info+'</span></td>'+fileSize+'<td></td></tr>');
var $summary = $('<tr class="summary"><td><span class="info">'+info+'</span></td>'+fileSize+'<td></td></tr>');
$('#fileList').append($summary);
var $dirInfo = $('.summary .dirinfo');
var $fileInfo = $('.summary .fileinfo');
var $connector = $('.summary .connector');
var $dirInfo = $summary.find('.dirinfo');
var $fileInfo = $summary.find('.fileinfo');
var $connector = $summary.find('.connector');
// Show only what's necessary, e.g.: no files: don't show "0 files"
if ($dirInfo.html().charAt(0) === "0") {
if (totalDirs === 0) {
$dirInfo.hide();
$connector.hide();
}
if ($fileInfo.html().charAt(0) === "0") {
if (totalFiles === 0) {
$fileInfo.hide();
$connector.hide();
}

View File

@ -228,69 +228,73 @@ class Shared_Cache extends Cache {
*/
public function search($pattern) {
$where = '`name` LIKE ? AND ';
// normalize pattern
$pattern = $this->normalize($pattern);
$value = $this->normalize($pattern);
$ids = $this->getAll();
return $this->searchWithWhere($where, $value);
$files = array();
// divide into 1k chunks
$chunks = array_chunk($ids, 1000);
foreach ($chunks as $chunk) {
$placeholders = join(',', array_fill(0, count($chunk), '?'));
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
`encrypted`, `unencrypted_size`, `etag`
FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `fileid` IN (' . $placeholders . ')';
$result = \OC_DB::executeAudited($sql, array_merge(array($pattern), $chunk));
while ($row = $result->fetchRow()) {
if (substr($row['path'], 0, 6)==='files/') {
$row['path'] = substr($row['path'],6); // remove 'files/' from path as it's relative to '/Shared'
}
$row['mimetype'] = $this->getMimetype($row['mimetype']);
$row['mimepart'] = $this->getMimetype($row['mimepart']);
$files[] = $row;
}
}
return $files;
}
/**
* search for files by mimetype
*
* @param string $part1
* @param string $part2
* @param string $mimetype
* @return array
*/
public function searchByMime($mimetype) {
if (strpos($mimetype, '/')) {
$where = '`mimetype` = ?';
$where = '`mimetype` = ? AND ';
} else {
$where = '`mimepart` = ?';
$where = '`mimepart` = ? AND ';
}
$mimetype = $this->getMimetypeId($mimetype);
$value = $this->getMimetypeId($mimetype);
return $this->searchWithWhere($where, $value);
}
/**
* The maximum number of placeholders that can be used in an SQL query.
* Value MUST be <= 1000 for oracle:
* see ORA-01795 maximum number of expressions in a list is 1000
* FIXME we should get this from doctrine as other DBs allow a lot more placeholders
*/
const MAX_SQL_CHUNK_SIZE = 1000;
/**
* search for files with a custom where clause and value
* the $wherevalue will be array_merge()d with the file id chunks
*
* @param string $sqlwhere
* @param string $wherevalue
* @return array
*/
private function searchWithWhere($sqlwhere, $wherevalue, $chunksize = self::MAX_SQL_CHUNK_SIZE) {
$ids = $this->getAll();
$files = array();
// divide into 1k chunks
$chunks = array_chunk($ids, 1000);
// divide into chunks
$chunks = array_chunk($ids, $chunksize);
foreach ($chunks as $chunk) {
$placeholders = join(',', array_fill(0, count($ids), '?'));
$placeholders = join(',', array_fill(0, count($chunk), '?'));
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
`encrypted`, `unencrypted_size`, `etag`
FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `fileid` IN (' . $placeholders . ')';
FROM `*PREFIX*filecache` WHERE ' . $sqlwhere . ' `fileid` IN (' . $placeholders . ')';
$result = \OC_DB::executeAudited($sql, array_merge(array($mimetype), $chunk));
$stmt = \OC_DB::prepare($sql);
$result = $stmt->execute(array_merge(array($wherevalue), $chunk));
while ($row = $result->fetchRow()) {
if (substr($row['path'], 0, 6)==='files/') {
$row['path'] = substr($row['path'],6); // remove 'files/' from path as it's relative to '/Shared'
if (substr($row['path'], 0, 6) === 'files/') {
$row['path'] = substr($row['path'], 6); // remove 'files/' from path as it's relative to '/Shared'
}
$row['mimetype'] = $this->getMimetype($row['mimetype']);
$row['mimepart'] = $this->getMimetype($row['mimepart']);

View File

@ -56,7 +56,7 @@ OC.Share={
var path = dir;
// Search for possible parent folders that are shared
while (path != last) {
if (path == data['path']) {
if (path == data['path'] && !data['link']) {
var actions = $('.fileactions .action[data-action="Share"]');
$.each(actions, function(index, action) {
var img = $(action).find('img');
@ -244,7 +244,9 @@ OC.Share={
if (data.shares) {
$.each(data.shares, function(index, share) {
if (share.share_type == OC.Share.SHARE_TYPE_LINK) {
OC.Share.showLink(share.token, share.share_with, itemSource);
if ( !('file_target' in share) ) {
OC.Share.showLink(share.token, share.share_with, itemSource);
}
} else {
if (share.collection) {
OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, share.collection);

View File

@ -250,7 +250,8 @@ class OC_API {
// reuse existing login
$loggedIn = OC_User::isLoggedIn();
if ($loggedIn === true) {
$ocsApiRequest = isset($_SERVER['HTTP_OCS_APIREQUEST']) ? $_SERVER['HTTP_OCS_APIREQUEST'] === 'true' : false;
if ($loggedIn === true && $ocsApiRequest) {
return OC_User::getUser();
}

View File

@ -579,6 +579,7 @@ class OC_Util {
* @return void
*/
public static function checkAdminUser() {
OC_Util::checkLoggedIn();
if( !OC_User::isAdminUser(OC_User::getUser())) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
exit();
@ -611,6 +612,7 @@ class OC_Util {
* @return array $groups where the current user is subadmin
*/
public static function checkSubAdminUser() {
OC_Util::checkLoggedIn();
if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
exit();

View File

@ -4,6 +4,13 @@
* See the COPYING-README file.
*/
$levels = array('Debug', 'Info', 'Warning', 'Error', 'Fatal');
$levelLabels = array(
$l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ),
$l->t( 'Info, warnings, errors and fatal issues' ),
$l->t( 'Warnings, errors and fatal issues' ),
$l->t( 'Errors and fatal issues' ),
$l->t( 'Fatal issues only' ),
);
?>
<?php
@ -210,12 +217,13 @@ if (!$_['internetconnectionworking']) {
<fieldset class="personalblock">
<h2><?php p($l->t('Log'));?></h2>
<?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'>
<option value='<?php p($_['loglevel'])?>'><?php p($levels[$_['loglevel']])?></option>
<?php for ($i = 0; $i < 5; $i++):
if ($i !== $_['loglevel']):?>
<option value='<?php p($i)?>'><?php p($levels[$i])?></option>
<?php endif;
endfor;?>
<?php for ($i = 0; $i < 5; $i++):
$selected = '';
if ($i == $_['loglevel']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($i)?>' <?php p($selected) ?>><?php p($levelLabels[$i])?></option>
<?php endfor;?>
</select>
<table id="log" class="grid">
<?php foreach ($_['entries'] as $entry): ?>

View File

@ -134,13 +134,11 @@ class Preview extends \PHPUnit_Framework_TestCase {
}
private function initFS() {
if(\OC\Files\Filesystem::getView()){
$user = \OC_User::getUser();
}else{
$user=uniqid();
\OC_User::setUserId($user);
\OC\Files\Filesystem::init($user, '/'.$user.'/files');
}
// create a new user with his own filesystem view
// this gets called by each test in this test class
$user=uniqid();
\OC_User::setUserId($user);
\OC\Files\Filesystem::init($user, '/'.$user.'/files');
\OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/');