Skip to content

Commit

Permalink
bisheng OnlyOffice plugins: change to use hashsimple to generate docu…
Browse files Browse the repository at this point in the history
…ment ID
  • Loading branch information
zhtengw committed May 24, 2020
1 parent 7961590 commit 1906821
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
3 changes: 1 addition & 2 deletions kodbox-plugins/OnlyOffice/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public function index() {
'apiServer' => $http_header.$dsServer,
'url' => $fileUrl,
'callbackUrl' => "",
// key 必须不为null,分享页面fileInfo['hashMd5'],非分享页面$this->fileInfo['fileInfo']['hashMd5']
'key' => $this->fileInfo['hashMd5'] ? : $this->fileInfo['fileInfo']['hashMd5'],
'key' => IO::hashSimple($path),
'fileType' => $this->fileTypeAlias($fileExt),
'title' => $fileName,
'compact' => false,
Expand Down
2 changes: 1 addition & 1 deletion kodbox-plugins/OnlyOffice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id":"OnlyOffice",
"name":"{{LNG['OnlyOffice.meta.name']}}",
"title":"{{LNG['OnlyOffice.meta.title']}}",
"version":"2.3",
"version":"2.4",
"category":"file",
"source":{
"icon":"{{pluginHost}}static/images/icon.png",
Expand Down
5 changes: 2 additions & 3 deletions kodbox-plugins/bisheng/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ public function index() {
$fileName = $this->fileInfo['name'];
$fileExt = get_path_ext($this->fileInfo['name']);

//show_tips(json_encode(Session::get('kodUser')));
//show_tips(IO::hashSimple($path));
$config = $this->getConfig();
$apiServer = $config['apiServer'].'/apps/editor/openPreview?callURL=';
$options = array(
'doc' => array(
// docID 必须不为null,分享页面fileInfo['hashMd5'],非分享页面$this->fileInfo['fileInfo']['hashMd5']
'docId' => $this->fileInfo['hashMd5'] ? : $this->fileInfo['fileInfo']['hashMd5'],
'docId' => IO::hashSimple($path),
'title' => $fileName,
//'mime_type' => mime_content_type($fileName),
'fetchUrl' => $fileUrl,
Expand Down
2 changes: 1 addition & 1 deletion kodbox-plugins/bisheng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id":"bisheng",
"name":"{{LNG['bisheng.meta.name']}}",
"title":"{{LNG['bisheng.meta.title']}}",
"version":"1.4",
"version":"1.5",
"category":"file",
"source":{
"icon":"{{pluginHost}}static/images/icon.png",
Expand Down
8 changes: 3 additions & 5 deletions kodexplorer-plugins/OnlyOffice/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function index() {
$fileExt = get_path_ext($path);


//explorer::mkdir($parentDir.'/.hist-'.$fileName);
//explorer::mkfile($parentDir.'/.hist-'.$fileName.'/histdata.txt');
//mkdir($parentDir.'/.hist-'.$fileName);
//mkfile($parentDir.'/.hist-'.$fileName.'/histdata.txt');
//explorer::mkfile($parentDir.'/histdata.txt');

$config = $this->getConfig();
Expand All @@ -50,8 +50,7 @@ public function index() {
'apiServer' => $http_header.$dsServer,
'url' => $fileUrl,
'callbackUrl' => "",
'key' => md5_file($path),
'time' => filemtime($path),
'key' => file_hash_simple($path),
'fileType' => $this->fileTypeAlias($fileExt),
'title' => $fileName,
'compact' => false,
Expand Down Expand Up @@ -93,7 +92,6 @@ public function index() {
if (!$config['previewMode'] && check_file_writable_user($path)) {
$option['mode'] = 'edit';
$option['canEdit'] = true;
$option['key'] = md5($path.$option['time']);
$option['callbackUrl'] = $this->pluginHost.'php/save.php?path='.rawurlencode($path);
}
//内部对话框打开时,使用紧凑显示
Expand Down
2 changes: 1 addition & 1 deletion kodexplorer-plugins/OnlyOffice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id":"OnlyOffice",
"name":"{{LNG.OnlyOffice.meta.name}}",
"title":"{{LNG.OnlyOffice.meta.title}}",
"version":"2.3",
"version":"2.4",
"category":"file",
"source":{
"icon":"{{pluginHost}}static/images/icon.png",
Expand Down
4 changes: 1 addition & 3 deletions kodexplorer-plugins/bisheng/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function index() {
//show_tips(json_encode($_SESSION));
$options = array(
'doc' => array(
'docId' => md5_file($path),
'docId' => file_hash_simple($path),
'title' => $fileName,
//'mime_type' => mime_content_type($fileName),
'fetchUrl' => $fileUrl,
Expand All @@ -54,7 +54,6 @@ public function index() {
$options['user']['privilege'] = array('FILE_READ',);
}

$timestamp = filemtime($path);
if (!$GLOBALS['isRoot']) {
/** * 下载&打印&导出:权限取决于文件是否可以下载;(管理员无视所有权限拦截) * 1. 当前用户是否允许下载 * 2. 所在群组文件,用户在群组内的权限是否可下载 * 3. 文件分享,限制了下载 */
if ($GLOBALS['auth'] && !$GLOBALS['auth']['explorer.fileDownload']) {
Expand All @@ -70,7 +69,6 @@ public function index() {
//可写权限检测
if (!$config['previewMode'] && check_file_writable_user($path)) {
array_push($options['user']['privilege'],'FILE_WRITE');
$options['doc']['docId'] = md5($path.$timestamp);
$options['doc']['callback'] = $this->pluginHost.'php/handler.php?act=save&path='.rawurlencode($path).'&api='.$config['apiServer'];
if(!$options['doc']['pdf_viewer']) $apiServer = $config['apiServer'].'/apps/editor/openEditor?callURL=';
}
Expand Down
2 changes: 1 addition & 1 deletion kodexplorer-plugins/bisheng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id":"bisheng",
"name":"{{LNG.bisheng.meta.name}}",
"title":"{{LNG.bisheng.meta.title}}",
"version":"1.4",
"version":"1.5",
"category":"file",
"source":{
"icon":"{{pluginHost}}static/images/icon.png",
Expand Down

0 comments on commit 1906821

Please sign in to comment.