You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shareconfigmodel.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 */
  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. defaultExpireDate: oc_appconfig.core.defaultExpireDate,
  26. isResharingAllowed: oc_appconfig.core.resharingAllowed,
  27. allowGroupSharing: oc_appconfig.core.allowGroupSharing
  28. },
  29. /**
  30. * @returns {boolean}
  31. */
  32. areAvatarsEnabled: function() {
  33. return oc_config.enable_avatars === true;
  34. },
  35. /**
  36. * @returns {boolean}
  37. */
  38. isPublicUploadEnabled: function() {
  39. var publicUploadEnabled = $('#filestable').data('allow-public-upload');
  40. return publicUploadEnabled === 'yes';
  41. },
  42. /**
  43. * @returns {boolean}
  44. */
  45. isMailPublicNotificationEnabled: function() {
  46. return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
  47. },
  48. /**
  49. * @returns {boolean}
  50. */
  51. isMailNotificationEnabled: function() {
  52. return $('input:hidden[name=mailNotificationEnabled]').val() === 'yes';
  53. },
  54. /**
  55. * @returns {boolean}
  56. */
  57. isShareWithLinkAllowed: function() {
  58. return $('#allowShareWithLink').val() === 'yes';
  59. },
  60. /**
  61. * @returns {string}
  62. */
  63. getFederatedShareDocLink: function() {
  64. return oc_appconfig.core.federatedCloudShareDoc;
  65. },
  66. getDefaultExpirationDateString: function () {
  67. var expireDateString = '';
  68. if (this.get('isDefaultExpireDateEnabled')) {
  69. var date = moment.utc();
  70. var expireAfterDays = this.get('defaultExpireDate');
  71. date.add(expireAfterDays, 'days');
  72. expireDateString = date.format('YYYY-MM-DD 00:00:00');
  73. }
  74. return expireDateString;
  75. }
  76. });
  77. OC.Share.ShareConfigModel = ShareConfigModel;
  78. })();