shweta_newscontacts - Version 0.1.0

Version Notes

Please review the extension.

Download this release

Release Info

Developer Shweta Agarwal
Extension shweta_newscontacts
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Shweta/Newscontacts/controllers/IndexController.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once('Mage/Contacts/controllers/IndexController.php');
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Contacts
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Contacts index controller
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Contacts
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Shweta_Newscontacts_IndexController extends Mage_Core_Controller_Front_Action
36
+ {
37
+
38
+ const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
39
+ const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
40
+ const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';
41
+ const XML_PATH_ENABLED = 'contacts/contacts/enabled';
42
+
43
+ public function preDispatch()
44
+ {
45
+ parent::preDispatch();
46
+
47
+ if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
48
+ $this->norouteAction();
49
+ }
50
+ }
51
+
52
+ public function indexAction()
53
+ {
54
+ $this->loadLayout();
55
+ $this->getLayout()->getBlock('contactForm')
56
+ ->setFormAction( Mage::getUrl('*/*/post') );
57
+
58
+ $this->_initLayoutMessages('customer/session');
59
+ $this->_initLayoutMessages('catalog/session');
60
+ $this->renderLayout();
61
+ }
62
+
63
+ public function postAction()
64
+ {
65
+ $post = $this->getRequest()->getPost();
66
+ if($post['is_subscribed'] == 1){
67
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($post['email']);
68
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
69
+ Mage::getSingleton('core/session')
70
+ ->addSuccess($this->__('Confirmation request has been sent.'));
71
+ }
72
+ else {
73
+ Mage::getSingleton('core/session')
74
+ ->addSuccess($this->__('Thank you for your subscription.'));
75
+ }
76
+ }
77
+
78
+
79
+ if ( $post ) {
80
+ $translate = Mage::getSingleton('core/translate');
81
+ /* @var $translate Mage_Core_Model_Translate */
82
+ $translate->setTranslateInline(false);
83
+ try {
84
+ $postObject = new Varien_Object();
85
+ $postObject->setData($post);
86
+
87
+ $error = false;
88
+
89
+ if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
90
+ $error = true;
91
+ }
92
+
93
+ if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
94
+ $error = true;
95
+ }
96
+
97
+ if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
98
+ $error = true;
99
+ }
100
+
101
+ if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
102
+ $error = true;
103
+ }
104
+
105
+ if ($error) {
106
+ throw new Exception();
107
+ }
108
+ $mailTemplate = Mage::getModel('core/email_template');
109
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
110
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
111
+ ->setReplyTo($post['email'])
112
+ ->sendTransactional(
113
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
114
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
115
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
116
+ null,
117
+ array('data' => $postObject)
118
+ );
119
+
120
+ if (!$mailTemplate->getSentSuccess()) {
121
+ throw new Exception();
122
+ }
123
+
124
+ $translate->setTranslateInline(true);
125
+
126
+ Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
127
+ $this->_redirect('*/*/');
128
+
129
+ return;
130
+ } catch (Exception $e) {
131
+ $translate->setTranslateInline(true);
132
+
133
+ Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
134
+ $this->_redirect('*/*/');
135
+ return;
136
+ }
137
+
138
+ } else {
139
+ $this->_redirect('*/*/');
140
+ }
141
+ }
142
+
143
+ }
app/code/local/Shweta/Newscontacts/etc/config.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <frontend>
4
+ <routers>
5
+ <contacts>
6
+ <args>
7
+ <modules>
8
+ <Shweta_Newscontacts before="Mage_Contacts">Shweta_Newscontacts</Shweta_Newscontacts>
9
+ </modules>
10
+ </args>
11
+ </contacts>
12
+ </routers>
13
+ </frontend>
14
+ </config>
app/design/frontend/default/default/template/contacts/form.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
28
+ <div class="page-title">
29
+ <h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
30
+ </div>
31
+ <form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
32
+ <div class="fieldset">
33
+ <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
34
+ <ul class="form-list">
35
+ <li class="fields">
36
+ <div class="field">
37
+ <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
38
+ <div class="input-box">
39
+ <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
40
+ </div>
41
+ </div>
42
+ <div class="field">
43
+ <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
44
+ <div class="input-box">
45
+ <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
46
+ </div>
47
+ </div>
48
+ </li>
49
+ <li class="control"><input type="checkbox" name="is_subscribed" id="subscription" value="1" title="<?php echo $this->__('General Subscription') ?>" class="checkbox" /><label for="subscription"><?php echo $this->__('General Subscription') ?></label></li>
50
+ <li>
51
+ <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
52
+ <div class="input-box">
53
+ <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
54
+ </div>
55
+ </li>
56
+ <li class="wide">
57
+ <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
58
+ <div class="input-box">
59
+ <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
60
+ </div>
61
+ </li>
62
+ </ul>
63
+ </div>
64
+ <div class="buttons-set">
65
+ <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
66
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
67
+ <button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
68
+ </div>
69
+ </form>
70
+ <script type="text/javascript">
71
+ //<![CDATA[
72
+ var contactForm = new VarienForm('contactForm', true);
73
+ //]]>
74
+ </script>
app/etc/modules/Shweta_Newscontacts.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Shweta_Newscontacts>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>0.1.0</version>
8
+ </Shweta_Newscontacts>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>shweta_newscontacts</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>With This Extension the news-letter Check-Box added with Contacts Us page. </summary>
10
+ <description>With This Extension the news-letter Check-Box added with Contacts Us page. &#xD;
11
+ You can also easily customize the extension.</description>
12
+ <notes>Please review the extension.</notes>
13
+ <authors><author><name>Shweta Agarwal</name><user>sasmilyshweta</user><email>shweta@ptiwebtech.com</email></author></authors>
14
+ <date>2013-08-27</date>
15
+ <time>13:10:12</time>
16
+ <contents><target name="magelocal"><dir name="Shweta"><dir name="Newscontacts"><dir name="controllers"><file name="IndexController.php" hash="0c3db9704c83be08a2f8ecac659e4e33"/></dir><dir name="etc"><file name="config.xml" hash="c6536661cafb3e9eb40f54bde64ffa8a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shweta_Newscontacts.xml" hash="ee3bf49ec1edd818b7b3d3aa9ddfb4b6"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="contacts"><file name="form.phtml" hash="d8153da2b16c01394adfc11578d04c74"/></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>