2015-08-13 02:38:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-08-19 21:03:25 +02:00
|
|
|
/* global moment, oc_appconfig, oc_config */
|
2016-01-28 12:28:30 +01:00
|
|
|
|
2015-08-13 02:38:14 +02:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
OC.Share.Types = {};
|
|
|
|
}
|
|
|
|
|
2015-09-15 10:27:33 +02:00
|
|
|
// FIXME: the config model should populate its own model attributes based on
|
|
|
|
// the old DOM-based config
|
2015-08-13 02:38:14 +02:00
|
|
|
var ShareConfigModel = OC.Backbone.Model.extend({
|
|
|
|
defaults: {
|
2015-09-03 15:53:17 +02:00
|
|
|
publicUploadEnabled: false,
|
2015-09-04 15:31:45 +02:00
|
|
|
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
|
2016-10-17 09:11:30 +02:00
|
|
|
enableLinkPasswordByDefault: oc_appconfig.core.enableLinkPasswordByDefault,
|
2015-09-04 15:31:45 +02:00
|
|
|
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
|
2015-09-12 14:21:14 +02:00
|
|
|
isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
|
|
|
|
isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
|
2016-10-31 11:52:00 +01:00
|
|
|
isMailShareAllowed: oc_appconfig.shareByMailEnabled !== undefined,
|
2015-09-04 15:31:45 +02:00
|
|
|
defaultExpireDate: oc_appconfig.core.defaultExpireDate,
|
2016-03-21 19:47:10 +01:00
|
|
|
isResharingAllowed: oc_appconfig.core.resharingAllowed,
|
2017-04-10 18:36:23 +02:00
|
|
|
isPasswordForMailSharesRequired: (oc_appconfig.shareByMail === undefined) ? false : oc_appconfig.shareByMail.enforcePasswordProtection,
|
2016-03-21 19:47:10 +01:00
|
|
|
allowGroupSharing: oc_appconfig.core.allowGroupSharing
|
2015-08-13 02:38:14 +02:00
|
|
|
},
|
|
|
|
|
2015-08-18 12:13:08 +02:00
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
2017-02-14 00:49:05 +01:00
|
|
|
* @deprecated here for legacy reasons - will always return true
|
2015-08-18 12:13:08 +02:00
|
|
|
*/
|
|
|
|
areAvatarsEnabled: function() {
|
2017-02-14 00:49:05 +01:00
|
|
|
return true;
|
2015-08-18 12:13:08 +02:00
|
|
|
},
|
|
|
|
|
2015-08-13 02:38:14 +02:00
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isPublicUploadEnabled: function() {
|
|
|
|
var publicUploadEnabled = $('#filestable').data('allow-public-upload');
|
2015-09-14 00:43:11 +02:00
|
|
|
return publicUploadEnabled === 'yes';
|
2015-08-13 02:38:14 +02:00
|
|
|
},
|
|
|
|
|
2015-08-18 12:13:08 +02:00
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isShareWithLinkAllowed: function() {
|
|
|
|
return $('#allowShareWithLink').val() === 'yes';
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getFederatedShareDocLink: function() {
|
|
|
|
return oc_appconfig.core.federatedCloudShareDoc;
|
2015-09-12 14:21:14 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultExpirationDateString: function () {
|
|
|
|
var expireDateString = '';
|
|
|
|
if (this.get('isDefaultExpireDateEnabled')) {
|
2016-01-28 12:28:30 +01: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 14:21:14 +02:00
|
|
|
}
|
|
|
|
return expireDateString;
|
2015-08-13 02:38:14 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
OC.Share.ShareConfigModel = ShareConfigModel;
|
|
|
|
})();
|