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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. isMailPublicNotificationEnabled: function() {
  47. return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
  48. },
  49. /**
  50. * @returns {boolean}
  51. */
  52. isMailNotificationEnabled: function() {
  53. return $('input:hidden[name=mailNotificationEnabled]').val() === 'yes';
  54. },
  55. /**
  56. * @returns {boolean}
  57. */
  58. isShareWithLinkAllowed: function() {
  59. return $('#allowShareWithLink').val() === 'yes';
  60. },
  61. /**
  62. * @returns {string}
  63. */
  64. getFederatedShareDocLink: function() {
  65. return oc_appconfig.core.federatedCloudShareDoc;
  66. },
  67. getDefaultExpirationDateString: function () {
  68. var expireDateString = '';
  69. if (this.get('isDefaultExpireDateEnabled')) {
  70. var date = moment.utc();
  71. var expireAfterDays = this.get('defaultExpireDate');
  72. date.add(expireAfterDays, 'days');
  73. expireDateString = date.format('YYYY-MM-DD 00:00:00');
  74. }
  75. return expireDateString;
  76. }
  77. });
  78. OC.Share.ShareConfigModel = ShareConfigModel;
  79. })();