Version Notes
First Preview Release
Download this release
Release Info
| Developer | Piplayan |
| Extension | Conversionmonk_Cmembedcode |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid.php +101 -0
- app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Firstname.php +29 -0
- app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Lastname.php +30 -0
- app/code/community/Conversionmonk/Cmembedcode/Helper/Data.php +5 -0
- app/code/community/Conversionmonk/Cmembedcode/Model/Mysql4/Subscriber/Collection.php +6 -0
- app/code/community/Conversionmonk/Cmembedcode/Model/Observer.php +37 -0
- app/code/community/Conversionmonk/Cmembedcode/Model/Resource/Mysql4/Setup.php +5 -0
- app/code/community/Conversionmonk/Cmembedcode/Model/Subscriber.php +44 -0
- app/code/community/Conversionmonk/Cmembedcode/controllers/Newsletter/SubscriberController.php +79 -0
- app/code/community/Conversionmonk/Cmembedcode/etc/adminhtml.xml +23 -0
- app/code/community/Conversionmonk/Cmembedcode/etc/config.xml +88 -0
- app/code/community/Conversionmonk/Cmembedcode/etc/system.xml +41 -0
- app/code/community/Conversionmonk/Cmembedcode/sql/conversionmonk_cmembedcode_setup/mysql4-install-1.0.0.php +28 -0
- app/design/frontend/base/default/layout/cmembedcode.xml +14 -0
- app/design/frontend/base/default/template/cmembedcode/index.phtml +3 -0
- app/etc/modules/Conversionmonk_Cmembedcode.xml +10 -0
- package.xml +20 -0
app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid.php
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Newsletter_Subscriber_Grid
|
| 3 |
+
{
|
| 4 |
+
protected function _prepareCollection()
|
| 5 |
+
{
|
| 6 |
+
$collection = Mage::getResourceSingleton('newsletter/subscriber_collection');
|
| 7 |
+
$collection->showCustomerInfo();
|
| 8 |
+
|
| 9 |
+
$collection->addSubscriberTypeField()
|
| 10 |
+
->showStoreInfo();
|
| 11 |
+
|
| 12 |
+
if($this->getRequest()->getParam('queue', false)) {
|
| 13 |
+
$collection->useQueue(Mage::getModel('newsletter/queue')
|
| 14 |
+
->load($this->getRequest()->getParam('queue')));
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
$this->setCollection($collection);
|
| 18 |
+
|
| 19 |
+
if ($this->getCollection()) {
|
| 20 |
+
|
| 21 |
+
$this->_preparePage();
|
| 22 |
+
|
| 23 |
+
$columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
|
| 24 |
+
$dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
|
| 25 |
+
$filter = $this->getParam($this->getVarNameFilter(), null);
|
| 26 |
+
|
| 27 |
+
if (is_null($filter)) {
|
| 28 |
+
$filter = $this->_defaultFilter;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (is_string($filter)) {
|
| 32 |
+
$data = $this->helper('adminhtml')->prepareFilterString($filter);
|
| 33 |
+
$this->_setFilterValues($data);
|
| 34 |
+
}
|
| 35 |
+
else if ($filter && is_array($filter)) {
|
| 36 |
+
$this->_setFilterValues($filter);
|
| 37 |
+
}
|
| 38 |
+
else if(0 !== sizeof($this->_defaultFilter)) {
|
| 39 |
+
$this->_setFilterValues($this->_defaultFilter);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (isset($this->_columns[$columnId]) && $this->_columns[$columnId]->getIndex()) {
|
| 43 |
+
$dir = (strtolower($dir)=='desc') ? 'desc' : 'asc';
|
| 44 |
+
$this->_columns[$columnId]->setDir($dir);
|
| 45 |
+
$this->_setCollectionOrder($this->_columns[$columnId]);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (!$this->_isExport) {
|
| 49 |
+
$this->getCollection()->load();
|
| 50 |
+
$this->_afterLoadCollection();
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
protected function _prepareColumns()
|
| 56 |
+
{
|
| 57 |
+
parent::_prepareColumns();
|
| 58 |
+
|
| 59 |
+
$this->mrRemoveColumn('firstname');
|
| 60 |
+
$this->mrRemoveColumn('lastname');
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
$this->addColumnAfter('firstname', array(
|
| 64 |
+
'header' => Mage::helper('newsletter')->__('First Name'),
|
| 65 |
+
'index' => 'customer_firstname',
|
| 66 |
+
'renderer' => 'Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Firstname'
|
| 67 |
+
), Mage::getStoreConfig('newsletterextended/fields/show_prefix') ? 'prefix' : (Mage::getStoreConfig('newsletterextended/fields/show_gender') ? 'gender' : 'type'));
|
| 68 |
+
|
| 69 |
+
$this->addColumnAfter('lastname', array(
|
| 70 |
+
'header' => Mage::helper('newsletter')->__('Last Name'),
|
| 71 |
+
'index' => 'customer_lastname',
|
| 72 |
+
'renderer' => 'Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Lastname'
|
| 73 |
+
), 'firstname');
|
| 74 |
+
|
| 75 |
+
$this->addColumnAfter('cmonk_subscriber_source', array(
|
| 76 |
+
'header' => Mage::helper('newsletter')->__('Source'),
|
| 77 |
+
'index' => 'cmonk_subscriber_source'
|
| 78 |
+
), 'lastname');
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
// manually sort again, that our custom order works
|
| 82 |
+
$this->sortColumnsByOrder();
|
| 83 |
+
|
| 84 |
+
return $this;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
public function mrRemoveColumn($columnId)
|
| 88 |
+
{
|
| 89 |
+
if (method_exists($this, "removeColumn")) {
|
| 90 |
+
return $this->removeColumn($columnId);
|
| 91 |
+
}
|
| 92 |
+
else if (isset($this->_columns[$columnId])) {
|
| 93 |
+
unset($this->_columns[$columnId]);
|
| 94 |
+
if ($this->_lastColumnId == $columnId) {
|
| 95 |
+
$this->_lastColumnId = key($this->_columns);
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
return $this;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Firstname.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Firstname extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function render(Varien_Object $row)
|
| 5 |
+
{
|
| 6 |
+
// not logged in => use subscriber data
|
| 7 |
+
if ($row->getType() != 2) {
|
| 8 |
+
$value = $row->getCmonkSubscriberFirstname();
|
| 9 |
+
}
|
| 10 |
+
// logged-in with override
|
| 11 |
+
elseif (Mage::getStoreConfig('cmembedcode/fields/customer_override')) {
|
| 12 |
+
|
| 13 |
+
// fallback enabled => fallback to customer data if no data found in subscriber
|
| 14 |
+
if (Mage::getStoreConfig('cmembedcode/fields/customer_fallback')) {
|
| 15 |
+
$value = $row->getCmonkSubscriberFirstname() ? $row->getCmonkSubscriberFirstname() : $row->getCustomerFirstname();
|
| 16 |
+
}
|
| 17 |
+
// fallback disabled => only use subscriber data event if it's empty
|
| 18 |
+
else {
|
| 19 |
+
$value = $row->getCmonkSubscriberFirstname();
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
// logged-in without override => only use customer data even if it's empty
|
| 23 |
+
else {
|
| 24 |
+
$value = $row->getCustomerFirstname();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
return $value ? $value : '---';
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Lastname.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Lastname extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
public function render(Varien_Object $row)
|
| 6 |
+
{
|
| 7 |
+
// not logged in => use subscriber data
|
| 8 |
+
if ($row->getType() != 2) {
|
| 9 |
+
$value = $row->getCmonkSubscriberLastname();
|
| 10 |
+
}
|
| 11 |
+
// logged-in with override
|
| 12 |
+
elseif (Mage::getStoreConfig('cmembedcode/fields/customer_override')) {
|
| 13 |
+
|
| 14 |
+
// fallback enabled => fallback to customer data if no data found in subscriber
|
| 15 |
+
if (Mage::getStoreConfig('cmembedcode/fields/customer_fallback')) {
|
| 16 |
+
$value = $row->getCmonkSubscriberLastname() ? $row->getCmonkSubscriberLastname() : $row->getCustomerLastname();
|
| 17 |
+
}
|
| 18 |
+
// fallback disabled => only use subscriber data event if it's empty
|
| 19 |
+
else {
|
| 20 |
+
$value = $row->getCmonkSubscriberLastname();
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
// logged-in without override => only use customer data even if it's empty
|
| 24 |
+
else {
|
| 25 |
+
$value = $row->getCustomerLastname();
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return $value ? $value : '---';
|
| 29 |
+
}
|
| 30 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Helper/Data.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
}
|
| 5 |
+
|
app/code/community/Conversionmonk/Cmembedcode/Model/Mysql4/Subscriber/Collection.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Model_Mysql4_Subscriber_Collection extends Mage_Newsletter_Model_Mysql4_Subscriber_Collection
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Model/Observer.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Model_Observer
|
| 3 |
+
{
|
| 4 |
+
public function newsletterSubscriberChange(Varien_Event_Observer $observer)
|
| 5 |
+
{
|
| 6 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
| 7 |
+
$data = Mage::app()->getRequest()->getParams() ? Mage::app()->getRequest()->getParams() : array();
|
| 8 |
+
|
| 9 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
| 10 |
+
|
| 11 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 12 |
+
|
| 13 |
+
if (isset($data['email']) && $customer->getEmail() === $data['email']) {
|
| 14 |
+
|
| 15 |
+
if (!Mage::getStoreConfig('cmembedcode/fields/customer_override')) {
|
| 16 |
+
$data['firstname'] = '';
|
| 17 |
+
$data['lastname'] = '';
|
| 18 |
+
$data['subscriber_source'] = '';
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// store data only if email is provided
|
| 25 |
+
if (isset($data['email'])) {
|
| 26 |
+
//$data['firstname'] = 'testfirst1';
|
| 27 |
+
/*echo "<pre />";
|
| 28 |
+
print_r($data);
|
| 29 |
+
die;*/
|
| 30 |
+
if (isset($data['firstname'])) $subscriber->setCmonkSubscriberFirstname($data['firstname']);
|
| 31 |
+
if (isset($data['lastname'])) $subscriber->setCmonkSubscriberLastname($data['lastname']);
|
| 32 |
+
if (isset($data['subscriber_source'])) $subscriber->setCmonkSubscriberSource($data['subscriber_source']);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
return $this;
|
| 36 |
+
}
|
| 37 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Model/Resource/Mysql4/Setup.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/Model/Subscriber.php
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Conversionmonk_Cmembedcode_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
|
| 3 |
+
{
|
| 4 |
+
protected $customer;
|
| 5 |
+
|
| 6 |
+
public function getCustomer()
|
| 7 |
+
{
|
| 8 |
+
if (!isset($this->customer)) {
|
| 9 |
+
$this->customer = Mage::getModel('customer/customer')->load($this->getCustomerId());
|
| 10 |
+
}
|
| 11 |
+
return $this->customer;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function getSubscriberFirstname()
|
| 15 |
+
{
|
| 16 |
+
$firstname = parent::getCmonkSubscriberFirstname();
|
| 17 |
+
|
| 18 |
+
if (!$firstname && $this->getCustomer()) {
|
| 19 |
+
$firstname = $this->getCustomer()->getFirstname();
|
| 20 |
+
}
|
| 21 |
+
return $firstname;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
public function getSubscriberLastname()
|
| 25 |
+
{
|
| 26 |
+
$lastname = parent::getCmonkSubscriberLastname();
|
| 27 |
+
|
| 28 |
+
if (!$lastname && $this->getCustomer()) {
|
| 29 |
+
$lastname = $this->getCustomer()->getLastname();
|
| 30 |
+
}
|
| 31 |
+
return $lastname;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function getSubscriberFullName()
|
| 35 |
+
{
|
| 36 |
+
return trim($this->getCmonkSubscriberFirstname() . ' ' . $this->getCmonkSubscriberLastname());
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/controllers/Newsletter/SubscriberController.php
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
include_once("Mage/Newsletter/controllers/SubscriberController.php");
|
| 3 |
+
|
| 4 |
+
class Conversionmonk_Cmembedcode_Newsletter_SubscriberController extends Mage_Newsletter_SubscriberController
|
| 5 |
+
{
|
| 6 |
+
/**
|
| 7 |
+
* New subscription action override
|
| 8 |
+
*/
|
| 9 |
+
public function newAction()
|
| 10 |
+
{
|
| 11 |
+
// this prevents a "Notice: undefined variable" error
|
| 12 |
+
$status = false;
|
| 13 |
+
|
| 14 |
+
// default new Action
|
| 15 |
+
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
|
| 16 |
+
$session = Mage::getSingleton('core/session');
|
| 17 |
+
$customerSession = Mage::getSingleton('customer/session');
|
| 18 |
+
$email = (string) $this->getRequest()->getPost('email');
|
| 19 |
+
$after_subscribe_email = $this->getRequest()->getPost('after_subscribe_email');
|
| 20 |
+
|
| 21 |
+
try {
|
| 22 |
+
if (!Zend_Validate::is($email, 'EmailAddress')) {
|
| 23 |
+
Mage::throwException($this->__('Please enter a valid email address.'));
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
|
| 27 |
+
!$customerSession->isLoggedIn()) {
|
| 28 |
+
Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
$ownerId = Mage::getModel('customer/customer')
|
| 32 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
| 33 |
+
->loadByEmail($email)
|
| 34 |
+
->getId();
|
| 35 |
+
if ($ownerId !== null && $ownerId != $customerSession->getId()) {
|
| 36 |
+
Mage::throwException($this->__('This email address is already assigned to another user.'));
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
if($after_subscribe_email == 'n'){
|
| 40 |
+
$status = Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($email);
|
| 41 |
+
// Here we will create subscriber without sending confirmation mail to user
|
| 42 |
+
}
|
| 43 |
+
else{
|
| 44 |
+
$status = Mage::getModel('newsletter/subscriber')->subscribe($email);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
|
| 48 |
+
$session->addSuccess($this->__('Confirmation request has been sent.'));
|
| 49 |
+
}
|
| 50 |
+
else {
|
| 51 |
+
$session->addSuccess($this->__('Thank you for your subscription.'));
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
catch (Mage_Core_Exception $e) {
|
| 55 |
+
$session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
|
| 56 |
+
}
|
| 57 |
+
catch (Exception $e) {
|
| 58 |
+
$session->addException($e, $this->__('There was a problem with the subscription.'));
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// json return for ajax request
|
| 63 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
| 64 |
+
$messages = NULL;
|
| 65 |
+
|
| 66 |
+
// return json
|
| 67 |
+
$jsonData = Mage::helper('core')->jsonEncode(array(
|
| 68 |
+
'success' => $status,
|
| 69 |
+
'messages' => $messages
|
| 70 |
+
));
|
| 71 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
| 72 |
+
$this->getResponse()->setBody($jsonData);
|
| 73 |
+
return;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// normal redirect for non ajax request
|
| 77 |
+
$this->_redirectReferer();
|
| 78 |
+
}
|
| 79 |
+
}
|
app/code/community/Conversionmonk/Cmembedcode/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<acl>
|
| 4 |
+
<resources>
|
| 5 |
+
<admin>
|
| 6 |
+
<children>
|
| 7 |
+
<system>
|
| 8 |
+
<children>
|
| 9 |
+
<config>
|
| 10 |
+
<children>
|
| 11 |
+
<csettings translate="title" module="cmembedcode">
|
| 12 |
+
<title>Conversionmonk Settings Section</title>
|
| 13 |
+
<sort_order>0</sort_order>
|
| 14 |
+
</csettings>
|
| 15 |
+
</children>
|
| 16 |
+
</config>
|
| 17 |
+
</children>
|
| 18 |
+
</system>
|
| 19 |
+
</children>
|
| 20 |
+
</admin>
|
| 21 |
+
</resources>
|
| 22 |
+
</acl>
|
| 23 |
+
</config>
|
app/code/community/Conversionmonk/Cmembedcode/etc/config.xml
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Conversionmonk_Cmembedcode>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</Conversionmonk_Cmembedcode>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<cmembedcode>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>Conversionmonk_Cmembedcode</module>
|
| 14 |
+
<frontName>cmonk</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</cmembedcode>
|
| 17 |
+
</routers>
|
| 18 |
+
<layout>
|
| 19 |
+
<updates>
|
| 20 |
+
<cmembedcode>
|
| 21 |
+
<file>cmembedcode.xml</file>
|
| 22 |
+
</cmembedcode>
|
| 23 |
+
</updates>
|
| 24 |
+
</layout>
|
| 25 |
+
</frontend>
|
| 26 |
+
<global>
|
| 27 |
+
<helpers>
|
| 28 |
+
<cmembedcode>
|
| 29 |
+
<class>Conversionmonk_Cmembedcode_Helper</class>
|
| 30 |
+
</cmembedcode>
|
| 31 |
+
</helpers>
|
| 32 |
+
<models>
|
| 33 |
+
<conversionmonk_cmembedcode>
|
| 34 |
+
<class>Conversionmonk_Cmembedcode_Model</class>
|
| 35 |
+
</conversionmonk_cmembedcode>
|
| 36 |
+
<newsletter>
|
| 37 |
+
<rewrite>
|
| 38 |
+
<subscriber>Conversionmonk_Cmembedcode_Model_Subscriber</subscriber>
|
| 39 |
+
</rewrite>
|
| 40 |
+
</newsletter>
|
| 41 |
+
<newsletter_resource>
|
| 42 |
+
<rewrite>
|
| 43 |
+
<subscriber_collection>Conversionmonk_Cmembedcode_Model_Mysql4_Subscriber_Collection</subscriber_collection>
|
| 44 |
+
</rewrite>
|
| 45 |
+
</newsletter_resource>
|
| 46 |
+
</models>
|
| 47 |
+
<resources>
|
| 48 |
+
<conversionmonk_cmembedcode_setup>
|
| 49 |
+
<setup>
|
| 50 |
+
<module>Conversionmonk_Cmembedcode</module>
|
| 51 |
+
<class>Conversionmonk_Cmembedcode_Model_Resource_Mysql4_Setup</class>
|
| 52 |
+
</setup>
|
| 53 |
+
<connection>
|
| 54 |
+
<use>core_setup</use>
|
| 55 |
+
</connection>
|
| 56 |
+
</conversionmonk_cmembedcode_setup>
|
| 57 |
+
<conversionmonk_cmembedcode_read>
|
| 58 |
+
<connection>
|
| 59 |
+
<use>core_read</use>
|
| 60 |
+
</connection>
|
| 61 |
+
</conversionmonk_cmembedcode_read>
|
| 62 |
+
<conversionmonk_cmembedcode_write>
|
| 63 |
+
<connection>
|
| 64 |
+
<use>core_write</use>
|
| 65 |
+
</connection>
|
| 66 |
+
</conversionmonk_cmembedcode_write>
|
| 67 |
+
</resources>
|
| 68 |
+
<events>
|
| 69 |
+
<newsletter_subscriber_save_before>
|
| 70 |
+
<observers>
|
| 71 |
+
<newsletterSubscriberChange>
|
| 72 |
+
<class>Conversionmonk_Cmembedcode_Model_Observer</class>
|
| 73 |
+
<method>newsletterSubscriberChange</method>
|
| 74 |
+
</newsletterSubscriberChange>
|
| 75 |
+
</observers>
|
| 76 |
+
</newsletter_subscriber_save_before>
|
| 77 |
+
</events>
|
| 78 |
+
<blocks>
|
| 79 |
+
<adminhtml>
|
| 80 |
+
<rewrite>
|
| 81 |
+
<newsletter_subscriber_grid>Conversionmonk_Cmembedcode_Adminhtml_Block_Newsletter_Subscriber_Grid</newsletter_subscriber_grid>
|
| 82 |
+
</rewrite>
|
| 83 |
+
</adminhtml>
|
| 84 |
+
</blocks>
|
| 85 |
+
</global>
|
| 86 |
+
<adminhtml>
|
| 87 |
+
</adminhtml>
|
| 88 |
+
</config>
|
app/code/community/Conversionmonk/Cmembedcode/etc/system.xml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<cnsettings translate="label" module="cmembedcode">
|
| 5 |
+
<label>Conversionmonk</label>
|
| 6 |
+
<sort_order>999</sort_order>
|
| 7 |
+
</cnsettings>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<csettings translate="label" module="cmembedcode">
|
| 11 |
+
<label>ConversionMonk</label>
|
| 12 |
+
<tab>cnsettings</tab>
|
| 13 |
+
<frontend_type>text</frontend_type>
|
| 14 |
+
<sort_order>999</sort_order>
|
| 15 |
+
<show_in_default>1</show_in_default>
|
| 16 |
+
<show_in_website>1</show_in_website>
|
| 17 |
+
<show_in_store>1</show_in_store>
|
| 18 |
+
<groups>
|
| 19 |
+
<gcsettings translate="label">
|
| 20 |
+
<label>ConversionMonk Settings</label>
|
| 21 |
+
<frontend_type>text</frontend_type>
|
| 22 |
+
<sort_order>0</sort_order>
|
| 23 |
+
<show_in_default>1</show_in_default>
|
| 24 |
+
<show_in_website>1</show_in_website>
|
| 25 |
+
<show_in_store>1</show_in_store>
|
| 26 |
+
<fields>
|
| 27 |
+
<cmanalyticscode translate="label">
|
| 28 |
+
<label>Embed Code</label>
|
| 29 |
+
<frontend_type>textarea</frontend_type>
|
| 30 |
+
<sort_order>1</sort_order>
|
| 31 |
+
<show_in_default>1</show_in_default>
|
| 32 |
+
<show_in_website>1</show_in_website>
|
| 33 |
+
<show_in_store>1</show_in_store>
|
| 34 |
+
<comment><![CDATA[You can find your embed code, inside your ConversionMonk account under Embed Code Menu. <br/>Don't have account? Sign up <a href='http://conversionmonk.com/signup?source=magento_extension' target='_blank'>here</a>]]></comment>
|
| 35 |
+
</cmanalyticscode>
|
| 36 |
+
</fields>
|
| 37 |
+
</gcsettings>
|
| 38 |
+
</groups>
|
| 39 |
+
</csettings>
|
| 40 |
+
</sections>
|
| 41 |
+
</config>
|
app/code/community/Conversionmonk/Cmembedcode/sql/conversionmonk_cmembedcode_setup/mysql4-install-1.0.0.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
// add additional columns to "newsletter_subscriber" table
|
| 6 |
+
$tableName = $installer->getTable('newsletter_subscriber');
|
| 7 |
+
|
| 8 |
+
$installer->getConnection()->addColumn($tableName, 'cmonk_subscriber_firstname', array(
|
| 9 |
+
'nullable' => true,
|
| 10 |
+
'length' => 255,
|
| 11 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 12 |
+
'comment' => 'added by conversionmonk'
|
| 13 |
+
));
|
| 14 |
+
$installer->getConnection()->addColumn($tableName, 'cmonk_subscriber_lastname', array(
|
| 15 |
+
'nullable' => true,
|
| 16 |
+
'length' => 255,
|
| 17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 18 |
+
'comment' => 'added by conversionmonk'
|
| 19 |
+
));
|
| 20 |
+
$installer->getConnection()->addColumn($tableName, 'cmonk_subscriber_source', array(
|
| 21 |
+
'nullable' => true,
|
| 22 |
+
'length' => 255,
|
| 23 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 24 |
+
'comment' => 'added by conversionmonk'
|
| 25 |
+
));
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/cmembedcode.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="1.0.0">
|
| 3 |
+
|
| 4 |
+
<default>
|
| 5 |
+
<block type="core/template" name="cmembedcode_index" after="-" template="cmembedcode/index.phtml"/>
|
| 6 |
+
<reference name="head" >
|
| 7 |
+
<action method="append">
|
| 8 |
+
<block>cmembedcode_index</block>
|
| 9 |
+
</action>
|
| 10 |
+
|
| 11 |
+
</reference>
|
| 12 |
+
</default>
|
| 13 |
+
</layout>
|
| 14 |
+
|
app/design/frontend/base/default/template/cmembedcode/index.phtml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
echo Mage::getStoreConfig('csettings/gcsettings/cmanalyticscode');
|
| 3 |
+
?>
|
app/etc/modules/Conversionmonk_Cmembedcode.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Conversionmonk_Cmembedcode>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<version>1.0.0</version>
|
| 8 |
+
</Conversionmonk_Cmembedcode>
|
| 9 |
+
</modules>
|
| 10 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Conversionmonk_Cmembedcode</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>Open Software License (OSL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This extension for Magento allows you to easily integrate ConversionMonk with Magento. </summary>
|
| 10 |
+
<description>ConversionMonk extension for Magento allows you to easily integrate ConversionMonk with Magento. The extension works with both Magento Enterprise Edition and Magento Community Edition.
|
| 11 |
+

|
| 12 |
+
ConversionMonk is an automated conversion optimization and web personalization platform. Our web-based SaaS software tracks website visitors' behavior and then displays targeted content, messages and offers in real time.</description>
|
| 13 |
+
<notes>First Preview Release</notes>
|
| 14 |
+
<authors><author><name>Piplayan</name><user>piplayan</user><email>piplayan@conversionmonk.com</email></author></authors>
|
| 15 |
+
<date>2015-11-24</date>
|
| 16 |
+
<time>06:12:31</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="Conversionmonk"><dir name="Cmembedcode"><dir name="Adminhtml"><dir name="Block"><dir name="Newsletter"><dir name="Subscriber"><dir name="Grid"><dir name="Renderer"><file name="Firstname.php" hash="b4ad83a7a22963ab905b3e4f17870e48"/><file name="Lastname.php" hash="86225f344469264dd0dfbe3fe5bb66d4"/></dir></dir><file name="Grid.php" hash="211dfbf38c5dd5e578b3f8b9a2d554c4"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="b01c803a7f2a19e05cd81ef2967abd24"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Subscriber"><file name="Collection.php" hash="667a7c7106afbf9b1502e3585d12ddec"/></dir></dir><file name="Observer.php" hash="b763797a715476e834b58a6cd806c87f"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="6632d5d5376b25d0374aaa90c8175383"/></dir></dir><file name="Subscriber.php" hash="4553a916f4a102e87ebc77bdae978c09"/></dir><dir name="controllers"><dir name="Newsletter"><file name="SubscriberController.php" hash="3c049a7166adb2dd22b10bef4b9a8c85"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cc9ae9cb60d382a0d99c5c545670d366"/><file name="config.xml" hash="f149882fb237b44526ce64537f9bbd83"/><file name="system.xml" hash="68232ab3a4c1e860963efad39921ad74"/></dir><dir name="sql"><dir name="conversionmonk_cmembedcode_setup"><file name="mysql4-install-1.0.0.php" hash="efee1132c56800bd1d67809d3081fcf6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cmembedcode.xml" hash="5c0ec2245cace3245a8c28cfcf04c954"/></dir><dir name="template"><dir name="cmembedcode"><file name="index.phtml" hash="1f529d1f53dcafeb02fd06b5224a0bdf"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conversionmonk_Cmembedcode.xml" hash="0f8d77cf82d0f36093637afc79522738"/></dir></target></contents>
|
| 18 |
+
<compatible/>
|
| 19 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
+
</package>
|
