1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sendfriend
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Sendfriend Data Helper
30: *
31: * @category Mage
32: * @package Mage_Sedfriend
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Sendfriend_Helper_Data extends Mage_Core_Helper_Abstract
36: {
37: const XML_PATH_ENABLED = 'sendfriend/email/enabled';
38: const XML_PATH_ALLOW_FOR_GUEST = 'sendfriend/email/allow_guest';
39: const XML_PATH_MAX_RECIPIENTS = 'sendfriend/email/max_recipients';
40: const XML_PATH_MAX_PER_HOUR = 'sendfriend/email/max_per_hour';
41: const XML_PATH_LIMIT_BY = 'sendfriend/email/check_by';
42: const XML_PATH_EMAIL_TEMPLATE = 'sendfriend/email/template';
43:
44: const COOKIE_NAME = 'stf';
45:
46: const CHECK_IP = 1;
47: const CHECK_COOKIE = 0;
48:
49: /**
50: * Check is enabled Module
51: *
52: * @param int $store
53: * @return bool
54: */
55: public function isEnabled($store = null)
56: {
57: return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
58: }
59:
60: /**
61: * Check allow send email for guest
62: *
63: * @param int $store
64: * @return bool
65: */
66: public function isAllowForGuest($store = null)
67: {
68: return Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_FOR_GUEST, $store);
69: }
70:
71: /**
72: * Retrieve Max Recipients
73: *
74: * @param int $store
75: * @return int
76: */
77: public function getMaxRecipients($store = null)
78: {
79: return (int)Mage::getStoreConfig(self::XML_PATH_MAX_RECIPIENTS, $store);
80: }
81:
82: /**
83: * Retrieve Max Products Sent in 1 Hour
84: *
85: * @param int $store
86: * @return int
87: */
88: public function getMaxEmailPerPeriod($store = null)
89: {
90: return (int)Mage::getStoreConfig(self::XML_PATH_MAX_PER_HOUR, $store);
91: }
92:
93: /**
94: * Retrieve Limitation Period in seconds (1 hour)
95: *
96: * @return int
97: */
98: public function getPeriod()
99: {
100: return 3600;
101: }
102:
103: /**
104: * Retrieve Limit Sending By
105: *
106: * @param int $store
107: * @return int
108: */
109: public function getLimitBy($store = null)
110: {
111: return (int)Mage::getStoreConfig(self::XML_PATH_LIMIT_BY, $store);
112: }
113:
114: /**
115: * Retrieve Email Template
116: *
117: * @param int $store
118: * @return mixed
119: */
120: public function getEmailTemplate($store = null)
121: {
122: return Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $store);
123: }
124:
125: /**
126: * Retrieve Key Name for Cookie
127: *
128: * @see self::COOKIE_NAME
129: * @return string
130: */
131: public function getCookieName()
132: {
133: return self::COOKIE_NAME;
134: }
135: }
136: