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#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'],
]

@ -262,7 +262,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'),
@ -293,10 +292,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');

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

@ -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
*/
@ -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);

@ -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" 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>

@ -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