1
0

shareconfigmodel.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /* global moment, oc_appconfig, oc_config */
  11. (function() {
  12. if (!OC.Share) {
  13. OC.Share = {};
  14. OC.Share.Types = {};
  15. }
  16. // FIXME: the config model should populate its own model attributes based on
  17. // the old DOM-based config
  18. var ShareConfigModel = OC.Backbone.Model.extend({
  19. defaults: {
  20. publicUploadEnabled: false,
  21. enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
  22. enableLinkPasswordByDefault: oc_appconfig.core.enableLinkPasswordByDefault,
  23. isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
  24. isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
  25. isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
  26. isMailShareAllowed: oc_appconfig.shareByMailEnabled !== undefined,
  27. defaultExpireDate: oc_appconfig.core.defaultExpireDate,
  28. isResharingAllowed: oc_appconfig.core.resharingAllowed,
  29. isPasswordForMailSharesRequired: (oc_appconfig.shareByMail === undefined) ? false : oc_appconfig.shareByMail.enforcePasswordProtection,
  30. allowGroupSharing: oc_appconfig.core.allowGroupSharing
  31. },
  32. /**
  33. * @returns {boolean}
  34. */
  35. isPublicUploadEnabled: function() {
  36. var publicUploadEnabled = $('#filestable').data('allow-public-upload');
  37. return publicUploadEnabled === 'yes';
  38. },
  39. /**
  40. * @returns {boolean}
  41. */
  42. isShareWithLinkAllowed: function() {
  43. return $('#allowShareWithLink').val() === 'yes';
  44. },
  45. /**
  46. * @returns {string}
  47. */
  48. getFederatedShareDocLink: function() {
  49. return oc_appconfig.core.federatedCloudShareDoc;
  50. },
  51. getDefaultExpirationDateString: function () {
  52. var expireDateString = '';
  53. if (this.get('isDefaultExpireDateEnabled')) {
  54. var date = moment.utc();
  55. var expireAfterDays = this.get('defaultExpireDate');
  56. date.add(expireAfterDays, 'days');
  57. expireDateString = date.format('YYYY-MM-DD 00:00:00');
  58. }
  59. return expireDateString;
  60. }
  61. });
  62. OC.Share.ShareConfigModel = ShareConfigModel;
  63. })();