summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files/appinfo/remote.php6
-rwxr-xr-xapps/files_encryption/tests/webdav.php8
-rw-r--r--apps/files_external/lib/webdav.php6
-rw-r--r--apps/files_sharing/app/sharing.php25
-rw-r--r--apps/files_sharing/appinfo/app.php3
-rw-r--r--apps/files_sharing/appinfo/routes.php15
-rw-r--r--apps/files_sharing/controller/adminsettingscontroller.php60
-rw-r--r--apps/files_sharing/css/settings-admin.css33
-rw-r--r--apps/files_sharing/http/mailtemplateresponse.php55
-rw-r--r--apps/files_sharing/js/settings-admin.js78
-rw-r--r--apps/files_sharing/lib/api.php1
-rw-r--r--apps/files_sharing/lib/connector/publicauth.php2
-rw-r--r--apps/files_sharing/lib/mailtemplate.php126
-rw-r--r--apps/files_sharing/publicwebdav.php6
-rw-r--r--apps/files_sharing/settings-admin.php21
-rw-r--r--apps/files_sharing/templates/settings-admin.php41
-rw-r--r--apps/files_trashbin/appinfo/update.php3
-rw-r--r--apps/files_trashbin/lib/trashbin.php4
-rw-r--r--apps/files_versions/appinfo/database.xml35
-rw-r--r--apps/files_versions/appinfo/update.php12
-rw-r--r--apps/files_versions/appinfo/version2
-rw-r--r--apps/files_versions/lib/versions.php72
22 files changed, 483 insertions, 131 deletions
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