diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-10-23 12:02:06 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-10-23 12:02:06 +0200 |
commit | 3121dc8cb5e436af3f465dd8a5da5ddcf43377e0 (patch) | |
tree | 60f5cb38c2439403b9edb83a13ac62f781148c13 | |
parent | 8ed73e5cedac5e22a8e50d1fdf04feb400b676fd (diff) | |
parent | 2d14daf36bf6c808e55895c78b42144942b73246 (diff) | |
download | nextcloud-server-3121dc8cb5e436af3f465dd8a5da5ddcf43377e0.tar.gz nextcloud-server-3121dc8cb5e436af3f465dd8a5da5ddcf43377e0.zip |
Merge branch 'master' into prevent_user_from_creating_or_renaming_to_an_existing_filename
Conflicts:
apps/files/js/filelist.js
27 files changed, 111 insertions, 33 deletions
diff --git a/apps/files/index.php b/apps/files/index.php index 2f1e084560b..f0f95b3bac8 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -118,6 +118,10 @@ if ($needUpgrade) { $trashEmpty = \OCA\Files_Trashbin\Trashbin::isEmpty($user); } + $isCreatable = \OC\Files\Filesystem::isCreatable($dir . '/'); + $fileHeader = (!isset($files) or count($files) > 0); + $emptyContent = ($isCreatable and !$fileHeader) or $ajaxLoad; + OCP\Util::addscript('files', 'fileactions'); OCP\Util::addscript('files', 'files'); OCP\Util::addscript('files', 'keyboardshortcuts'); @@ -125,7 +129,7 @@ if ($needUpgrade) { $tmpl->assign('fileList', $list->fetchPage()); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage()); $tmpl->assign('dir', \OC\Files\Filesystem::normalizePath($dir)); - $tmpl->assign('isCreatable', \OC\Files\Filesystem::isCreatable($dir . '/')); + $tmpl->assign('isCreatable', $isCreatable); $tmpl->assign('permissions', $permissions); $tmpl->assign('files', $files); $tmpl->assign('trash', $trashEnabled); @@ -142,6 +146,8 @@ if ($needUpgrade) { $tmpl->assign("encryptionInitStatus", $encryptionInitStatus); $tmpl->assign('disableSharing', false); $tmpl->assign('ajaxLoad', $ajaxLoad); + $tmpl->assign('emptyContent', $emptyContent); + $tmpl->assign('fileHeader', $fileHeader); $tmpl->printPage(); } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 980260928e8..c33a06bbdc3 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -7,11 +7,9 @@ var FileList={ }); }, update:function(fileListHtml) { - var $fileList = $('#fileList'), - permissions = $('#permissions').val(), - isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; + var $fileList = $('#fileList'); $fileList.empty().html(fileListHtml); - $('#emptycontent').toggleClass('hidden', !isCreatable || $fileList.find('tr').exists()); + FileList.updateEmptyContent(); $fileList.find('tr').each(function () { FileActions.display($(this).children('td.filename')); }); @@ -252,7 +250,6 @@ var FileList={ $('.creatable').toggleClass('hidden', !isCreatable); $('.notCreatable').toggleClass('hidden', isCreatable); }, - /** * Shows/hides action buttons * @@ -284,6 +281,7 @@ var FileList={ FileList.updateFileSummary(); if ( ! $('tr[data-file]').exists() ) { $('#emptycontent').removeClass('hidden'); + $('#filescontent th').addClass('hidden'); } }, insertElement:function(name, type, element) { @@ -316,6 +314,7 @@ var FileList={ $('#fileList').append(element); } $('#emptycontent').addClass('hidden'); + $('#filestable th').removeClass('hidden'); FileList.updateFileSummary(); }, loadingDone:function(name, id) { @@ -551,6 +550,7 @@ var FileList={ procesSelection(); checkTrashStatus(); FileList.updateFileSummary(); + FileList.updateEmptyContent(); } else { $.each(files,function(index,file) { var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); @@ -664,6 +664,13 @@ var FileList={ } } }, + updateEmptyContent: function() { + var $fileList = $('#fileList'); + var permissions = $('#permissions').val(); + var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; + $('#emptycontent').toggleClass('hidden', !isCreatable || $fileList.find('tr').exists()); + $('#filestable th').toggleClass('hidden', $fileList.find('tr').exists() === false); + }, showMask: function() { // in case one was shown before var $mask = $('#content .mask'); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 3567904f2f2..389bf1bf197 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -663,8 +663,16 @@ function lazyLoadPreview(path, mime, ready, width, height) { $.get(previewURL, function() { previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); - //set preview thumbnail URL - ready(previewURL + '&reload=true'); + previewURL += '&reload=true'; + + // preload image to prevent delay + // this will make the browser cache the image + var img = new Image(); + img.onload = function(){ + //set preview thumbnail URL + ready(previewURL); + } + img.src = previewURL; }); }); } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 001adb77ab5..2e88bf2dbb4 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -1,6 +1,6 @@ <div id="controls"> <?php print_unescaped($_['breadcrumb']); ?> - <div class="actions creatable <?php if (!$_['isCreatable']):?>hidden<?php endif; ?> <?php if (isset($_['files']) and count($_['files'])==0):?>emptycontent<?php endif; ?>"> + <div class="actions creatable <?php if (!$_['isCreatable']):?>hidden<?php endif; ?>"> <div id="new" class="button"> <a><?php p($l->t('New'));?></a> <ul> @@ -42,14 +42,14 @@ <input type="hidden" name="permissions" value="<?php p($_['permissions']); ?>" id="permissions"> </div> -<div id="emptycontent" <?php if (!isset($_['files']) or !$_['isCreatable'] or count($_['files']) > 0 or $_['ajaxLoad']):?>class="hidden"<?php endif; ?>><?php p($l->t('Nothing in here. Upload something!'))?></div> +<div id="emptycontent" <?php if (!$_['emptyContent']):?>class="hidden"<?php endif; ?>><?php p($l->t('Nothing in here. Upload something!'))?></div> <input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>"></input> <table id="filestable" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" data-preview-x="36" data-preview-y="36"> <thead> <tr> - <th id='headerName'> + <th <?php if (!$_['fileHeader']):?>class="hidden"<?php endif; ?> id='headerName'> <div id="headerName-container"> <input type="checkbox" id="select_all" /> <label for="select_all"></label> @@ -65,8 +65,8 @@ </span> </div> </th> - <th id="headerSize"><?php p($l->t('Size')); ?></th> - <th id="headerDate"> + <th <?php if (!$_['fileHeader']):?>class="hidden"<?php endif; ?> id="headerSize"><?php p($l->t('Size')); ?></th> + <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 --> diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index d9a76becf25..6e2d360917b 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -555,4 +555,15 @@ class Hooks { }
}
+ /**
+ * set the init status to 'NOT_INITIALIZED' (0) if the app gets enabled
+ * @param array $params contains the app ID
+ */
+ public static function postEnable($params) {
+ if ($params['app'] === 'files_encryption') {
+ $session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
+ $session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
+ }
+ }
+
}
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index a754f9f28c4..91dd08ec08d 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -69,6 +69,7 @@ class Helper { public static function registerAppHooks() { \OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable'); + \OCP\Util::connectHook('OC_App', 'post_disable', 'OCA\Encryption\Hooks', 'postEnable'); } /** diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 53d58fbf40d..b9592a32cb2 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1278,7 +1278,7 @@ class Util { // If no record is found if (empty($migrationStatus)) { \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR); - return false; + return self::MIGRATION_OPEN; // If a record is found } else { return (int)$migrationStatus[0]; diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 1f5453468b4..ef4c1c433da 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -15,10 +15,10 @@ <div class="header-right"> <?php if (isset($_['folder'])): ?> <span id="details"><?php p($l->t('%s shared the folder %s with you', - array($_['displayName'], $_['fileTarget']))) ?></span> + array($_['displayName'], $_['filename']))) ?></span> <?php else: ?> <span id="details"><?php p($l->t('%s shared the file %s with you', - array($_['displayName'], $_['fileTarget']))) ?></span> + array($_['displayName'], $_['filename']))) ?></span> <?php endif; ?> @@ -88,7 +88,7 @@ <?php else: ?> <ul id="noPreview"> <li class="error"> - <?php p($l->t('No preview available for').' '.$_['fileTarget']); ?><br /> + <?php p($l->t('No preview available for').' '.$_['filename']); ?><br /> <a href="<?php p($_['downloadURL']); ?>" id="download"><img class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>" /><?php p($l->t('Download'))?></a> diff --git a/lib/private/api.php b/lib/private/api.php index 31f3f968d9b..26091657b31 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -46,6 +46,7 @@ class OC_API { * api actions */ protected static $actions = array(); + private static $logoutRequired = false; /** * registers an api call @@ -115,7 +116,9 @@ class OC_API { $formats = array('json', 'xml'); $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml'; - OC_User::logout(); + if (self::$logoutRequired) { + OC_User::logout(); + } self::respond($response, $format); } @@ -235,10 +238,23 @@ class OC_API { * http basic auth * @return string|false (username, or false on failure) */ - private static function loginUser(){ + private static function loginUser(){ + // basic auth $authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; $authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; - return OC_User::login($authUser, $authPw) ? $authUser : false; + $return = OC_User::login($authUser, $authPw); + if ($return === true) { + self::$logoutRequired = true; + return $authUser; + } + + // reuse existing login + $loggedIn = OC_User::isLoggedIn(); + if ($loggedIn === true) { + return OC_User::getUser(); + } + + return false; } /** diff --git a/lib/private/app.php b/lib/private/app.php index 6f45b6e6dd7..eca40a81cc1 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -249,6 +249,7 @@ class OC_App{ if(isset($appdata['id'])) { OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] ); } + \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); } }else{ throw new \Exception($l->t("No app name specified")); diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php index 81910df6990..ae2c5e8546b 100644 --- a/lib/private/appframework/dependencyinjection/dicontainer.php +++ b/lib/private/appframework/dependencyinjection/dicontainer.php @@ -24,7 +24,7 @@ namespace OC\AppFramework\DependencyInjection; -use OC\AppFramework\Http\Http; +use OC\AppFramework\Http; use OC\AppFramework\Http\Request; use OC\AppFramework\Http\Dispatcher; use OC\AppFramework\Core\API; diff --git a/lib/private/appframework/http/http.php b/lib/private/appframework/http.php index e00dc9cdc4a..41fc0db6b38 100644 --- a/lib/private/appframework/http/http.php +++ b/lib/private/appframework/http.php @@ -22,10 +22,11 @@ */ -namespace OC\AppFramework\Http; +namespace OC\AppFramework; +use OCP\AppFramework\Http as BaseHttp; -class Http extends \OCP\AppFramework\Http\Http{ +class Http extends BaseHttp { private $server; private $protocolVersion; diff --git a/lib/private/appframework/http/dispatcher.php b/lib/private/appframework/http/dispatcher.php index 51283fd64e7..a2afb53f0fa 100644 --- a/lib/private/appframework/http/dispatcher.php +++ b/lib/private/appframework/http/dispatcher.php @@ -25,6 +25,7 @@ namespace OC\AppFramework\Http; use \OC\AppFramework\Middleware\MiddlewareDispatcher; +use \OC\AppFramework\Http; use OCP\AppFramework\Controller; diff --git a/lib/private/appframework/http/redirectresponse.php b/lib/private/appframework/http/redirectresponse.php index 688447f1618..c4e21059480 100644 --- a/lib/private/appframework/http/redirectresponse.php +++ b/lib/private/appframework/http/redirectresponse.php @@ -24,7 +24,8 @@ namespace OC\AppFramework\Http; -use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http\Response, + OCP\AppFramework\Http; /** diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php index f103a40ee7f..c3143754823 100644 --- a/lib/private/appframework/middleware/security/securitymiddleware.php +++ b/lib/private/appframework/middleware/security/securitymiddleware.php @@ -24,7 +24,7 @@ namespace OC\AppFramework\Middleware\Security; -use OC\AppFramework\Http\Http; +use OC\AppFramework\Http; use OC\AppFramework\Http\RedirectResponse; use OC\AppFramework\Utility\MethodAnnotationReader; use OCP\AppFramework\Middleware; diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 3402946a136..6ace8d14484 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -148,6 +148,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D } \OC\Files\Filesystem::unlink($this->path); + // remove properties + $this->removeProperties(); + } /** diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index c38e9f86375..3c2ad60f1dd 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -191,6 +191,17 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr } /** + * removes all properties for this node and user + */ + public function removeProperties() { + $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties`' + .' WHERE `userid` = ? AND `propertypath` = ?' ); + $query->execute( array( OC_User::getUser(), $this->path)); + + $this->setPropertyCache(null); + } + + /** * @brief Returns a list of properties for this nodes.; * @param array $properties * @return array diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index df8902f66e2..cd3f081f7cc 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -97,6 +97,11 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { throw new \Sabre_DAV_Exception_Forbidden(''); } + // update properties + $query = \OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ?' + .' WHERE `userid` = ? AND `propertypath` = ?' ); + $query->execute( array( $destinationPath, \OC_User::getUser(), $sourcePath )); + $this->markDirty($sourceDir); $this->markDirty($destinationDir); diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index fc13e881bff..416e2f55426 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -61,6 +61,7 @@ class MDB2SchemaManager { $toSchema = $schemaReader->loadSchemaFromFile($file); // remove tables we don't know about + /** @var $table \Doctrine\DBAL\Schema\Table */ foreach($fromSchema->getTables() as $table) { if (!$toSchema->hasTable($table->getName())) { $fromSchema->dropTable($table->getName()); @@ -77,11 +78,10 @@ class MDB2SchemaManager { $schemaDiff = $comparator->compare($fromSchema, $toSchema); $platform = $this->conn->getDatabasePlatform(); - $tables = $schemaDiff->newTables + $schemaDiff->changedTables + $schemaDiff->removedTables; - foreach($tables as $tableDiff) { + foreach($schemaDiff->changedTables as $tableDiff) { $tableDiff->name = $platform->quoteIdentifier($tableDiff->name); } - + if ($generateSql) { return $this->generateChangeScript($schemaDiff); } @@ -110,6 +110,7 @@ class MDB2SchemaManager { $schemaReader = new MDB2SchemaReader(\OC_Config::getObject(), $this->conn->getDatabasePlatform()); $fromSchema = $schemaReader->loadSchemaFromFile($file); $toSchema = clone $fromSchema; + /** @var $table \Doctrine\DBAL\Schema\Table */ foreach($toSchema->getTables() as $table) { $toSchema->dropTable($table->getName()); } diff --git a/lib/public/appframework/http/http.php b/lib/public/appframework/http.php index 9eafe782726..c05d8f8e46e 100644 --- a/lib/public/appframework/http/http.php +++ b/lib/public/appframework/http.php @@ -22,7 +22,7 @@ */ -namespace OCP\AppFramework\Http; +namespace OCP\AppFramework; class Http { diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php index 085fdbed2f9..fa7d32596e8 100644 --- a/lib/public/appframework/http/jsonresponse.php +++ b/lib/public/appframework/http/jsonresponse.php @@ -24,6 +24,7 @@ namespace OCP\AppFramework\Http; +use OCP\AppFramework\Http; /** * A renderer for JSON calls diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php index 5ca389b9946..54dc860fec2 100644 --- a/lib/public/appframework/http/response.php +++ b/lib/public/appframework/http/response.php @@ -24,6 +24,7 @@ namespace OCP\AppFramework\Http; +use OCP\AppFramework\Http; /** * Base class for responses. Also used to just send headers. diff --git a/tests/lib/appframework/http/DispatcherTest.php b/tests/lib/appframework/http/DispatcherTest.php index 9052fe0781a..6cf0da879ff 100644 --- a/tests/lib/appframework/http/DispatcherTest.php +++ b/tests/lib/appframework/http/DispatcherTest.php @@ -26,7 +26,7 @@ namespace OC\AppFramework\Http; use OC\AppFramework\Core\API; use OC\AppFramework\Middleware\MiddlewareDispatcher; - +use OCP\AppFramework\Http; //require_once(__DIR__ . "/../classloader.php"); @@ -53,7 +53,7 @@ class DispatcherTest extends \PHPUnit_Framework_TestCase { ->disableOriginalConstructor() ->getMock(); $this->http = $this->getMockBuilder( - '\OC\AppFramework\Http\Http') + '\OC\AppFramework\Http') ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/appframework/http/HttpTest.php b/tests/lib/appframework/http/HttpTest.php index 382d511b116..0bdcee24c99 100644 --- a/tests/lib/appframework/http/HttpTest.php +++ b/tests/lib/appframework/http/HttpTest.php @@ -24,6 +24,7 @@ namespace OC\AppFramework\Http; +use OC\AppFramework\Http; //require_once(__DIR__ . "/../classloader.php"); diff --git a/tests/lib/appframework/http/RedirectResponseTest.php b/tests/lib/appframework/http/RedirectResponseTest.php index 1946655b0fa..f82d0c3a675 100644 --- a/tests/lib/appframework/http/RedirectResponseTest.php +++ b/tests/lib/appframework/http/RedirectResponseTest.php @@ -24,6 +24,7 @@ namespace OC\AppFramework\Http; +use OCP\AppFramework\Http; //require_once(__DIR__ . "/../classloader.php"); diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php index 7e09086f801..1a38c38c1e7 100644 --- a/tests/lib/appframework/http/ResponseTest.php +++ b/tests/lib/appframework/http/ResponseTest.php @@ -25,7 +25,8 @@ namespace OC\AppFramework\Http; -use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http\Response, + OCP\AppFramework\Http; class ResponseTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php index 4bfd725ffd0..dae6135dc54 100644 --- a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php +++ b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php @@ -24,7 +24,7 @@ namespace OC\AppFramework\Middleware\Security; -use OC\AppFramework\Http\Http; +use OC\AppFramework\Http; use OC\AppFramework\Http\Request; use OC\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\JSONResponse; |