diff options
24 files changed, 415 insertions, 299 deletions
diff --git a/3rdparty b/3rdparty -Subproject 25e8568d41a9b9a6d1662ccf33058822a890e7f +Subproject 72db6ce87d69f00ce62d2f3f277a54f6fdd0f69 diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index a1444141099..9b114ca2e37 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -23,7 +23,7 @@ * */ // load needed apps -$RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging'); +$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging'); OC_App::loadApps($RUNTIME_APPTYPES); @@ -35,10 +35,11 @@ $lockBackend = new OC_Connector_Sabre_Locks(); $requestBackend = new OC_Connector_Sabre_Request(); // Create ownCloud Dir -$publicDir = new OC_Connector_Sabre_Directory(''); +$rootDir = new OC_Connector_Sabre_Directory(''); +$objectTree = new \OC\Connector\Sabre\ObjectTree($rootDir); // Fire up server -$server = new Sabre_DAV_Server($publicDir); +$server = new Sabre_DAV_Server($objectTree); $server->httpRequest = $requestBackend; $server->setBaseUri($baseuri); diff --git a/apps/files_external/lib/irods.php b/apps/files_external/lib/irods.php index ddce8639ff4..a343ac5fb27 100644 --- a/apps/files_external/lib/irods.php +++ b/apps/files_external/lib/irods.php @@ -11,8 +11,10 @@ namespace OC\Files\Storage; set_include_path(get_include_path() . PATH_SEPARATOR . \OC_App::getAppPath('files_external') . '/3rdparty/irodsphp/prods/src'); +ob_start(); require_once 'ProdsConfig.inc.php'; require_once 'ProdsStreamer.class.php'; +ob_end_clean(); class iRODS extends \OC\Files\Storage\StreamWrapper{ private $password; diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index f9174c45a65..4f48f71d8ca 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -2,24 +2,22 @@ OCP\JSON::checkAppEnabled('files_versions'); $source = $_GET['source']; +$start = $_GET['start']; list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source); $count = 5; //show the newest revisions -if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) { +if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename)) ) { - $versionsFormatted = array(); - - foreach ( $versions AS $version ) { - $versionsFormatted[] = OCP\Util::formatDate( $version['version'] ); + $endReached = false; + if (count($versions) <= $start+$count) { + $endReached = true; } - $versionsSorted = array_reverse( $versions ); + $versions = array_slice($versions, $start, $count); - if ( !empty( $versionsSorted ) ) { - OCP\JSON::encodedPrint($versionsSorted); - } + \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); } else { - return; + \OCP\JSON::success(array('data' => array('versions' => false, 'endReached' => true))); } diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index 284b46ee093..900d8cd6e28 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -3,8 +3,6 @@ OCP\JSON::checkAppEnabled('files_versions'); OCP\JSON::callCheck(); -$userDirectory = "/".OCP\USER::getUser()."/files"; - $file = $_GET['file']; $revision=(int)$_GET['revision']; diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 0d0850e1864..5b1e464ba6c 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -6,6 +6,7 @@ OC::$CLASSPATH['OCA\Files_Versions\Hooks'] = 'files_versions/lib/hooks.php'; OC::$CLASSPATH['OCA\Files_Versions\Capabilities'] = 'files_versions/lib/capabilities.php'; OCP\Util::addscript('files_versions', 'versions'); +OCP\Util::addStyle('files_versions', 'versions'); // Listen to write signals OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\Files_Versions\Hooks", "write_hook"); diff --git a/apps/files_versions/css/versions.css b/apps/files_versions/css/versions.css index a9b259ce140..6146eda3372 100644 --- a/apps/files_versions/css/versions.css +++ b/apps/files_versions/css/versions.css @@ -1,16 +1,44 @@ -#history { - margin: 2em 2em 0; +#found_versions li { + width: 100%; + cursor: default; + height: 36px; + float: left; + border-bottom: 1px solid rgba(100,100,100,.1); +} +#found_versions li:last-child { + border-bottom: none; +} + +#found_versions li > * { + padding: 7px; + float: left; + vertical-align: top; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + filter: alpha(opacity=50); + opacity: .5; +} +#found_versions li > *:hover, +#found_versions li > *:focus { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); + opacity: 1; } -#feedback-messages h3 { - font-size: 1.3em; - font-style: italic; +#found_versions img { + cursor: pointer; + padding-right: 4px; } -.success { - color: green; +#found_versions .versionDate { + min-width: 100px; + vertical-align: text-bottom; } -.failure { - color: red; -}
\ No newline at end of file +#found_versions .revertVersion { + cursor: pointer; + float: right; +} + +.drop-versions #makelink { + float: left; +} diff --git a/apps/files_versions/download.php b/apps/files_versions/download.php new file mode 100644 index 00000000000..040a662e61b --- /dev/null +++ b/apps/files_versions/download.php @@ -0,0 +1,50 @@ +<?php + +/** +* ownCloud - Download versions directly from the versions drop-down +* +* @author Bjoern Schiessle +* @copyright 2013 Bjoern Schiessle schiessle@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +OCP\JSON::checkAppEnabled('files_versions'); +//OCP\JSON::callCheck(); + +$file = $_GET['file']; +$revision=(int)$_GET['revision']; + +list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file); + +$versionName = '/'.$uid.'/files_versions/'.$filename.'.v'.$revision; + +$view = new OC\Files\View('/'); + +$ftype = $view->getMimeType('/'.$uid.'/files/'.$filename); + +header('Content-Type:'.$ftype); +if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) { + header( 'Content-Disposition: attachment; filename="' . rawurlencode( basename($filename) ) . '"' ); +} else { + header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode( basename($filename) ) + . '; filename="' . rawurlencode( basename($filename) ) . '"' ); +} +OCP\Response::disableCaching(); +header('Content-Length: '.$view->filesize($versionName)); + +OC_Util::obEnd(); + +$view->readfile($versionName); diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php deleted file mode 100644 index 719a7208fed..00000000000 --- a/apps/files_versions/history.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -/** - * ownCloud - History page of the Versions App - * - * @author Frank Karlitschek - * @copyright 2012 Frank Karlitschek frank@owncloud.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - */ - -OCP\User::checkLoggedIn( ); -OCP\Util::addStyle('files_versions', 'versions'); -$tmpl = new OCP\Template( 'files_versions', 'history', 'user' ); -$l = OC_L10N::get('files_versions'); - -if ( isset( $_GET['path'] ) ) { - - $path = $_GET['path']; - $tmpl->assign( 'path', $path ); - $versions = new OCA\Files_Versions\Storage(); - - // roll back to old version if button clicked - if( isset( $_GET['revert'] ) ) { - - if( $versions->rollback( $path, $_GET['revert'] ) ) { - - $tmpl->assign( 'outcome_stat', $l->t('success') ); - - $message = $l->t('File %s was reverted to version %s', - array($_GET['path'], OCP\Util::formatDate( doubleval($_GET['revert']) ) ) ); - - $tmpl->assign( 'outcome_msg', $message); - - } else { - - $tmpl->assign( 'outcome_stat', $l->t('failure') ); - - $message = $l->t('File %s could not be reverted to version %s', - array($_GET['path'], OCP\Util::formatDate( doubleval($_GET['revert']) ) ) ); - - $tmpl->assign( 'outcome_msg', $message); - - } - - } - - // show the history only if there is something to show - $count = 999; //show the newest revisions - list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($path); - if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) { - - $tmpl->assign( 'versions', array_reverse( $versions ) ); - - }else{ - - $tmpl->assign( 'message', $l->t('No old versions available') ); - - } -}else{ - - $tmpl->assign( 'message', $l->t('No path specified') ); - -} - -$tmpl->printPage( ); diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index a5b24417483..ca479507d48 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -1,4 +1,5 @@ $(document).ready(function(){ + if (typeof FileActions !== 'undefined') { // Add versions button to 'files/index.php' FileActions.register( @@ -14,39 +15,68 @@ $(document).ready(function(){ if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback var file = $('#dir').val()+'/'+filename; + var createDropDown = true; // Check if drop down is already visible for a different file - if (($('#dropdown').length > 0) && $('#dropdown').hasClass('drop-versions') ) { - if (file != $('#dropdown').data('file')) { - $('#dropdown').hide('blind', function() { - $('#dropdown').remove(); - $('tr').removeClass('mouseOver'); - createVersionsDropdown(filename, file); - }); + if (($('#dropdown').length > 0) ) { + if ( $('#dropdown').hasClass('drop-versions') && file == $('#dropdown').data('file')) { + createDropDown = false; } - } else { + $('#dropdown').remove(); + $('tr').removeClass('mouseOver'); + } + + if(createDropDown === true) { createVersionsDropdown(filename, file); } } ); } + + $(document).on("click", 'span[class="revertVersion"]', function() { + var revision = $(this).attr('id'); + var file = $(this).attr('value'); + revertFile(file, revision); + }); + }); +function revertFile(file, revision) { + + $.ajax({ + type: 'GET', + url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'), + dataType: 'json', + data: {file: file, revision: revision}, + async: false, + success: function(response) { + if (response.status === 'error') { + OC.Notification.show( t('files_version', 'Failed to revert {file} to revision {timestamp}.', {file:file, timestamp:formatDate(revision * 1000)}) ); + } else { + $('#dropdown').hide('blind', function() { + $('#dropdown').remove(); + $('tr').removeClass('mouseOver'); + // TODO also update the modified time in the web ui + }); + } + } + }); + +} + function goToVersionPage(url){ window.location.assign(url); } function createVersionsDropdown(filename, files) { - var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename ); + var start = 0; var html = '<div id="dropdown" class="drop drop-versions" data-file="'+escapeHTML(files)+'">'; html += '<div id="private">'; - html += '<select data-placeholder="Saved versions" id="found_versions" class="chzen-select" style="width:16em;">'; - html += '<option value=""></option>'; - html += '</select>'; + html += '<ul id="found_versions">'; + html += '</ul>'; html += '</div>'; - html += '<input type="button" value="All versions..." name="makelink" id="makelink" />'; - html += '<input id="link" style="display:none; width:90%;" />'; + html += '<input type="button" value="'+ t('files_versions', 'More versions...') + '" name="show-more-versions" id="show-more-versions" style="display: none;" />'; if (filename) { $('tr').filterAttr('data-file',filename).addClass('mouseOver'); @@ -55,73 +85,72 @@ function createVersionsDropdown(filename, files) { $(html).appendTo($('thead .share')); } - $("#makelink").click(function() { - goToVersionPage(historyUrl); - }); + getVersions(start); + start = start + 5; - $.ajax({ - type: 'GET', - url: OC.filePath('files_versions', 'ajax', 'getVersions.php'), - dataType: 'json', - data: { source: files }, - async: false, - success: function( versions ) { - - if (versions) { - $.each( versions, function(index, row ) { - addVersion( row ); - }); - } else { - $('#found_versions').hide(); - $('#makelink').hide(); - $('<div style="text-align:center;">No other versions available</div>').appendTo('#dropdown'); - } - $('#found_versions').change(function(){ - var revision=parseInt($(this).val()); - revertFile(files,revision); - }); - } + $("#show-more-versions").click(function() { + //get more versions + getVersions(start); + start = start + 5; }); - function revertFile(file, revision) { - + function getVersions(start) { $.ajax({ type: 'GET', - url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'), + url: OC.filePath('files_versions', 'ajax', 'getVersions.php'), dataType: 'json', - data: {file: file, revision: revision}, + data: {source: files, start: start}, async: false, - success: function(response) { - if (response.status=='error') { - OC.dialogs.alert('Failed to revert '+file+' to revision '+formatDate(revision*1000)+'.','Failed to revert'); + success: function(result) { + var versions = result.data.versions; + if (result.data.endReached === true) { + document.getElementById("show-more-versions").style.display="none"; } else { - $('#dropdown').hide('blind', function() { - $('#dropdown').remove(); - $('tr').removeClass('mouseOver'); - // TODO also update the modified time in the web ui + document.getElementById("show-more-versions").style.display="block"; + } + if (versions) { + $.each(versions, function(index, row) { + addVersion(row); }); + } else { + $('<div style="text-align:center;">'+ t('files_versions', 'No other versions available') + '</div>').appendTo('#dropdown'); } + $('#found_versions').change(function() { + var revision = parseInt($(this).val()); + revertFile(files, revision); + }); } }); - } function addVersion( revision ) { - name=formatDate(revision.version*1000); - var version=$('<option/>'); - version.attr('value',revision.version); - version.text(name); - -// } else { -// var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"'); -// var style = ((permissions == 0) ? 'style="display:none;"' : ''); -// var user = '<li data-uid_shared_with="'+uid_shared_with+'">'; -// user += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>'; -// user += uid_shared_with; -// user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />'; -// user += '<label for="'+uid_shared_with+'" '+style+'>can edit</label>'; -// user += '</li>'; -// } + title = formatDate(revision.version*1000); + name ='<span class="versionDate" title="' + title + '">' + revision.humanReadableTimestamp + '</span>'; + + path = OC.filePath('files_versions', '', 'download.php'); + + download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">'; + download+='<img'; + download+=' src="' + OC.imagePath('core', 'actions/download') + '"'; + download+=' id="' + revision.version + '"'; + download+=' value="' + files + '"'; + download+=' name="downloadVersion" />'; + download+=name; + download+='</a>'; + + revert='<span class="revertVersion"'; + revert+=' id="' + revision.version + '"'; + revert+=' value="' + files + '">'; + revert+='<img'; + revert+=' src="' + OC.imagePath('core', 'actions/history') + '"'; + revert+=' id="' + revision.version + '"'; + revert+=' value="' + files + '"'; + revert+=' name="revertVersion"'; + revert+='/>'+t('files_versions', 'Restore')+'</span>'; + + var version=$('<li/>'); + version.attr('value', revision.version); + version.html(download + revert); version.appendTo('#found_versions'); } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index c083a000c37..7c75d70f79c 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -239,10 +239,9 @@ class Storage { * @brief get a list of all available versions of a file in descending chronological order * @param $uid user id from the owner of the file * @param $filename file to find versions of, relative to the user files dir - * @param $count number of versions to return * @returns array */ - public static function getVersions($uid, $filename, $count = 0 ) { + public static function getVersions($uid, $filename ) { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { $versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions'); $versionsName = $versions_fileview->getLocalFile($filename).'.v'; @@ -268,6 +267,7 @@ class Storage { $key = $version.'#'.$filename; $versions[$key]['cur'] = 0; $versions[$key]['version'] = $version; + $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version); $versions[$key]['path'] = $filename; $versions[$key]['size'] = $versions_fileview->filesize($filename.'.v'.$version); @@ -276,6 +276,7 @@ class Storage { } + // newest versions first $versions = array_reverse( $versions ); foreach( $versions as $key => $value ) { @@ -286,13 +287,6 @@ class Storage { } } - $versions = array_reverse( $versions ); - - // only show the newest commits - if( $count != 0 and ( count( $versions )>$count ) ) { - $versions = array_slice( $versions, count( $versions ) - $count ); - } - return( $versions ); } else { @@ -302,6 +296,32 @@ class Storage { } + /** + * @brief translate a timestamp into a string like "5 days ago" + * @param int $timestamp + * @return string for example "5 days ago" + */ + private static function getHumanReadableTimestamp($timestamp) { + + $diff = time() - $timestamp; + + if ($diff < 60) { // first minute + return $diff . " seconds ago"; + } elseif ($diff < 3600) { //first hour + return round($diff / 60) . " minutes ago"; + } elseif ($diff < 86400) { // first day + return round($diff / 3600) . " hours ago"; + } elseif ($diff < 604800) { //first week + return round($diff / 86400) . " days ago"; + } elseif ($diff < 2419200) { //first month + return round($diff / 604800) . " weeks ago"; + } elseif ($diff < 29030400) { // first year + return round($diff / 2419200) . " months ago"; + } else { + return round($diff / 29030400) . " years ago"; + } + + } /** * @brief deletes used space for files versions in db if user was deleted diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php deleted file mode 100644 index 3a6d5f0c9e7..00000000000 --- a/apps/files_versions/templates/history.php +++ /dev/null @@ -1,36 +0,0 @@ -<div id="history"> - -<?php - -if( isset( $_['message'] ) ) { - - - if( isset($_['path'] ) ) print_unescaped('<strong>File: '.OC_Util::sanitizeHTML($_['path']).'</strong><br>'); - print_unescaped('<strong>'.OC_Util::sanitizeHTML($_['message']) .'</strong><br>'); - -}else{ - - if( isset( $_['outcome_stat'] ) ) { - - print_unescaped( '<div id="feedback-messages" class="'.OC_Util::sanitizeHTML($_['outcome_stat']).'"><h3>'.OC_Util::sanitizeHTML($_['outcome_msg']).'</h3></div><br>'); - - } - - print_unescaped( '<strong>Versions of '.OC_Util::sanitizeHTML($_['path']).'</strong><br>'); - print_unescaped('<p><em>'.OC_Util::sanitizeHTML($l->t('Revert a file to a previous version by clicking on its revert button')).'</em></p><br />'); - - foreach ( $_['versions'] as $v ) { - p(' '); - p(OCP\Util::formatDate( doubleval($v['version']))); - print_unescaped(' <a href="'.OCP\Util::linkTo('files_versions', 'history.php', - array('path' => $_['path'], 'revert' => $v['version'])) .'" class="button">Revert</a><br /><br />'); - if ( $v['cur'] ) { - print_unescaped(' (<b>Current</b>)'); - } - print_unescaped('<br /><br />'); - } - -} - -?> -</div> diff --git a/core/js/setup.js b/core/js/setup.js index 76812b29979..c0df1ed96b0 100644 --- a/core/js/setup.js +++ b/core/js/setup.js @@ -11,42 +11,36 @@ $(document).ready(function() { $('#selectDbType').buttonset(); $('#datadirContent').hide(250); $('#databaseField').hide(250); - if($('#hasSQLite').val()=='true'){ + if($('#hasSQLite').val()){ $('#use_other_db').hide(); - $('#dbhost').hide(); - $('#dbhostlabel').hide(); + $('#use_oracle_db').hide(); } $('#adminlogin').change(function(){ $('#adminlogin').val($.trim($('#adminlogin').val())); }); $('#sqlite').click(function() { $('#use_other_db').slideUp(250); - $('#dbhost').hide(250); - $('#dbhostlabel').hide(250); + $('#use_oracle_db').slideUp(250); }); $('#mysql').click(function() { $('#use_other_db').slideDown(250); - $('#dbhost').show(250); - $('#dbhostlabel').show(250); + $('#use_oracle_db').slideUp(250); }); - + $('#pgsql').click(function() { $('#use_other_db').slideDown(250); - $('#dbhost').show(250); - $('#dbhostlabel').show(250); + $('#use_oracle_db').slideUp(250); }); - + $('#oci').click(function() { $('#use_other_db').slideDown(250); - $('#dbhost').show(250); - $('#dbhostlabel').show(250); + $('#use_oracle_db').show(250); }); - + $('#mssql').click(function() { $('#use_other_db').slideDown(250); - $('#dbhost').show(250); - $('#dbhostlabel').show(250); + $('#use_oracle_db').slideUp(250); }); $('input[checked]').trigger('click'); diff --git a/core/templates/installation.php b/core/templates/installation.php index 6de67a83d42..77c455304d3 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -121,7 +121,7 @@ <?php OC_Helper::init_radio('dbtype', 'oci', 'sqlite'); ?>/> <?php endif; ?> <?php endif; ?> - + <?php if($_['hasMSSQL']): ?> <input type='hidden' id='hasMSSQL' value='true'/> <?php if(!$_['hasSQLite'] and !$_['hasMySQL'] and !$_['hasPostgreSQL'] and !$_['hasOracle']): ?> @@ -131,7 +131,7 @@ <label class="mssql" for="mssql">MS SQL</label> <input type="radio" name="dbtype" value='mssql' id="mssql" <?php OC_Helper::init_radio('dbtype', 'mssql', 'sqlite'); ?>/> <?php endif; ?> - <?php endif; ?> + <?php endif; ?> </div> <?php if($hasOtherDB): ?> @@ -154,22 +154,22 @@ value="<?php p(OC_Helper::init_var('dbname')); ?>" autocomplete="off" pattern="[0-9a-zA-Z$_-]+" /> </p> - </div> - <?php endif; ?> - <?php if($_['hasOracle']): ?> - <div id="use_oracle_db"> - <p class="infield groupmiddle"> - <label for="dbtablespace" class="infield"><?php p($l->t( 'Database tablespace' )); ?></label> - <input type="text" name="dbtablespace" id="dbtablespace" placeholder="" - value="<?php p(OC_Helper::init_var('dbtablespace')); ?>" autocomplete="off" /> + <?php if($_['hasOracle']): ?> + <div id="use_oracle_db"> + <p class="infield groupmiddle"> + <label for="dbtablespace" class="infield"><?php p($l->t( 'Database tablespace' )); ?></label> + <input type="text" name="dbtablespace" id="dbtablespace" placeholder="" + value="<?php p(OC_Helper::init_var('dbtablespace')); ?>" autocomplete="off" /> + </p> + </div> + <?php endif; ?> + <p class="infield groupbottom"> + <label for="dbhost" class="infield"><?php p($l->t( 'Database host' )); ?></label> + <input type="text" name="dbhost" id="dbhost" placeholder="" + value="<?php p(OC_Helper::init_var('dbhost')); ?>" /> </p> </div> <?php endif; ?> - <p class="infield groupbottom"> - <label for="dbhost" class="infield" id="dbhostlabel"><?php p($l->t( 'Database host' )); ?></label> - <input type="text" name="dbhost" id="dbhost" placeholder="" - value="<?php p(OC_Helper::init_var('dbhost')); ?>" /> - </p> </fieldset> <div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" /></div> diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 3d15a2a584d..ed8d085462d 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -222,7 +222,6 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa throw new \Sabre_DAV_Exception_Forbidden(); } if ($this->path != "/Shared") { - foreach($this->getChildren() as $child) $child->delete(); \OC\Files\Filesystem::rmdir($this->path); } diff --git a/lib/connector/sabre/objecttree.php b/lib/connector/sabre/objecttree.php new file mode 100644 index 00000000000..c4ddcbecbb8 --- /dev/null +++ b/lib/connector/sabre/objecttree.php @@ -0,0 +1,102 @@ +<?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 OC\Connector\Sabre; + +use OC\Files\Filesystem; + +class ObjectTree extends \Sabre_DAV_ObjectTree { + /** + * Returns the INode object for the requested path + * + * @param string $path + * @throws \Sabre_DAV_Exception_NotFound + * @return \Sabre_DAV_INode + */ + public function getNodeForPath($path) { + + $path = trim($path, '/'); + if (isset($this->cache[$path])) return $this->cache[$path]; + + // Is it the root node? + if (!strlen($path)) { + return $this->rootNode; + } + + $info = Filesystem::getFileInfo($path); + + if (!$info) { + throw new \Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located'); + } + + if ($info['mimetype'] === 'httpd/unix-directory') { + $node = new \OC_Connector_Sabre_Directory($path); + } else { + $node = new \OC_Connector_Sabre_File($path); + } + + $node->setFileinfoCache($info); + + $this->cache[$path] = $node; + return $node; + + } + + /** + * Moves a file from one location to another + * + * @param string $sourcePath The path to the file which should be moved + * @param string $destinationPath The full destination path, so not just the destination parent node + * @throws \Sabre_DAV_Exception_Forbidden + * @return int + */ + public function move($sourcePath, $destinationPath) { + + $sourceNode = $this->getNodeForPath($sourcePath); + if ($sourceNode instanceof \Sabre_DAV_ICollection and $this->nodeExists($destinationPath)) { + throw new \Sabre_DAV_Exception_Forbidden('Could not copy directory ' . $sourceNode . ', target exists'); + } + list($sourceDir,) = \Sabre_DAV_URLUtil::splitPath($sourcePath); + list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destinationPath); + + Filesystem::rename($sourcePath, $destinationPath); + + $this->markDirty($sourceDir); + $this->markDirty($destinationDir); + + } + + /** + * Copies a file or directory. + * + * This method must work recursively and delete the destination + * if it exists + * + * @param string $source + * @param string $destination + * @return void + */ + public function copy($source, $destination) { + + if (Filesystem::is_file($source)) { + Filesystem::copy($source, $destination); + } else { + Filesystem::mkdir($destination); + $dh = Filesystem::opendir($source); + while ($subnode = readdir($dh)) { + + if ($subnode == '.' || $subnode == '..') continue; + $this->copy($source . '/' . $subnode, $destination . '/' . $subnode); + + } + } + + list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destination); + $this->markDirty($destinationDir); + } +} diff --git a/lib/group/group.php b/lib/group/group.php index 7a639313247..a752c4311c1 100644 --- a/lib/group/group.php +++ b/lib/group/group.php @@ -13,7 +13,7 @@ class Group { /** * @var string $id */ - private $fid; + private $gid; /** * @var \OC\User\User[] $users diff --git a/lib/memcache/apcu.php b/lib/memcache/apcu.php new file mode 100644 index 00000000000..ccc1aa6e562 --- /dev/null +++ b/lib/memcache/apcu.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Memcache; + +class APCu extends APC { + public function clear($prefix = '') { + $ns = $this->getNamespace() . $prefix; + $ns = preg_quote($ns, '/'); + $iter = new \APCIterator('/^'.$ns.'/'); + return apc_delete($iter); + } + + static public function isAvailable() { + if (!extension_loaded('apcu')) { + return false; + } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) { + return false; + } else { + return true; + } + } +} diff --git a/lib/memcache/factory.php b/lib/memcache/factory.php index b1b49971031..4c1b1ab207f 100644 --- a/lib/memcache/factory.php +++ b/lib/memcache/factory.php @@ -18,6 +18,8 @@ class Factory { function create($prefix = '') { if (XCache::isAvailable()) { return new XCache($prefix); + } elseif (APCu::isAvailable()) { + return new APCu($prefix); } elseif (APC::isAvailable()) { return new APC($prefix); } elseif (Memcached::isAvailable()) { @@ -33,6 +35,6 @@ class Factory { * @return bool */ public function isAvailable() { - return XCache::isAvailable() || APC::isAvailable() || Memcached::isAvailable(); + return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable(); } } diff --git a/lib/public/files.php b/lib/public/files.php index 4975bbb7dfa..852b041eefb 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -61,7 +61,7 @@ class Files { * @param string $query * @return array */ - public function searchByMime($mimetype) { + static public function searchByMime($mimetype) { return(\OC\Files\Filesystem::searchByMime( $mimetype )); } diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index fbf502fbc1c..3f339a10016 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -176,68 +176,21 @@ abstract class Storage extends \PHPUnit_Framework_TestCase { $this->assertEquals(filesize($textFile), $this->instance->filesize('/lorem.txt')); $stat = $this->instance->stat('/lorem.txt'); - //only size and mtime are requered in the result + //only size and mtime are required in the result $this->assertEquals($stat['size'], $this->instance->filesize('/lorem.txt')); $this->assertEquals($stat['mtime'], $mTime); - $mtimeStart = time(); - $supportsTouch = $this->instance->touch('/lorem.txt'); - $mtimeEnd = time(); - if ($supportsTouch !== false) { + if ($this->instance->touch('/lorem.txt', 100) !== false) { $mTime = $this->instance->filemtime('/lorem.txt'); - $this->assertTrue(($mtimeStart - 5) <= $mTime); - $this->assertTrue($mTime <= ($mtimeEnd + 5)); - - $this->assertTrue($this->instance->hasUpdated('/lorem.txt', $mtimeStart - 5)); - - if ($this->instance->touch('/lorem.txt', 100) !== false) { - $mTime = $this->instance->filemtime('/lorem.txt'); - $this->assertEquals($mTime, 100); - } + $this->assertEquals($mTime, 100); } $mtimeStart = time(); - $fh = $this->instance->fopen('/lorem.txt', 'a'); - fwrite($fh, ' '); - fclose($fh); - clearstatcache(); - $mtimeEnd = time(); - $mTime = $this->instance->filemtime('/lorem.txt'); - $this->assertTrue(($mtimeStart - 5) <= $mTime); - $this->assertTrue($mTime <= ($mtimeEnd + 5)); $this->instance->unlink('/lorem.txt'); $this->assertTrue($this->instance->hasUpdated('/', $mtimeStart - 5)); } - public function testSearch() { - $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; - $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile, 'r')); - $pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png'; - $this->instance->file_put_contents('/logo-wide.png', file_get_contents($pngFile, 'r')); - $svgFile = \OC::$SERVERROOT . '/tests/data/logo-wide.svg'; - $this->instance->file_put_contents('/logo-wide.svg', file_get_contents($svgFile, 'r')); - $result = $this->instance->search('logo'); - $this->assertEquals(2, count($result)); - $this->assertContains('/logo-wide.svg', $result); - $this->assertContains('/logo-wide.png', $result); - } - - public function testSearchInSubFolder() { - $this->instance->mkdir('sub'); - $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; - $this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r')); - $pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png'; - $this->instance->file_put_contents('/sub/logo-wide.png', file_get_contents($pngFile, 'r')); - $svgFile = \OC::$SERVERROOT . '/tests/data/logo-wide.svg'; - $this->instance->file_put_contents('/sub/logo-wide.svg', file_get_contents($svgFile, 'r')); - - $result = $this->instance->search('logo'); - $this->assertEquals(2, count($result)); - $this->assertContains('/sub/logo-wide.svg', $result); - $this->assertContains('/sub/logo-wide.png', $result); - } - public function testFOpen() { $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; diff --git a/tests/lib/memcache/apc.php b/tests/lib/memcache/apc.php index 6b2a49470ba..e5d753a4fa5 100644 --- a/tests/lib/memcache/apc.php +++ b/tests/lib/memcache/apc.php @@ -15,6 +15,10 @@ class APC extends Cache { $this->markTestSkipped('The apc extension is not available.'); return; } + if(\OC\Memcache\APCu::isAvailable()) { + $this->markTestSkipped('The apc extension is emulated by ACPu.'); + return; + } $this->instance=new \OC\Memcache\APC(uniqid()); } } diff --git a/tests/lib/memcache/apcu.php b/tests/lib/memcache/apcu.php new file mode 100644 index 00000000000..7b99e7cd5e0 --- /dev/null +++ b/tests/lib/memcache/apcu.php @@ -0,0 +1,20 @@ +<?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\Memcache; + +class APCu extends Cache { + public function setUp() { + if(!\OC\Memcache\APCu::isAvailable()) { + $this->markTestSkipped('The APCu extension is not available.'); + return; + } + $this->instance=new \OC\Memcache\APCu(uniqid()); + } +} diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index 23b2d6c0060..a893e96ad97 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8" ?> <phpunit bootstrap="bootstrap.php" strict="true" + verbose="true" timeoutForSmallTests="900" timeoutForMediumTests="900" timeoutForLargeTests="900" |