Use path for creating sessions, store fileid to db
This commit is contained in:
parent
2635421222
commit
968a418ec9
@ -31,13 +31,16 @@ class Controller {
|
||||
public static function startSession($args){
|
||||
$uid = self::preDispatch();
|
||||
try{
|
||||
$fileId = @$_POST['fileid'];
|
||||
if (!$fileId){
|
||||
throw new \Exception('No fileId has been passed');
|
||||
$path = @$_POST['path'];
|
||||
if (!$path){
|
||||
throw new \Exception('No file has been passed');
|
||||
}
|
||||
|
||||
$officeView = View::initOfficeView($uid);
|
||||
$genesisPath = View::storeDocument($uid, $fileId);
|
||||
$genesisPath = View::storeDocument($uid, $path);
|
||||
$info = \OC_Files::getFileInfo($path);
|
||||
|
||||
$fileId = $info['fileid'];
|
||||
if (!$genesisPath){
|
||||
throw new \Exception('Unable to copy document. Check permissions and make sure you have enought free space.');
|
||||
}
|
||||
@ -52,7 +55,7 @@ class Controller {
|
||||
\OCP\JSON::success($session);
|
||||
exit();
|
||||
} catch (\Exception $e){
|
||||
Helper::warnLog('Starting a session failed. Reason:') . $e->getMessage();
|
||||
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
||||
\OCP\JSON::error();
|
||||
exit();
|
||||
}
|
||||
@ -75,7 +78,7 @@ class Controller {
|
||||
\OCP\JSON::success($session);
|
||||
exit();
|
||||
} catch (\Exception $e){
|
||||
Helper::warnLog('Joining a session failed. Reason:') . $e->getMessage();
|
||||
Helper::warnLog('Joining a session failed. Reason:' . $e->getMessage());
|
||||
\OCP\JSON::error();
|
||||
exit();
|
||||
}
|
||||
|
@ -66,18 +66,6 @@ try{
|
||||
$members
|
||||
);
|
||||
|
||||
break;
|
||||
case 'session_list':
|
||||
OCA\Office\Controller::listSessions();
|
||||
exit();
|
||||
break;
|
||||
case 'join_session':
|
||||
// should fail when session is non-existent
|
||||
break;
|
||||
OCA\Office\Controller::joinSession(array(
|
||||
'es_id' => $request->getParam('args/es_id')
|
||||
));
|
||||
exit();
|
||||
break;
|
||||
case 'sync_ops':
|
||||
$seqHead = (string) $request->getParam('args/seq_head');
|
||||
|
@ -92,7 +92,7 @@ var officeMain = {
|
||||
}
|
||||
|
||||
$.post(OC.Router.generate('office_session_start'),
|
||||
{'fileid': filepath},
|
||||
{'path': filepath},
|
||||
officeMain.initSession
|
||||
);
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ class Session {
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
public static function getSessionByFileId($fileId){
|
||||
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `file_id`= ?');
|
||||
$result = $query->execute(array($fileId));
|
||||
|
15
lib/view.php
15
lib/view.php
@ -30,21 +30,20 @@ class View extends \OC\Files\View{
|
||||
return new \OC\Files\View('/' . $uid . self::OFFICE_DIRNAME);
|
||||
}
|
||||
|
||||
public static function storeDocument($uid, $fileid){
|
||||
public static function storeDocument($uid, $filePath){
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
$path = \OC\Files\Cache\Cache::getById($fileid);
|
||||
if (is_null($path)){
|
||||
// No longer exists
|
||||
} else {
|
||||
$path = $path[1];
|
||||
$view = new \OC\Files\View('/' . $uid);
|
||||
|
||||
$relPath = '/files' . $filePath;
|
||||
if (!$view->file_exists($relPath)){
|
||||
throw new \Exception('Original document doesn\'t exist any more');
|
||||
}
|
||||
|
||||
$view = new \OC\Files\View('/' . $uid);
|
||||
$newName = '/' . sha1($view->file_get_contents($path)) . '.odt';
|
||||
|
||||
$view->copy( $path, self::OFFICE_DIRNAME . $newName);
|
||||
$view->copy($relPath, self::OFFICE_DIRNAME . $newName);
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
return $newName;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php foreach($_['list'] as $entry) { ?>
|
||||
<tr data-file="<?php p($entry['fileid']) ?>">
|
||||
<tr data-file="<?php p($entry['path']) ?>">
|
||||
<td>
|
||||
<img align="left" src="<?php p(\OCP\Util::linkToAbsolute('office','ajax/thumbnail.php').'?filepath='.\OCP\Util::encodePath($entry['path'])) ?>" />
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user