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