|
@@ -49,31 +49,46 @@ protocol NCPermission: NCToggleCellConfig {
|
|
|
static var forDirectoryE2EE: [Self] { get }
|
|
|
static var forFile: [Self] { get }
|
|
|
func hasResharePermission(for parentPermission: Int) -> Bool
|
|
|
+ func hasDownload() -> Bool
|
|
|
}
|
|
|
|
|
|
enum NCUserPermission: CaseIterable, NCPermission {
|
|
|
func hasResharePermission(for parentPermission: Int) -> Bool {
|
|
|
+ if self == .download { return true }
|
|
|
return ((permissionBitFlag & parentPermission) != 0)
|
|
|
}
|
|
|
|
|
|
+ func hasDownload() -> Bool {
|
|
|
+ return self == .download
|
|
|
+ }
|
|
|
+
|
|
|
var permissionBitFlag: Int {
|
|
|
switch self {
|
|
|
case .reshare: return NCGlobal.shared.permissionShareShare
|
|
|
case .edit: return NCGlobal.shared.permissionUpdateShare
|
|
|
case .create: return NCGlobal.shared.permissionCreateShare
|
|
|
case .delete: return NCGlobal.shared.permissionDeleteShare
|
|
|
+ case .download: return NCGlobal.shared.permissionDownloadShare
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func didChange(_ share: NCTableShareable, to newValue: Bool) {
|
|
|
- share.permissions ^= permissionBitFlag
|
|
|
+ if self == .download {
|
|
|
+ share.attributes = NCManageDatabase.shared.setAttibuteDownload(state: newValue)
|
|
|
+ } else {
|
|
|
+ share.permissions ^= permissionBitFlag
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func isOn(for share: NCTableShareable) -> Bool {
|
|
|
- return (share.permissions & permissionBitFlag) != 0
|
|
|
+ if self == .download {
|
|
|
+ return NCManageDatabase.shared.isAttributeDownloadEnabled(attributes: share.attributes)
|
|
|
+ } else {
|
|
|
+ return (share.permissions & permissionBitFlag) != 0
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- case reshare, edit, create, delete
|
|
|
+ case reshare, edit, create, delete, download
|
|
|
static let forDirectory: [NCUserPermission] = NCUserPermission.allCases
|
|
|
static let forDirectoryE2EE: [NCUserPermission] = []
|
|
|
static let forFile: [NCUserPermission] = [.reshare, .edit]
|
|
@@ -84,11 +99,13 @@ enum NCUserPermission: CaseIterable, NCPermission {
|
|
|
case .edit: return NSLocalizedString("_share_can_change_", comment: "")
|
|
|
case .create: return NSLocalizedString("_share_can_create_", comment: "")
|
|
|
case .delete: return NSLocalizedString("_share_can_delete_", comment: "")
|
|
|
+ case .download: return NSLocalizedString("_share_can_download_", comment: "")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
enum NCLinkPermission: NCPermission {
|
|
|
+
|
|
|
func didChange(_ share: NCTableShareable, to newValue: Bool) {
|
|
|
guard self != .allowEdit || newValue else {
|
|
|
share.permissions = NCGlobal.shared.permissionReadShare
|
|
@@ -101,6 +118,10 @@ enum NCLinkPermission: NCPermission {
|
|
|
permissionValue & parentPermission == permissionValue
|
|
|
}
|
|
|
|
|
|
+ func hasDownload() -> Bool {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
var permissionValue: Int {
|
|
|
switch self {
|
|
|
case .allowEdit:
|
|
@@ -225,7 +246,7 @@ struct NCShareConfig {
|
|
|
let cellConfig = config(for: indexPath)
|
|
|
let cell = cellConfig?.getCell(for: share)
|
|
|
cell?.textLabel?.text = cellConfig?.title
|
|
|
- if let cellConfig = cellConfig as? NCPermission, !cellConfig.hasResharePermission(for: resharePermission) {
|
|
|
+ if let cellConfig = cellConfig as? NCPermission, !cellConfig.hasResharePermission(for: resharePermission), !cellConfig.hasDownload() {
|
|
|
cell?.isUserInteractionEnabled = false
|
|
|
cell?.textLabel?.isEnabled = false
|
|
|
}
|