1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-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 Mage
22: * @package Mage_Core
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Config data model
30: *
31: * @method Mage_Core_Model_Resource_Config_Data _getResource()
32: * @method Mage_Core_Model_Resource_Config_Data getResource()
33: * @method string getScope()
34: * @method Mage_Core_Model_Config_Data setScope(string $value)
35: * @method int getScopeId()
36: * @method Mage_Core_Model_Config_Data setScopeId(int $value)
37: * @method string getPath()
38: * @method Mage_Core_Model_Config_Data setPath(string $value)
39: * @method string getValue()
40: * @method Mage_Core_Model_Config_Data setValue(string $value)
41: *
42: * @category Mage
43: * @package Mage_Core
44: * @author Magento Core Team <core@magentocommerce.com>
45: */
46: class Mage_Core_Model_Config_Data extends Mage_Core_Model_Abstract
47: {
48: const ENTITY = 'core_config_data';
49: /**
50: * Prefix of model events names
51: *
52: * @var string
53: */
54: protected $_eventPrefix = 'core_config_data';
55:
56: /**
57: * Parameter name in event
58: *
59: * In observe method you can use $observer->getEvent()->getObject() in this case
60: *
61: * @var string
62: */
63: protected $_eventObject = 'config_data';
64:
65: /**
66: * Varien model constructor
67: */
68: protected function _construct()
69: {
70: $this->_init('core/config_data');
71: }
72:
73: /**
74: * Add availability call after load as public
75: */
76: public function afterLoad()
77: {
78: $this->_afterLoad();
79: }
80:
81: /**
82: * Check if config data value was changed
83: *
84: * @return bool
85: */
86: public function isValueChanged()
87: {
88: return $this->getValue() != $this->getOldValue();
89: }
90:
91: /**
92: * Get old value from existing config
93: *
94: * @return string
95: */
96: public function getOldValue()
97: {
98: $storeCode = $this->getStoreCode();
99: $websiteCode = $this->getWebsiteCode();
100: $path = $this->getPath();
101:
102: if ($storeCode) {
103: return Mage::app()->getStore($storeCode)->getConfig($path);
104: }
105: if ($websiteCode) {
106: return Mage::app()->getWebsite($websiteCode)->getConfig($path);
107: }
108: return (string) Mage::getConfig()->getNode('default/' . $path);
109: }
110:
111:
112: /**
113: * Get value by key for new user data from <section>/groups/<group>/fields/<field>
114: *
115: * @return string
116: */
117: public function getFieldsetDataValue($key)
118: {
119: $data = $this->_getData('fieldset_data');
120: return (is_array($data) && isset($data[$key])) ? $data[$key] : null;
121: }
122: }
123: