Move rename controller to document
This commit is contained in:
parent
b7d71e025b
commit
988ae02b8e
@ -55,6 +55,25 @@ class DocumentController extends Controller{
|
|||||||
$download = new Download($sessionData['owner'], $filename);
|
$download = new Download($sessionData['owner'], $filename);
|
||||||
$download->sendResponse();
|
$download->sendResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function rename($args){
|
||||||
|
$fileId = intval(@$args['file_id']);
|
||||||
|
$name = @$_POST['name'];
|
||||||
|
$file = new File($fileId);
|
||||||
|
$l = new \OC_L10n('documents');
|
||||||
|
|
||||||
|
if (isset($name) && $file->getPermissions() & \OCP\PERMISSION_UPDATE) {
|
||||||
|
if ($file->renameTo($name)) {
|
||||||
|
// TODO: propagate to other clients
|
||||||
|
\OCP\JSON::success();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\OCP\JSON::error(array(
|
||||||
|
'message' => $l->t('You don\'t have permission to rename this document')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lists the documents the user has access to (including shared files, once the code in core has been fixed)
|
* lists the documents the user has access to (including shared files, once the code in core has been fixed)
|
||||||
|
@ -22,24 +22,6 @@ class SessionController extends Controller{
|
|||||||
self::join($uid, $file);
|
self::join($uid, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function renameDocument($args){
|
|
||||||
$fileId = intval(@$args['file_id']);
|
|
||||||
$name = @$_POST['name'];
|
|
||||||
$file = new File($fileId);
|
|
||||||
$l = new \OC_L10n('documents');
|
|
||||||
|
|
||||||
if (isset($name) && $file->getPermissions() & \OCP\PERMISSION_UPDATE) {
|
|
||||||
if ($file->renameTo($name)) {
|
|
||||||
// TODO: propagate to other clients
|
|
||||||
\OCP\JSON::success();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
\OCP\JSON::error(array(
|
|
||||||
'message' => $l->t('You don\'t have permission to rename this document')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function joinAsUser($args){
|
public static function joinAsUser($args){
|
||||||
$uid = self::preDispatch();
|
$uid = self::preDispatch();
|
||||||
$fileId = intval(@$args['file_id']);
|
$fileId = intval(@$args['file_id']);
|
||||||
|
@ -21,6 +21,10 @@ $this->create('documents_genesis', 'ajax/genesis/{es_id}')
|
|||||||
->post()
|
->post()
|
||||||
->action('\OCA\Documents\DocumentController', 'serve')
|
->action('\OCA\Documents\DocumentController', 'serve')
|
||||||
;
|
;
|
||||||
|
$this->create('documents_rename', 'ajax/documents/rename/{file_id}')
|
||||||
|
->post()
|
||||||
|
->action('\OCA\Documents\DocumentController', 'rename')
|
||||||
|
;
|
||||||
$this->create('documents_genesis', 'ajax/genesis/{es_id}')
|
$this->create('documents_genesis', 'ajax/genesis/{es_id}')
|
||||||
->get()
|
->get()
|
||||||
->action('\OCA\Documents\DocumentController', 'serve')
|
->action('\OCA\Documents\DocumentController', 'serve')
|
||||||
@ -73,10 +77,6 @@ $this->create('documents_session_joinasguest', 'ajax/session/joinasguest/{token}
|
|||||||
->post()
|
->post()
|
||||||
->action('\OCA\Documents\SessionController', 'joinAsGuest')
|
->action('\OCA\Documents\SessionController', 'joinAsGuest')
|
||||||
;
|
;
|
||||||
$this->create('documents_session_renamedocument', 'ajax/session/renamedocument/{file_id}')
|
|
||||||
->post()
|
|
||||||
->action('\OCA\Documents\SessionController', 'renameDocument')
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->create('documents_session_save', 'ajax/session/save')
|
$this->create('documents_session_save', 'ajax/session/save')
|
||||||
->post()
|
->post()
|
||||||
|
@ -290,7 +290,7 @@ var documentsMain = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
renameDocument: function(name) {
|
renameDocument: function(name) {
|
||||||
var url = OC.Router.generate('documents_session_renamedocument') + '/' + documentsMain.fileId;
|
var url = OC.Router.generate('documents_rename') + '/' + documentsMain.fileId;
|
||||||
$.post(
|
$.post(
|
||||||
url,
|
url,
|
||||||
{ name : name },
|
{ name : name },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user