Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2016-09-12 20:38:01 +0300
committerAndras Timar <andras.timar@collabora.com>2016-09-12 20:42:46 +0300
commit6fc595eb938c02ad6dde025f6eac5a9305643880 (patch)
tree94d46e64063d9a7e44b3afa236d5b62d2f53f1d1
parent7a0d2b944cde026abd6527bf3e51f41e809faa9c (diff)
remove unused 'Save new documents to' setting, fixes #76
-rw-r--r--appinfo/routes.php1
-rw-r--r--controller/documentcontroller.php6
-rw-r--r--controller/sessioncontroller.php70
-rw-r--r--controller/settingscontroller.php42
-rw-r--r--js/personal.js21
-rw-r--r--personal.php19
-rw-r--r--templates/documents.php1
-rw-r--r--templates/personal.php10
8 files changed, 36 insertions, 134 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 0cca478a..3b5d539c 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -39,7 +39,6 @@ $application->registerRoutes($this, [
['name' => 'document#wopiGetFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'GET'],
['name' => 'document#wopiPutFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'POST'],
//settings
- ['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'],
['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
]
diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php
index 7ccafe85..2977e6f1 100644
--- a/controller/documentcontroller.php
+++ b/controller/documentcontroller.php
@@ -261,7 +261,6 @@ class DocumentController extends Controller {
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$response = new TemplateResponse('richdocuments', 'documents', [
'enable_previews' => $this->settings->getSystemValue('enable_previews', true),
- 'savePath' => $this->settings->getUserValue($this->uid, 'richdocuments', 'save_path', '/'),
'uploadMaxFilesize' => $maxUploadFilesize,
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
@@ -292,10 +291,7 @@ class DocumentController extends Controller {
$view = new View('/' . $this->uid . '/files');
if (!$dir){
- $dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
- if (!$view->is_dir($dir)){
- $dir = '/';
- }
+ $dir = '/';
}
$basename = $this->l10n->t('New Document.odt');
diff --git a/controller/sessioncontroller.php b/controller/sessioncontroller.php
index 916f00d1..7f63855d 100644
--- a/controller/sessioncontroller.php
+++ b/controller/sessioncontroller.php
@@ -36,7 +36,7 @@ class BadRequestException extends \Exception {
}
class SessionController extends Controller{
-
+
protected $uid;
protected $logger;
protected $shareToken;
@@ -46,21 +46,21 @@ class SessionController extends Controller{
$this->uid = $uid;
$this->logger = $logger;
}
-
+
/**
* @NoAdminRequired
* @PublicPage
*/
public function joinAsGuest($token, $name){
$uid = substr($name, 0, 16);
-
+
try {
$file = File::getByShareToken($token);
if ($file->isPasswordProtected() && !$file->checkPassword('')){
throw new \Exception('Not authorized');
}
- $response = array_merge(
+ $response = array_merge(
Db\Session::start($uid, $file),
[ 'status'=>'success' ]
);
@@ -68,10 +68,10 @@ class SessionController extends Controller{
$this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), ['app' => $this->appName]);
$response = [ 'status'=>'error' ];
}
-
+
return $response;
}
-
+
/**
* @NoAdminRequired
* @PublicPage
@@ -80,7 +80,7 @@ class SessionController extends Controller{
$this->shareToken = $this->request->getParam('token');
return $this->poll($command, $args);
}
-
+
/**
* Store the document content to its origin
* @NoAdminRequired
@@ -90,7 +90,7 @@ class SessionController extends Controller{
$this->shareToken = $this->request->getParam('token');
return $this->save();
}
-
+
/**
* @NoAdminRequired
*/
@@ -98,7 +98,7 @@ class SessionController extends Controller{
try {
$view = \OC\Files\Filesystem::getView();
$path = $view->getPath($fileId);
-
+
if ($view->isUpdatable($path)) {
$file = new File($fileId);
$response = Db\Session::start($this->uid, $file);
@@ -109,7 +109,7 @@ class SessionController extends Controller{
'id' => $fileId
];
}
- $response = array_merge(
+ $response = array_merge(
$response,
[ 'status'=>'success' ]
);
@@ -117,10 +117,10 @@ class SessionController extends Controller{
$this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), [ 'app' => $this->appName ]);
$response = [ 'status'=>'error' ];
}
-
+
return $response;
}
-
+
/**
* @NoAdminRequired
*/
@@ -130,21 +130,21 @@ class SessionController extends Controller{
try{
$esId = isset($args['es_id']) ? $args['es_id'] : null;
$session = $this->loadSession($esId);
-
+
$memberId = isset($args['member_id']) ? $args['member_id'] : null;
$member = $this->loadMember($memberId);
$this->validateSession($session);
-
+
switch ($command){
case 'sync_ops':
$seqHead = (string) isset($args['seq_head']) ? $args['seq_head'] : null;
if (!is_null($seqHead)){
$ops = isset($args['client_ops']) ? $args['client_ops'] : [];
-
+
$op = new Db\Op();
$currentHead = $op->getHeadSeq($esId);
-
+
try {
$member->updateActivity($memberId);
} catch (\Exception $e){
@@ -180,7 +180,7 @@ class SessionController extends Controller{
}
return $response;
}
-
+
/**
* Store the document content to its origin
* @NoAdminRequired
@@ -190,13 +190,13 @@ class SessionController extends Controller{
try {
$esId = $this->request->server['HTTP_WEBODF_SESSION_ID'];
$session = $this->loadSession($esId);
-
+
$memberId = $this->request->server['HTTP_WEBODF_MEMBER_ID'];
$currentMember = $this->loadMember($memberId, $esId);
-
+
// Extra info for future usage
// $sessionRevision = $this->request->server['HTTP_WEBODF_SESSION_REVISION'];
-
+
//NB ouch! New document content is passed as an input stream content
$stream = fopen('php://input','r');
if (!$stream){
@@ -210,7 +210,7 @@ class SessionController extends Controller{
} else {
$file = new File($session->getFileId());
}
-
+
$view = $file->getOwnerView(true);
$path = $file->getPath(true);
} catch (\Exception $e){
@@ -218,14 +218,14 @@ class SessionController extends Controller{
//Sorry, but for guests it would be lost :(
if ($this->uid){
$view = new View('/' . $this->uid . '/files');
-
- $dir = \OC::$server->getConfig()->getUserValue($this->uid, 'richdocuments', 'save_path', '');
+
+ $dir = '/';
$path = Helper::getNewFileName($view, $dir . 'New Document.odt');
} else {
throw $e;
}
}
-
+
$member = new Db\Member();
$members = $member->getActiveCollection($esId);
$memberIds = array_map(
@@ -234,25 +234,25 @@ class SessionController extends Controller{
},
$members
);
-
+
// Active users except current user
$memberCount = count($memberIds) - 1;
-
+
if ($view->file_exists($path)){
$currentHash = $view->hash('sha1', $path, false);
-
+
if (!Helper::isVersionsEnabled() && $currentHash !== $session->getGenesisHash()){
// Original file was modified externally. Save to a new one
$path = Helper::getNewFileName($view, $path, '-conflict');
}
-
+
$mimetype = $view->getMimeType($path);
} else {
$mimetype = Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR;
}
-
+
$data = Filter::write($content, $mimetype);
-
+
if ($view->file_put_contents($path, $data['content'])){
// Not a last user
if ($memberCount>0){
@@ -263,7 +263,7 @@ class SessionController extends Controller{
// Last user. Kill session data
Db\Session::cleanUp($esId);
}
-
+
$view->touch($path);
}
$response->setData(['status'=>'success']);
@@ -275,7 +275,7 @@ class SessionController extends Controller{
return $response;
}
-
+
protected function validateSession($session){
try {
if (is_null($this->shareToken)) {
@@ -292,12 +292,12 @@ class SessionController extends Controller{
throw $ex;
}
}
-
+
protected function loadSession($esId){
if (!$esId){
throw new \Exception('Session id can not be empty');
}
-
+
$session = new Db\Session();
$session->load($esId);
if (!$session->getEsId()){
@@ -305,7 +305,7 @@ class SessionController extends Controller{
}
return $session;
}
-
+
protected function loadMember($memberId, $expectedEsId = null){
if (!$memberId){
throw new \Exception('Member id can not be empty');
diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php
index 79f12752..5a5e9897 100644
--- a/controller/settingscontroller.php
+++ b/controller/settingscontroller.php
@@ -44,19 +44,6 @@ class SettingsController extends Controller{
}
/**
- * @NoAdminRequired
- * @NoCSRFRequired
- */
- public function personalIndex(){
- return new TemplateResponse(
- $this->appName,
- 'personal',
- [ 'save_path' => $this->appConfig->getUserValue($this->userId, 'save_path') ],
- 'blank'
- );
- }
-
- /**
* @NoCSRFRequired
*/
public function settingsIndex(){
@@ -81,35 +68,6 @@ class SettingsController extends Controller{
);
}
- /**
- * @NoAdminRequired
- */
- public function savePersonal($savePath){
- if (is_null($savePath)){
- $savePath = '/';
- }
- $status = true;
- if (\OC\Files\Filesystem::file_exists($savePath) === false ){
- $status = \OC\Files\Filesystem::mkdir($savePath);
- }
-
- if ($status){
- $this->appConfig->setUserValue($this->userId, 'save_path', $savePath);
- $response = array(
- 'status' => 'success',
- 'data' => array('message'=> $this->l10n->t('Directory saved successfully.'))
- );
- } else {
- $response = array(
- 'status' => 'error',
- 'data' => array(
- 'message'=> $this->l10n->t('An error occurred while changing directory.')
- )
- );
- }
- return $response;
- }
-
public function setSettings($wopi_url){
if (!is_null($wopi_url)){
$this->appConfig->setAppValue('wopi_url', $wopi_url);
diff --git a/js/personal.js b/js/personal.js
deleted file mode 100644
index 7bf434f4..00000000
--- a/js/personal.js
+++ /dev/null
@@ -1,21 +0,0 @@
-$(document).ready(function(){
- var documentsSettings = {
- save : function() {
- var data = {
- savePath : $('#documents-default-path').val()
- };
- OC.msg.startSaving('#documents-personal .msg');
- $.post(OC.filePath('richdocuments', 'ajax', 'personal.php'), data, documentsSettings.afterSave);
- },
- afterSave : function(data){
- OC.msg.finishedSaving('#documents-personal .msg', data);
- }
- };
- $('#documents-default-path').blur(documentsSettings.save);
- $('#documents-default-path').keypress(function( event ) {
- if (event.which == 13) {
- event.preventDefault();
- documentsSettings.save();
- }
- });
-});
diff --git a/personal.php b/personal.php
deleted file mode 100644
index 213c37b9..00000000
--- a/personal.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/**
- * ownCloud - Richdocuments App
- *
- * @author Victor Dubiniuk
- * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- */
-
-namespace OCA\Richdocuments;
-
-use \OCA\Richdocuments\AppInfo\Application;
-
-$app = new Application();
-$response = $app->getContainer()->query('\OCA\Richdocuments\Controller\SettingsController')->personalIndex();
-return $response->render();
diff --git a/templates/documents.php b/templates/documents.php
index ffe2e187..2019fbae 100644
--- a/templates/documents.php
+++ b/templates/documents.php
@@ -35,7 +35,6 @@ script('files', 'jquery.fileupload');
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken" />
<input type="hidden" class="max_human_file_size"
value="(max <?php p($_['uploadMaxHumanFilesize']); ?>)" />
- <input type="hidden" name="dir" value="<?php p($_['savePath']) ?>" id="dir" />
<input type="file" id="file_upload_start" name='files[]' />
<a href="#" class="icon-upload upload svg">
<label><?php p($l->t('Upload')) ?></label></a>
diff --git a/templates/personal.php b/templates/personal.php
deleted file mode 100644
index 616c97ac..00000000
--- a/templates/personal.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-script('richdocuments', 'personal');
-?>
-<div class="section" id="richdocuments-personal">
- <h2><?php p($l->t('Collabora Online')); ?></h2>
- <div>
- <label for="documents-default-path"><?php p($l->t('Save new documents to')) ?></label>
- <input type="text" id="documents-default-path" value="<?php p($_['save_path']) ?>" /><span class="msg"></span>
- </div>
-</div>