shareconfigmodel.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
  23. isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
  24. isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
  25. isMailShareAllowed: oc_appconfig.shareByMailEnabled !== undefined,
  26. defaultExpireDate: oc_appconfig.core.defaultExpireDate,
  27. isResharingAllowed: oc_appconfig.core.resharingAllowed,
  28. allowGroupSharing: oc_appconfig.core.allowGroupSharing
  29. },
  30. /**
  31. * @returns {boolean}
  32. */
  33. areAvatarsEnabled: function() {
  34. return oc_config.enable_avatars === true;
  35. },
  36. /**
  37. * @returns {boolean}
  38. */
  39. isPublicUploadEnabled: function() {
  40. var publicUploadEnabled = $('#filestable').data('allow-public-upload');
  41. return publicUploadEnabled === 'yes';
  42. },
  43. /**
  44. * @returns {boolean}
  45. */
  46. isShareWithLinkAllowed: function() {
  47. return $('#allowShareWithLink').val() === 'yes';
  48. },
  49. /**
  50. * @returns {string}
  51. */
  52. getFederatedShareDocLink: function() {
  53. return oc_appconfig.core.federatedCloudShareDoc;
  54. },
  55. getDefaultExpirationDateString: function () {
  56. var expireDateString = '';
  57. if (this.get('isDefaultExpireDateEnabled')) {
  58. var date = moment.utc();
  59. var expireAfterDays = this.get('defaultExpireDate');
  60. date.add(expireAfterDays, 'days');
  61. expireDateString = date.format('YYYY-MM-DD 00:00:00');
  62. }
  63. return expireDateString;
  64. }
  65. });
  66. OC.Share.ShareConfigModel = ShareConfigModel;
  67. })();