Version Notes
Fixed core issue: warning on system config save for dynamic fields (eg. disable modules output).
Download this release
Release Info
Developer | WebFlakeStudio |
Extension | Wfs_DisableEmails |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
app/code/community/Wfs/DisableEmails/Model/Adminhtml/Config/Data.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WebFlakeStudio
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
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://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
*
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* WebFlakeStudio does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* WebFlakeStudio does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
*
|
21 |
+
* DISCLAIMER
|
22 |
+
*
|
23 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
24 |
+
* versions in the future.
|
25 |
+
*
|
26 |
+
* @category Wfs
|
27 |
+
* @package Wfs_DisableEmails
|
28 |
+
* @copyright Copyright (c) 2013 WebFlakeStudio (http://webflakestudio.com)
|
29 |
+
* @license http://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt
|
30 |
+
*/
|
31 |
+
class Wfs_DisableEmails_Model_Adminhtml_Config_Data extends Mage_Adminhtml_Model_Config_Data
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* Save config section
|
35 |
+
* Require set: section, website, store and groups
|
36 |
+
*
|
37 |
+
* @return Mage_Adminhtml_Model_Config_Data
|
38 |
+
*/
|
39 |
+
public function save()
|
40 |
+
{
|
41 |
+
$this->_validate();
|
42 |
+
$this->_getScope();
|
43 |
+
|
44 |
+
Mage::dispatchEvent('model_config_data_save_before', array('object' => $this));
|
45 |
+
|
46 |
+
$section = $this->getSection();
|
47 |
+
$website = $this->getWebsite();
|
48 |
+
$store = $this->getStore();
|
49 |
+
$groups = $this->getGroups();
|
50 |
+
$scope = $this->getScope();
|
51 |
+
$scopeId = $this->getScopeId();
|
52 |
+
|
53 |
+
if (empty($groups)) {
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
$sections = Mage::getModel('adminhtml/config')->getSections();
|
58 |
+
/* @var $sections Mage_Core_Model_Config_Element */
|
59 |
+
|
60 |
+
$oldConfig = $this->_getConfig(true);
|
61 |
+
|
62 |
+
$deleteTransaction = Mage::getModel('core/resource_transaction');
|
63 |
+
/* @var $deleteTransaction Mage_Core_Model_Resource_Transaction */
|
64 |
+
$saveTransaction = Mage::getModel('core/resource_transaction');
|
65 |
+
/* @var $saveTransaction Mage_Core_Model_Resource_Transaction */
|
66 |
+
|
67 |
+
// Extends for old config data
|
68 |
+
$oldConfigAdditionalGroups = array();
|
69 |
+
|
70 |
+
foreach ($groups as $group => $groupData) {
|
71 |
+
/**
|
72 |
+
* Map field names if they were cloned
|
73 |
+
*/
|
74 |
+
$groupConfig = $sections->descend($section.'/groups/'.$group);
|
75 |
+
|
76 |
+
if ($clonedFields = !empty($groupConfig->clone_fields)) {
|
77 |
+
if ($groupConfig->clone_model) {
|
78 |
+
$cloneModel = Mage::getModel((string)$groupConfig->clone_model);
|
79 |
+
} else {
|
80 |
+
Mage::throwException('Config form fieldset clone model required to be able to clone fields');
|
81 |
+
}
|
82 |
+
$mappedFields = array();
|
83 |
+
$fieldsConfig = $sections->descend($section.'/groups/'.$group.'/fields');
|
84 |
+
|
85 |
+
if ($fieldsConfig->hasChildren()) {
|
86 |
+
foreach ($fieldsConfig->children() as $field => $node) {
|
87 |
+
foreach ($cloneModel->getPrefixes() as $prefix) {
|
88 |
+
$mappedFields[$prefix['field'].(string)$field] = (string)$field;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
// set value for group field entry by fieldname
|
94 |
+
// use extra memory
|
95 |
+
$fieldsetData = array();
|
96 |
+
foreach ($groupData['fields'] as $field => $fieldData) {
|
97 |
+
$fieldsetData[$field] = (is_array($fieldData) && isset($fieldData['value']))
|
98 |
+
? $fieldData['value'] : null;
|
99 |
+
}
|
100 |
+
|
101 |
+
foreach ($groupData['fields'] as $field => $fieldData) {
|
102 |
+
$fieldConfig = $sections->descend($section . '/groups/' . $group . '/fields/' . $field);
|
103 |
+
if (!$fieldConfig && $clonedFields && isset($mappedFields[$field])) {
|
104 |
+
$fieldConfig = $sections->descend($section . '/groups/' . $group . '/fields/'
|
105 |
+
. $mappedFields[$field]);
|
106 |
+
}
|
107 |
+
if (!$fieldConfig) {
|
108 |
+
$node = $sections->xpath($section .'//' . $group . '[@type="group"]/fields/' . $field);
|
109 |
+
if ($node) {
|
110 |
+
$fieldConfig = $node[0];
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Get field backend model
|
116 |
+
* Fix core issue here, because not all fields has 'backend_model' property
|
117 |
+
*/
|
118 |
+
if (!empty($fieldConfig->backend_model)) {
|
119 |
+
$backendClass = $fieldConfig->backend_model;
|
120 |
+
} else {
|
121 |
+
$backendClass = 'core/config_data';
|
122 |
+
}
|
123 |
+
|
124 |
+
/** @var $dataObject Mage_Core_Model_Config_Data */
|
125 |
+
$dataObject = Mage::getModel($backendClass);
|
126 |
+
if (!$dataObject instanceof Mage_Core_Model_Config_Data) {
|
127 |
+
Mage::throwException('Invalid config field backend model: '.$backendClass);
|
128 |
+
}
|
129 |
+
|
130 |
+
$dataObject
|
131 |
+
->setField($field)
|
132 |
+
->setGroups($groups)
|
133 |
+
->setGroupId($group)
|
134 |
+
->setStoreCode($store)
|
135 |
+
->setWebsiteCode($website)
|
136 |
+
->setScope($scope)
|
137 |
+
->setScopeId($scopeId)
|
138 |
+
->setFieldConfig($fieldConfig)
|
139 |
+
->setFieldsetData($fieldsetData)
|
140 |
+
;
|
141 |
+
|
142 |
+
if (!isset($fieldData['value'])) {
|
143 |
+
$fieldData['value'] = null;
|
144 |
+
}
|
145 |
+
|
146 |
+
$path = $section . '/' . $group . '/' . $field;
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Look for custom defined field path
|
150 |
+
*/
|
151 |
+
if (is_object($fieldConfig)) {
|
152 |
+
$configPath = (string)$fieldConfig->config_path;
|
153 |
+
if (!empty($configPath) && strrpos($configPath, '/') > 0) {
|
154 |
+
// Extend old data with specified section group
|
155 |
+
$groupPath = substr($configPath, 0, strrpos($configPath, '/'));
|
156 |
+
if (!isset($oldConfigAdditionalGroups[$groupPath])) {
|
157 |
+
$oldConfig = $this->extendConfig($groupPath, true, $oldConfig);
|
158 |
+
$oldConfigAdditionalGroups[$groupPath] = true;
|
159 |
+
}
|
160 |
+
$path = $configPath;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
$inherit = !empty($fieldData['inherit']);
|
165 |
+
|
166 |
+
$dataObject->setPath($path)
|
167 |
+
->setValue($fieldData['value']);
|
168 |
+
|
169 |
+
if (isset($oldConfig[$path])) {
|
170 |
+
$dataObject->setConfigId($oldConfig[$path]['config_id']);
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Delete config data if inherit
|
174 |
+
*/
|
175 |
+
if (!$inherit) {
|
176 |
+
$saveTransaction->addObject($dataObject);
|
177 |
+
}
|
178 |
+
else {
|
179 |
+
$deleteTransaction->addObject($dataObject);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
elseif (!$inherit) {
|
183 |
+
$dataObject->unsConfigId();
|
184 |
+
$saveTransaction->addObject($dataObject);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
$deleteTransaction->delete();
|
190 |
+
$saveTransaction->save();
|
191 |
+
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
}
|
app/code/community/Wfs/DisableEmails/etc/config.xml
CHANGED
@@ -26,14 +26,14 @@
|
|
26 |
*
|
27 |
* @category Wfs
|
28 |
* @package Wfs_DisableEmails
|
29 |
-
* @copyright Copyright (c)
|
30 |
* @license http://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt
|
31 |
*/
|
32 |
-->
|
33 |
<config>
|
34 |
<modules>
|
35 |
<Wfs_DisableEmails>
|
36 |
-
<version>1.0.
|
37 |
</Wfs_DisableEmails>
|
38 |
</modules>
|
39 |
<global>
|
@@ -49,6 +49,14 @@
|
|
49 |
<email_template_mailer>Wfs_DisableEmails_Model_Email_Template_Mailer</email_template_mailer>
|
50 |
</rewrite>
|
51 |
</core>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
</models>
|
53 |
<blocks>
|
54 |
<wfs_disableemails>
|
@@ -56,4 +64,4 @@
|
|
56 |
</wfs_disableemails>
|
57 |
</blocks>
|
58 |
</global>
|
59 |
-
</config>
|
26 |
*
|
27 |
* @category Wfs
|
28 |
* @package Wfs_DisableEmails
|
29 |
+
* @copyright Copyright (c) 2013 WebFlakeStudio (http://webflakestudio.com)
|
30 |
* @license http://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt
|
31 |
*/
|
32 |
-->
|
33 |
<config>
|
34 |
<modules>
|
35 |
<Wfs_DisableEmails>
|
36 |
+
<version>1.0.2</version>
|
37 |
</Wfs_DisableEmails>
|
38 |
</modules>
|
39 |
<global>
|
49 |
<email_template_mailer>Wfs_DisableEmails_Model_Email_Template_Mailer</email_template_mailer>
|
50 |
</rewrite>
|
51 |
</core>
|
52 |
+
<wfs_disable_emails>
|
53 |
+
<class>Wfs_DisableEmails_Model</class>
|
54 |
+
</wfs_disable_emails>
|
55 |
+
<adminhtml>
|
56 |
+
<rewrite>
|
57 |
+
<config_data>Wfs_DisableEmails_Model_Adminhtml_Config_Data</config_data>
|
58 |
+
</rewrite>
|
59 |
+
</adminhtml>
|
60 |
</models>
|
61 |
<blocks>
|
62 |
<wfs_disableemails>
|
64 |
</wfs_disableemails>
|
65 |
</blocks>
|
66 |
</global>
|
67 |
+
</config>
|
package.xml
CHANGED
@@ -1,20 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Wfs_DisableEmails</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="http://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt">
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This extension allows to disable specific email notifications in Magento.</summary>
|
10 |
-
<description>Disable Emails extension from WebFlakeStudio allows to disable specific email notifications in Magento store. In some cases it is needed to disable particular transactional email. You can do this easily with Wfs_DisableEmails module
|
11 |
-
|
12 |
-
|
13 |
-
<
|
14 |
-
<
|
15 |
-
<
|
16 |
-
<time>10:21:24</time>
|
17 |
-
<contents><target name="magecommunity"><dir name="Wfs"><dir name="DisableEmails"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><file name="DisableEmails.php" hash="c22d12aa471d2ff9ddad366c97dc8c62"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="44996e62b767efce86d7cbeae9ee56de"/></dir><dir name="Model"><dir name="Email"><dir name="Template"><file name="Mailer.php" hash="17218d1c3762d30a646b607d2a25a1f3"/></dir><file name="Template.php" hash="8e7d6db646896664929dc11278cc330a"/></dir></dir><dir name="etc"><file name="config.xml" hash="e1a6f10878c10c7ecd0f4a4381321143"/><file name="system.xml" hash="8a56a027b9e5dfa040b06c39265a3e95"/></dir><file name="WFS-LICENSE-COMMUNITY.txt" hash="5110d0940ef56f2f91bfd8da858c1c1f"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wfs_DisableEmails.xml" hash="0bbc0af646ff4c4d1e31e4bf844cc5ed"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
-
<dependencies
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Wfs_DisableEmails</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://webflakestudio.com/WFS-LICENSE-COMMUNITY.txt">Custom</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This extension allows to disable specific email notifications in Magento.</summary>
|
10 |
+
<description>Disable Emails extension from WebFlakeStudio allows to disable specific email notifications in Magento store. In some cases it is needed to disable particular transactional email. You can do this easily with Wfs_DisableEmails module. This extension can be used to disable all native Magento email notifications and even notifications of custom modules.</description>
|
11 |
+
<notes>Fixed core issue: warning on system config save for dynamic fields (eg. disable modules output).</notes>
|
12 |
+
<authors><author><name>WebFlakeStudio</name><user>WebFlakeStudio</user><email>webflakestudio@gmail.com</email></author></authors>
|
13 |
+
<date>2013-04-10</date>
|
14 |
+
<time>15:22:19</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Wfs"><dir name="DisableEmails"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><file name="DisableEmails.php" hash="c22d12aa471d2ff9ddad366c97dc8c62"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="44996e62b767efce86d7cbeae9ee56de"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Config"><file name="Data.php" hash="077c84bfad5cf74e4ccc496af121efce"/></dir></dir><dir name="Email"><dir name="Template"><file name="Mailer.php" hash="17218d1c3762d30a646b607d2a25a1f3"/></dir><file name="Template.php" hash="8e7d6db646896664929dc11278cc330a"/></dir></dir><file name="WFS-LICENSE-COMMUNITY.txt" hash="5110d0940ef56f2f91bfd8da858c1c1f"/><dir name="etc"><file name="config.xml" hash="b62a2e98fb8063a8b4ffa6856ed46ad3"/><file name="system.xml" hash="8a56a027b9e5dfa040b06c39265a3e95"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wfs_DisableEmails.xml" hash="0bbc0af646ff4c4d1e31e4bf844cc5ed"/></dir></target></contents>
|
|
|
|
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|