2019-09-25 19:19:42 +03:00
|
|
|
/* eslint-disable */
|
2015-08-13 03:38:14 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-05-03 09:42:42 +03:00
|
|
|
/* global moment, OC */
|
2016-01-28 14:28:30 +03:00
|
|
|
|
2015-08-13 03:38:14 +03:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
2019-09-25 19:19:42 +03:00
|
|
|
OC.Share = {}
|
|
|
|
OC.Share.Types = {}
|
2015-08-13 03:38:14 +03:00
|
|
|
}
|
|
|
|
|
2015-09-15 11:27:33 +03:00
|
|
|
// FIXME: the config model should populate its own model attributes based on
|
|
|
|
// the old DOM-based config
|
2015-08-13 03:38:14 +03:00
|
|
|
var ShareConfigModel = OC.Backbone.Model.extend({
|
|
|
|
defaults: {
|
2015-09-03 16:53:17 +03:00
|
|
|
publicUploadEnabled: false,
|
2019-05-03 09:42:42 +03:00
|
|
|
enforcePasswordForPublicLink: OC.appConfig.core.enforcePasswordForPublicLink,
|
|
|
|
enableLinkPasswordByDefault: OC.appConfig.core.enableLinkPasswordByDefault,
|
|
|
|
isDefaultExpireDateEnforced: OC.appConfig.core.defaultExpireDateEnforced === true,
|
|
|
|
isDefaultExpireDateEnabled: OC.appConfig.core.defaultExpireDateEnabled === true,
|
|
|
|
isRemoteShareAllowed: OC.appConfig.core.remoteShareAllowed,
|
|
|
|
isMailShareAllowed: OC.appConfig.shareByMailEnabled !== undefined,
|
|
|
|
defaultExpireDate: OC.appConfig.core.defaultExpireDate,
|
|
|
|
isResharingAllowed: OC.appConfig.core.resharingAllowed,
|
|
|
|
isPasswordForMailSharesRequired: (OC.appConfig.shareByMail === undefined) ? false : OC.appConfig.shareByMail.enforcePasswordProtection,
|
|
|
|
allowGroupSharing: OC.appConfig.core.allowGroupSharing
|
2015-08-13 03:38:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isPublicUploadEnabled: function() {
|
2019-09-25 19:19:42 +03:00
|
|
|
var publicUploadEnabled = $('#filestable').data('allow-public-upload')
|
|
|
|
return publicUploadEnabled === 'yes'
|
2015-08-13 03:38:14 +03:00
|
|
|
},
|
|
|
|
|
2015-08-18 13:13:08 +03:00
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isShareWithLinkAllowed: function() {
|
2019-09-25 19:19:42 +03:00
|
|
|
return $('#allowShareWithLink').val() === 'yes'
|
2015-08-18 13:13:08 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getFederatedShareDocLink: function() {
|
2019-09-25 19:19:42 +03:00
|
|
|
return OC.appConfig.core.federatedCloudShareDoc
|
2015-09-12 15:21:14 +03:00
|
|
|
},
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
getDefaultExpirationDateString: function() {
|
|
|
|
var expireDateString = ''
|
2015-09-12 15:21:14 +03:00
|
|
|
if (this.get('isDefaultExpireDateEnabled')) {
|
2019-09-25 19:19:42 +03:00
|
|
|
var date = moment.utc()
|
|
|
|
var expireAfterDays = this.get('defaultExpireDate')
|
|
|
|
date.add(expireAfterDays, 'days')
|
|
|
|
expireDateString = date.format('YYYY-MM-DD 00:00:00')
|
2015-09-12 15:21:14 +03:00
|
|
|
}
|
2019-09-25 19:19:42 +03:00
|
|
|
return expireDateString
|
2015-08-13 03:38:14 +03:00
|
|
|
}
|
2019-09-25 19:19:42 +03:00
|
|
|
})
|
2015-08-13 03:38:14 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
OC.Share.ShareConfigModel = ShareConfigModel
|
|
|
|
})()
|