Cubix_CookieLaw - Version 0.1.0

Version Notes

First release

Download this release

Release Info

Developer Magento Core Team
Extension Cubix_CookieLaw
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Cubix/CookieLaw/Block/Popup.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Cubix
4
+ * @package Cubix_CookieLaw
5
+ * @author Harshit <support@cubixws.co.uk>
6
+ * @copyright Copyright (c) 2012 Cubix Web Solutions Limited (http://www.cubixws.co.uk)
7
+ */
8
+ class Cubix_CookieLaw_Block_Popup extends Mage_Core_Block_Template {
9
+
10
+ /**
11
+ * One first run assign all stores ids to block
12
+ * We cannot do this in the install file since the stores are not initialised by then
13
+ *
14
+ * @return null
15
+ */
16
+ protected function _construct() {
17
+ if (!is_null(Mage::registry('cubix_cookielaw_new_install'))) {
18
+ $block = Mage::getModel('cms/block')->load(Mage::registry('cubix_cookielaw_new_install'));
19
+ $block->setStores(array_keys(Mage::app()->getStores()))->save();
20
+ }
21
+ return parent::_construct();
22
+ }
23
+
24
+ /**
25
+ * CookieLaw module helper
26
+ *
27
+ * @return Cubix_CookieLaw_Helper_Data
28
+ */
29
+ protected function _helper() {
30
+ return Mage::helper('cookielaw');
31
+ }
32
+
33
+ /**
34
+ * Check if cookie law cookie accepted
35
+ *
36
+ * @return boolean
37
+ */
38
+ public function getCookieCheck() {
39
+ if (!Mage::getStoreConfigFlag('web/cookie/cookielaw_alert')) {
40
+ return true;
41
+ }
42
+ if ($this->_helper()->getCookie()) {
43
+ return true;
44
+ }
45
+ return false;
46
+ }
47
+ }
app/code/local/Cubix/CookieLaw/Helper/Data.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Cubix
4
+ * @package Cubix_CookieLaw
5
+ * @author Harshit <support@cubixws.co.uk>
6
+ * @copyright Copyright (c) 2012 Cubix Web Solutions Limited (http://www.cubixws.co.uk)
7
+ */
8
+ class Cubix_CookieLaw_Helper_Data extends Mage_Core_Helper_Abstract {
9
+
10
+ public function getCookieName() {
11
+ return 'cubix_cookielaw';
12
+ }
13
+
14
+ /**
15
+ * Cookie model
16
+ *
17
+ * @return Mage_Core_Model_Cookie
18
+ */
19
+ public function getCookieModel() {
20
+ return Mage::getModel('core/cookie');
21
+ }
22
+
23
+ /**
24
+ * Get cookie or return false
25
+ *
26
+ * @return mixed
27
+ */
28
+ public function getCookie() {
29
+ return $this->getCookieModel()->get($this->getCookieName());
30
+ }
31
+
32
+ /**
33
+ * Set cookie
34
+ *
35
+ * @return boolean
36
+ */
37
+ public function setCookie() {
38
+ $this->getCookieModel()->set($this->getCookieName(), 'eu cookie law policy accepted', true);
39
+ return true;
40
+ }
41
+ }
app/code/local/Cubix/CookieLaw/controllers/AcceptController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Cubix
4
+ * @package Cubix_CookieLaw
5
+ * @author Harshit <support@cubixws.co.uk>
6
+ * @copyright Copyright (c) 2012 Cubix Web Solutions Limited (http://www.cubixws.co.uk)
7
+ */
8
+ class Cubix_CookieLaw_AcceptController extends Mage_Core_Controller_Front_Action {
9
+
10
+ /**
11
+ * CookieLaw module helper
12
+ *
13
+ * @return Cubix_CookieLaw_Helper_Data
14
+ */
15
+ protected function _helper() {
16
+ return Mage::helper('cookielaw');
17
+ }
18
+
19
+
20
+ /**
21
+ * Save the cookie acceptance
22
+ */
23
+ public function saveAction() {
24
+ $this->_helper()->setCookie();
25
+ }
26
+
27
+ /**
28
+ * Delete all domain cookies if rejected
29
+ */
30
+ public function rejectAction() {
31
+ $cookiemodel = Mage::getModel('core/cookie');
32
+ $cookies = $cookiemodel->get();
33
+ foreach ($cookies as $key => $cookie) {
34
+ $cookiemodel->delete($key);
35
+ }
36
+ }
37
+ }
app/code/local/Cubix/CookieLaw/etc/config.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cubix_CookieLaw>
5
+ <version>0.1.0</version>
6
+ </Cubix_CookieLaw>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <cookielaw>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Cubix_CookieLaw</module>
15
+ <frontName>cookielaw</frontName>
16
+ </args>
17
+ </cookielaw>
18
+ </routers>
19
+ <layout>
20
+ <updates>
21
+ <cookielaw>
22
+ <file>cubix_cookielaw.xml</file>
23
+ </cookielaw>
24
+ </updates>
25
+ </layout>
26
+ </frontend>
27
+
28
+ <global>
29
+ <blocks>
30
+ <cookielaw>
31
+ <class>Cubix_CookieLaw_Block</class>
32
+ </cookielaw>
33
+ </blocks>
34
+
35
+ <helpers>
36
+ <cookielaw>
37
+ <class>Cubix_CookieLaw_Helper</class>
38
+ </cookielaw>
39
+ </helpers>
40
+
41
+ <resources>
42
+ <cookielaw_setup>
43
+ <setup>
44
+ <module>Cubix_CookieLaw</module>
45
+ <class>Mage_Core_Model_Resource_Setup</class>
46
+ </setup>
47
+ <connection>
48
+ <use>core_setup</use>
49
+ </connection>
50
+ </cookielaw_setup>
51
+ <cookielaw_write>
52
+ <connection>
53
+ <use>core_write</use>
54
+ </connection>
55
+ </cookielaw_write>
56
+ <cookielaw_read>
57
+ <connection>
58
+ <use>core_read</use>
59
+ </connection>
60
+ </cookielaw_read>
61
+ </resources>
62
+ </global>
63
+
64
+ <default>
65
+ <web>
66
+ <cookie>
67
+ <cookielaw_alert>1</cookielaw_alert>
68
+ </cookie>
69
+ </web>
70
+ </default>
71
+ </config>
app/code/local/Cubix/CookieLaw/etc/system.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <web>
5
+ <groups>
6
+ <cookie>
7
+ <fields>
8
+ <cookielaw_alert translate="label">
9
+ <label>EU Cookie Law Alert</label>
10
+ <frontend_type>select</frontend_type>
11
+ <source_model>adminhtml/system_config_source_yesno</source_model>
12
+ <sort_order>50</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ </cookielaw_alert>
17
+ </fields>
18
+ </cookie>
19
+ </groups>
20
+ </web>
21
+ </sections>
22
+ </config>
app/code/local/Cubix/CookieLaw/sql/cookielaw_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Cubix
4
+ * @package Cubix_CookieLaw
5
+ * @author Harshit <support@cubixws.co.uk>
6
+ * @copyright Copyright (c) 2012 Cubix Web Solutions Limited (http://www.cubixws.co.uk)
7
+ */
8
+
9
+ $installer = $this;
10
+ /* @var $installer Mage_Core_Model_Resource_Setup */
11
+ $installer->startSetup();
12
+
13
+ $content = "<h3>Cookie Policy</h3>
14
+ <p>We use cookies to ensure that we give you the best experience on our website. Cookies help recognise you each time you visit us and mean our team can understand which parts of the site you find most interesting. To learn more about cookies and their benefits, please view our cookie policy.</p>
15
+ <p>By continuing to use the site you agree to our <a href=\"{{store direct_url='cookie_law'}}\" title=\"Cookie Policy\">cookie policy</a>. if you would like to, you can <a href=\"{{store direct_url='cookie_law'}}#manage-cookie\" title=\"Manage Cookies\">change your cookie settings</a> at any time but please be aware that parts of the site will not function correctly if you disable cookies.</p>";
16
+
17
+ try {
18
+ $block = Mage::getModel('cms/block')
19
+ ->setTitle('EU Cookie Law Text')
20
+ ->setIdentifier('cubix_cookielaw')
21
+ ->setContent($content)
22
+ ->setIsActive(1)
23
+ ->setStores($stores)
24
+ ->save();
25
+ // Set a flag which will be used by the popup block to assign store ids to the block created above. We cannot assign the stores ids here because the stores are not initialised yet.
26
+ if ($block->getId()) {
27
+ Mage::register('cubix_cookielaw_new_install', $block->getId());
28
+ }
29
+ else {
30
+ Mage::throwException('Cookie Law CMS block creation error');
31
+ }
32
+ }
33
+ catch (Exception $e) {
34
+ Mage::log('Unable to create cookie law cms block. See exception log for more details');
35
+ Mage::logException($e);
36
+ }
37
+
38
+ $installer->endSetup();
39
+
app/design/frontend/base/default/layout/cubix_cookielaw.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="after_body_start">
5
+ <block type="cookielaw/popup" template="cubix/cookielaw/popup.phtml" name="cookie_law" as="cookie_law">
6
+ <action method="setIsModuleActive" ifconfig="web/cookie/cookielaw_alert"><value>1</value></action>
7
+ </block>
8
+ </reference>
9
+ </default>
10
+ </layout>
app/design/frontend/base/default/template/cubix/cookielaw/popup.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!$this->getCookieCheck()): ?>
2
+ <div id="cookie-law-container" class="cookie-law-container" style="opacity: 0.92; padding: 20px; position: fixed; top: 30%; left: 50%; margin-left: -350px; width: 700px; border: 2px solid #FF9000; background: #FFCF0D; z-index: 1000000">
3
+ <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('cubix_cookielaw')->toHtml() ?>
4
+ <div class="button-set">
5
+ <button onclick="cookie_law_accept()" class="button">
6
+ <span><span>
7
+ <?php echo $this->__('Close') ?>
8
+ </span></span>
9
+ </button>
10
+ </div>
11
+ <script type="text/javascript">
12
+ function cookie_law_accept() {
13
+ new Ajax.Request('<?php echo $this->getUrl('cookielaw/accept/save') ?>');
14
+ $('cookie-law-container').hide();
15
+ }
16
+ </script>
17
+ </div>
18
+ <?php endif; ?>
app/etc/modules/Cubix_CookieLaw.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cubix_CookieLaw>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Cubix_CookieLaw>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Cubix_CookieLaw</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>BSD License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>A lightweight extension by Cubix that shows a EU cookie law popup when users first visit your website</summary>
10
+ <description>Cubix EU Cookie Law Policy Confirmation&#xD;
11
+ &#xD;
12
+ &lt;br /&gt;&lt;br /&gt;As per the new law in the EU http://www.cookielaw.org you are required to advise people of your cookie policy. This extension shows a cookie policy alert popup to your customers when they first visit your website. Once the popup is closed it is not showed again until your cookies are cleared. This ensures compliance with the cookie law and is a valid method as used by http://www.ft.com/uk&#xD;
13
+ &#xD;
14
+ &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Features:&lt;/strong&gt;&lt;br /&gt;&#xD;
15
+ * Ability to manage the popup text as a CMS block from the admin panel&lt;br /&gt;&#xD;
16
+ * Ability to enable / disable per sore view for multi-store installations&lt;br /&gt;&#xD;
17
+ * Extremely lightweight. Uses barely few files and does not conflict with any other extension.&#xD;
18
+ &#xD;
19
+ &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Demo:&lt;/strong&gt; &lt;a href="http://magedemo1.cubixws.co.uk"&gt;http://magedemo1.cubixws.co.uk&lt;/a&gt;&#xD;
20
+ &#xD;
21
+ &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Installation instructions:&lt;/strong&gt;&lt;br /&gt;&#xD;
22
+ * Go to Admin Panel &gt; System &gt; Magento Connect &gt; Magento Connect Manager and install the extension.&lt;br /&gt;&#xD;
23
+ * Refresh all cache. go to Admin Panel &gt; System &gt; Cache Management, click on 'Select All' to select all your cache, choose 'Refresh' from Actions and click on Submit.&lt;br /&gt;&#xD;
24
+ * Go to Admin Panel &gt; CMS &gt; Static Blocks and click on 'EU Cookie Law Text'. Modify the text if required or hit Save. &lt;strong&gt;Note:&lt;/strong&gt; Even if you do no want to change the text this step is required to register your CMS block with your store id. Without this step no text will be shown on you popup.&lt;br /&gt;&#xD;
25
+ * To edit the styling of the popup, edit the file app/design/frontend/base/default/template/cubix/cookielaw/popup.phtml</description>
26
+ <notes>First release</notes>
27
+ <authors><author><name>Harshit Jain</name><user>auto-converted</user><email>enquiry@cubixws.com</email></author></authors>
28
+ <date>2012-06-06</date>
29
+ <time>15:29:47</time>
30
+ <contents><target name="magelocal"><dir name="Cubix"><dir name="CookieLaw"><dir name="Block"><file name="Popup.php" hash="900f07100dba459c21f9980f5b7e74b6"/></dir><dir name="Helper"><file name="Data.php" hash="9f3fdcda61fd4299d0a76fb39b9cd77d"/></dir><dir name="controllers"><file name="AcceptController.php" hash="99b82d5b071aa4e7176b52f950ee1983"/></dir><dir name="etc"><file name="config.xml" hash="a9b130339d6c0ade22a7fa8890637e3b"/><file name="system.xml" hash="3965e372b9bf55bf12e8117d9534ec08"/></dir><dir name="sql"><dir name="cookielaw_setup"><file name="mysql4-install-0.1.0.php" hash="443bd8dce83ec6207d3dfad6c363f172"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cubix_CookieLaw.xml" hash="e06f28a4fa5f08dab14179d39bad56a0"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cubix_cookielaw.xml" hash="6bdc3a03dd88ae546bce27831f455539"/></dir><dir name="template"><dir name="cubix"><dir name="cookielaw"><file name="popup.phtml" hash="78774baba11f891841e2d1051385173c"/></dir></dir></dir></dir></dir></dir></target></contents>
31
+ <compatible/>
32
+ <dependencies/>
33
+ </package>