Move rename controller to document

pull/1/head
Victor Dubiniuk 11 years ago
parent b7d71e025b
commit 988ae02b8e

@ -55,6 +55,25 @@ class DocumentController extends Controller{
$download = new Download($sessionData['owner'], $filename);
$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)

@ -22,24 +22,6 @@ class SessionController extends Controller{
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){
$uid = self::preDispatch();
$fileId = intval(@$args['file_id']);

@ -21,6 +21,10 @@ $this->create('documents_genesis', 'ajax/genesis/{es_id}')
->post()
->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}')
->get()
->action('\OCA\Documents\DocumentController', 'serve')
@ -73,10 +77,6 @@ $this->create('documents_session_joinasguest', 'ajax/session/joinasguest/{token}
->post()
->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')
->post()

@ -290,7 +290,7 @@ var documentsMain = {
},
renameDocument: function(name) {
var url = OC.Router.generate('documents_session_renamedocument') + '/' + documentsMain.fileId;
var url = OC.Router.generate('documents_rename') + '/' + documentsMain.fileId;
$.post(
url,
{ name : name },

Loading…
Cancel
Save