Skip to content

Commit

Permalink
Fixed "if newsletter module disabled, customer backend would blank wi…
Browse files Browse the repository at this point in the history
…thout notice" (OpenMage#3078)

Co-authored-by: Fabrizio Balliano <[email protected]>
  • Loading branch information
sidealice and fballiano authored May 13, 2023
1 parent c0d136a commit 63595d0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
16 changes: 9 additions & 7 deletions app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ protected function _beforeToHtml()
'url' => $this->getUrl('*/*/wishlist', ['_current' => true]),
]);

/** @var Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter $block */
$block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter');
if (Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber')) {
$this->addTab('newsletter', [
'label' => Mage::helper('customer')->__('Newsletter'),
'content' => $block->initForm()->toHtml()
]);
if (Mage::helper('core')->isModuleOutputEnabled('Mage_Newsletter')) {
/** @var Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter $block */
$block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter');
if (Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber')) {
$this->addTab('newsletter', [
'label' => Mage::helper('customer')->__('Newsletter'),
'content' => $block->initForm()->toHtml()
]);
}
}

if (Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings')) {
Expand Down
29 changes: 17 additions & 12 deletions app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Giftmessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ public function getOrder()
*/
protected function _beforeToHtml()
{
if ($this->getParentBlock() && ($order = $this->getOrder())) {
$this->setEntity($order);
if (Mage::helper('core')->isModuleOutputEnabled('Mage_Giftmessage')) {
if ($this->getParentBlock() && ($order = $this->getOrder())) {
$this->setEntity($order);
}
return parent::_beforeToHtml();
} else {
return parent::_beforeToHtml();
}
return parent::_beforeToHtml();
}

/**
Expand All @@ -63,15 +67,16 @@ protected function _beforeToHtml()
*/
protected function _prepareLayout()
{
$this->setChild(
'save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('giftmessage')->__('Save Gift Message'),
'class' => 'save'
])
);

if (Mage::helper('core')->isModuleOutputEnabled('Mage_Giftmessage')) {
$this->setChild(
'save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('giftmessage')->__('Save Gift Message'),
'class' => 'save'
])
);
}
return $this;
}

Expand Down
4 changes: 1 addition & 3 deletions app/etc/modules/Mage_Captcha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
<codePool>core</codePool>
<depends>
<Mage_Adminhtml/>
<Mage_Customer/>
<Mage_Sendfriend/>
<Mage_Wishlist/>
<Mage_Customer/>
</depends>
</Mage_Captcha>
</modules>
Expand Down
8 changes: 7 additions & 1 deletion lib/Varien/Data/Form/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ public function addField($elementId, $type, $config, $after = false)
} else {
$className = 'Varien_Data_Form_Element_' . ucfirst(strtolower($type));
}
$element = new $className($config);

if (class_exists($className)) {
$element = new $className($config);
} else {
$className = 'Varien_Data_Form_Element_Note';
$element = new $className($config);
}
$element->setId($elementId);
$this->addElement($element, $after);
return $element;
Expand Down

0 comments on commit 63595d0

Please sign in to comment.