diff --git a/lib/zin/wg/docapp/js/v1.js b/lib/zin/wg/docapp/js/v1.js index ef9f0e07a8..4e9dca95d5 100644 --- a/lib/zin/wg/docapp/js/v1.js +++ b/lib/zin/wg/docapp/js/v1.js @@ -55,9 +55,10 @@ function getLang(key, args) * Check if the specified privilege exists, privileges are defined in $privs in module/doc/ui/app.html.php. * @param {string} priv */ -function hasPriv(priv) +function hasPriv(priv, value) { - return !!userPrivs[priv]; + const setting = userPrivs[priv]; + return value !== undefined ? setting === value : !!setting; } /** @@ -477,7 +478,7 @@ const actionsMap = if(hasPriv('exportDoc')) moreItems.push({icon: 'export', text: lang.export, command: 'exportDoc'}); return [ - {icon: doc.isCollector ? 'star text-warning' : 'star-empty', text: doc.collects || null, hint: doc.isCollector ? lang.cancelCollection : lang.collect, rounded: 'lg', textClass: 'text-gray', type: 'ghost', command: hasPriv('collect') ? `collectDoc/${doc.id}` : null}, + hasPriv('collect', 'no') ? null : {icon: doc.isCollector ? 'star text-warning' : 'star-empty', text: doc.collects || null, hint: doc.isCollector ? lang.cancelCollection : lang.collect, rounded: 'lg', textClass: 'text-gray', type: 'ghost', command: hasPriv('collect') ? `collectDoc/${doc.id}` : null}, canEditDoc ? {icon: 'edit', type: 'ghost text-primary', hint: lang.edit, rounded: 'lg', command: 'startEditDoc'} : null, moreItems.length ? {icon: 'icon-ellipsis-v', type: 'dropdown', rounded: 'lg', placement: 'bottom-end', caret: false, items: moreItems} : null, ]; @@ -584,6 +585,7 @@ const actionsMap = const canCreateLib = canModify && hasPriv('createLib'); const canCreateSpace = canModify && hasPriv('createSpace'); const canCreateOffice = canModify && hasPriv('createOffice'); + const canUploadDoc = canModify && hasPriv('uploadFile'); const canExportDoc = hasPriv('exportDoc'); /* 文档列表没有文档时的按钮。Actions for empty doc list. */ @@ -596,17 +598,17 @@ const actionsMap = [ canCreateDoc ? {icon: 'plus', text: lang.createDoc, command: 'startCreateDoc'} : null, canCreateDoc ? {type: 'divider'} : null, - canCreateOffice ? {icon: 'file-word', text: lang.createList.word, command: 'startCreateOffice/word'} : null, - canCreateOffice ? {icon: 'file-powerpoint', text: lang.createList.ppt, command: 'startCreateOffice/ppt'} : null, - canCreateOffice ? {icon: 'file-excel', text: lang.createList.excel, command: 'startCreateOffice/excel'} : null, - (canCreateLib || canCreateSpace) ? {type: 'divider'} : null, + canCreateOffice ? {icon: 'file-word', text: lang.createList.word, command: 'startCreateOffice/word'} : null, + canCreateOffice ? {icon: 'file-powerpoint', text: lang.createList.ppt, command: 'startCreateOffice/ppt'} : null, + canCreateOffice ? {icon: 'file-excel', text: lang.createList.excel, command: 'startCreateOffice/excel'} : null, + (canCreateOffice && (canCreateLib || canCreateSpace)) ? {type: 'divider'} : null, canCreateSpace ? {icon: 'cube', text: lang.createSpace, command: 'createSpace'} : null, canCreateLib ? {icon: 'wiki-lib', text: lang.createLib, command: 'createLib'} : null, ].filter(Boolean) : []; return [ ((canExportDoc && docApp.libID > 0 ) || canCreateDoc) ? {type: 'divider', style: {margin: '6px 0'}} : null, canExportDoc && docApp.libID > 0 ? {icon: 'export', text: lang.export, command: 'exportDoc'} : null, // 不在库中,无法导出 - canCreateDoc ? {icon: 'import', text: lang.uploadDoc, command: 'uploadDoc'} : null, + canUploadDoc ? {icon: 'import', text: lang.uploadDoc, command: 'uploadDoc'} : null, items.length ? {icon: 'plus', type: 'dropdown', btnType: 'primary', size: 'md', text: lang.create, items: items} : null, ]; }, diff --git a/module/doc/ui/app.html.php b/module/doc/ui/app.html.php index 42b276f264..0599d5763e 100644 --- a/module/doc/ui/app.html.php +++ b/module/doc/ui/app.html.php @@ -39,6 +39,7 @@ $privs['editLib'] = hasPriv('doc', 'editLib'); $privs['moveLib'] = hasPriv('doc', 'moveLib'); $privs['deleteLib'] = hasPriv('doc', 'deleteLib'); $privs['sortDocLib'] = hasPriv('doc', 'sortDocLib'); +$privs['uploadFile'] = hasPriv('doc', 'create'); $privs['exportFiles'] = hasPriv('doc', 'exportFiles'); $privs['createSpace'] = $hasCustomSpace && hasPriv('doc', 'createSpace'); $privs['deleteSpace'] = $hasCustomSpace && hasPriv('doc', 'deleteSpace');