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 */
  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. })();