Data.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\SendFriend\Helper;
  7. /**
  8. * SendFriend Data Helper
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. *
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  16. {
  17. const XML_PATH_ENABLED = 'sendfriend/email/enabled';
  18. const XML_PATH_ALLOW_FOR_GUEST = 'sendfriend/email/allow_guest';
  19. const XML_PATH_MAX_RECIPIENTS = 'sendfriend/email/max_recipients';
  20. const XML_PATH_MAX_PER_HOUR = 'sendfriend/email/max_per_hour';
  21. const XML_PATH_LIMIT_BY = 'sendfriend/email/check_by';
  22. const XML_PATH_EMAIL_TEMPLATE = 'sendfriend/email/template';
  23. const COOKIE_NAME = 'stf';
  24. const CHECK_IP = 1;
  25. const CHECK_COOKIE = 0;
  26. /**
  27. * Check is enabled Module
  28. *
  29. * @param int $store
  30. * @return bool
  31. */
  32. public function isEnabled($store = null)
  33. {
  34. return $this->scopeConfig->isSetFlag(
  35. self::XML_PATH_ENABLED,
  36. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  37. $store
  38. );
  39. }
  40. /**
  41. * Check allow send email for guest
  42. *
  43. * @param int $store
  44. * @return bool
  45. */
  46. public function isAllowForGuest($store = null)
  47. {
  48. return $this->scopeConfig->isSetFlag(
  49. self::XML_PATH_ALLOW_FOR_GUEST,
  50. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  51. $store
  52. );
  53. }
  54. /**
  55. * Retrieve Max Recipients
  56. *
  57. * @param int $store
  58. * @return int
  59. */
  60. public function getMaxRecipients($store = null)
  61. {
  62. return (int)$this->scopeConfig->getValue(
  63. self::XML_PATH_MAX_RECIPIENTS,
  64. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  65. $store
  66. );
  67. }
  68. /**
  69. * Retrieve Max Products Sent in 1 Hour
  70. *
  71. * @param int $store
  72. * @return int
  73. */
  74. public function getMaxEmailPerPeriod($store = null)
  75. {
  76. return (int)$this->scopeConfig->getValue(
  77. self::XML_PATH_MAX_PER_HOUR,
  78. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  79. $store
  80. );
  81. }
  82. /**
  83. * Retrieve Limitation Period in seconds (1 hour)
  84. *
  85. * @return int
  86. */
  87. public function getPeriod()
  88. {
  89. return 3600;
  90. }
  91. /**
  92. * Retrieve Limit Sending By
  93. *
  94. * @param int $store
  95. * @return int
  96. */
  97. public function getLimitBy($store = null)
  98. {
  99. return (int)$this->scopeConfig->getValue(
  100. self::XML_PATH_LIMIT_BY,
  101. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  102. $store
  103. );
  104. }
  105. /**
  106. * Retrieve Email Template
  107. *
  108. * @param int $store
  109. * @return mixed
  110. */
  111. public function getEmailTemplate($store = null)
  112. {
  113. return $this->scopeConfig->getValue(
  114. self::XML_PATH_EMAIL_TEMPLATE,
  115. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  116. $store
  117. );
  118. }
  119. /**
  120. * Retrieve Key Name for Cookie
  121. *
  122. * @see self::COOKIE_NAME
  123. * @return string
  124. */
  125. public function getCookieName()
  126. {
  127. return self::COOKIE_NAME;
  128. }
  129. }