-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce254ce
commit 2293a10
Showing
5 changed files
with
339 additions
and
0 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
app/code/core/Mage/Adminhtml/Model/Customer/Observer.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,148 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
|
||
/** | ||
* Customer EAV Observer | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
*/ | ||
class Mage_Adminhtml_Model_Customer_Observer | ||
{ | ||
|
||
/** | ||
* Add frontend properties to customer attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAttributeEditPrepareForm($observer) | ||
{ | ||
/* @var $attribute Mage_Customer_Model_Attribute */ | ||
$attribute = $observer->getAttribute(); | ||
|
||
/* @var $form Varien_Data_Form */ | ||
$form = $observer->getForm(); | ||
|
||
/* @var $fieldset Varien_Data_Form_Element_Fieldset */ | ||
$fieldset = $form->getElement('base_fieldset'); | ||
|
||
// frontend properties fieldset | ||
$fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Extra Properties'))); | ||
|
||
$fieldset->addField('use_in_forms', 'multiselect', array( | ||
'name' => 'use_in_forms', | ||
'label' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'title' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'values' => Mage::getModel('customer/config_forms')->toOptionArray(), | ||
'value' => Mage::getResourceModel('customer/form_attribute')->getFormTypesByAttribute($attribute) | ||
)); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Save frontend properties from customer attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAttributeEditPrepareSave($observer) | ||
{ | ||
/** @var Mage_Core_Controller_Request_Http $request */ | ||
$request = $observer->getRequest(); | ||
|
||
$data = $request->getPost(); | ||
if ($data) { | ||
|
||
/** @var Mage_Eav_Model_Entity_Attribute $object */ | ||
$model = $observer->getObject(); | ||
|
||
if (!isset($data['use_in_forms'])) { | ||
$data['use_in_forms'] = array(); | ||
} | ||
|
||
$model->setData('used_in_forms', $data['use_in_forms']); | ||
|
||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* Add frontend properties to customer address attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAddressAttributeEditPrepareForm($observer) | ||
{ | ||
/* @var $attribute Mage_Customer_Model_Attribute */ | ||
$attribute = $observer->getAttribute(); | ||
|
||
/* @var $form Varien_Data_Form */ | ||
$form = $observer->getForm(); | ||
|
||
/* @var $fieldset Varien_Data_Form_Element_Fieldset */ | ||
$fieldset = $form->getElement('base_fieldset'); | ||
|
||
// frontend properties fieldset | ||
$fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Extra Properties'))); | ||
|
||
$fieldset->addField('use_in_forms', 'multiselect', array( | ||
'name' => 'use_in_forms', | ||
'label' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'title' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'values' => Mage::getModel('customer/config_address_forms')->toOptionArray(), | ||
'value' => Mage::getResourceModel('customer/form_attribute')->getFormTypesByAttribute($attribute) | ||
)); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Save frontend properties from customer address attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAddressAttributeEditPrepareSave($observer) | ||
{ | ||
/** @var Mage_Core_Controller_Request_Http $request */ | ||
$request = $observer->getRequest(); | ||
|
||
$data = $request->getPost(); | ||
if ($data) { | ||
|
||
/** @var Mage_Eav_Model_Entity_Attribute $object */ | ||
$model = $observer->getObject(); | ||
|
||
if (!isset($data['use_in_forms'])) { | ||
$data['use_in_forms'] = array(); | ||
} | ||
|
||
$model->setData('used_in_forms', $data['use_in_forms']); | ||
|
||
} | ||
return $this; | ||
} | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
app/code/core/Mage/Customer/Model/Config/Address/Forms.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,64 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Customer | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Used in creating options for use_in_forms selection | ||
* | ||
*/ | ||
class Mage_Customer_Model_Config_Address_Forms | ||
{ | ||
|
||
/** | ||
* Options getter | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return array( | ||
array( | ||
'value' => 'adminhtml_customer_address', | ||
'label' => Mage::helper('customer')->__('Adminhtml Customer Address') | ||
), | ||
array( | ||
'value' => 'customer_address_edit', | ||
'label' => Mage::helper('customer')->__('Customer Address Edit') | ||
), | ||
array( | ||
'value' => 'customer_register_address', | ||
'label' => Mage::helper('customer')->__('Customer Register Address') | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Get options in "key-value" format | ||
* | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
return array_combine( | ||
array_column($this->toOptionArray(), 'value'), | ||
array_column($this->toOptionArray(), 'label') | ||
); | ||
} | ||
|
||
} |
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,72 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Customer | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Used in creating options for use_in_forms selection | ||
* | ||
*/ | ||
class Mage_Customer_Model_Config_Forms | ||
{ | ||
|
||
/** | ||
* Options getter | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return array( | ||
array( | ||
'value' => 'adminhtml_checkout', | ||
'label' => Mage::helper('customer')->__('Adminhtml Checkout') | ||
), | ||
array( | ||
'value' => 'adminhtml_customer', | ||
'label' => Mage::helper('customer')->__('Adminhtml Customer') | ||
), | ||
array( | ||
'value' => 'checkout_register', | ||
'label' => Mage::helper('customer')->__('Checkout Register') | ||
), | ||
array( | ||
'value' => 'customer_account_create', | ||
'label' => Mage::helper('customer')->__('Customer Account Create') | ||
), | ||
array( | ||
'value' => 'customer_account_edit', | ||
'label' => Mage::helper('customer')->__('Customer Account Edit') | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Get options in "key-value" format | ||
* | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
return array_combine( | ||
array_column($this->toOptionArray(), 'value'), | ||
array_column($this->toOptionArray(), 'label') | ||
); | ||
} | ||
|
||
} |
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