shareconfigmodel.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * @deprecated here for legacy reasons - will always return true
  35. */
  36. areAvatarsEnabled: function() {
  37. return true;
  38. },
  39. /**
  40. * @returns {boolean}
  41. */
  42. isPublicUploadEnabled: function() {
  43. var publicUploadEnabled = $('#filestable').data('allow-public-upload');
  44. return publicUploadEnabled === 'yes';
  45. },
  46. /**
  47. * @returns {boolean}
  48. */
  49. isShareWithLinkAllowed: function() {
  50. return $('#allowShareWithLink').val() === 'yes';
  51. },
  52. /**
  53. * @returns {string}
  54. */
  55. getFederatedShareDocLink: function() {
  56. return oc_appconfig.core.federatedCloudShareDoc;
  57. },
  58. getDefaultExpirationDateString: function () {
  59. var expireDateString = '';
  60. if (this.get('isDefaultExpireDateEnabled')) {
  61. var date = moment.utc();
  62. var expireAfterDays = this.get('defaultExpireDate');
  63. date.add(expireAfterDays, 'days');
  64. expireDateString = date.format('YYYY-MM-DD 00:00:00');
  65. }
  66. return expireDateString;
  67. }
  68. });
  69. OC.Share.ShareConfigModel = ShareConfigModel;
  70. })();