diff options
52 files changed, 669 insertions, 334 deletions
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index 421bb563c0e..81f0715c288 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -46,6 +46,7 @@ </value> </option> <option name="USE_PER_PROJECT_SETTINGS" value="true" /> + <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" /> </component> </project> diff --git a/3rdparty b/3rdparty -Subproject 554277edd6155ca3f5b21e32fe16b818d7fb827 +Subproject 045dde529e050316788a63cd0067a38bbc6921b diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index c1baee4f1ef..92c76183876 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -36,9 +36,9 @@ $server->setBaseUri($baseuri); // Load plugins $defaults = new OC_Defaults(); -$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, $defaults->getName())); -$server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); -$server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); +$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName())); +$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend)); +$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload $server->addPlugin(new OC_Connector_Sabre_FilesPlugin()); $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav')); diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index f299116ff23..84db54ff30b 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -238,14 +238,14 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { $objectTree->init($publicDir, $view); // Fire up server - $server = new Sabre_DAV_Server($publicDir); + $server = new \Sabre\DAV\Server($publicDir); $server->httpRequest = $requestBackend; $server->setBaseUri('/remote.php/webdav/'); // Load plugins - $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); - $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); - $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload + $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')); + $server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend)); + $server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); $server->debugExceptions = true; diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index dc98dcfb808..3ea2db0656d 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -17,7 +17,7 @@ class DAV extends \OC\Files\Storage\Common { private $certPath; private $ready; /** - * @var \Sabre_DAV_Client + * @var \Sabre\DAV\Client */ private $client; @@ -71,7 +71,7 @@ class DAV extends \OC\Files\Storage\Common { 'password' => $this->password, ); - $this->client = new \Sabre_DAV_Client($settings); + $this->client = new \Sabre\DAV\Client($settings); if ($this->secure === true && $this->certPath) { $this->client->addTrustedCertificates($this->certPath); @@ -252,7 +252,7 @@ class DAV extends \OC\Files\Storage\Common { if ($this->file_exists($path)) { try { $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime)); - } catch (\Sabre_DAV_Exception_NotImplemented $e) { + } catch (\Sabre\DAV\Exception\NotImplemented $e) { return false; } } else { diff --git a/apps/files_sharing/app/sharing.php b/apps/files_sharing/app/sharing.php new file mode 100644 index 00000000000..427269755b9 --- /dev/null +++ b/apps/files_sharing/app/sharing.php @@ -0,0 +1,25 @@ +<?php + +namespace OCA\Files_Sharing\App; + +use \OCP\AppFramework\App; +use \OCA\Files_Sharing\Controller\AdminSettingsController; + +class Sharing extends App { + + public function __construct(array $urlParams=array()){ + parent::__construct('files_sharing', $urlParams); + + $container = $this->getContainer(); + + /** + * Controllers + */ + $container->registerService('AdminSettingsController', function($c) { + return new AdminSettingsController( + $c->query('AppName'), + $c->query('Request') + ); + }); + } +} diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 21b2646c5ea..81f91b60d30 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -21,6 +21,9 @@ OCP\Util::addScript('files_sharing', 'share'); \OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook'); \OC_Hook::connect('OC_Appconfig', 'post_set_value', '\OCA\Files\Share\Maintainer', 'configChangeHook'); +// Register settings scripts for mail template editing +OCP\App::registerAdmin('files_sharing', 'settings-admin'); + OC_FileProxy::register(new OCA\Files\Share\Proxy()); \OCA\Files\App::getNavigationManager()->add( diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 7c2834dc9c2..5b6286e2bfb 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -5,6 +5,21 @@ $this->create('core_ajax_public_preview', '/publicpreview')->action( require_once __DIR__ . '/../ajax/publicpreview.php'; }); +use \OCA\Files_Sharing\App\Sharing; + +$app = new Sharing(); + +$app->registerRoutes($this, array('routes' => array( + + // mailTemplate settings + array('name' => 'admin_settings#render', 'url' => '/settings/mailtemplate', 'verb' => 'GET'), + + array('name' => 'admin_settings#update', 'url' => '/settings/mailtemplate', 'verb' => 'POST'), + + array('name' => 'admin_settings#reset', 'url' => '/settings/mailtemplate', 'verb' => 'DELETE') + +))); + // OCS API //TODO: SET: mail notification, waiting for PR #4689 to be accepted diff --git a/apps/files_sharing/controller/adminsettingscontroller.php b/apps/files_sharing/controller/adminsettingscontroller.php new file mode 100644 index 00000000000..fed3147a99c --- /dev/null +++ b/apps/files_sharing/controller/adminsettingscontroller.php @@ -0,0 +1,60 @@ +<?php + +namespace OCA\Files_Sharing\Controller; + +use \OCP\AppFramework\ApiController; +use \OCP\IRequest; +use \OCP\AppFramework\Http\JSONResponse; + +class AdminSettingsController extends ApiController { + + public function __construct($appName, IRequest $request) { + parent::__construct($appName, $request); + } + + /** + * @param string $theme + * @param string $template + * @return \OCA\Files_Sharing\Http\MailTemplateResponse + */ + public function render( $theme, $template ) { + try { + $template = new \OCA\Files_Sharing\MailTemplate( $theme, $template ); + return $template->getResponse(); + } catch (\Exception $ex) { + return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode()); + } + } + + /** + * @param string $theme + * @param string $template + * @param string $content + * @return JSONResponse + */ + public function update( $theme, $template, $content ) { + try { + $template = new \OCA\Files_Sharing\MailTemplate( $theme, $template ); + $template->setContent( $content ); + return new JSONResponse(); + } catch (\Exception $ex) { + return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode()); + } + } + + /** + * @param string $theme + * @param string $template + * @return JSONResponse + */ + public function reset( $theme, $template ) { + try { + $template = new \OCA\Files_Sharing\MailTemplate( $theme, $template ); + $template->reset(); + return new JSONResponse(); + } catch (\Exception $ex) { + return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode()); + } + } + +} diff --git a/apps/files_sharing/css/settings-admin.css b/apps/files_sharing/css/settings-admin.css new file mode 100644 index 00000000000..7ee71963436 --- /dev/null +++ b/apps/files_sharing/css/settings-admin.css @@ -0,0 +1,33 @@ +#mailTemplateSettings .actions div { + display: inline-block; +} + +#mailTemplateSettings div label { + display: block +} + +#mailTemplateSettings textarea { + box-sizing: border-box; + width: 100%; + height: 150px; +} + +#mailTemplateSettings .templateEditor + .actions { + height:28px; +} + + +#mailTemplateSettings .actions .reset { + margin: 0; +} + +#mailTemplateSettings .actions .save { + float: right; + margin: 0; +} + +#mailTemplateSettings #mts-msg { + float: right; + margin: 1px 5px; + padding:3px; +} diff --git a/apps/files_sharing/http/mailtemplateresponse.php b/apps/files_sharing/http/mailtemplateresponse.php new file mode 100644 index 00000000000..98a2dfcc94e --- /dev/null +++ b/apps/files_sharing/http/mailtemplateresponse.php @@ -0,0 +1,55 @@ +<?php + +/** + * ownCloud - App Framework + * + * @author Jörn Dreyer + * @copyright 2014 Jörn Dreyer <jfd@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/>. + * + */ + +namespace OCA\Files_Sharing\Http; + +/** + * Prompts the user to download the a file + */ +class MailTemplateResponse extends \OCP\AppFramework\Http\Response { + + private $filename; + private $contentType; + + /** + * Creates a response that prompts the user to download the file + * @param string $filename the name that the downloaded file should have + * @param string $contentType the mimetype that the downloaded file should have + */ + public function __construct($filename, $contentType = 'text/php') { + $this->filename = $filename; + $this->contentType = $contentType; + + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $this->addHeader('Content-Type', $contentType); + } + + /** + * Returns the raw template content + * @return string the file + */ + public function render(){ + return file_get_contents($this->filename); + } + +} diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js new file mode 100644 index 00000000000..fa9b236ea98 --- /dev/null +++ b/apps/files_sharing/js/settings-admin.js @@ -0,0 +1,78 @@ +$(document).ready(function() { + + var loadTemplate = function (theme, template) { + $.get( + OC.generateUrl('apps/files_sharing/settings/mailtemplate'), + { theme: theme, template: template } + ).done(function( result ) { + $( '#mailTemplateSettings textarea' ).val(result); + }).fail(function( result ) { + OC.dialogs.alert(result.message, t('files_sharing', 'Could not load template')); + }); + }; + + // load default template + var theme = $( '#mts-theme' ).val(); + var template = $( '#mts-template' ).val(); + loadTemplate(theme, template); + + $( '#mts-template' ).change( + function() { + var theme = $( '#mts-theme' ).val(); + var template = $( this ).val(); + loadTemplate(theme, template); + } + ); + + $( '#mts-theme' ).change( + function() { + var theme = $( this ).val(); + var template = $( '#mts-template' ).val(); + loadTemplate(theme, template); + } + ); + + $( '#mailTemplateSettings .actions' ).on('click', '.save', + function() { + var theme = $( '#mts-theme' ).val(); + var template = $( '#mts-template' ).val(); + var content = $( '#mailTemplateSettings textarea' ).val(); + OC.msg.startSaving('#mts-msg'); + $.post( + OC.generateUrl('apps/files_sharing/settings/mailtemplate'), + { theme: theme, template: template, content: content } + ).done(function() { + var data = { status:'success', data:{message:t('files_sharing', 'Saved')} }; + OC.msg.finishedSaving('#mts-msg', data); + }).fail(function(result) { + var data = { status: 'error', data:{message:result.responseJSON.message} }; + OC.msg.finishedSaving('#mts-msg', data); + }); + } + ); + + $( '#mailTemplateSettings .actions' ).on('click', '.reset', + function() { + var theme = $( '#mts-theme' ).val(); + var template = $( '#mts-template' ).val(); + OC.msg.startSaving('#mts-msg'); + $.ajax({ + type: "DELETE", + url: OC.generateUrl('apps/files_sharing/settings/mailtemplate'), + data: { theme: theme, template: template } + }).done(function() { + var data = { status:'success', data:{message:t('files_sharing', 'Reset')} }; + OC.msg.finishedSaving('#mts-msg', data); + + // load default template + var theme = $( '#mts-theme' ).val(); + var template = $( '#mts-template' ).val(); + loadTemplate(theme, template); + }).fail(function(result) { + var data = { status: 'error', data:{message:result.responseJSON.message} }; + OC.msg.finishedSaving('#mts-msg', data); + }); + } + ); + +}); diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index dc4e5cf6c49..c4f761f9153 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -337,6 +337,7 @@ class Api { return self::updatePublicUpload($share, $params); } } catch (\Exception $e) { + return new \OC_OCS_Result(null, 400, $e->getMessage()); } diff --git a/apps/files_sharing/lib/connector/publicauth.php b/apps/files_sharing/lib/connector/publicauth.php index 0831129ce79..ec7b68ba69c 100644 --- a/apps/files_sharing/lib/connector/publicauth.php +++ b/apps/files_sharing/lib/connector/publicauth.php @@ -9,7 +9,7 @@ namespace OCA\Files_Sharing\Connector; -class PublicAuth extends \Sabre_DAV_Auth_Backend_AbstractBasic { +class PublicAuth extends \Sabre\DAV\Auth\Backend\AbstractBasic { /** * @var \OCP\IConfig diff --git a/apps/files_sharing/lib/mailtemplate.php b/apps/files_sharing/lib/mailtemplate.php new file mode 100644 index 00000000000..ca1b0234ccf --- /dev/null +++ b/apps/files_sharing/lib/mailtemplate.php @@ -0,0 +1,126 @@ +<?php + +namespace OCA\Files_Sharing; + +use \OCP\Files\NotPermittedException; +use \OC\AppFramework\Middleware\Security\SecurityException; +use OCA\Files_Sharing\Http\MailTemplateResponse; + +class MailTemplate extends \OC_Template { + + private $path; + private $theme; + private $editableThemes; + private $editableTemplates; + + public function __construct($theme, $path) { + $this->theme = $theme; + $this->path = $path; + + //determine valid theme names + $this->editableThemes = self::getEditableThemes(); + //for now hard code the valid mail template paths + $this->editableTemplates = self::getEditableTemplates(); + } + + /** + * + * @return \OCA\Files_Sharing\Http\MailTemplateResponse + */ + public function getResponse() { + if($this->isEditable()) { + list($app, $filename) = explode('/templates/', $this->path, 2); + $name = substr($filename, 0, -4); + list($path, $template) = $this->findTemplate($this->theme, $app, $name, ''); + return new MailTemplateResponse($template); + } + throw new SecurityException('Template not editable.', 403); + } + + public function renderContent() { + if($this->isEditable()) { + list($app, $filename) = explode('/templates/', $this->path, 2); + $name = substr($filename, 0, -4); + list($path, $template) = $this->findTemplate($this->theme, $app, $name, ''); + \OC_Response::sendFile($template); + } else { + throw new SecurityException('Template not editable.', 403); + } + } + + public function isEditable() { + if ($this->editableThemes[$this->theme] + && $this->editableTemplates[$this->path] + ) { + return true; + } + return false; + } + + public function setContent($data) { + if($this->isEditable()) { + //save default templates in default folder to overwrite core template + $absolutePath = \OC::$SERVERROOT.'/themes/'.$this->theme.'/'.$this->path; + $parent = dirname($absolutePath); + if ( ! is_dir($parent) ) { + if ( ! mkdir(dirname($absolutePath), 0777, true) ){ + throw new \Exception('Could not create directory.', 500); + } + } + if ( $this->theme !== 'default' && is_file($absolutePath) ) { + if ( ! copy($absolutePath, $absolutePath.'.bak') ){ + throw new \Exception('Could not overwrite template.', 500); + } + } + //overwrite theme templates? versioning? + return file_put_contents($absolutePath, $data); + } + throw new SecurityException('Template not editable.', 403); + } + + public function reset(){ + if($this->isEditable()) { + $absolutePath = \OC::$SERVERROOT.'/themes/'.$this->theme.'/'.$this->path; + if ($this->theme === 'default') { + //templates can simply be deleted in the themes folder + if (unlink($absolutePath)) { + return true; + } + } else { + //if a bak file exists overwrite the template with it + if (is_file($absolutePath.'.bak')) { + if (rename($absolutePath.'.bak', $absolutePath)) { + return true; + } + } + } + return false; + } + throw new NotPermittedException('Template not editable.', 403); + } + + public static function getEditableThemes() { + $themes = array( + 'default' => true + ); + if ($handle = opendir(\OC::$SERVERROOT.'/themes')) { + while (false !== ($entry = readdir($handle))) { + if ($entry != '.' && $entry != '..' && $entry != 'default') { + if (is_dir(\OC::$SERVERROOT.'/themes/'.$entry)) { + $themes[$entry] = true; + } + } + } + closedir($handle); + } + return $themes; + } + + public static function getEditableTemplates() { + return array( + 'core/templates/mail.php' => true, + 'core/templates/altmail.php' => true, + 'core/lostpassword/templates/email.php' => true, + ); + } +} diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php index 954c3a3144d..df2c04cf45c 100644 --- a/apps/files_sharing/publicwebdav.php +++ b/apps/files_sharing/publicwebdav.php @@ -26,9 +26,9 @@ $server->setBaseUri($baseuri); // Load plugins $defaults = new OC_Defaults(); -$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, $defaults->getName())); -$server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); -$server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload +$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName())); +$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend)); +$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload $server->addPlugin(new OC_Connector_Sabre_FilesPlugin()); $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav')); diff --git a/apps/files_sharing/settings-admin.php b/apps/files_sharing/settings-admin.php new file mode 100644 index 00000000000..8f15e272312 --- /dev/null +++ b/apps/files_sharing/settings-admin.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright (c) 2011 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +\OC_Util::checkAdminUser(); + +\OCP\Util::addStyle('files_sharing', 'settings-admin'); +\OCP\Util::addScript('files_sharing', 'settings-admin'); + +$themes = \OCA\Files_Sharing\MailTemplate::getEditableThemes(); +$editableTemplates = \OCA\Files_Sharing\MailTemplate::getEditableTemplates(); + +$tmpl = new OCP\Template('files_sharing', 'settings-admin'); +$tmpl->assign('themes', $themes); +$tmpl->assign('editableTemplates', $editableTemplates); + +return $tmpl->fetchPage(); diff --git a/apps/files_sharing/templates/settings-admin.php b/apps/files_sharing/templates/settings-admin.php new file mode 100644 index 00000000000..4021be871cd --- /dev/null +++ b/apps/files_sharing/templates/settings-admin.php @@ -0,0 +1,41 @@ +<div class="section" id="mailTemplateSettings" > + + <h2><?php p($l->t('Mail templates'));?></h2> + + <div class="actions"> + + <div> + <label for="mts-theme"><?php p($l->t('Theme'));?></label> + <select id="mts-theme"> + <?php foreach($_['themes'] as $theme => $editable): ?> + <option><?php p($theme); ?></option> + <?php endforeach; ?> + </select> + </div> + + <div> + <label for="mts-template"><?php p($l->t('Template'));?></label> + <select id="mts-template"> + <?php foreach($_['editableTemplates'] as $template => $editable): ?> + <option><?php p($template); ?></option> + <?php endforeach; ?> + </select> + </div> + + </div> + + <div class="templateEditor"> + <textarea></textarea> + </div> + + <div class="actions"> + + <button class="reset"><?php p($l->t('Reset'));?></button> + + <button class="save"><?php p($l->t('Save'));?></button> + + <span id="mts-msg" class="msg"></span> + + </div> + +</div> diff --git a/apps/files_trashbin/appinfo/update.php b/apps/files_trashbin/appinfo/update.php index ca7b87a8681..191d3cf25d9 100644 --- a/apps/files_trashbin/appinfo/update.php +++ b/apps/files_trashbin/appinfo/update.php @@ -5,6 +5,5 @@ $installedVersion=OCP\Config::getAppValue('files_trashbin', 'installed_version') if (version_compare($installedVersion, '0.6', '<')) { //size of the trash bin could be incorrect, remove it for all users to //enforce a recalculation during next usage. - $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trashsize`'); - $result = $query->execute(); + \OC_DB::dropTable('files_trashsize'); } diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index fb23b516208..a8e66b06bbd 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -905,12 +905,12 @@ class Trashbin { * get current size of trash bin from a given user * * @param string $user user who owns the trash bin - * @return mixed trash bin size or false if no trash bin size is stored + * @return integer trash bin size */ private static function getTrashbinSize($user) { $view = new \OC\Files\View('/' . $user); $fileInfo = $view->getFileInfo('/files_trashbin'); - return $fileInfo['size']; + return isset($fileInfo['size']) ? $fileInfo['size'] : 0; } /** diff --git a/apps/files_versions/appinfo/database.xml b/apps/files_versions/appinfo/database.xml deleted file mode 100644 index d3854776980..00000000000 --- a/apps/files_versions/appinfo/database.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<database> - - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*files_versions</name> - - <declaration> - - <field> - <name>user</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - <field> - <name>size</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>50</length> - </field> - - </declaration> - - </table> - -</database> diff --git a/apps/files_versions/appinfo/update.php b/apps/files_versions/appinfo/update.php index 52a4850758a..fdc6b1e5f1b 100644 --- a/apps/files_versions/appinfo/update.php +++ b/apps/files_versions/appinfo/update.php @@ -2,14 +2,6 @@ $installedVersion=OCP\Config::getAppValue('files_versions', 'installed_version'); // move versions to new directory -if (version_compare($installedVersion, '1.0.2', '<')) { - $users = \OCP\User::getUsers(); - $datadir = \OCP\Config::getSystemValue('datadirectory').'/'; - foreach ($users as $user) { - $oldPath = $datadir.$user.'/versions'; - $newPath = $datadir.$user.'/files_versions'; - if(is_dir($oldPath)) { - rename($oldPath, $newPath); - } - } +if (version_compare($installedVersion, '1.0.4', '<')) { + \OC_DB::dropTable("files_versions"); } diff --git a/apps/files_versions/appinfo/version b/apps/files_versions/appinfo/version index e4c0d46e55f..ee90284c27f 100644 --- a/apps/files_versions/appinfo/version +++ b/apps/files_versions/appinfo/version @@ -1 +1 @@ -1.0.3
\ No newline at end of file +1.0.4 diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 56e1dfc2e24..15d0e032ea0 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -54,31 +54,12 @@ class Storage { * get current size of all versions from a given user * * @param string $user user who owns the versions - * @return mixed versions size or false if no versions size is stored + * @return int versions size */ private static function getVersionsSize($user) { - $query = \OC_DB::prepare('SELECT `size` FROM `*PREFIX*files_versions` WHERE `user`=?'); - $result = $query->execute(array($user))->fetchAll(); - - if ($result) { - return $result[0]['size']; - } - return false; - } - - /** - * write to the database how much space is in use for versions - * - * @param string $user owner of the versions - * @param int $size size of the versions - */ - private static function setVersionsSize($user, $size) { - if ( self::getVersionsSize($user) === false) { - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*files_versions` (`size`, `user`) VALUES (?, ?)'); - }else { - $query = \OC_DB::prepare('UPDATE `*PREFIX*files_versions` SET `size`=? WHERE `user`=?'); - } - $query->execute(array($size, $user)); + $view = new \OC\Files\View('/' . $user); + $fileInfo = $view->getFileInfo('/files_versions'); + return isset($fileInfo['size']) ? $fileInfo['size'] : 0; } /** @@ -115,16 +96,13 @@ class Storage { self::createMissingDirectories($filename, $users_view); $versionsSize = self::getVersionsSize($uid); - if ( $versionsSize === false || $versionsSize < 0 ) { - $versionsSize = self::calculateSize($uid); - } // assumption: we need filesize($filename) for the new version + // some more free space for the modified file which might be // 1.5 times as large as the current version -> 2.5 $neededSpace = $files_view->filesize($filename) * 2.5; - $versionsSize = self::expire($filename, $versionsSize, $neededSpace); + self::expire($filename, $versionsSize, $neededSpace); // disable proxy to prevent multiple fopen calls $proxyStatus = \OC_FileProxy::$enabled; @@ -138,10 +116,6 @@ class Storage { // reset proxy state \OC_FileProxy::$enabled = $proxyStatus; - - $versionsSize += $users_view->filesize('files'.$filename); - - self::setVersionsSize($uid, $versionsSize); } } @@ -173,17 +147,11 @@ class Storage { $abs_path = $versions_fileview->getLocalFile($filename . '.v'); $versions = self::getVersions($uid, $filename); if (!empty($versions)) { - $versionsSize = self::getVersionsSize($uid); - if ($versionsSize === false || $versionsSize < 0) { - $versionsSize = self::calculateSize($uid); - } foreach ($versions as $v) { \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $abs_path . $v['version'])); unlink($abs_path . $v['version']); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $abs_path . $v['version'])); - $versionsSize -= $v['size']; } - self::setVersionsSize($uid, $versionsSize); } } unset(self::$deletedFiles[$path]); @@ -345,33 +313,6 @@ class Storage { } /** - * get the size of all stored versions from a given user - * @param string $uid id from the user - * @return int size of versions - */ - private static function calculateSize($uid) { - if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') { - $view = new \OC\Files\View('/' . $uid . '/files_versions'); - - $size = 0; - - $dirContent = $view->getDirectoryContent('/'); - - while (!empty($dirContent)) { - $path = reset($dirContent); - if ($path['type'] === 'dir') { - $dirContent = array_merge($dirContent, $view->getDirectoryContent(substr($path['path'], strlen('files_versions')))); - } else { - $size += $view->filesize(substr($path['path'], strlen('files_versions'))); - } - unset($dirContent[key($dirContent)]); - } - - return $size; - } - } - - /** * returns all stored file versions from a given user * @param string $uid id of the user * @return array with contains two arrays 'all' which contains all versions sorted by age and 'by_file' which contains all versions sorted by filename @@ -500,9 +441,6 @@ class Storage { // make sure that we have the current size of the version history if ( $versionsSize === null ) { $versionsSize = self::getVersionsSize($uid); - if ( $versionsSize === false || $versionsSize < 0 ) { - $versionsSize = self::calculateSize($uid); - } } // calculate available space for version history diff --git a/lib/private/connector/sabre/ServiceUnavailable.php b/lib/private/connector/sabre/ServiceUnavailable.php deleted file mode 100644 index c1cc815c989..00000000000 --- a/lib/private/connector/sabre/ServiceUnavailable.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * ownCloud - * - * @author Thomas Müller - * @copyright 2013 Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL3 - */ - -class Sabre_DAV_Exception_ServiceUnavailable extends Sabre_DAV_Exception { - - /** - * Returns the HTTP statuscode for this exception - * - * @return int - */ - public function getHTTPCode() { - - return 503; - } -} diff --git a/lib/private/connector/sabre/aborteduploaddetectionplugin.php b/lib/private/connector/sabre/aborteduploaddetectionplugin.php index 1a092a59a82..b569f9a83c3 100644 --- a/lib/private/connector/sabre/aborteduploaddetectionplugin.php +++ b/lib/private/connector/sabre/aborteduploaddetectionplugin.php @@ -12,12 +12,12 @@ * This plugin will verify if the uploaded data has been stored completely. * This is done by comparing the content length of the request with the file size on storage. */ -class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPlugin { +class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends \Sabre\DAV\ServerPlugin { /** * Reference to main server object * - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; @@ -36,14 +36,14 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl /** * This initializes the plugin. * - * This function is called by Sabre_DAV_Server, after + * This function is called by \Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the requires event subscriptions. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server */ - public function initialize(Sabre_DAV_Server $server) { + public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; @@ -53,10 +53,10 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl /** * @param string $filePath - * @param Sabre_DAV_INode $node - * @throws Sabre_DAV_Exception_BadRequest + * @param \Sabre\DAV\INode $node + * @throws \Sabre\DAV\Exception\BadRequest */ - public function verifyContentLength($filePath, Sabre_DAV_INode $node = null) { + public function verifyContentLength($filePath, \Sabre\DAV\INode $node = null) { // we should only react on PUT which is used for upload // e.g. with LOCK this will not work, but LOCK uses createFile() as well @@ -78,7 +78,7 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl $actual = $this->fileView->filesize($filePath); if ($actual != $expected) { $this->fileView->unlink($filePath); - throw new Sabre_DAV_Exception_BadRequest('expected filesize ' . $expected . ' got ' . $actual); + throw new \Sabre\DAV\Exception\BadRequest('expected filesize ' . $expected . ' got ' . $actual); } } diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php index 9ebf5fc05cf..b1ef698583d 100644 --- a/lib/private/connector/sabre/auth.php +++ b/lib/private/connector/sabre/auth.php @@ -21,7 +21,7 @@ * */ -class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { +class OC_Connector_Sabre_Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic { /** * Validates a username and password * @@ -69,11 +69,11 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { * even if there are no HTTP Basic Auth headers. * In other case, just fallback to the parent implementation. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @param $realm * @return bool */ - public function authenticate(Sabre_DAV_Server $server, $realm) { + public function authenticate(\Sabre\DAV\Server $server, $realm) { $result = $this->auth($server, $realm); @@ -84,11 +84,11 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { } /** - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @param $realm * @return bool */ - private function auth(Sabre_DAV_Server $server, $realm) { + private function auth(\Sabre\DAV\Server $server, $realm) { if (OC_User::handleApacheAuth() || OC_User::isLoggedIn()) { $user = OC_User::getUser(); OC_Util::setupFS($user); diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php index 1bb526e451e..aa467cec535 100644 --- a/lib/private/connector/sabre/directory.php +++ b/lib/private/connector/sabre/directory.php @@ -21,7 +21,8 @@ * */ -class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sabre_DAV_ICollection, Sabre_DAV_IQuota { +class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node + implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota { /** * Creates a new file in the directory @@ -45,7 +46,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * * @param string $name Name of the file * @param resource|string $data Initial payload - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\Forbidden * @return null|string */ public function createFile($name, $data = null) { @@ -58,13 +59,13 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $info = OC_FileChunking::decodeName($name); if (!$this->fileView->isCreatable($this->path) && !$this->fileView->isUpdatable($this->path . '/' . $info['name'])) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } } else { // For non-chunked upload it is enough to check if we can create a new file if (!$this->fileView->isCreatable($this->path)) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } } @@ -79,17 +80,17 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * Creates a new subdirectory * * @param string $name - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\Forbidden * @return void */ public function createDirectory($name) { if (!$this->fileView->isCreatable($this->path)) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } $newPath = $this->path . '/' . $name; if(!$this->fileView->mkdir($newPath)) { - throw new Sabre_DAV_Exception_Forbidden('Could not create directory '.$newPath); + throw new \Sabre\DAV\Exception\Forbidden('Could not create directory '.$newPath); } } @@ -99,8 +100,8 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * * @param string $name * @param \OCP\Files\FileInfo $info - * @throws Sabre_DAV_Exception_NotFound - * @return Sabre_DAV_INode + * @throws \Sabre\DAV\Exception\FileNotFound + * @return \Sabre\DAV\INode */ public function getChild($name, $info = null) { @@ -110,7 +111,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa } if (!$info) { - throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located'); + throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); } if ($info['mimetype'] == 'httpd/unix-directory') { @@ -124,7 +125,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa /** * Returns an array with all the child nodes * - * @return Sabre_DAV_INode[] + * @return \Sabre\DAV\INode[] */ public function getChildren() { @@ -183,12 +184,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * Deletes all files in this directory, and then itself * * @return void - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\Forbidden */ public function delete() { if (!$this->info->isDeletable()) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } $this->fileView->rmdir($this->path); diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php index 2bda51f2f3e..2524fbaa74c 100644 --- a/lib/private/connector/sabre/exception/entitytoolarge.php +++ b/lib/private/connector/sabre/exception/entitytoolarge.php @@ -6,7 +6,7 @@ * This exception is thrown whenever a user tries to upload a file which exceeds hard limitations * */ -class OC_Connector_Sabre_Exception_EntityTooLarge extends Sabre_DAV_Exception { +class OC_Connector_Sabre_Exception_EntityTooLarge extends \Sabre\DAV\Exception { /** * Returns the HTTP status code for this exception diff --git a/lib/private/connector/sabre/exception/filelocked.php b/lib/private/connector/sabre/exception/filelocked.php index ec200f847e3..59d932d22de 100644 --- a/lib/private/connector/sabre/exception/filelocked.php +++ b/lib/private/connector/sabre/exception/filelocked.php @@ -7,7 +7,7 @@ * */ -class OC_Connector_Sabre_Exception_FileLocked extends Sabre_DAV_Exception { +class OC_Connector_Sabre_Exception_FileLocked extends \Sabre\DAV\Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { if($previous instanceof \OCP\Files\LockNotAcquiredException) { diff --git a/lib/private/connector/sabre/exception/unsupportedmediatype.php b/lib/private/connector/sabre/exception/unsupportedmediatype.php index 95d6a8cc651..9b285196ebd 100644 --- a/lib/private/connector/sabre/exception/unsupportedmediatype.php +++ b/lib/private/connector/sabre/exception/unsupportedmediatype.php @@ -6,7 +6,7 @@ * This exception is thrown whenever a user tries to upload a file which holds content which is not allowed * */ -class OC_Connector_Sabre_Exception_UnsupportedMediaType extends Sabre_DAV_Exception { +class OC_Connector_Sabre_Exception_UnsupportedMediaType extends \Sabre\DAV\Exception { /** * Returns the HTTP status code for this exception diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php index 5eaf1e87621..5963123709b 100644 --- a/lib/private/connector/sabre/exceptionloggerplugin.php +++ b/lib/private/connector/sabre/exceptionloggerplugin.php @@ -9,17 +9,17 @@ * @license AGPL3 */ -class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin +class OC_Connector_Sabre_ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { private $nonFatalExceptions = array( - 'Sabre_DAV_Exception_NotAuthenticated' => true, + 'Sabre\DAV\Exception\NotAuthenticated' => true, // the sync client uses this to find out whether files exist, // so it is not always an error, log it as debug - 'Sabre_DAV_Exception_NotFound' => true, + 'Sabre\DAV\Exception\NotFound' => true, // this one mostly happens when the same file is uploaded at // exactly the same time from two clients, only one client // wins, the second one gets "Precondition failed" - 'Sabre_DAV_Exception_PreconditionFailed' => true, + 'Sabre\DAV\Exception\PreconditionFailed' => true, ); private $appName; @@ -34,15 +34,15 @@ class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin /** * This initializes the plugin. * - * This function is called by Sabre_DAV_Server, after + * This function is called by \Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the required event subscriptions. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @return void */ - public function initialize(Sabre_DAV_Server $server) { + public function initialize(\Sabre\DAV\Server $server) { $server->subscribeEvent('exception', array($this, 'logException'), 10); } diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 48287b1e503..4e90d46ad41 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -21,7 +21,7 @@ * */ -class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_DAV_IFile { +class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\DAV\IFile { /** * Updates the data @@ -41,28 +41,28 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D * return an ETag, and just return null. * * @param resource $data - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\Forbidden * @throws OC_Connector_Sabre_Exception_UnsupportedMediaType - * @throws Sabre_DAV_Exception_BadRequest - * @throws Sabre_DAV_Exception + * @throws \Sabre\DAV\Exception\BadRequest + * @throws \Sabre\DAV\Exception * @throws OC_Connector_Sabre_Exception_EntityTooLarge - * @throws Sabre_DAV_Exception_ServiceUnavailable + * @throws \Sabre\DAV\Exception\ServiceUnavailable * @return string|null */ public function put($data) { if ($this->info && $this->fileView->file_exists($this->path) && !$this->info->isUpdateable()) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } // throw an exception if encryption was disabled but the files are still encrypted if (\OC_Util::encryptedFiles()) { - throw new \Sabre_DAV_Exception_ServiceUnavailable(); + throw new \Sabre\DAV\Exception\ServiceUnavailable(); } $fileName = basename($this->path); if (!\OCP\Util::isValidFileName($fileName)) { - throw new \Sabre_DAV_Exception_BadRequest(); + throw new \Sabre\DAV\Exception\BadRequest(); } // chunked handling @@ -79,11 +79,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); $this->fileView->unlink($partpath); // because we have no clue about the cause we can only throw back a 500/Internal Server Error - throw new Sabre_DAV_Exception('Could not write file contents'); + throw new \Sabre\DAV\Exception('Could not write file contents'); } } catch (\OCP\Files\NotPermittedException $e) { // a more general case - due to whatever reason the content could not be written - throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); + throw new \Sabre\DAV\Exception\Forbidden($e->getMessage()); } catch (\OCP\Files\EntityTooLargeException $e) { // the file is too big to be stored @@ -96,7 +96,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D } catch (\OCP\Files\InvalidPathException $e) { // the path for the file was not valid // TODO: find proper http status code for this case - throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); + throw new \Sabre\DAV\Exception\Forbidden($e->getMessage()); } catch (\OCP\Files\LockNotAcquiredException $e) { // the file is currently being written to by another process throw new OC_Connector_Sabre_Exception_FileLocked($e->getMessage(), $e->getCode(), $e); @@ -109,7 +109,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D if ($renameOkay === false || $fileExists === false) { \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); $this->fileView->unlink($partpath); - throw new Sabre_DAV_Exception('Could not rename part file to final file'); + throw new \Sabre\DAV\Exception('Could not rename part file to final file'); } } catch (\OCP\Files\LockNotAcquiredException $e) { @@ -138,7 +138,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D //throw exception if encryption is disabled but files are still encrypted if (\OC_Util::encryptedFiles()) { - throw new \Sabre_DAV_Exception_ServiceUnavailable(); + throw new \Sabre\DAV\Exception\ServiceUnavailable(); } else { return $this->fileView->fopen($this->path, 'rb'); } @@ -149,11 +149,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D * Delete the current file * * @return void - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\Forbidden */ public function delete() { if (!$this->info->isDeletable()) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } $this->fileView->unlink($this->path); @@ -205,11 +205,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D */ private function createFileChunked($data) { - list($path, $name) = \Sabre_DAV_URLUtil::splitPath($this->path); + list($path, $name) = \Sabre\DAV\URLUtil::splitPath($this->path); $info = OC_FileChunking::decodeName($name); if (empty($info)) { - throw new Sabre_DAV_Exception_NotImplemented(); + throw new \Sabre\DAV\Exception\NotImplemented(); } $chunk_handler = new OC_FileChunking($info); $bytesWritten = $chunk_handler->store($info['index'], $data); @@ -220,7 +220,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D $expected = $_SERVER['CONTENT_LENGTH']; if ($bytesWritten != $expected) { $chunk_handler->remove($info['index']); - throw new Sabre_DAV_Exception_BadRequest( + throw new \Sabre\DAV\Exception\BadRequest( 'expected filesize ' . $expected . ' got ' . $bytesWritten); } } @@ -242,7 +242,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D if ($fileExists) { $this->fileView->unlink($targetPath); } - throw new Sabre_DAV_Exception('Could not rename part file assembled from chunks'); + throw new \Sabre\DAV\Exception('Could not rename part file assembled from chunks'); } // allow sync clients to send the mtime along in a header diff --git a/lib/private/connector/sabre/filesplugin.php b/lib/private/connector/sabre/filesplugin.php index 25d7fd53343..871fac88e68 100644 --- a/lib/private/connector/sabre/filesplugin.php +++ b/lib/private/connector/sabre/filesplugin.php @@ -9,7 +9,7 @@ * @license AGPL3 */ -class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin +class OC_Connector_Sabre_FilesPlugin extends \Sabre\DAV\ServerPlugin { // namespace @@ -18,22 +18,22 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin /** * Reference to main server object * - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; /** * This initializes the plugin. * - * This function is called by Sabre_DAV_Server, after + * This function is called by \Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the required event subscriptions. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @return void */ - public function initialize(Sabre_DAV_Server $server) { + public function initialize(\Sabre\DAV\Server $server) { $server->xmlNamespaces[self::NS_OWNCLOUD] = 'oc'; $server->protectedProperties[] = '{' . self::NS_OWNCLOUD . '}id'; @@ -49,12 +49,12 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin * Adds all ownCloud-specific properties * * @param string $path - * @param Sabre_DAV_INode $node + * @param \Sabre\DAV\INode $node * @param array $requestedProperties * @param array $returnedProperties * @return void */ - public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) { + public function beforeGetProperties($path, \Sabre\DAV\INode $node, array &$requestedProperties, array &$returnedProperties) { if ($node instanceof OC_Connector_Sabre_Node) { @@ -84,13 +84,13 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin /** * @param string $filePath - * @param Sabre_DAV_INode $node - * @throws Sabre_DAV_Exception_BadRequest + * @param \Sabre\DAV\INode $node + * @throws \Sabre\DAV\Exception\BadRequest */ - public function sendFileIdHeader($filePath, Sabre_DAV_INode $node = null) { + public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) { // chunked upload handling if (isset($_SERVER['HTTP_OC_CHUNKED'])) { - list($path, $name) = \Sabre_DAV_URLUtil::splitPath($filePath); + list($path, $name) = \Sabre\DAV\URLUtil::splitPath($filePath); $info = OC_FileChunking::decodeName($name); if (!empty($info)) { $filePath = $path . '/' . $info['name']; diff --git a/lib/private/connector/sabre/locks.php b/lib/private/connector/sabre/locks.php index 69496c15ada..09bf874ec70 100644 --- a/lib/private/connector/sabre/locks.php +++ b/lib/private/connector/sabre/locks.php @@ -21,10 +21,10 @@ * */ -class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { +class OC_Connector_Sabre_Locks extends \Sabre\DAV\Locks\Backend\AbstractBackend { /** - * Returns a list of Sabre_DAV_Locks_LockInfo objects + * Returns a list of \Sabre\DAV\Locks_LockInfo objects * * This method should return all the locks for a particular uri, including * locks that might be set on a parent uri. @@ -93,7 +93,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { $lockList = array(); while( $row = $result->fetchRow()) { - $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo = new \Sabre\DAV\Locks\LockInfo(); $lockInfo->owner = $row['owner']; $lockInfo->token = $row['token']; $lockInfo->timeout = $row['timeout']; @@ -113,10 +113,10 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { * Locks a uri * * @param string $uri - * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @param \Sabre\DAV\Locks\LockInfo $lockInfo * @return bool */ - public function lock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) { + public function lock($uri, \Sabre\DAV\Locks\LockInfo $lockInfo) { // We're making the lock timeout 5 minutes $lockInfo->timeout = 300; @@ -170,10 +170,10 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { * Removes a lock from a uri * * @param string $uri - * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @param \Sabre\DAV\Locks\LockInfo $lockInfo * @return bool */ - public function unlock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) { + public function unlock($uri, \Sabre\DAV\Locks\LockInfo $lockInfo) { $sql = 'DELETE FROM `*PREFIX*locks` WHERE `userid` = ? AND `uri` = ? AND `token` = ?'; if (OC_Config::getValue( "dbtype") === 'oci') { diff --git a/lib/private/connector/sabre/maintenanceplugin.php b/lib/private/connector/sabre/maintenanceplugin.php index 2eda269afc2..0208f3fb5a6 100644 --- a/lib/private/connector/sabre/maintenanceplugin.php +++ b/lib/private/connector/sabre/maintenanceplugin.php @@ -9,30 +9,28 @@ * @license AGPL3 */ -require 'ServiceUnavailable.php'; - -class OC_Connector_Sabre_MaintenancePlugin extends Sabre_DAV_ServerPlugin +class OC_Connector_Sabre_MaintenancePlugin extends \Sabre\DAV\ServerPlugin { /** * Reference to main server object * - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; /** * This initializes the plugin. * - * This function is called by Sabre_DAV_Server, after + * This function is called by \Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the required event subscriptions. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @return void */ - public function initialize(Sabre_DAV_Server $server) { + public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; $this->server->subscribeEvent('beforeMethod', array($this, 'checkMaintenanceMode'), 10); @@ -42,16 +40,16 @@ class OC_Connector_Sabre_MaintenancePlugin extends Sabre_DAV_ServerPlugin * This method is called before any HTTP method and returns http status code 503 * in case the system is in maintenance mode. * - * @throws Sabre_DAV_Exception_ServiceUnavailable + * @throws \Sabre\DAV\Exception\ServiceUnavailable * @internal param string $method * @return bool */ public function checkMaintenanceMode() { if (OC_Config::getValue('maintenance', false)) { - throw new Sabre_DAV_Exception_ServiceUnavailable(); + throw new \Sabre\DAV\Exception\ServiceUnavailable(); } if (OC::checkUpgrade(false)) { - throw new Sabre_DAV_Exception_ServiceUnavailable('Upgrade needed'); + throw new \Sabre\DAV\Exception\ServiceUnavailable('Upgrade needed'); } return true; diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index f124b754443..8a369eccf6b 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -1,4 +1,5 @@ <?php +use Sabre\DAV\URLUtil; /** * ownCloud @@ -20,7 +21,7 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ -abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IProperties { +abstract class OC_Connector_Sabre_Node implements \Sabre\DAV\INode, \Sabre\DAV\IProperties { const GETETAG_PROPERTYNAME = '{DAV:}getetag'; const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified'; @@ -81,21 +82,21 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr /** * Renames the node * @param string $name The new name - * @throws Sabre_DAV_Exception_BadRequest - * @throws Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\BadRequest + * @throws \Sabre\DAV\Exception\Forbidden */ public function setName($name) { // rename is only allowed if the update privilege is granted if (!$this->info->isUpdateable()) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } - list($parentPath,) = Sabre_DAV_URLUtil::splitPath($this->path); - list(, $newName) = Sabre_DAV_URLUtil::splitPath($name); + list($parentPath,) = URLUtil::splitPath($this->path); + list(, $newName) = URLUtil::splitPath($name); if (!\OCP\Util::isValidFileName($newName)) { - throw new \Sabre_DAV_Exception_BadRequest(); + throw new \Sabre\DAV\Exception\BadRequest(); } $newPath = $parentPath . '/' . $newName; @@ -139,7 +140,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr /** * Updates properties on this node, - * @see Sabre_DAV_IProperties::updateProperties + * @see \Sabre\DAV\IProperties::updateProperties * @param array $properties * @return boolean */ diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index 35cc1679ab6..a3de2efaa50 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -11,7 +11,7 @@ namespace OC\Connector\Sabre; use OC\Files\FileInfo; use OC\Files\Filesystem; -class ObjectTree extends \Sabre_DAV_ObjectTree { +class ObjectTree extends \Sabre\DAV\ObjectTree { /** * @var \OC\Files\View @@ -27,10 +27,10 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { } /** - * @param \Sabre_DAV_ICollection $rootNode + * @param \Sabre\DAV\ICollection $rootNode * @param \OC\Files\View $view */ - public function init(\Sabre_DAV_ICollection $rootNode, \OC\Files\View $view) { + public function init(\Sabre\DAV\ICollection $rootNode, \OC\Files\View $view) { $this->rootNode = $rootNode; $this->fileView = $view; } @@ -39,13 +39,13 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * Returns the INode object for the requested path * * @param string $path - * @throws \Sabre_DAV_Exception_ServiceUnavailable - * @throws \Sabre_DAV_Exception_NotFound - * @return \Sabre_DAV_INode + * @throws \Sabre\DAV\Exception\ServiceUnavailable + * @throws \Sabre\DAV\Exception\NotFound + * @return \Sabre\DAV\INode */ public function getNodeForPath($path) { if (!$this->fileView) { - throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); } $path = trim($path, '/'); @@ -79,7 +79,7 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { } if (!$info) { - throw new \Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located'); + throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); } if ($info->getType() === 'dir') { @@ -98,22 +98,22 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * * @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_BadRequest - * @throws \Sabre_DAV_Exception_ServiceUnavailable - * @throws \Sabre_DAV_Exception_Forbidden + * @throws \Sabre\DAV\Exception\BadRequest + * @throws \Sabre\DAV\Exception\ServiceUnavailable + * @throws \Sabre\DAV\Exception\Forbidden * @return int */ public function move($sourcePath, $destinationPath) { if (!$this->fileView) { - throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); } $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'); + 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); + list($sourceDir,) = \Sabre\DAV\URLUtil::splitPath($sourcePath); + list($destinationDir,) = \Sabre\DAV\URLUtil::splitPath($destinationPath); $isShareMountPoint = false; list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath( '/' . \OCP\User::getUser() . '/files/' . $sourcePath); @@ -123,38 +123,39 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { // check update privileges if (!$this->fileView->isUpdatable($sourcePath) && !$isShareMountPoint) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } if ($sourceDir !== $destinationDir) { // for a full move we need update privileges on sourcePath and sourceDir as well as destinationDir if (ltrim($destinationDir, '/') === '') { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } if (!$this->fileView->isUpdatable($sourceDir)) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } if (!$this->fileView->isUpdatable($destinationDir)) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } if (!$this->fileView->isDeletable($sourcePath)) { - throw new \Sabre_DAV_Exception_Forbidden(); + throw new \Sabre\DAV\Exception\Forbidden(); } } $fileName = basename($destinationPath); if (!\OCP\Util::isValidFileName($fileName)) { - throw new \Sabre_DAV_Exception_BadRequest(); + throw new \Sabre\DAV\Exception\BadRequest(); } $renameOkay = $this->fileView->rename($sourcePath, $destinationPath); if (!$renameOkay) { - throw new \Sabre_DAV_Exception_Forbidden(''); + throw new \Sabre\DAV\Exception\Forbidden(''); } // update properties $query = \OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?'); - $query->execute(array(\OC\Files\Filesystem::normalizePath($destinationPath), \OC_User::getUser(), \OC\Files\Filesystem::normalizePath($sourcePath))); + $query->execute(array(\OC\Files\Filesystem::normalizePath($destinationPath), \OC_User::getUser(), + \OC\Files\Filesystem::normalizePath($sourcePath))); $this->markDirty($sourceDir); $this->markDirty($destinationDir); @@ -169,12 +170,12 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * * @param string $source * @param string $destination - * @throws \Sabre_DAV_Exception_ServiceUnavailable + * @throws \Sabre\DAV\Exception\ServiceUnavailable * @return void */ public function copy($source, $destination) { if (!$this->fileView) { - throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); } if ($this->fileView->is_file($source)) { @@ -192,7 +193,7 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { } } - list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destination); + list($destinationDir,) = \Sabre\DAV\URLUtil::splitPath($destination); $this->markDirty($destinationDir); } } diff --git a/lib/private/connector/sabre/principal.php b/lib/private/connector/sabre/principal.php index 2075aa55c86..9bad3b9df16 100644 --- a/lib/private/connector/sabre/principal.php +++ b/lib/private/connector/sabre/principal.php @@ -7,7 +7,7 @@ * See the COPYING-README file. */ -class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { +class OC_Connector_Sabre_Principal implements \Sabre\DAVACL\PrincipalBackend\BackendInterface { /** * Returns a list of principals based on a prefix. * @@ -68,7 +68,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { // TODO: for now the group principal has only one member, the user itself $principal = $this->getPrincipalByPath($principal); if (!$principal) { - throw new Sabre_DAV_Exception('Principal not found'); + throw new \Sabre\DAV\Exception('Principal not found'); } return array( @@ -83,13 +83,13 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { * @return array */ public function getGroupMembership($principal) { - list($prefix, $name) = Sabre_DAV_URLUtil::splitPath($principal); + list($prefix, $name) = \Sabre\DAV\URLUtil::splitPath($principal); $group_membership = array(); if ($prefix == 'principals') { $principal = $this->getPrincipalByPath($principal); if (!$principal) { - throw new Sabre_DAV_Exception('Principal not found'); + throw new \Sabre\DAV\Exception('Principal not found'); } // TODO: for now the user principal has only its own groups @@ -115,7 +115,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { * @return void */ public function setGroupMemberSet($principal, array $members) { - throw new Sabre_DAV_Exception('Setting members of the group is not supported yet'); + throw new \Sabre\DAV\Exception('Setting members of the group is not supported yet'); } function updatePrincipal($path, $mutations) { diff --git a/lib/private/connector/sabre/quotaplugin.php b/lib/private/connector/sabre/quotaplugin.php index c9b8336b57b..cf3c1103f84 100644 --- a/lib/private/connector/sabre/quotaplugin.php +++ b/lib/private/connector/sabre/quotaplugin.php @@ -1,4 +1,5 @@ <?php +use Sabre\DAV\URLUtil; /** * This plugin check user quota and deny creating files when they exceeds the quota. @@ -7,7 +8,7 @@ * @copyright Copyright (C) 2012 entreCables S.L. All rights reserved. * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { +class OC_Connector_Sabre_QuotaPlugin extends \Sabre\DAV\ServerPlugin { /** * @var \OC\Files\View @@ -17,7 +18,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { /** * Reference to main server object * - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; @@ -31,15 +32,15 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { /** * This initializes the plugin. * - * This function is called by Sabre_DAV_Server, after + * This function is called by \Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the requires event subscriptions. * - * @param Sabre_DAV_Server $server + * @param \Sabre\DAV\Server $server * @return void */ - public function initialize(Sabre_DAV_Server $server) { + public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; @@ -52,7 +53,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { * * @param string $uri * @param null $data - * @throws Sabre_DAV_Exception_InsufficientStorage + * @throws \Sabre\DAV\Exception\InsufficientStorage * @return bool */ public function checkQuota($uri, $data = null) { @@ -61,7 +62,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { if (substr($uri, 0, 1) !== '/') { $uri = '/' . $uri; } - list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri); + list($parentUri, $newName) = URLUtil::splitPath($uri); $req = $this->server->httpRequest; if ($req->getHeader('OC-Chunked')) { $info = OC_FileChunking::decodeName($newName); @@ -75,7 +76,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { if (isset($chunkHandler)) { $chunkHandler->cleanup(); } - throw new Sabre_DAV_Exception_InsufficientStorage(); + throw new \Sabre\DAV\Exception\InsufficientStorage(); } } return true; diff --git a/lib/private/connector/sabre/request.php b/lib/private/connector/sabre/request.php index d70c25c4e70..c98b28c4d74 100644 --- a/lib/private/connector/sabre/request.php +++ b/lib/private/connector/sabre/request.php @@ -21,7 +21,7 @@ * */ -class OC_Connector_Sabre_Request extends Sabre_HTTP_Request { +class OC_Connector_Sabre_Request extends \Sabre\HTTP\Request { /** * Returns the requested uri * diff --git a/lib/private/connector/sabre/server.php b/lib/private/connector/sabre/server.php index cf28b11163f..e4ee5dcefbf 100644 --- a/lib/private/connector/sabre/server.php +++ b/lib/private/connector/sabre/server.php @@ -12,7 +12,7 @@ /** * Class OC_Connector_Sabre_Server * - * This class reimplements some methods from @see Sabre_DAV_Server. + * This class reimplements some methods from @see \Sabre\DAV\Server. * * Basically we add handling of depth: infinity. * @@ -24,16 +24,16 @@ * * For ownCloud 7 we will upgrade SabreDAV and submit the patch - if needed. * - * @see Sabre_DAV_Server + * @see \Sabre\DAV\Server */ -class OC_Connector_Sabre_Server extends Sabre_DAV_Server { +class OC_Connector_Sabre_Server extends Sabre\DAV\Server { /** - * @see Sabre_DAV_Server + * @see \Sabre\DAV\Server */ protected function httpPropfind($uri) { - // $xml = new Sabre_DAV_XMLReader(file_get_contents('php://input')); + // $xml = new \Sabre\DAV\XMLReader(file_get_contents('php://input')); $requestedProperties = $this->parsePropFindRequest($this->httpRequest->getBody(true)); $depth = $this->getHTTPDepth(1); @@ -72,7 +72,7 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { private function addPathNodesRecursively(&$nodes, $path) { foreach($this->tree->getChildren($path) as $childNode) { $nodes[$path . '/' . $childNode->getName()] = $childNode; - if ($childNode instanceof Sabre_DAV_ICollection) + if ($childNode instanceof \Sabre\DAV\ICollection) $this->addPathNodesRecursively($nodes, $path . '/' . $childNode->getName()); } } @@ -89,10 +89,10 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { $nodes = array( $path => $parentNode ); - if ($depth==1 && $parentNode instanceof Sabre_DAV_ICollection) { + if ($depth==1 && $parentNode instanceof \Sabre\DAV\ICollection) { foreach($this->tree->getChildren($path) as $childNode) $nodes[$path . '/' . $childNode->getName()] = $childNode; - } else if ($depth == self::DEPTH_INFINITY && $parentNode instanceof Sabre_DAV_ICollection) { + } else if ($depth == self::DEPTH_INFINITY && $parentNode instanceof \Sabre\DAV\ICollection) { $this->addPathNodesRecursively($nodes, $path); } @@ -140,7 +140,7 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { if (count($currentPropertyNames) > 0) { - if ($node instanceof Sabre_DAV_IProperties) { + if ($node instanceof \Sabre\DAV\IProperties) { $nodeProperties = $node->getProperties($currentPropertyNames); // The getProperties method may give us too much, @@ -165,9 +165,9 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { if (isset($newProperties[200][$prop])) continue; switch($prop) { - case '{DAV:}getlastmodified' : if ($node->getLastModified()) $newProperties[200][$prop] = new Sabre_DAV_Property_GetLastModified($node->getLastModified()); break; + case '{DAV:}getlastmodified' : if ($node->getLastModified()) $newProperties[200][$prop] = new \Sabre\DAV\Property\GetLastModified($node->getLastModified()); break; case '{DAV:}getcontentlength' : - if ($node instanceof Sabre_DAV_IFile) { + if ($node instanceof \Sabre\DAV\IFile) { $size = $node->getSize(); if (!is_null($size)) { $newProperties[200][$prop] = 0 + $size; @@ -175,28 +175,28 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { } break; case '{DAV:}quota-used-bytes' : - if ($node instanceof Sabre_DAV_IQuota) { + if ($node instanceof \Sabre\DAV\IQuota) { $quotaInfo = $node->getQuotaInfo(); $newProperties[200][$prop] = $quotaInfo[0]; } break; case '{DAV:}quota-available-bytes' : - if ($node instanceof Sabre_DAV_IQuota) { + if ($node instanceof \Sabre\DAV\IQuota) { $quotaInfo = $node->getQuotaInfo(); $newProperties[200][$prop] = $quotaInfo[1]; } break; - case '{DAV:}getetag' : if ($node instanceof Sabre_DAV_IFile && $etag = $node->getETag()) $newProperties[200][$prop] = $etag; break; - case '{DAV:}getcontenttype' : if ($node instanceof Sabre_DAV_IFile && $ct = $node->getContentType()) $newProperties[200][$prop] = $ct; break; + case '{DAV:}getetag' : if ($node instanceof \Sabre\DAV\IFile && $etag = $node->getETag()) $newProperties[200][$prop] = $etag; break; + case '{DAV:}getcontenttype' : if ($node instanceof \Sabre\DAV\IFile && $ct = $node->getContentType()) $newProperties[200][$prop] = $ct; break; case '{DAV:}supported-report-set' : $reports = array(); foreach($this->plugins as $plugin) { $reports = array_merge($reports, $plugin->getSupportedReportSet($myPath)); } - $newProperties[200][$prop] = new Sabre_DAV_Property_SupportedReportSet($reports); + $newProperties[200][$prop] = new \Sabre\DAV\Property\SupportedReportSet($reports); break; case '{DAV:}resourcetype' : - $newProperties[200]['{DAV:}resourcetype'] = new Sabre_DAV_Property_ResourceType(); + $newProperties[200]['{DAV:}resourcetype'] = new \Sabre\DAV\Property\ResourceType(); foreach($this->resourceTypeMapping as $className => $resourceType) { if ($node instanceof $className) $newProperties[200]['{DAV:}resourcetype']->add($resourceType); } diff --git a/lib/private/davclient.php b/lib/private/davclient.php index a7bf0486519..6a544d27068 100644 --- a/lib/private/davclient.php +++ b/lib/private/davclient.php @@ -25,7 +25,7 @@ * like request timeout. */ -class OC_DAVClient extends \Sabre_DAV_Client { +class OC_DAVClient extends \Sabre\DAV\Client { protected $requestTimeout; diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php index f61769f0b9b..06ae62015a5 100644 --- a/lib/private/files/cache/homecache.php +++ b/lib/private/files/cache/homecache.php @@ -17,7 +17,7 @@ class HomeCache extends Cache { * @return int */ public function calculateFolderSize($path, $entry = null) { - if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin') { + if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { return parent::calculateFolderSize($path, $entry); } elseif ($path === '' or $path === '/') { // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it diff --git a/lib/private/request.php b/lib/private/request.php index 09928021a7f..619eae3e9b5 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -184,7 +184,7 @@ class OC_Request { $path_info = $_SERVER['PATH_INFO']; }else{ $path_info = self::getRawPathInfo(); - // following is taken from Sabre_DAV_URLUtil::decodePathSegment + // following is taken from \Sabre\DAV\URLUtil::decodePathSegment $path_info = rawurldecode($path_info); $encoding = mb_detect_encoding($path_info, array('UTF-8', 'ISO-8859-1')); @@ -220,7 +220,7 @@ class OC_Request { $path_info = $requestUri; // strip off the script name's dir and file name - list($path, $name) = \Sabre_DAV_URLUtil::splitPath($scriptName); + list($path, $name) = \Sabre\DAV\URLUtil::splitPath($scriptName); if (!empty($path)) { if( $path === $path_info || strpos($path_info, $path.'/') === 0) { $path_info = substr($path_info, strlen($path)); diff --git a/lib/private/util.php b/lib/private/util.php index da67dbcee54..905f8d72cf4 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -983,7 +983,7 @@ class OC_Util { try { // test PROPFIND $client->propfind('', array('{DAV:}resourcetype')); - } catch (\Sabre_DAV_Exception_NotAuthenticated $e) { + } catch (\Sabre\DAV\Exception\NotAuthenticated $e) { $return = true; } catch (\Exception $e) { OC_Log::write('core', 'isWebDAVWorking: NO - Reason: '.$e->getMessage(). ' ('.get_class($e).')', OC_Log::WARN); diff --git a/settings/css/settings.css b/settings/css/settings.css index b67c88a9c8f..3a6e40ad361 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -20,10 +20,13 @@ input#openid, input#webdav { width:20em; } } /* Sync clients */ -.clientsbox { margin:12px; } -.clientsbox h1 { font-size:40px; font-weight:bold; margin:50px 0 20px; } -.clientsbox h2 { font-size:20px; font-weight:bold; margin:35px 0 10px; } -.clientsbox .center { margin-top:10px; } +.clientsbox h2 { + font-size: 20px; + margin: 35px 0 10px; +} +.clientsbox .center { + margin-top: 10px; +} #passworderror { display:none; } #passwordchanged { display:none; } diff --git a/tests/lib/connector/sabre/aborteduploaddetectionplugin.php b/tests/lib/connector/sabre/aborteduploaddetectionplugin.php index 60d141e72bc..7e9f70ddcd3 100644 --- a/tests/lib/connector/sabre/aborteduploaddetectionplugin.php +++ b/tests/lib/connector/sabre/aborteduploaddetectionplugin.php @@ -9,7 +9,7 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Framework_TestCase { /** - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; @@ -19,7 +19,7 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame private $plugin; private function init($view) { - $this->server = new Sabre_DAV_Server(); + $this->server = new \Sabre\DAV\Server(); $this->plugin = new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view); $this->plugin->initialize($this->server); } @@ -30,7 +30,7 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame public function testLength($expected, $headers) { $this->init(null); - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new \Sabre\HTTP\Request($headers); $length = $this->plugin->getLength(); $this->assertEquals($expected, $length); } @@ -42,14 +42,14 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame $this->init($this->buildFileViewMock($fileSize)); $headers['REQUEST_METHOD'] = $method; - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new Sabre\HTTP\Request($headers); $this->plugin->verifyContentLength('foo.txt'); $this->assertTrue(true); } /** * @dataProvider verifyContentLengthFailedProvider - * @expectedException Sabre_DAV_Exception_BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ public function testVerifyContentLengthFailed($method, $fileSize, $headers) { $view = $this->buildFileViewMock($fileSize); @@ -58,7 +58,7 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame $view->expects($this->once())->method('unlink'); $headers['REQUEST_METHOD'] = $method; - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new Sabre\HTTP\Request($headers); $this->plugin->verifyContentLength('foo.txt'); } diff --git a/tests/lib/connector/sabre/directory.php b/tests/lib/connector/sabre/directory.php index b2bf0d4a6d2..8a1550ffa95 100644 --- a/tests/lib/connector/sabre/directory.php +++ b/tests/lib/connector/sabre/directory.php @@ -23,7 +23,7 @@ class Test_OC_Connector_Sabre_Directory extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception_Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testCreateSharedFileFails() { $dir = $this->getRootDir(); @@ -31,7 +31,7 @@ class Test_OC_Connector_Sabre_Directory extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception_Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testCreateSharedFolderFails() { $dir = $this->getRootDir(); @@ -39,7 +39,7 @@ class Test_OC_Connector_Sabre_Directory extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception_Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteSharedFolderFails() { $dir = $this->getRootDir(); diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php index a9056460a5c..3dd5b328f46 100644 --- a/tests/lib/connector/sabre/file.php +++ b/tests/lib/connector/sabre/file.php @@ -9,7 +9,7 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase { /** - * @expectedException Sabre_DAV_Exception + * @expectedException \Sabre\DAV\Exception */ public function testSimplePutFails() { // setup @@ -33,7 +33,7 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception + * @expectedException \Sabre\DAV\Exception */ public function testSimplePutFailsOnRename() { // setup @@ -62,7 +62,7 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception_BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ public function testSimplePutInvalidChars() { // setup @@ -86,7 +86,7 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase { /** * Test setting name with setName() with invalid chars - * @expectedException Sabre_DAV_Exception_BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ public function testSetNameInvalidChars() { // setup diff --git a/tests/lib/connector/sabre/objecttree.php b/tests/lib/connector/sabre/objecttree.php index bc8ec98faee..0075b7832b8 100644 --- a/tests/lib/connector/sabre/objecttree.php +++ b/tests/lib/connector/sabre/objecttree.php @@ -12,7 +12,6 @@ namespace Test\OC\Connector\Sabre; use OC\Files\FileInfo; use OC_Connector_Sabre_Directory; use PHPUnit_Framework_TestCase; -use Sabre_DAV_Exception_Forbidden; class TestDoubleFileView extends \OC\Files\View{ @@ -43,7 +42,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase { /** * @dataProvider moveFailedProvider - * @expectedException Sabre_DAV_Exception_Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testMoveFailed($source, $dest, $updatables, $deletables) { $this->moveTest($source, $dest, $updatables, $deletables); @@ -59,7 +58,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase { /** * @dataProvider moveFailedInvalidCharsProvider - * @expectedException Sabre_DAV_Exception_BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ public function testMoveFailedInvalidChars($source, $dest, $updatables, $deletables) { $this->moveTest($source, $dest, $updatables, $deletables); diff --git a/tests/lib/connector/sabre/quotaplugin.php b/tests/lib/connector/sabre/quotaplugin.php index 6781b970a4f..1024ae6af8f 100644 --- a/tests/lib/connector/sabre/quotaplugin.php +++ b/tests/lib/connector/sabre/quotaplugin.php @@ -9,7 +9,7 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase { /** - * @var Sabre_DAV_Server + * @var \Sabre\DAV\Server */ private $server; @@ -20,7 +20,7 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase { private function init($quota) { $view = $this->buildFileViewMock($quota); - $this->server = new Sabre_DAV_Server(); + $this->server = new \Sabre\DAV\Server(); $this->plugin = new OC_Connector_Sabre_QuotaPlugin($view); $this->plugin->initialize($this->server); } @@ -30,7 +30,7 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase { */ public function testLength($expected, $headers) { $this->init(0); - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new \Sabre\HTTP\Request($headers); $length = $this->plugin->getLength(); $this->assertEquals($expected, $length); } @@ -41,19 +41,19 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase { public function testCheckQuota($quota, $headers) { $this->init($quota); - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new Sabre\HTTP\Request($headers); $result = $this->plugin->checkQuota(''); $this->assertTrue($result); } /** - * @expectedException Sabre_DAV_Exception_InsufficientStorage + * @expectedException \Sabre\DAV\Exception\InsufficientStorage * @dataProvider quotaExceededProvider */ public function testCheckExceededQuota($quota, $headers) { $this->init($quota); - $this->server->httpRequest = new Sabre_HTTP_Request($headers); + $this->server->httpRequest = new Sabre\HTTP\Request($headers); $this->plugin->checkQuota(''); } |