Default documents dir for upload. Ref #49
This commit is contained in:
parent
1aced0433c
commit
ad8c163436
@ -19,7 +19,9 @@ class DocumentController extends Controller{
|
||||
$uid = self::preDispatch();
|
||||
|
||||
$view = new \OC\Files\View('/' . $uid . '/files');
|
||||
$path = Helper::getNewFileName($view, '/New Document.odt');
|
||||
|
||||
$dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
|
||||
$path = Helper::getNewFileName($view, $dir . '/New Document.odt');
|
||||
|
||||
$view->file_put_contents(
|
||||
$path,
|
||||
|
38
ajax/personal.php
Normal file
38
ajax/personal.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Documents 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\Documents;
|
||||
|
||||
\OCP\JSON::callCheck();
|
||||
\OCP\JSON::checkLoggedIn();
|
||||
|
||||
$savePath = isset($_POST['savePath']) ? $_POST['savePath'] : null;
|
||||
if (!is_null($savePath)){
|
||||
if (\OC\Files\Filesystem::file_exists($savePath) ===false ){
|
||||
if(!\OC\Files\Filesystem::mkdir($savePath)){
|
||||
\OCP\JSON::error(
|
||||
array(
|
||||
'data' => array('message'=>'')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
\OCP\Config::setUserValue(\OCP\User::getUser(), 'documents', 'save_path', $savePath);
|
||||
\OCP\JSON::success(
|
||||
array(
|
||||
'data' => array('message'=>'')
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
exit();
|
@ -21,10 +21,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//OCP\Util::addStyle( 'documents', 'style');
|
||||
|
||||
OCP\App::register(array('order' => 70, 'id' => 'documents', 'name' => 'Documents'));
|
||||
OCP\App::registerAdmin('documents', 'settings');
|
||||
OCP\App::registerPersonal('documents', 'personal');
|
||||
|
||||
OCP\App::addNavigationEntry(array(
|
||||
'id' => 'documents_index',
|
||||
|
@ -39,8 +39,12 @@ namespace OCA\Documents;
|
||||
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'documents', 'user');
|
||||
|
||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
||||
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
|
||||
|
||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
||||
$tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
|
||||
$tmpl->assign('savePath', $savePath);
|
||||
|
||||
$tmpl->printPage();
|
||||
|
15
js/personal.js
Normal file
15
js/personal.js
Normal file
@ -0,0 +1,15 @@
|
||||
$(document).ready(function(){
|
||||
var documentsSettings = {
|
||||
save : function() {
|
||||
var data = {
|
||||
savePath : $('#documents-default-path').val()
|
||||
};
|
||||
OC.msg.startSaving('#documents-personal .msg');
|
||||
$.post(OC.filePath('documents', 'ajax', 'personal.php'), data, documentsSettings.afterSave);
|
||||
},
|
||||
afterSave : function(data){
|
||||
OC.msg.finishedSaving('#documents-personal .msg', data);
|
||||
}
|
||||
};
|
||||
$('#documents-default-path').blur(documentsSettings.save);
|
||||
});
|
21
personal.php
Normal file
21
personal.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Documents 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\Documents;
|
||||
|
||||
\OCP\Util::addScript('documents', 'personal');
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'personal');
|
||||
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
|
||||
$tmpl->assign('savePath', $savePath);
|
||||
|
||||
return $tmpl->fetchPage();
|
@ -21,7 +21,7 @@
|
||||
<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="/" id="dir">
|
||||
<input type="hidden" name="dir" value="<?php p($_['savePath']) ?>" id="dir">
|
||||
<input type="file" id="file_upload_start" name='files[]'/>
|
||||
<a href="#" class="upload svg">
|
||||
<label><?php p('Upload') ?></label></a>
|
||||
|
7
templates/personal.php
Normal file
7
templates/personal.php
Normal file
@ -0,0 +1,7 @@
|
||||
<fieldset class="personalblock" id="documents-personal">
|
||||
<legend><strong><?php p($l->t('Documents')); ?></strong></legend>
|
||||
<div>
|
||||
<label for="documents-default-path"><strong><?php p($l->t('Save new documents to')) ?></strong></label>
|
||||
<input type="text" id="documents-default-path" value="<?php p($_['savePath']) ?>" /><span class="msg"></span>
|
||||
</div>
|
||||
</fieldset>
|
Loading…
x
Reference in New Issue
Block a user