PageSourceSearch

https://portal.owncloud.com/core/js/shareconfigmodel.js?v=dd2774748f47720d9deea7a9f29fea34

js owncloud.com collected 2026-09-24 08:49:14 UTC 5,843 bytes, 212 lines download raw bytes

1/*
2 * Copyright (c) 2015
3 *
4 * This file is licensed under the Affero General Public License version 3
5 * or later.
6 *
7 * See the COPYING-README file.
8 *
9 */
10
11/* global moment */
12
13(function() {
14	if (!OC.Share) {
15		OC.Share = {};
16		OC.Share.Types = {};
17	}
18
19	// FIXME: the config model should populate its own model attributes based on
20	// the old DOM-based config
21	var ShareConfigModel = OC.Backbone.Model.extend({
22		defaults: {
23			publicUploadEnabled: false,
24			enforceLinkPasswordReadOnly: oc_appconfig.core.enforceLinkPasswordReadOnly,
25			enforceLinkPasswordReadWrite: oc_appconfig.core.enforceLinkPasswordReadWrite,
26			enforceLinkPasswordReadWriteDelete: oc_appconfig.core.enforceLinkPasswordReadWriteDelete,
27			enforceLinkPasswordWriteOnly: oc_appconfig.core.enforceLinkPasswordWriteOnly,
28			defaultExpireDateUser: oc_appconfig.core.defaultExpireDateUser,
29			isDefaultExpireDateUserEnabled: oc_appconfig.core.defaultExpireDateUserEnabled,
30			isDefaultExpireDateUserEnforced: oc_appconfig.core.enforceDefaultExpireDateUser,
31			defaultExpireDateGroup: oc_appconfig.core.defaultExpireDateGroup,
32			isDefaultExpireDateGroupEnabled: oc_appconfig.core.defaultExpireDateGroupEnabled,
33			isDefaultExpireDateGroupEnforced: oc_appconfig.core.enforceDefaultExpireDateGroup,
34			isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
35			isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
36			isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
37			defaultExpireDateRemote: oc_appconfig.core.defaultExpireDateRemote,
38			isDefaultExpireDateRemoteEnabled: oc_appconfig.core.defaultExpireDateRemoteEnabled,
39			isDefaultExpireDateRemoteEnforced: oc_appconfig.core.enforceDefaultExpireDateRemote,
40			defaultExpireDate: oc_appconfig.core.defaultExpireDate,
41			isResharingAllowed: oc_appconfig.core.resharingAllowed,
42			allowGroupSharing: oc_appconfig.core.allowGroupSharing
43		},
44
45		/**
46		 * @returns {boolean}
47		 */
48		areAvatarsEnabled: function() {
49			return oc_config.enable_avatars === true;
50		},
51
52		/**
53		 * @returns {boolean}
54		 */
55		isPublicUploadEnabled: function() {
56			var publicUploadEnabled = $('#filestable').data('allow-public-upload');
57			return publicUploadEnabled === 'yes';
58		},
59
60		/**
61		 * @returns {boolean}
62		 */
63		isMailPublicNotificationEnabled: function() {
64			return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
65		},
66
67		/**
68		 * @returns {boolean}
69		 */
70		isSocialShareEnabled: function() {
71			return $('input:hidden[name=socialShareEnabled]').val() === 'yes';
72		},
73
74		/**
75		 * @returns {boolean}
76		 */
77		isMailNotificationEnabled: function() {
78			return $('input:hidden[name=mailNotificationEnabled]').val() === 'yes';
79		},
80
81		/**
82		 * @returns {boolean}
83		 */
84		isShareWithLinkAllowed: function() {
85			return $('#allowShareWithLink').val() === 'yes';
86		},
87
88		/**
89		 * @returns {string}
90		 */
91		getFederatedShareDocLink: function() {
92			return oc_appconfig.core.federatedCloudShareDoc;
93		},
94
95		getDefaultExpirationDateString: function () {
96			var expireDateString = '';
97			if (this.get('isDefaultExpireDateEnabled')) {
98				var date = moment.utc();
99				var expireAfterDays = this.get('defaultExpireDate');
100				date.add(expireAfterDays, 'days');
101				expireDateString = date.format('YYYY-MM-DD 00:00:00');
102			}
103			return expireDateString;
104		},
105
106		/**
107		 * @returns {boolean}
108		 */
109		isDefaultExpireDateUserEnabled: function() {
110			return this.get('isDefaultExpireDateUserEnabled');
111		},
112
113		/**
114		 * @returns {boolean}
115		 */
116		isDefaultExpireDateUserEnforced: function() {
117			return this.get('isDefaultExpireDateUserEnforced');
118		},
119
120		/**
121		 * @returns {number/string}
122		 */
123		getDefaultExpireDateUser: function(format) {
124			format = format || false;
125			var defaultExpireDateUser = parseInt(this.get('defaultExpireDateUser'), 10);
126
127			if (format) {
128				return moment().add(defaultExpireDateUser, 'days').format(format);
129			}
130
131			return defaultExpireDateUser;
132		},
133
134		/**
135		 * @returns {boolean}
136		 */
137		isDefaultExpireDateGroupEnabled: function() {
138			return this.get('isDefaultExpireDateGroupEnabled');
139		},
140
141		/**
142		 * @returns {boolean}
143		 */
144		isDefaultExpireDateGroupEnforced: function() {
145			return this.get('isDefaultExpireDateGroupEnforced');
146		},
147
148		/**
149		 * @returns {number/string}
150		 */
151		getDefaultExpireDateGroup: function(format) {
152			format = format || false;
153			defaultExpireDateGroup = parseInt(this.get('defaultExpireDateGroup'), 10);
154
155			if (format) {
156				return moment().add(defaultExpireDateGroup, 'days').format(format);
157			}
158
159			return defaultExpireDateGroup;
160		},
161
162		/**
163		 * @returns {boolean}
164		 */
165		isDefaultExpireDateRemoteEnabled: function() {
166			return this.get('isDefaultExpireDateRemoteEnabled');
167		},
168
169		/**
170		 * @returns {boolean}
171		 */
172		isDefaultExpireDateRemoteEnforced: function() {
173			return this.get('isDefaultExpireDateRemoteEnforced');
174		},
175
176		/**
177		 * @returns {number/string}
178		 */
179		getDefaultExpireDateRemote: function(format) {
180			format = format || false;
181			defaultExpireDateRemote = parseInt(this.get('defaultExpireDateRemote'), 10);
182
183			if (format) {
184				return moment().add(defaultExpireDateRemote, 'days').format(format);
185			}
186
187			return defaultExpireDateRemote;
188		},
189
190		/**
191		 * @returns {boolean}
192		 */
193		isPublicSharingBlockedByAllowlist: function () {
194			var allowlistEnabled = oc_appconfig.files_sharing.publicShareSharersGroupsAllowlistEnabled;
195			var allowlistGroups = oc_appconfig.files_sharing.publicShareSharersGroupsAllowlist;
196
197			if (allowlistEnabled === true && allowlistGroups.length) {
198				var userGroups = OC.getCurrentUser().groups;
199				for (var i = 0; i < userGroups.length; i++) {
200					if (allowlistGroups.indexOf(userGroups[i]) >= 0) {
201						return false;
202					}
203				}
204				return true;
205			}
206			return false;
207		}
208	});
209
210
211	OC.Share.ShareConfigModel = ShareConfigModel;
212})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.