Merge pull request #109 from timar/master

remove unused 'Save new documents to' setting, fixes #76
pull/1/head
Lukas Reschke 8 years ago committed by GitHub
commit 0806876fd0

@ -39,7 +39,6 @@ $application->registerRoutes($this, [
['name' => 'document#wopiGetFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'GET'], ['name' => 'document#wopiGetFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'GET'],
['name' => 'document#wopiPutFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'POST'], ['name' => 'document#wopiPutFile', 'url' => 'wopi/files/{fileId}/contents', 'verb' => 'POST'],
//settings //settings
['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'],
['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'], ['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'], ['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
] ]

@ -262,7 +262,6 @@ class DocumentController extends Controller {
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/"); $maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$response = new TemplateResponse('richdocuments', 'documents', [ $response = new TemplateResponse('richdocuments', 'documents', [
'enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'enable_previews' => $this->settings->getSystemValue('enable_previews', true),
'savePath' => $this->settings->getUserValue($this->uid, 'richdocuments', 'save_path', '/'),
'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxFilesize' => $maxUploadFilesize,
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
@ -293,10 +292,7 @@ class DocumentController extends Controller {
$view = new View('/' . $this->uid . '/files'); $view = new View('/' . $this->uid . '/files');
if (!$dir){ if (!$dir){
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/'); $dir = '/';
if (!$view->is_dir($dir)){
$dir = '/';
}
} }
$basename = $this->l10n->t('New Document.odt'); $basename = $this->l10n->t('New Document.odt');

@ -36,7 +36,7 @@ class BadRequestException extends \Exception {
} }
class SessionController extends Controller{ class SessionController extends Controller{
protected $uid; protected $uid;
protected $logger; protected $logger;
protected $shareToken; protected $shareToken;
@ -46,21 +46,21 @@ class SessionController extends Controller{
$this->uid = $uid; $this->uid = $uid;
$this->logger = $logger; $this->logger = $logger;
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
* @PublicPage * @PublicPage
*/ */
public function joinAsGuest($token, $name){ public function joinAsGuest($token, $name){
$uid = substr($name, 0, 16); $uid = substr($name, 0, 16);
try { try {
$file = File::getByShareToken($token); $file = File::getByShareToken($token);
if ($file->isPasswordProtected() && !$file->checkPassword('')){ if ($file->isPasswordProtected() && !$file->checkPassword('')){
throw new \Exception('Not authorized'); throw new \Exception('Not authorized');
} }
$response = array_merge( $response = array_merge(
Db\Session::start($uid, $file), Db\Session::start($uid, $file),
[ 'status'=>'success' ] [ 'status'=>'success' ]
); );
@ -68,10 +68,10 @@ class SessionController extends Controller{
$this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), ['app' => $this->appName]); $this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), ['app' => $this->appName]);
$response = [ 'status'=>'error' ]; $response = [ 'status'=>'error' ];
} }
return $response; return $response;
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
* @PublicPage * @PublicPage
@ -80,7 +80,7 @@ class SessionController extends Controller{
$this->shareToken = $this->request->getParam('token'); $this->shareToken = $this->request->getParam('token');
return $this->poll($command, $args); return $this->poll($command, $args);
} }
/** /**
* Store the document content to its origin * Store the document content to its origin
* @NoAdminRequired * @NoAdminRequired
@ -90,7 +90,7 @@ class SessionController extends Controller{
$this->shareToken = $this->request->getParam('token'); $this->shareToken = $this->request->getParam('token');
return $this->save(); return $this->save();
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
*/ */
@ -98,7 +98,7 @@ class SessionController extends Controller{
try { try {
$view = \OC\Files\Filesystem::getView(); $view = \OC\Files\Filesystem::getView();
$path = $view->getPath($fileId); $path = $view->getPath($fileId);
if ($view->isUpdatable($path)) { if ($view->isUpdatable($path)) {
$file = new File($fileId); $file = new File($fileId);
$response = Db\Session::start($this->uid, $file); $response = Db\Session::start($this->uid, $file);
@ -109,7 +109,7 @@ class SessionController extends Controller{
'id' => $fileId 'id' => $fileId
]; ];
} }
$response = array_merge( $response = array_merge(
$response, $response,
[ 'status'=>'success' ] [ 'status'=>'success' ]
); );
@ -117,10 +117,10 @@ class SessionController extends Controller{
$this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), [ 'app' => $this->appName ]); $this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), [ 'app' => $this->appName ]);
$response = [ 'status'=>'error' ]; $response = [ 'status'=>'error' ];
} }
return $response; return $response;
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
*/ */
@ -130,21 +130,21 @@ class SessionController extends Controller{
try{ try{
$esId = isset($args['es_id']) ? $args['es_id'] : null; $esId = isset($args['es_id']) ? $args['es_id'] : null;
$session = $this->loadSession($esId); $session = $this->loadSession($esId);
$memberId = isset($args['member_id']) ? $args['member_id'] : null; $memberId = isset($args['member_id']) ? $args['member_id'] : null;
$member = $this->loadMember($memberId); $member = $this->loadMember($memberId);
$this->validateSession($session); $this->validateSession($session);
switch ($command){ switch ($command){
case 'sync_ops': case 'sync_ops':
$seqHead = (string) isset($args['seq_head']) ? $args['seq_head'] : null; $seqHead = (string) isset($args['seq_head']) ? $args['seq_head'] : null;
if (!is_null($seqHead)){ if (!is_null($seqHead)){
$ops = isset($args['client_ops']) ? $args['client_ops'] : []; $ops = isset($args['client_ops']) ? $args['client_ops'] : [];
$op = new Db\Op(); $op = new Db\Op();
$currentHead = $op->getHeadSeq($esId); $currentHead = $op->getHeadSeq($esId);
try { try {
$member->updateActivity($memberId); $member->updateActivity($memberId);
} catch (\Exception $e){ } catch (\Exception $e){
@ -180,7 +180,7 @@ class SessionController extends Controller{
} }
return $response; return $response;
} }
/** /**
* Store the document content to its origin * Store the document content to its origin
* @NoAdminRequired * @NoAdminRequired
@ -190,13 +190,13 @@ class SessionController extends Controller{
try { try {
$esId = $this->request->server['HTTP_WEBODF_SESSION_ID']; $esId = $this->request->server['HTTP_WEBODF_SESSION_ID'];
$session = $this->loadSession($esId); $session = $this->loadSession($esId);
$memberId = $this->request->server['HTTP_WEBODF_MEMBER_ID']; $memberId = $this->request->server['HTTP_WEBODF_MEMBER_ID'];
$currentMember = $this->loadMember($memberId, $esId); $currentMember = $this->loadMember($memberId, $esId);
// Extra info for future usage // Extra info for future usage
// $sessionRevision = $this->request->server['HTTP_WEBODF_SESSION_REVISION']; // $sessionRevision = $this->request->server['HTTP_WEBODF_SESSION_REVISION'];
//NB ouch! New document content is passed as an input stream content //NB ouch! New document content is passed as an input stream content
$stream = fopen('php://input','r'); $stream = fopen('php://input','r');
if (!$stream){ if (!$stream){
@ -210,7 +210,7 @@ class SessionController extends Controller{
} else { } else {
$file = new File($session->getFileId()); $file = new File($session->getFileId());
} }
$view = $file->getOwnerView(true); $view = $file->getOwnerView(true);
$path = $file->getPath(true); $path = $file->getPath(true);
} catch (\Exception $e){ } catch (\Exception $e){
@ -218,14 +218,14 @@ class SessionController extends Controller{
//Sorry, but for guests it would be lost :( //Sorry, but for guests it would be lost :(
if ($this->uid){ if ($this->uid){
$view = new View('/' . $this->uid . '/files'); $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'); $path = Helper::getNewFileName($view, $dir . 'New Document.odt');
} else { } else {
throw $e; throw $e;
} }
} }
$member = new Db\Member(); $member = new Db\Member();
$members = $member->getActiveCollection($esId); $members = $member->getActiveCollection($esId);
$memberIds = array_map( $memberIds = array_map(
@ -234,25 +234,25 @@ class SessionController extends Controller{
}, },
$members $members
); );
// Active users except current user // Active users except current user
$memberCount = count($memberIds) - 1; $memberCount = count($memberIds) - 1;
if ($view->file_exists($path)){ if ($view->file_exists($path)){
$currentHash = $view->hash('sha1', $path, false); $currentHash = $view->hash('sha1', $path, false);
if (!Helper::isVersionsEnabled() && $currentHash !== $session->getGenesisHash()){ if (!Helper::isVersionsEnabled() && $currentHash !== $session->getGenesisHash()){
// Original file was modified externally. Save to a new one // Original file was modified externally. Save to a new one
$path = Helper::getNewFileName($view, $path, '-conflict'); $path = Helper::getNewFileName($view, $path, '-conflict');
} }
$mimetype = $view->getMimeType($path); $mimetype = $view->getMimeType($path);
} else { } else {
$mimetype = Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR; $mimetype = Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR;
} }
$data = Filter::write($content, $mimetype); $data = Filter::write($content, $mimetype);
if ($view->file_put_contents($path, $data['content'])){ if ($view->file_put_contents($path, $data['content'])){
// Not a last user // Not a last user
if ($memberCount>0){ if ($memberCount>0){
@ -263,7 +263,7 @@ class SessionController extends Controller{
// Last user. Kill session data // Last user. Kill session data
Db\Session::cleanUp($esId); Db\Session::cleanUp($esId);
} }
$view->touch($path); $view->touch($path);
} }
$response->setData(['status'=>'success']); $response->setData(['status'=>'success']);
@ -275,7 +275,7 @@ class SessionController extends Controller{
return $response; return $response;
} }
protected function validateSession($session){ protected function validateSession($session){
try { try {
if (is_null($this->shareToken)) { if (is_null($this->shareToken)) {
@ -292,12 +292,12 @@ class SessionController extends Controller{
throw $ex; throw $ex;
} }
} }
protected function loadSession($esId){ protected function loadSession($esId){
if (!$esId){ if (!$esId){
throw new \Exception('Session id can not be empty'); throw new \Exception('Session id can not be empty');
} }
$session = new Db\Session(); $session = new Db\Session();
$session->load($esId); $session->load($esId);
if (!$session->getEsId()){ if (!$session->getEsId()){
@ -305,7 +305,7 @@ class SessionController extends Controller{
} }
return $session; return $session;
} }
protected function loadMember($memberId, $expectedEsId = null){ protected function loadMember($memberId, $expectedEsId = null){
if (!$memberId){ if (!$memberId){
throw new \Exception('Member id can not be empty'); throw new \Exception('Member id can not be empty');

@ -43,19 +43,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 * @NoCSRFRequired
*/ */
@ -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){ public function setSettings($wopi_url){
if (!is_null($wopi_url)){ if (!is_null($wopi_url)){
$this->appConfig->setAppValue('wopi_url', $wopi_url); $this->appConfig->setAppValue('wopi_url', $wopi_url);

@ -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();
}
});
});

@ -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();

@ -35,7 +35,6 @@ script('files', 'jquery.fileupload');
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken" /> <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken" />
<input type="hidden" class="max_human_file_size" <input type="hidden" class="max_human_file_size"
value="(max <?php p($_['uploadMaxHumanFilesize']); ?>)" /> 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[]' /> <input type="file" id="file_upload_start" name='files[]' />
<a href="#" class="icon-upload upload svg"> <a href="#" class="icon-upload upload svg">
<label><?php p($l->t('Upload')) ?></label></a> <label><?php p($l->t('Upload')) ?></label></a>

@ -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>
Loading…
Cancel
Save