-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #948 from mailchimp/pre-release/1.1.16
Pre release/1.1.16
- Loading branch information
Showing
89 changed files
with
6,988 additions
and
2,852 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* mc-magento Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @date: 3/6/18 2:22 PM | ||
* @file: Mailchimpstores.php | ||
*/ | ||
class Ebizmarts_MailChimp_Block_Adminhtml_Mailchimpstores extends Mage_Adminhtml_Block_Widget_Grid_Container | ||
{ | ||
public function __construct() | ||
{ | ||
$this->_blockGroup = 'mailchimp'; | ||
$this->_controller = 'adminhtml_mailchimpstores'; | ||
$this->_headerText = $this->__('Mailchimp stores'); | ||
|
||
parent::__construct(); | ||
} | ||
|
||
} |
116 changes: 116 additions & 0 deletions
116
app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
/** | ||
* mc-magento Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @file: Edit.php | ||
*/ | ||
class Ebizmarts_MailChimp_Block_Adminhtml_Mailchimpstores_Edit extends Mage_Adminhtml_Block_Widget_Form_Container | ||
{ | ||
public function __construct() | ||
{ | ||
$this->_objectId = 'id'; | ||
$this->_controller = 'adminhtml_mailchimpstores'; | ||
$this->_blockGroup = 'mailchimp'; | ||
|
||
parent::__construct(); | ||
|
||
$this->removeButton('reset'); | ||
$this->updateButton('delete', null, array( | ||
'label' => Mage::helper('adminhtml')->__('Delete Store'), | ||
'class' => 'delete', | ||
'onclick' => 'deleteMCStoreConfirm(\'' | ||
. Mage::helper('core')->jsQuoteEscape( | ||
Mage::helper('adminhtml')->__('Are you sure you want to delete this Mailchimp store?') | ||
) | ||
.'\', \'' | ||
. $this->getDeleteUrl() | ||
. '\')', | ||
'sort_order' => 0 | ||
)); | ||
|
||
$scopeArray = $this->getScopeArrayIfValueExists(); | ||
if ($scopeArray !== false) { | ||
$jsCondition = 'true'; | ||
} else { | ||
$jsCondition = 'false'; | ||
} | ||
$mcInUseMessage = $this->getMCInUseMessage($scopeArray); | ||
$this->_formScripts[] = "function deleteMCStoreConfirm(message, url) { | ||
if ($jsCondition) { | ||
if (confirm(message)) { | ||
deleteConfirm('$mcInUseMessage', url); | ||
} | ||
} else { | ||
deleteConfirm(message, url); | ||
} | ||
}"; | ||
} | ||
|
||
public function getStoreId() | ||
{ | ||
return Mage::registry('current_store')->getId(); | ||
} | ||
|
||
public function getHeaderText() | ||
{ | ||
if (Mage::registry('current_mailchimpstore')->getId()) { | ||
return $this->escapeHtml(Mage::registry('current_mailchimpstore')->getName()); | ||
} | ||
else { | ||
return Mage::helper('mailchimp')->__('New Store'); | ||
} | ||
} | ||
|
||
protected function _prepareLayout() | ||
{ | ||
$headBlock = Mage::app()->getLayout()->getBlock('head'); | ||
$headBlock->addJs('ebizmarts/mailchimp/editstores.js'); | ||
return parent::_prepareLayout(); | ||
} | ||
|
||
/** | ||
* @param $scope | ||
* @return string | ||
* @throws Mage_Core_Exception | ||
* @throws Mage_Core_Model_Store_Exception | ||
*/ | ||
protected function getMCInUseMessage($scope) | ||
{ | ||
$helper = $this->makeHelper(); | ||
if ($scope !== false) { | ||
$scopeName = $helper->getScopeName($scope); | ||
$message = $helper->__("This store is currently in use for this Magento store at %s scope. Do you want to proceed anyways?", $scopeName); | ||
} else { | ||
$message = $helper->__("This store is currently in use for this Magento store. Do you want to proceed anyways?"); | ||
} | ||
return $message; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getScopeArrayIfValueExists() | ||
{ | ||
$helper = $this->makeHelper(); | ||
$currentMCStoreId = Mage::registry('current_mailchimpstore')->getStoreid(); | ||
$keyIfExist = $helper->getScopeByMailChimpStoreId($currentMCStoreId); | ||
if ($keyIfExist === null) { | ||
$keyIfExist = 'false'; | ||
} | ||
return $keyIfExist; | ||
} | ||
|
||
/** | ||
* @return Ebizmarts_MailChimp_Helper_Data | ||
*/ | ||
protected function makeHelper() | ||
{ | ||
return Mage::helper('mailchimp'); | ||
} | ||
} | ||
|
171 changes: 171 additions & 0 deletions
171
app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit/Form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<?php | ||
/** | ||
* mc-magento Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @file: Form.php | ||
*/ | ||
|
||
class Ebizmarts_MailChimp_Block_Adminhtml_Mailchimpstores_Edit_Form extends Mage_Adminhtml_Block_Widget_Form | ||
{ | ||
|
||
protected function _prepareForm() | ||
{ | ||
$form = new Varien_Data_Form(array( | ||
'id' => 'edit_form', | ||
'action' => $this->getUrl('*/*/save'), | ||
'method' => 'post', | ||
)); | ||
|
||
$store = Mage::registry('current_mailchimpstore'); | ||
|
||
if ($store->getStoreid()) { | ||
$form->addField('storeid', 'hidden', array( | ||
'name' => 'storeid', | ||
)); | ||
$form->addField('apikey', 'hidden', array( | ||
'name' => 'apikey' | ||
)); | ||
$form->setValues($store->getData()); | ||
} | ||
$fieldset = $form->addFieldset('base_fieldset', array( | ||
'legend' => Mage::helper('mailchimp')->__('Store Information'), | ||
'class' => 'fieldset', | ||
)); | ||
if(!$store->getId()) { | ||
$stores = Mage::app()->getStores(); | ||
$apikeys = array(); | ||
foreach ($stores as $s) { | ||
$apikey = Mage::helper('mailchimp')->getConfigValueForScope(Ebizmarts_MailChimp_Model_Config::GENERAL_APIKEY,$s); | ||
if(!array_key_exists($apikey,$apikeys)) { | ||
$apikeys[$apikey] = $apikey; | ||
} | ||
} | ||
$apikeyField =$fieldset->addField('apikey', 'select', array( | ||
'label' => Mage::helper('mailchimp')->__('Api Key'), | ||
'title' => Mage::helper('mailchimp')->__('Api Key'), | ||
'name' => 'apikey', | ||
'required' => true, | ||
'options' => $apikeys, | ||
)); | ||
$getStoresUrl = Mage::helper('adminhtml')->getUrl('adminhtml/mailchimpstores/getstores'); | ||
$apikeyField->setAfterElementHtml("<script>var GET_STORES_URL = '".$getStoresUrl."';</script>"); | ||
|
||
$fieldset->addField('listid', 'select', array( | ||
'name' => 'listid', | ||
'label' => Mage::helper('mailchimp')->__('List'), | ||
'title' => Mage::helper('mailchimp')->__('List'), | ||
'required' => true, | ||
'options' => array() | ||
)); | ||
} | ||
$fieldset->addField('name', 'text', array( | ||
'name' => 'name', | ||
'label' => Mage::helper('mailchimp')->__('Store Name'), | ||
'title' => Mage::helper('mailchimp')->__('Store Name'), | ||
'required' => true, | ||
)); | ||
$fieldset->addField('domain', 'text',array( | ||
'name' => 'domain', | ||
'label' => Mage::helper('mailchimp')->__('Domain'), | ||
'title' => Mage::helper('mailchimp')->__('Domain'), | ||
'required' => true | ||
)); | ||
$fieldset->addField('email_address', 'text', array( | ||
'name' => 'email_address', | ||
'label' => Mage::helper('mailchimp')->__('Email'), | ||
'title' => Mage::helper('mailchimp')->__('Email'), | ||
'required' => true | ||
)); | ||
$currencies = Mage::getModel('adminhtml/system_config_source_currency')->toOptionArray(false); | ||
$currencyArray = array(); | ||
foreach ($currencies as $c) { | ||
$currencyArray[$c['value']] = $c['label']; | ||
} | ||
$fieldset->addField('currency_code', 'select', array( | ||
'label' => Mage::helper('mailchimp')->__('Currency'), | ||
'title' => Mage::helper('mailchimp')->__('Currency'), | ||
'name' => 'currency_code', | ||
'required' => true, | ||
'options' => $currencyArray, | ||
)); | ||
$locales = Mage::getModel('adminhtml/system_config_source_locale')->toOptionArray(); | ||
$localeArray = array(); | ||
foreach ($locales as $c) { | ||
$localeArray[$c['value']] = $c['label']; | ||
} | ||
$fieldset->addField('primary_locale', 'select', array( | ||
'label' => Mage::helper('mailchimp')->__('Locale'), | ||
'title' => Mage::helper('mailchimp')->__('Locale'), | ||
'name' => 'primary_locale', | ||
'required' => true, | ||
'options' => $localeArray, | ||
)); | ||
$timeszones = Mage::getModel('adminhtml/system_config_source_locale_timezone')->toOptionArray(); | ||
$timezoneArray = array(); | ||
foreach ($timeszones as $c) { | ||
$timezoneArray[$c['value']] = $c['label']; | ||
} | ||
$fieldset->addField('timezone', 'select', array( | ||
'label' => Mage::helper('mailchimp')->__('Time Zone'), | ||
'title' => Mage::helper('mailchimp')->__('Time Zone'), | ||
'name' => 'timezone', | ||
'required' => true, | ||
'options' => $timezoneArray, | ||
)); | ||
|
||
$fieldset->addField('phone', 'text', array( | ||
'name' => 'phone', | ||
'label' => Mage::helper('mailchimp')->__('Phone'), | ||
'title' => Mage::helper('mailchimp')->__('Phone'), | ||
'required' => true | ||
)); | ||
$fieldset->addField('address_address_one', 'text', array( | ||
'name' => 'address_address_one', | ||
'label' => Mage::helper('mailchimp')->__('Street'), | ||
'title' => Mage::helper('mailchimp')->__('Street'), | ||
'required' => true | ||
)); | ||
|
||
$fieldset->addField('address_address_two', 'text', array( | ||
'name' => 'address_address_two', | ||
'label' => Mage::helper('mailchimp')->__('Street'), | ||
'title' => Mage::helper('mailchimp')->__('Street'), | ||
'required' => false | ||
)); | ||
$fieldset->addField('address_city', 'text', array( | ||
'name' => 'address_city', | ||
'label' => Mage::helper('mailchimp')->__('City'), | ||
'title' => Mage::helper('mailchimp')->__('City'), | ||
'required' => true | ||
)); | ||
$fieldset->addField('address_postal_code', 'text', array( | ||
'name' => 'address_postal_code', | ||
'label' => Mage::helper('mailchimp')->__('Postal Code'), | ||
'title' => Mage::helper('mailchimp')->__('Postal Code'), | ||
'required' => true | ||
)); | ||
$countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(); | ||
$countryArray = array(); | ||
foreach ($countries as $c) { | ||
$countryArray[$c['value']] = $c['label']; | ||
} | ||
$fieldset->addField('address_country_code', 'select', array( | ||
'label' => Mage::helper('mailchimp')->__('Country'), | ||
'title' => Mage::helper('mailchimp')->__('Country'), | ||
'name' => 'address_country_code', | ||
'required' => true, | ||
'options' => $countryArray, | ||
)); | ||
|
||
$form->setValues($store->getData()); | ||
|
||
$form->setUseContainer(true); | ||
$this->setForm($form); | ||
return parent::_prepareForm(); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Grid.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* mc-magento Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @date: 3/5/18 1:41 PM | ||
* @file: Grid.php | ||
*/ | ||
class Ebizmarts_MailChimp_Block_Adminhtml_Mailchimpstores_Grid extends Mage_Adminhtml_Block_Widget_Grid | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->setId('mailchimp_stores_grid'); | ||
$this->setDefaultSort('id'); | ||
$this->setDefaultDir('DESC'); | ||
$this->setUseAjax(true); | ||
$this->setSaveParametersInSession(true); | ||
} | ||
|
||
protected function _prepareCollection() | ||
{ | ||
$collection = Mage::getModel('mailchimp/stores')->getCollection(); | ||
$this->setCollection($collection); | ||
return parent::_prepareCollection(); | ||
} | ||
|
||
protected function _prepareColumns() | ||
{ | ||
$this->addColumn( | ||
'title', array( | ||
'header' => Mage::helper('mailchimp')->__('API Key'), | ||
'index' => 'apikey', | ||
'sortable' => true | ||
) | ||
); | ||
$this->addColumn( | ||
'mc_account_name', array( | ||
'header' => Mage::helper('mailchimp')->__('MC Account name'), | ||
'index' => 'mc_account_name', | ||
'width' => '100px', | ||
'sortable' => true | ||
) | ||
); | ||
$this->addColumn( | ||
'name', array( | ||
'header' => Mage::helper('mailchimp')->__('Store Name'), | ||
'index' => 'name', | ||
'width' => '100px', | ||
'sortable' => true | ||
) | ||
); | ||
$this->addColumn( | ||
'list_name', array( | ||
'header' => Mage::helper('mailchimp')->__('List Name'), | ||
'index' => 'list_name', | ||
'sortable' => false | ||
) | ||
); | ||
$this->addColumn( | ||
'email_address', array( | ||
'header' => Mage::helper('mailchimp')->__('Email'), | ||
'index' => 'email_address', | ||
'sortable' => false | ||
) | ||
); | ||
|
||
return parent::_prepareColumns(); | ||
} | ||
|
||
public function getRowUrl($row) | ||
{ | ||
return $this->getUrl('*/*/edit', array('id' => $row->getId())); | ||
} | ||
public function getGridUrl() | ||
{ | ||
return $this->getUrl('*/*/grid', array('_current' => true)); | ||
} | ||
} |
Oops, something went wrong.