Web4pro_Attachments - Version 1.0.4

Version Notes

Fix functionality for Magento 1.9.2.

Download this release

Release Info

Developer Sergey Repin
Extension Web4pro_Attachments
Version 1.0.4
Comparing to
See all releases


Code changes from version 1.0.3 to 1.0.4

app/code/community/Web4pro/Attachments/Helper/Attachment.php CHANGED
@@ -72,4 +72,18 @@ class Web4pro_Attachments_Helper_Attachment extends Mage_Core_Helper_Abstract
72
  return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
73
  }
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
72
  return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
73
  }
74
  }
75
+
76
+
77
+ /**
78
+ * delete the file if need
79
+ * @param $postData
80
+ */
81
+ public function deleteAttachemntFileIfNeed($postData)
82
+ {
83
+ if(isset($postData['uploaded_file']['delete']) && isset($postData['uploaded_file']['value'])
84
+ && $postData['uploaded_file']['delete'] == 1 && !empty($postData['uploaded_file']['value'])){
85
+ $pathToDelete = $this->getFileBaseDir().$postData['uploaded_file']['value'];
86
+ unlink($pathToDelete);
87
+ }
88
+ }
89
  }
app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/AttachmentController.php CHANGED
@@ -123,11 +123,13 @@ class Web4pro_Attachments_Adminhtml_Attachments_AttachmentController extends Web
123
  try {
124
  $attachment = $this->_initAttachment();
125
  $attachment->addData($data);
 
126
  $uploadedFileName = $this->_uploadAndGetName(
127
  'uploaded_file',
128
- Mage::helper('web4pro_attachments/attachment')->getFileBaseDir(),
129
  $data
130
  );
 
131
  $attachment->setData('uploaded_file', $uploadedFileName);
132
  $products = $this->getRequest()->getPost('products', -1);
133
  if ($products != -1) {
123
  try {
124
  $attachment = $this->_initAttachment();
125
  $attachment->addData($data);
126
+ $attachmentHelper = Mage::helper('web4pro_attachments/attachment');
127
  $uploadedFileName = $this->_uploadAndGetName(
128
  'uploaded_file',
129
+ $attachmentHelper->getFileBaseDir(),
130
  $data
131
  );
132
+ $attachmentHelper->deleteAttachemntFileIfNeed($data);
133
  $attachment->setData('uploaded_file', $uploadedFileName);
134
  $products = $this->getRequest()->getPost('products', -1);
135
  if ($products != -1) {
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Attachments</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/lisenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Attach additional download files, manuals, media files, audio files with products for customer download.</description>
11
  <notes>Fix functionality for Magento 1.9.2.</notes>
12
  <authors><author><name>Sergey Repin</name><user>srepin</user><email>srepin@corp.web4pro.com.ua</email></author></authors>
13
- <date>2015-09-15</date>
14
- <time>11:43:42</time>
15
- <contents><target name="magecommunity"><dir name="Web4pro"><dir name="Attachments"><dir name="Block"><dir name="Adminhtml"><dir name="Attachment"><dir name="Edit"><file name="Form.php" hash="74159d2e86278a0952b1b63e37e76851"/><dir name="Tab"><file name="Form.php" hash="e7b8ddf29da1bdc492421062d98b6bad"/><file name="Product.php" hash="71bc7a5aeb5d26ad12b094cb18e3d803"/></dir><file name="Tabs.php" hash="b93dc50c79734cd19d2e05e486d5da3b"/></dir><file name="Edit.php" hash="379b58cda300c94afbe838a88e5851b9"/><file name="Grid.php" hash="f3f3f73e6dd676eb352c22bc3d2fa5ad"/><dir name="Helper"><file name="File.php" hash="3d936c71d4976c509db27a3452001cbc"/></dir><dir name="Widget"><file name="Chooser.php" hash="7806c94e4645ecc26cb19eaa4b886839"/></dir></dir><file name="Attachment.php" hash="76e8983cf68c6ca60ce0f727d8a40370"/><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Attachment.php" hash="9240ced751d8d3e5b80e88ce0b14eb7b"/></dir></dir></dir></dir><dir name="Helper"><dir name="Column"><dir name="Renderer"><file name="Relation.php" hash="5e7c2e6f689850cca6afd191557e8cc4"/></dir></dir></dir></dir><dir name="Attachment"><file name="List.php" hash="b2c35eab430959dbe2a6b4da75d1ff77"/><dir name="Widget"><file name="Link.php" hash="4cb020a28aaf5479caa64f725ad7fba1"/><file name="View.php" hash="eb6066fdbbd691e46e7eb2c69343c80d"/></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Attachment.php" hash="33a0db5ac985072232e9921debdac29a"/></dir></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="Attachments.php" hash="8a7ee1c174ea9318b21b3903ce53c353"/></dir></dir><dir name="Helper"><file name="Attachment.php" hash="4d61db9b52eb0b80ffc3d146030e9bf8"/><file name="Data.php" hash="9c992cb1aaccf1d08ac1552f5b7d546a"/><file name="Product.php" hash="36900b1d6f00dcdf4f2e66631a8a57ff"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="8e59205c8586dfdd5e4c7695345b749b"/><dir name="Search"><file name="Attachment.php" hash="448cff2ae24b1fa90d3eaf7562392fd5"/></dir></dir><dir name="Attachment"><file name="Product.php" hash="8b4edc5181ade4c24c145d7730a9d5a4"/></dir><file name="Attachment.php" hash="41dae9c3bc10de7b16e4d3cd9329ed6e"/><dir name="Resource"><dir name="Attachment"><file name="Collection.php" hash="496105c2d026e54ef053bd8e4eb7194b"/><dir name="Product"><file name="Collection.php" hash="0b5a31588f4eadaaa1d22f09f2b4808c"/></dir><file name="Product.php" hash="a5dd3a22b9c0c42e12322e86cc643cc8"/></dir><file name="Attachment.php" hash="595ba036a0f4b05b396811b78ab377df"/><file name="Setup.php" hash="56b4c9fb50f33a487315e9af44779f6a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Attachments"><dir name="Attachment"><dir name="Catalog"><file name="ProductController.php" hash="6a24f3ca5d8beb203a2dbe1e22ed5e3c"/></dir><file name="WidgetController.php" hash="dfceeec163058e74e5b757999a67d3f6"/></dir><file name="AttachmentController.php" hash="ed1f445b26248aad680f234c5e665b30"/></dir></dir><file name="AttachmentController.php" hash="e52f46b8268aebea7a8d9d26fb0a6826"/></dir><dir name="etc"><file name="adminhtml.xml" hash="00578db4ac5c15be9e8d2abaeefd0dae"/><file name="config.xml" hash="69c59ef86870a68de974659c40bc1db4"/><file name="widget.xml" hash="8319f4cd508ccef8c121fe7e68c9042b"/></dir><dir name="sql"><dir name="web4pro_attachments_setup"><file name="install-1.0.0.php" hash="3e001ecfd1fb2ea0b027fef3eb517b1c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Attachments.xml" hash="727e7cc825964f1a9547ba1476d53052"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="web4pro_attachments.xml" hash="7468ba3e03383738b1c581a6e52567c1"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_attachments.xml" hash="893ac94a5fcad8e3c24b43029ea4fb08"/></dir><dir name="template"><dir name="web4pro_attachments"><dir name="attachment"><dir name="widget"><file name="link.phtml" hash="a162409f65ddaeaeb0a26c67fb75c950"/><file name="view.phtml" hash="56063d72dceb0d62b3c4ae9682934e8c"/></dir></dir><dir name="catalog"><dir name="product"><dir name="list"><file name="attachment.phtml" hash="ff29c3e94916ddc050e21a940aef7af9"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="attachment"><dir name="icons"><file name="avi.png" hash="09c6b0a7673f3e42e041598018c171b5"/><file name="bmp.png" hash="fcfec54b446f4d63c84b666a3fd37366"/><file name="css.png" hash="1b687145ab8b16d0e3115db2d8228171"/><file name="csv.png" hash="b2d999841a097ea15d5c55964a0a3c06"/><file name="doc.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="docx.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="flv.png" hash="7f190e2a065e3703f87b0f7568754641"/><file name="gif.png" hash="43f9a1879ac63c78feae547129551fc3"/><file name="htm.png" hash="f343c0d04a67e9803b4fb59ff694d72e"/><file name="html.png" hash="5c75b131f9a380723355afbe647cc5cc"/><file name="jpeg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="jpg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="mov.png" hash="4cbea719f33a4e29ddd2e083c5a0b0d1"/><file name="mp3.png" hash="888d7552ad7566a092494f39882d56cb"/><file name="pdf.png" hash="3d6afa6a2ed73b461846b8a13cfc730b"/><file name="plain.png" hash="48bf4302227f60c0bf8d9d531586d6ca"/><file name="png.png" hash="174af144f77a8affdb93c721240bc83a"/><file name="ppt.png" hash="4745d6c5fbc03eb6c46ee4d1d51a9d01"/><file name="rtf.png" hash="be33fb7c5bb2b8be60efc6d3b63b2bc8"/><file name="swf.png" hash="3522dc3e70b84f4cdf892caea7331164"/><file name="txt.png" hash="96361d93eb50ce99ec69b65a3733ba47"/><file name="wav.png" hash="0febbe202b8da6866aab471f4d681a20"/><file name="wmv.png" hash="ee71824919d89a30fd5251067333b389"/><file name="xls.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xlsx.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xml.png" hash="0d4446adbe445426d782934af4037a04"/><file name="zip.png" hash="1752876d0bff9bb8727cfe3f3c8aea8c"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Web4pro_Attachments.csv" hash="a371f8ab59f227050d7187742e3189d6"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Attachments</name>
4
+ <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/lisenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
10
  <description>Attach additional download files, manuals, media files, audio files with products for customer download.</description>
11
  <notes>Fix functionality for Magento 1.9.2.</notes>
12
  <authors><author><name>Sergey Repin</name><user>srepin</user><email>srepin@corp.web4pro.com.ua</email></author></authors>
13
+ <date>2015-11-11</date>
14
+ <time>08:36:10</time>
15
+ <contents><target name="magecommunity"><dir name="Web4pro"><dir name="Attachments"><dir name="Block"><dir name="Adminhtml"><dir name="Attachment"><dir name="Edit"><file name="Form.php" hash="74159d2e86278a0952b1b63e37e76851"/><dir name="Tab"><file name="Form.php" hash="e7b8ddf29da1bdc492421062d98b6bad"/><file name="Product.php" hash="71bc7a5aeb5d26ad12b094cb18e3d803"/></dir><file name="Tabs.php" hash="b93dc50c79734cd19d2e05e486d5da3b"/></dir><file name="Edit.php" hash="379b58cda300c94afbe838a88e5851b9"/><file name="Grid.php" hash="f3f3f73e6dd676eb352c22bc3d2fa5ad"/><dir name="Helper"><file name="File.php" hash="3d936c71d4976c509db27a3452001cbc"/></dir><dir name="Widget"><file name="Chooser.php" hash="7806c94e4645ecc26cb19eaa4b886839"/></dir></dir><file name="Attachment.php" hash="76e8983cf68c6ca60ce0f727d8a40370"/><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Attachment.php" hash="9240ced751d8d3e5b80e88ce0b14eb7b"/></dir></dir></dir></dir><dir name="Helper"><dir name="Column"><dir name="Renderer"><file name="Relation.php" hash="5e7c2e6f689850cca6afd191557e8cc4"/></dir></dir></dir></dir><dir name="Attachment"><file name="List.php" hash="b2c35eab430959dbe2a6b4da75d1ff77"/><dir name="Widget"><file name="Link.php" hash="4cb020a28aaf5479caa64f725ad7fba1"/><file name="View.php" hash="eb6066fdbbd691e46e7eb2c69343c80d"/></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Attachment.php" hash="33a0db5ac985072232e9921debdac29a"/></dir></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="Attachments.php" hash="8a7ee1c174ea9318b21b3903ce53c353"/></dir></dir><dir name="Helper"><file name="Attachment.php" hash="f4a049281fc5edfa4f548529c7c1509e"/><file name="Data.php" hash="9c992cb1aaccf1d08ac1552f5b7d546a"/><file name="Product.php" hash="36900b1d6f00dcdf4f2e66631a8a57ff"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="8e59205c8586dfdd5e4c7695345b749b"/><dir name="Search"><file name="Attachment.php" hash="448cff2ae24b1fa90d3eaf7562392fd5"/></dir></dir><dir name="Attachment"><file name="Product.php" hash="8b4edc5181ade4c24c145d7730a9d5a4"/></dir><file name="Attachment.php" hash="41dae9c3bc10de7b16e4d3cd9329ed6e"/><dir name="Resource"><dir name="Attachment"><file name="Collection.php" hash="496105c2d026e54ef053bd8e4eb7194b"/><dir name="Product"><file name="Collection.php" hash="0b5a31588f4eadaaa1d22f09f2b4808c"/></dir><file name="Product.php" hash="a5dd3a22b9c0c42e12322e86cc643cc8"/></dir><file name="Attachment.php" hash="595ba036a0f4b05b396811b78ab377df"/><file name="Setup.php" hash="56b4c9fb50f33a487315e9af44779f6a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Attachments"><dir name="Attachment"><dir name="Catalog"><file name="ProductController.php" hash="6a24f3ca5d8beb203a2dbe1e22ed5e3c"/></dir><file name="WidgetController.php" hash="dfceeec163058e74e5b757999a67d3f6"/></dir><file name="AttachmentController.php" hash="baaf09598aa9bea1e069746c62ea26f0"/></dir></dir><file name="AttachmentController.php" hash="e52f46b8268aebea7a8d9d26fb0a6826"/></dir><dir name="etc"><file name="adminhtml.xml" hash="00578db4ac5c15be9e8d2abaeefd0dae"/><file name="config.xml" hash="69c59ef86870a68de974659c40bc1db4"/><file name="widget.xml" hash="8319f4cd508ccef8c121fe7e68c9042b"/></dir><dir name="sql"><dir name="web4pro_attachments_setup"><file name="install-1.0.0.php" hash="3e001ecfd1fb2ea0b027fef3eb517b1c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Attachments.xml" hash="727e7cc825964f1a9547ba1476d53052"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="web4pro_attachments.xml" hash="7468ba3e03383738b1c581a6e52567c1"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_attachments.xml" hash="893ac94a5fcad8e3c24b43029ea4fb08"/></dir><dir name="template"><dir name="web4pro_attachments"><dir name="attachment"><dir name="widget"><file name="link.phtml" hash="a162409f65ddaeaeb0a26c67fb75c950"/><file name="view.phtml" hash="56063d72dceb0d62b3c4ae9682934e8c"/></dir></dir><dir name="catalog"><dir name="product"><dir name="list"><file name="attachment.phtml" hash="ff29c3e94916ddc050e21a940aef7af9"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="attachment"><dir name="icons"><file name="avi.png" hash="09c6b0a7673f3e42e041598018c171b5"/><file name="bmp.png" hash="fcfec54b446f4d63c84b666a3fd37366"/><file name="css.png" hash="1b687145ab8b16d0e3115db2d8228171"/><file name="csv.png" hash="b2d999841a097ea15d5c55964a0a3c06"/><file name="doc.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="docx.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="flv.png" hash="7f190e2a065e3703f87b0f7568754641"/><file name="gif.png" hash="43f9a1879ac63c78feae547129551fc3"/><file name="htm.png" hash="f343c0d04a67e9803b4fb59ff694d72e"/><file name="html.png" hash="5c75b131f9a380723355afbe647cc5cc"/><file name="jpeg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="jpg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="mov.png" hash="4cbea719f33a4e29ddd2e083c5a0b0d1"/><file name="mp3.png" hash="888d7552ad7566a092494f39882d56cb"/><file name="pdf.png" hash="3d6afa6a2ed73b461846b8a13cfc730b"/><file name="plain.png" hash="48bf4302227f60c0bf8d9d531586d6ca"/><file name="png.png" hash="174af144f77a8affdb93c721240bc83a"/><file name="ppt.png" hash="4745d6c5fbc03eb6c46ee4d1d51a9d01"/><file name="rtf.png" hash="be33fb7c5bb2b8be60efc6d3b63b2bc8"/><file name="swf.png" hash="3522dc3e70b84f4cdf892caea7331164"/><file name="txt.png" hash="96361d93eb50ce99ec69b65a3733ba47"/><file name="wav.png" hash="0febbe202b8da6866aab471f4d681a20"/><file name="wmv.png" hash="ee71824919d89a30fd5251067333b389"/><file name="xls.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xlsx.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xml.png" hash="0d4446adbe445426d782934af4037a04"/><file name="zip.png" hash="1752876d0bff9bb8727cfe3f3c8aea8c"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Web4pro_Attachments.csv" hash="a371f8ab59f227050d7187742e3189d6"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>