Version Notes
0.0.10
Download this release
Release Info
Developer | Magento Core Team |
Extension | commercesciences |
Version | 0.0.10 |
Comparing to | |
See all releases |
Code changes from version 0.0.8 to 0.0.10
- app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/About.php +4 -2
- app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Campaignid.php +110 -110
- app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Isactive.php +2 -2
- app/code/local/Commercesciences/Base/Helper/Data.php +333 -333
- app/code/local/Commercesciences/Base/Model/Observer.php +167 -167
- app/code/local/Commercesciences/Base/etc/config.xml +129 -129
- app/code/local/Commercesciences/Base/etc/system.xml +75 -75
- app/etc/modules/Commercesciences_Base.xml +7 -7
- package.xml +6 -6
- skin/adminhtml/default/default/commercesciences/css/skin.css +29 -9
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/About.php
CHANGED
@@ -29,8 +29,10 @@ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_About extends M
|
|
29 |
<div class="cs_key-text-block">
|
30 |
<div class="cs_container">
|
31 |
<div class="cs_row">
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
</div>
|
35 |
</div>
|
36 |
</div>
|
29 |
<div class="cs_key-text-block">
|
30 |
<div class="cs_container">
|
31 |
<div class="cs_row">
|
32 |
+
<div class="cs_span12">
|
33 |
+
<h3><strong>The Personal Bar<span class="cs_sans-serif cs_tm">™</span> Is a free E-Commerce add-on, floating at the bottom of your site\'s pages,</strong></h3>
|
34 |
+
<h3><strong>designed to ease navigation, increase engagement and revenue</strong></h3>
|
35 |
+
</div>
|
36 |
</div>
|
37 |
</div>
|
38 |
</div>
|
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Campaignid.php
CHANGED
@@ -1,111 +1,111 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Campaignid extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
protected $_csHelper = null;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* retrieve the module helper
|
9 |
-
* @return Commercesciences_Base_Helper_Data
|
10 |
-
*/
|
11 |
-
protected function getCsHelper(){
|
12 |
-
if(!$this->_csHelper){
|
13 |
-
$this->_csHelper = Mage::helper("commercesciences_base");
|
14 |
-
}
|
15 |
-
return $this->_csHelper;
|
16 |
-
}
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* renders and returns the full HTML of the upper part (email) on the configurations panel
|
21 |
-
* here we can decide just not to show anything
|
22 |
-
*
|
23 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
-
* @return string
|
25 |
-
*/
|
26 |
-
public function render(Varien_Data_Form_Element_Abstract $element){
|
27 |
-
$html = '<tr><td><script type="text/javascript">
|
28 |
-
document.observe("dom:loaded", function() {
|
29 |
-
|
30 |
-
$$(".scalable.save").each(function(element){
|
31 |
-
element.writeAttribute("onclick",null);
|
32 |
-
element.observe("click", function(event){
|
33 |
-
$$(".scalable.save").each(function(element){
|
34 |
-
element.writeAttribute("disabled","disabled");
|
35 |
-
});
|
36 |
-
configForm.submit();
|
37 |
-
});
|
38 |
-
|
39 |
-
});
|
40 |
-
|
41 |
-
});
|
42 |
-
</script>
|
43 |
-
';
|
44 |
-
|
45 |
-
try{
|
46 |
-
|
47 |
-
$step = $this->getCsHelper()->getStep();
|
48 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
49 |
-
|
50 |
-
if(!$element->getValue()){
|
51 |
-
$currentUser = Mage::getSingleton('admin/session');
|
52 |
-
$currentUserEmail = $currentUser->getUser()->getEmail();
|
53 |
-
|
54 |
-
$element->setValue($currentUserEmail);
|
55 |
-
}
|
56 |
-
$inputBox = $element->getElementHtml();
|
57 |
-
$configEditBlock = Mage::getBlockSingleton("adminhtml/system_config_edit");
|
58 |
-
/* @var Mage_Adminhtml_Block_Widget_Button $saveButton */
|
59 |
-
$saveButton = $configEditBlock->getLayout()->createBlock('adminhtml/widget_button')
|
60 |
-
->setData(array(
|
61 |
-
'label' => Mage::helper('adminhtml')->__('Create My Account »'),
|
62 |
-
'onclick' => 'configForm.submit()',
|
63 |
-
'class' => 'save',
|
64 |
-
));
|
65 |
-
if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
|
66 |
-
$html .= '<div class="cswrapper form-list">';
|
67 |
-
$html .= '<div class="csexp1">'.$this->__("You're almost there! Please enter your email below to activate your account (Note: this email would be used to provide you updates and reports).").'</div>';
|
68 |
-
$html .= '<div class="csexp2"><div class="csexp2_left">Email Address</div><div class="csexp2_right">'.$inputBox.'</div></div>';
|
69 |
-
$html .= '<div class="csexp3"><div class="csexp3_left"></div><div class="csexp2_right"><p class="note"><span>The personal bar will be hidden from your shoppers until you click "Go Live" from your Config Panel or your Magento dashboard.</span></p>'.$saveButton->toHtml();
|
70 |
-
$html .= '<p class="note"><span style="color:#ff0000;">Before clicking "Create My Account" - Please make sure you have logged-out and logged back in from your Magento admin, <br>and that you have clicked "Flush Magento Cache" (under System > Cache Management)</span></p>';
|
71 |
-
$html .= '</div></div>';
|
72 |
-
$html .= '</div></td></tr>';
|
73 |
-
|
74 |
-
return $html;
|
75 |
-
}
|
76 |
-
if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
|
77 |
-
$linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
|
78 |
-
|
79 |
-
$html .= '<div class="cswrapper form-list">';
|
80 |
-
$html .= '<div class="csexp11">';
|
81 |
-
$html .= '<div class="csexp11_1">'.$this->__("Congratulations! Your new Personal Bar account is now ready.").'</div>';
|
82 |
-
$html .= '<div class="csexp11_2">'.$this->__("To configure the Personal Bar Experiences, Style and more, please click on
|
83 |
-
$html .= '<div class="csexp11_3">'.$this->__("Your personal Bar will remain hidden from your store visitors until you Publish it.").'</div>';
|
84 |
-
$html .= '</div>';
|
85 |
-
$html .= '<div class="csexp11_5">'.$this->__("Personal Bar Settings").'</div>';
|
86 |
-
$html .= '<div class="csexp11_6">'.$this->__("The Personal Bar is fully customizable to fit your store's look & feel and to help you increase engagement and revenue.").'</div>';
|
87 |
-
$html .= '<div class="csexp11_7"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel»").'</a></div>';
|
88 |
-
|
89 |
-
$html .= '</div>';
|
90 |
-
|
91 |
-
return $html;
|
92 |
-
}
|
93 |
-
if($step == Commercesciences_Base_Helper_Data::STEP_TWO){
|
94 |
-
$linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
|
95 |
-
|
96 |
-
$html .= '<div class="cswrapper form-list">';
|
97 |
-
$html .= '<div class="csexp21">'.$this->__("Personal Bar Settings").'</div>';
|
98 |
-
$html .= '<div class="csexp22">'.$this->__("The Personal Bar is fully customizable to fit your store’s look & feel and to help you increase engagement and revenue.").'</div>';
|
99 |
-
$html .= '<div class="csexp23"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel»").'</a></div>';
|
100 |
-
$html .= '</div>';
|
101 |
-
|
102 |
-
return $html;
|
103 |
-
}
|
104 |
-
|
105 |
-
return '';
|
106 |
-
}catch(Exception $e){
|
107 |
-
return '';
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Campaignid extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
protected $_csHelper = null;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* retrieve the module helper
|
9 |
+
* @return Commercesciences_Base_Helper_Data
|
10 |
+
*/
|
11 |
+
protected function getCsHelper(){
|
12 |
+
if(!$this->_csHelper){
|
13 |
+
$this->_csHelper = Mage::helper("commercesciences_base");
|
14 |
+
}
|
15 |
+
return $this->_csHelper;
|
16 |
+
}
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* renders and returns the full HTML of the upper part (email) on the configurations panel
|
21 |
+
* here we can decide just not to show anything
|
22 |
+
*
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function render(Varien_Data_Form_Element_Abstract $element){
|
27 |
+
$html = '<tr><td><script type="text/javascript">
|
28 |
+
document.observe("dom:loaded", function() {
|
29 |
+
|
30 |
+
$$(".scalable.save").each(function(element){
|
31 |
+
element.writeAttribute("onclick",null);
|
32 |
+
element.observe("click", function(event){
|
33 |
+
$$(".scalable.save").each(function(element){
|
34 |
+
element.writeAttribute("disabled","disabled");
|
35 |
+
});
|
36 |
+
configForm.submit();
|
37 |
+
});
|
38 |
+
|
39 |
+
});
|
40 |
+
|
41 |
+
});
|
42 |
+
</script>
|
43 |
+
';
|
44 |
+
|
45 |
+
try{
|
46 |
+
|
47 |
+
$step = $this->getCsHelper()->getStep();
|
48 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
49 |
+
|
50 |
+
if(!$element->getValue()){
|
51 |
+
$currentUser = Mage::getSingleton('admin/session');
|
52 |
+
$currentUserEmail = $currentUser->getUser()->getEmail();
|
53 |
+
|
54 |
+
$element->setValue($currentUserEmail);
|
55 |
+
}
|
56 |
+
$inputBox = $element->getElementHtml();
|
57 |
+
$configEditBlock = Mage::getBlockSingleton("adminhtml/system_config_edit");
|
58 |
+
/* @var Mage_Adminhtml_Block_Widget_Button $saveButton */
|
59 |
+
$saveButton = $configEditBlock->getLayout()->createBlock('adminhtml/widget_button')
|
60 |
+
->setData(array(
|
61 |
+
'label' => Mage::helper('adminhtml')->__('Create My Account »'),
|
62 |
+
'onclick' => 'configForm.submit()',
|
63 |
+
'class' => 'save',
|
64 |
+
));
|
65 |
+
if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
|
66 |
+
$html .= '<div class="cswrapper form-list">';
|
67 |
+
$html .= '<div class="csexp1">'.$this->__("You're almost there! Please enter your email below to activate your account (Note: this email would be used to provide you updates and reports).").'</div>';
|
68 |
+
$html .= '<div class="csexp2"><div class="csexp2_left">Email Address</div><div class="csexp2_right">'.$inputBox.'</div></div>';
|
69 |
+
$html .= '<div class="csexp3"><div class="csexp3_left"></div><div class="csexp2_right"><p class="note"><span>The personal bar will be hidden from your shoppers until you click "Go Live" from your Config Panel or your Magento dashboard.</span></p>'.$saveButton->toHtml();
|
70 |
+
$html .= '<p class="note"><span style="color:#ff0000;">Before clicking "Create My Account" - Please make sure you have logged-out and logged back in from your Magento admin, <br>and that you have clicked "Flush Magento Cache" (under System > Cache Management)</span></p>';
|
71 |
+
$html .= '</div></div>';
|
72 |
+
$html .= '</div></td></tr>';
|
73 |
+
|
74 |
+
return $html;
|
75 |
+
}
|
76 |
+
if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
|
77 |
+
$linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
|
78 |
+
|
79 |
+
$html .= '<div class="cswrapper form-list">';
|
80 |
+
$html .= '<div class="csexp11">';
|
81 |
+
$html .= '<div class="csexp11_1">'.$this->__("Congratulations! Your new Personal Bar account is now ready.").'</div>';
|
82 |
+
$html .= '<div class="csexp11_2">'.$this->__("(To configure the Personal Bar Experiences, Style and more, please click on Go to my Config Panel below.)").'</div>';
|
83 |
+
$html .= '<div class="csexp11_3">'.$this->__("Your personal Bar will remain hidden from your store visitors until you Publish it.").'</div>';
|
84 |
+
$html .= '</div>';
|
85 |
+
$html .= '<div class="csexp11_5">'.$this->__("Personal Bar Settings").'</div>';
|
86 |
+
$html .= '<div class="csexp11_6">'.$this->__("The Personal Bar is fully customizable to fit your store's look & feel and to help you increase engagement and revenue.").'</div>';
|
87 |
+
$html .= '<div class="csexp11_7"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel»").'</a></div>';
|
88 |
+
|
89 |
+
$html .= '</div></td></tr>';
|
90 |
+
|
91 |
+
return $html;
|
92 |
+
}
|
93 |
+
if($step == Commercesciences_Base_Helper_Data::STEP_TWO){
|
94 |
+
$linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
|
95 |
+
|
96 |
+
$html .= '<div class="cswrapper form-list">';
|
97 |
+
$html .= '<div class="csexp21">'.$this->__("Personal Bar Settings").'</div>';
|
98 |
+
$html .= '<div class="csexp22">'.$this->__("The Personal Bar is fully customizable to fit your store’s look & feel and to help you increase engagement and revenue.").'</div>';
|
99 |
+
$html .= '<div class="csexp23"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel»").'</a></div>';
|
100 |
+
$html .= '</div></td></tr>';
|
101 |
+
|
102 |
+
return $html;
|
103 |
+
}
|
104 |
+
|
105 |
+
return '';
|
106 |
+
}catch(Exception $e){
|
107 |
+
return '';
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
}
|
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Isactive.php
CHANGED
@@ -59,7 +59,7 @@ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Isactive extend
|
|
59 |
if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
|
60 |
$html = '<div class="cswrapper form-list">';
|
61 |
$html .= '<div class="csexp12"><div class="csexp12_left">Enabled?</div><div class="csexp12_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
|
62 |
-
$html .= '</div
|
63 |
|
64 |
return $html;
|
65 |
}
|
@@ -67,7 +67,7 @@ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Isactive extend
|
|
67 |
$html = '<div class="cswrapper form-list">';
|
68 |
$html .= '<div class="csexp24"><div class="csexp24_left">Is Live on my store?</div><div class="csexp24_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
|
69 |
$html .= '<div class="csexp25"><div class="csexp25_left">'.$this->__("Have questions? contact our").'</div> <a class="csexp25_left2" href="mailto: support@commercesciences.com">'.$this->__("support team").'</a></div>';
|
70 |
-
$html .= '</div
|
71 |
|
72 |
return $html;
|
73 |
}
|
59 |
if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
|
60 |
$html = '<div class="cswrapper form-list">';
|
61 |
$html .= '<div class="csexp12"><div class="csexp12_left">Enabled?</div><div class="csexp12_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
|
62 |
+
$html .= '</div>';
|
63 |
|
64 |
return $html;
|
65 |
}
|
67 |
$html = '<div class="cswrapper form-list">';
|
68 |
$html .= '<div class="csexp24"><div class="csexp24_left">Is Live on my store?</div><div class="csexp24_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
|
69 |
$html .= '<div class="csexp25"><div class="csexp25_left">'.$this->__("Have questions? contact our").'</div> <a class="csexp25_left2" href="mailto: support@commercesciences.com">'.$this->__("support team").'</a></div>';
|
70 |
+
$html .= '</div>';
|
71 |
|
72 |
return $html;
|
73 |
}
|
app/code/local/Commercesciences/Base/Helper/Data.php
CHANGED
@@ -1,334 +1,334 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Commercesciences_Base_Helper_Data extends Mage_Core_Helper_Abstract{
|
4 |
-
|
5 |
-
const STEP_ZERO = 0;
|
6 |
-
const STEP_ONE = 1;
|
7 |
-
const STEP_TWO = 2;
|
8 |
-
|
9 |
-
const CONFIG_EMAIL = 'commercesciences/required_param/email';
|
10 |
-
const DEFAULT_MYSQL_TIMEOUT = 10;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* handles the errors
|
14 |
-
*/
|
15 |
-
public function handleError($error){
|
16 |
-
//Mage::log("Error:".$error, null, 'cs-error.log', true);
|
17 |
-
throw new Exception($error);
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* return the current step of the system
|
22 |
-
*
|
23 |
-
* @return int
|
24 |
-
*/
|
25 |
-
public function getStep(){
|
26 |
-
if(!$this->_step){
|
27 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
28 |
-
if(!$csConfig || !$csConfig->getId()){
|
29 |
-
$csConfig = Mage::getModel("commercesciences_base/config");
|
30 |
-
$csConfig->save();
|
31 |
-
}
|
32 |
-
if(!$csConfig->getUserId()){
|
33 |
-
$this->_step = Commercesciences_Base_Helper_Data::STEP_ZERO;
|
34 |
-
return $this->_step;
|
35 |
-
}
|
36 |
-
|
37 |
-
//we have userId its step 1 or 2
|
38 |
-
$aStateArr = $this->getActiveState();
|
39 |
-
if($aStateArr['error'] != false){
|
40 |
-
$this->handleError($aStateArr['error']);
|
41 |
-
return;
|
42 |
-
}
|
43 |
-
if($aStateArr['data'] == 'NotConfigured'){
|
44 |
-
$this->_step = Commercesciences_Base_Helper_Data::STEP_ONE;
|
45 |
-
}elseif($aStateArr['data'] == 'Hidden' || $aStateArr['data'] == 'Visible'){
|
46 |
-
$this->_step = Commercesciences_Base_Helper_Data::STEP_TWO;
|
47 |
-
}else{
|
48 |
-
$error = $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)");
|
49 |
-
//Mage::log("Error:".$error, null, 'cs-error.log', true);
|
50 |
-
throw new Exception($error);
|
51 |
-
return;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
return $this->_step;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* converts the first layer of stdObject to array
|
60 |
-
* @param stdObject $stdObj
|
61 |
-
* @return array
|
62 |
-
*/
|
63 |
-
public function stdObject2Array($stdObj)
|
64 |
-
{
|
65 |
-
if (is_object($stdObj)){
|
66 |
-
$stdObj = get_object_vars($stdObj);
|
67 |
-
}
|
68 |
-
return $stdObj;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* register the email + domain on commercesciences
|
73 |
-
*
|
74 |
-
* @return array - format [error] => ''
|
75 |
-
*/
|
76 |
-
public function register($email, $storeUrl){
|
77 |
-
|
78 |
-
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
79 |
-
|
80 |
-
$httpClient = $RESTClient->getHttpClient();
|
81 |
-
$httpClient->setConfig(array(
|
82 |
-
"timeout" => 30
|
83 |
-
));
|
84 |
-
|
85 |
-
try {
|
86 |
-
|
87 |
-
//Mage::log("xxx", null, "debug6.log", true);
|
88 |
-
|
89 |
-
$timeBeforeApiCall = time();
|
90 |
-
|
91 |
-
$response = $RESTClient->restPost("/magento/registerPost", array('email' => $email, 'storeURL'=>$storeUrl));
|
92 |
-
$responseJson = $response->getBody();
|
93 |
-
|
94 |
-
$timeAfterApiCall = time();
|
95 |
-
//Mage::log("yyy-".$responseJson, null, "debug6.log", true);
|
96 |
-
//Mage::log("zzz-".($timeAfterApiCall-$timeBeforeApiCall), null, "debug6.log", true);
|
97 |
-
|
98 |
-
//fictive
|
99 |
-
//$responseJson = '{"good":true,"data":{"securityToken":"qfJpXFdiccH2LtAXy3U3mMZFRNiAbMsiGocKpk9RLarqda9001YYxXjYyQwy","userID":12296,"tag":"\u003c!-- CS Bar --\u003e\r\n\u003cscript type\u003d\u0027text/javascript\u0027\u003e\r\nvar script \u003d document.createElement(\u0027script\u0027);\r\nscript.type \u003d \u0027text/javascript\u0027;\r\nscript.src \u003d ((document.location.protocol \u003d\u003d \u0027https:\u0027) ? \u0027https://\u0027 : \u0027http://\u0027) +\r\n \u0027app.cdn-cs.com/b/4Udqvg/k9rip6/l/cs_all.js\u0027;\r\ndocument.getElementsByTagName(\u0027head\u0027)[0].appendChild(script);\r\n\u003c/script\u003e\r\n\u003c!-- end CS --\u003e\r\n"}}';
|
100 |
-
|
101 |
-
//Mage::log("response-".$responseJson, null, 'debug4.log', true);
|
102 |
-
|
103 |
-
//fictive response for testing
|
104 |
-
|
105 |
-
/*$parsedResponse = array(
|
106 |
-
'security_token' => 'abcdefghijklmnop',
|
107 |
-
'user_id' => '123456',
|
108 |
-
'tag' => '<script type="text/javascript">alert(\'Hello!\');</script>'
|
109 |
-
);
|
110 |
-
*/
|
111 |
-
|
112 |
-
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
113 |
-
if(!isset($parsedResponseArr['good'])){
|
114 |
-
//timeout occured
|
115 |
-
return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 003)"));
|
116 |
-
}
|
117 |
-
if($parsedResponseArr['good'] == false){
|
118 |
-
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
119 |
-
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
120 |
-
$errorMsg = '';
|
121 |
-
foreach($fieldErrorsArr as $field => $fError){
|
122 |
-
$errorMsg .= "<br />";
|
123 |
-
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
124 |
-
}
|
125 |
-
return array('error' => $errorMsg);
|
126 |
-
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
127 |
-
return array('error' => $this->__($parsedResponseArr['globalError']));
|
128 |
-
}
|
129 |
-
}
|
130 |
-
$parsedResponse = $this->stdObject2Array($parsedResponseArr['data']);
|
131 |
-
|
132 |
-
if(!isset($parsedResponse['securityToken']) || !$parsedResponse['securityToken']
|
133 |
-
|| !isset($parsedResponse['userID']) || !$parsedResponse['userID']
|
134 |
-
|| !isset($parsedResponse['tag']) || !$parsedResponse['tag']){
|
135 |
-
return $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 001)");
|
136 |
-
}
|
137 |
-
|
138 |
-
if($timeAfterApiCall-$timeBeforeApiCall > self::DEFAULT_MYSQL_TIMEOUT){
|
139 |
-
//Mage::log("ffff", null, "debug6.log", true);
|
140 |
-
|
141 |
-
//pobably mysql serer has gone away, save data in the session
|
142 |
-
|
143 |
-
$adminSession = Mage::getModel('customer/session');
|
144 |
-
$adminSession->setCsUserId($parsedResponse['userID']);
|
145 |
-
$adminSession->setCsSecurityToken($parsedResponse['securityToken']);
|
146 |
-
$adminSession->setCsTag($parsedResponse['tag']);
|
147 |
-
}else{
|
148 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
149 |
-
if(!$csConfig){
|
150 |
-
$csConfig = Mage::getModel("commercesciences_base/config");
|
151 |
-
}
|
152 |
-
$csConfig->setSecurityToken($parsedResponse['securityToken'])
|
153 |
-
->setUserId($parsedResponse['userID'])
|
154 |
-
->setTag($parsedResponse['tag'])
|
155 |
-
->save();
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
$message = '';
|
160 |
-
if(isset($parsedResponse['message']) && $parsedResponse['message']){
|
161 |
-
$message = $parsedResponse['message'];
|
162 |
-
}
|
163 |
-
|
164 |
-
return array('error' => false, 'message' => $message);
|
165 |
-
|
166 |
-
}catch(Exception $e){
|
167 |
-
//timeout or other unhandled exception was thrown
|
168 |
-
return array('error' => $this->__($e->getMessage()));
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Change the is_state of the bar
|
174 |
-
*
|
175 |
-
* @param int $changeTo
|
176 |
-
* @return array
|
177 |
-
*/
|
178 |
-
protected function changeActiveState($changeTo=1){
|
179 |
-
|
180 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
181 |
-
if(!$csConfig || !$csConfig->getUserId() || !$csConfig->getSecurityToken()){
|
182 |
-
//we must be already at least on step 1, so the DB record has to exist
|
183 |
-
return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 002)"));
|
184 |
-
}
|
185 |
-
|
186 |
-
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
187 |
-
|
188 |
-
$httpClient = $RESTClient->getHttpClient();
|
189 |
-
$httpClient->setConfig(array(
|
190 |
-
"timeout" => 30
|
191 |
-
));
|
192 |
-
|
193 |
-
try{
|
194 |
-
if($changeTo){
|
195 |
-
$response = $RESTClient->restPost("/magento/showBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
196 |
-
}else{
|
197 |
-
$response = $RESTClient->restPost("/magento/hideBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
198 |
-
}
|
199 |
-
|
200 |
-
$responseJson = $response->getBody();
|
201 |
-
//Mage::log("activation-response-".$responseJson, null, 'debug4.log', true);
|
202 |
-
|
203 |
-
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
204 |
-
if(!isset($parsedResponseArr['good'])){
|
205 |
-
return $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 004)");
|
206 |
-
}
|
207 |
-
if($parsedResponseArr['good'] == false){
|
208 |
-
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
209 |
-
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
210 |
-
$errorMsg = '';
|
211 |
-
foreach($fieldErrorsArr as $field => $fError){
|
212 |
-
$errorMsg .= "<br />";
|
213 |
-
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
214 |
-
}
|
215 |
-
//remove the last comma
|
216 |
-
$errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
|
217 |
-
return array('error' => $errorMsg);
|
218 |
-
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
219 |
-
return array('error' => $this->__($parsedResponseArr['globalError']));
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
-
return array('error'=> false, 'data' => ($parsedResponseArr['data']==true ? 1 : 0));
|
224 |
-
|
225 |
-
|
226 |
-
}catch(Exception $e){
|
227 |
-
//timeout or other unhandled exception was thrown
|
228 |
-
return array('error' => $this->__($e->getMessage()));
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* activate the CS bar
|
234 |
-
*
|
235 |
-
* @return array
|
236 |
-
*/
|
237 |
-
public function activate(){
|
238 |
-
$this->changeActiveState(1);
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* deactivate the CS bar
|
243 |
-
*
|
244 |
-
* @return array
|
245 |
-
*/
|
246 |
-
public function deactivate(){
|
247 |
-
$this->changeActiveState(0);
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* get commercesciences tag
|
252 |
-
*
|
253 |
-
* @return string
|
254 |
-
*/
|
255 |
-
public function getTag(){
|
256 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
257 |
-
if(!$csConfig){
|
258 |
-
return '';
|
259 |
-
}
|
260 |
-
return ($csConfig->getTag() ? $csConfig->getTag() : '');
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* check whether the bar is active
|
265 |
-
*
|
266 |
-
* @return array
|
267 |
-
*/
|
268 |
-
public function getActiveState(){
|
269 |
-
|
270 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
271 |
-
if(!$csConfig){
|
272 |
-
//we must be already at least on step 1, so the DB record has to exist
|
273 |
-
return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)"));
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
278 |
-
|
279 |
-
$httpClient = $RESTClient->getHttpClient();
|
280 |
-
$httpClient->setConfig(array(
|
281 |
-
"timeout" => 30
|
282 |
-
));
|
283 |
-
|
284 |
-
try{
|
285 |
-
$response = $RESTClient->restGet("/magento/getBarStatus", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
286 |
-
|
287 |
-
$responseJson = $response->getBody();
|
288 |
-
//dummy response
|
289 |
-
//$responseJson = '{"good":true,"data":"Hidden"}';
|
290 |
-
|
291 |
-
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
292 |
-
|
293 |
-
|
294 |
-
if(!isset($parsedResponseArr['good'])){
|
295 |
-
return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 006)"));
|
296 |
-
}
|
297 |
-
if($parsedResponseArr['good'] == false){
|
298 |
-
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
299 |
-
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
300 |
-
$errorMsg = '';
|
301 |
-
foreach($fieldErrorsArr as $field => $fError){
|
302 |
-
$errorMsg .= "<br />";
|
303 |
-
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
304 |
-
}
|
305 |
-
$errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
|
306 |
-
return array('error' => $errorMsg);
|
307 |
-
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
308 |
-
return array('error' =>$parsedResponseArr['globalError']);
|
309 |
-
}
|
310 |
-
}
|
311 |
-
return array('error'=> false, 'data' => $parsedResponseArr['data']);
|
312 |
-
}catch(Exception $e){
|
313 |
-
return array('error' => $this->__($e->getMessage()));
|
314 |
-
}
|
315 |
-
}
|
316 |
-
|
317 |
-
/*
|
318 |
-
* get a code of the first store in the magento installation
|
319 |
-
*/
|
320 |
-
public function getFirstStoreCode(){
|
321 |
-
if(!$this->_firstStore){
|
322 |
-
foreach (Mage::app()->getWebsites() as $website) {
|
323 |
-
foreach ($website->getGroups() as $group) {
|
324 |
-
$stores = $group->getStores();
|
325 |
-
foreach ($stores as $store) {
|
326 |
-
$this->_firstStore = $store->getCode();
|
327 |
-
break;
|
328 |
-
}
|
329 |
-
}
|
330 |
-
}
|
331 |
-
}
|
332 |
-
return $this->_firstStore;
|
333 |
-
}
|
334 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Commercesciences_Base_Helper_Data extends Mage_Core_Helper_Abstract{
|
4 |
+
|
5 |
+
const STEP_ZERO = 0;
|
6 |
+
const STEP_ONE = 1;
|
7 |
+
const STEP_TWO = 2;
|
8 |
+
|
9 |
+
const CONFIG_EMAIL = 'commercesciences/required_param/email';
|
10 |
+
const DEFAULT_MYSQL_TIMEOUT = 10;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* handles the errors
|
14 |
+
*/
|
15 |
+
public function handleError($error){
|
16 |
+
//Mage::log("Error:".$error, null, 'cs-error.log', true);
|
17 |
+
throw new Exception($error);
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* return the current step of the system
|
22 |
+
*
|
23 |
+
* @return int
|
24 |
+
*/
|
25 |
+
public function getStep(){
|
26 |
+
if(!$this->_step){
|
27 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
28 |
+
if(!$csConfig || !$csConfig->getId()){
|
29 |
+
$csConfig = Mage::getModel("commercesciences_base/config");
|
30 |
+
$csConfig->save();
|
31 |
+
}
|
32 |
+
if(!$csConfig->getUserId()){
|
33 |
+
$this->_step = Commercesciences_Base_Helper_Data::STEP_ZERO;
|
34 |
+
return $this->_step;
|
35 |
+
}
|
36 |
+
|
37 |
+
//we have userId its step 1 or 2
|
38 |
+
$aStateArr = $this->getActiveState();
|
39 |
+
if($aStateArr['error'] != false){
|
40 |
+
$this->handleError($aStateArr['error']);
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
if($aStateArr['data'] == 'NotConfigured'){
|
44 |
+
$this->_step = Commercesciences_Base_Helper_Data::STEP_ONE;
|
45 |
+
}elseif($aStateArr['data'] == 'Hidden' || $aStateArr['data'] == 'Visible'){
|
46 |
+
$this->_step = Commercesciences_Base_Helper_Data::STEP_TWO;
|
47 |
+
}else{
|
48 |
+
$error = $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)");
|
49 |
+
//Mage::log("Error:".$error, null, 'cs-error.log', true);
|
50 |
+
throw new Exception($error);
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->_step;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* converts the first layer of stdObject to array
|
60 |
+
* @param stdObject $stdObj
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function stdObject2Array($stdObj)
|
64 |
+
{
|
65 |
+
if (is_object($stdObj)){
|
66 |
+
$stdObj = get_object_vars($stdObj);
|
67 |
+
}
|
68 |
+
return $stdObj;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* register the email + domain on commercesciences
|
73 |
+
*
|
74 |
+
* @return array - format [error] => ''
|
75 |
+
*/
|
76 |
+
public function register($email, $storeUrl){
|
77 |
+
|
78 |
+
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
79 |
+
|
80 |
+
$httpClient = $RESTClient->getHttpClient();
|
81 |
+
$httpClient->setConfig(array(
|
82 |
+
"timeout" => 30
|
83 |
+
));
|
84 |
+
|
85 |
+
try {
|
86 |
+
|
87 |
+
//Mage::log("xxx", null, "debug6.log", true);
|
88 |
+
|
89 |
+
$timeBeforeApiCall = time();
|
90 |
+
|
91 |
+
$response = $RESTClient->restPost("/magento/registerPost", array('email' => $email, 'storeURL'=>$storeUrl));
|
92 |
+
$responseJson = $response->getBody();
|
93 |
+
|
94 |
+
$timeAfterApiCall = time();
|
95 |
+
//Mage::log("yyy-".$responseJson, null, "debug6.log", true);
|
96 |
+
//Mage::log("zzz-".($timeAfterApiCall-$timeBeforeApiCall), null, "debug6.log", true);
|
97 |
+
|
98 |
+
//fictive
|
99 |
+
//$responseJson = '{"good":true,"data":{"securityToken":"qfJpXFdiccH2LtAXy3U3mMZFRNiAbMsiGocKpk9RLarqda9001YYxXjYyQwy","userID":12296,"tag":"\u003c!-- CS Bar --\u003e\r\n\u003cscript type\u003d\u0027text/javascript\u0027\u003e\r\nvar script \u003d document.createElement(\u0027script\u0027);\r\nscript.type \u003d \u0027text/javascript\u0027;\r\nscript.src \u003d ((document.location.protocol \u003d\u003d \u0027https:\u0027) ? \u0027https://\u0027 : \u0027http://\u0027) +\r\n \u0027app.cdn-cs.com/b/4Udqvg/k9rip6/l/cs_all.js\u0027;\r\ndocument.getElementsByTagName(\u0027head\u0027)[0].appendChild(script);\r\n\u003c/script\u003e\r\n\u003c!-- end CS --\u003e\r\n"}}';
|
100 |
+
|
101 |
+
//Mage::log("response-".$responseJson, null, 'debug4.log', true);
|
102 |
+
|
103 |
+
//fictive response for testing
|
104 |
+
|
105 |
+
/*$parsedResponse = array(
|
106 |
+
'security_token' => 'abcdefghijklmnop',
|
107 |
+
'user_id' => '123456',
|
108 |
+
'tag' => '<script type="text/javascript">alert(\'Hello!\');</script>'
|
109 |
+
);
|
110 |
+
*/
|
111 |
+
|
112 |
+
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
113 |
+
if(!isset($parsedResponseArr['good'])){
|
114 |
+
//timeout occured
|
115 |
+
return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 003)"));
|
116 |
+
}
|
117 |
+
if($parsedResponseArr['good'] == false){
|
118 |
+
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
119 |
+
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
120 |
+
$errorMsg = '';
|
121 |
+
foreach($fieldErrorsArr as $field => $fError){
|
122 |
+
$errorMsg .= "<br />";
|
123 |
+
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
124 |
+
}
|
125 |
+
return array('error' => $errorMsg);
|
126 |
+
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
127 |
+
return array('error' => $this->__($parsedResponseArr['globalError']));
|
128 |
+
}
|
129 |
+
}
|
130 |
+
$parsedResponse = $this->stdObject2Array($parsedResponseArr['data']);
|
131 |
+
|
132 |
+
if(!isset($parsedResponse['securityToken']) || !$parsedResponse['securityToken']
|
133 |
+
|| !isset($parsedResponse['userID']) || !$parsedResponse['userID']
|
134 |
+
|| !isset($parsedResponse['tag']) || !$parsedResponse['tag']){
|
135 |
+
return $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 001)");
|
136 |
+
}
|
137 |
+
|
138 |
+
if($timeAfterApiCall-$timeBeforeApiCall > self::DEFAULT_MYSQL_TIMEOUT){
|
139 |
+
//Mage::log("ffff", null, "debug6.log", true);
|
140 |
+
|
141 |
+
//pobably mysql serer has gone away, save data in the session
|
142 |
+
|
143 |
+
$adminSession = Mage::getModel('customer/session');
|
144 |
+
$adminSession->setCsUserId($parsedResponse['userID']);
|
145 |
+
$adminSession->setCsSecurityToken($parsedResponse['securityToken']);
|
146 |
+
$adminSession->setCsTag($parsedResponse['tag']);
|
147 |
+
}else{
|
148 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
149 |
+
if(!$csConfig){
|
150 |
+
$csConfig = Mage::getModel("commercesciences_base/config");
|
151 |
+
}
|
152 |
+
$csConfig->setSecurityToken($parsedResponse['securityToken'])
|
153 |
+
->setUserId($parsedResponse['userID'])
|
154 |
+
->setTag($parsedResponse['tag'])
|
155 |
+
->save();
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
$message = '';
|
160 |
+
if(isset($parsedResponse['message']) && $parsedResponse['message']){
|
161 |
+
$message = $parsedResponse['message'];
|
162 |
+
}
|
163 |
+
|
164 |
+
return array('error' => false, 'message' => $message);
|
165 |
+
|
166 |
+
}catch(Exception $e){
|
167 |
+
//timeout or other unhandled exception was thrown
|
168 |
+
return array('error' => $this->__($e->getMessage()));
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Change the is_state of the bar
|
174 |
+
*
|
175 |
+
* @param int $changeTo
|
176 |
+
* @return array
|
177 |
+
*/
|
178 |
+
protected function changeActiveState($changeTo=1){
|
179 |
+
|
180 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
181 |
+
if(!$csConfig || !$csConfig->getUserId() || !$csConfig->getSecurityToken()){
|
182 |
+
//we must be already at least on step 1, so the DB record has to exist
|
183 |
+
return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 002)"));
|
184 |
+
}
|
185 |
+
|
186 |
+
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
187 |
+
|
188 |
+
$httpClient = $RESTClient->getHttpClient();
|
189 |
+
$httpClient->setConfig(array(
|
190 |
+
"timeout" => 30
|
191 |
+
));
|
192 |
+
|
193 |
+
try{
|
194 |
+
if($changeTo){
|
195 |
+
$response = $RESTClient->restPost("/magento/showBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
196 |
+
}else{
|
197 |
+
$response = $RESTClient->restPost("/magento/hideBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
198 |
+
}
|
199 |
+
|
200 |
+
$responseJson = $response->getBody();
|
201 |
+
//Mage::log("activation-response-".$responseJson, null, 'debug4.log', true);
|
202 |
+
|
203 |
+
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
204 |
+
if(!isset($parsedResponseArr['good'])){
|
205 |
+
return $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 004)");
|
206 |
+
}
|
207 |
+
if($parsedResponseArr['good'] == false){
|
208 |
+
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
209 |
+
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
210 |
+
$errorMsg = '';
|
211 |
+
foreach($fieldErrorsArr as $field => $fError){
|
212 |
+
$errorMsg .= "<br />";
|
213 |
+
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
214 |
+
}
|
215 |
+
//remove the last comma
|
216 |
+
$errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
|
217 |
+
return array('error' => $errorMsg);
|
218 |
+
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
219 |
+
return array('error' => $this->__($parsedResponseArr['globalError']));
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
return array('error'=> false, 'data' => ($parsedResponseArr['data']==true ? 1 : 0));
|
224 |
+
|
225 |
+
|
226 |
+
}catch(Exception $e){
|
227 |
+
//timeout or other unhandled exception was thrown
|
228 |
+
return array('error' => $this->__($e->getMessage()));
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* activate the CS bar
|
234 |
+
*
|
235 |
+
* @return array
|
236 |
+
*/
|
237 |
+
public function activate(){
|
238 |
+
$this->changeActiveState(1);
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* deactivate the CS bar
|
243 |
+
*
|
244 |
+
* @return array
|
245 |
+
*/
|
246 |
+
public function deactivate(){
|
247 |
+
$this->changeActiveState(0);
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* get commercesciences tag
|
252 |
+
*
|
253 |
+
* @return string
|
254 |
+
*/
|
255 |
+
public function getTag(){
|
256 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
257 |
+
if(!$csConfig){
|
258 |
+
return '';
|
259 |
+
}
|
260 |
+
return ($csConfig->getTag() ? $csConfig->getTag() : '');
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* check whether the bar is active
|
265 |
+
*
|
266 |
+
* @return array
|
267 |
+
*/
|
268 |
+
public function getActiveState(){
|
269 |
+
|
270 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
271 |
+
if(!$csConfig){
|
272 |
+
//we must be already at least on step 1, so the DB record has to exist
|
273 |
+
return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)"));
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
$RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
|
278 |
+
|
279 |
+
$httpClient = $RESTClient->getHttpClient();
|
280 |
+
$httpClient->setConfig(array(
|
281 |
+
"timeout" => 30
|
282 |
+
));
|
283 |
+
|
284 |
+
try{
|
285 |
+
$response = $RESTClient->restGet("/magento/getBarStatus", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
|
286 |
+
|
287 |
+
$responseJson = $response->getBody();
|
288 |
+
//dummy response
|
289 |
+
//$responseJson = '{"good":true,"data":"Hidden"}';
|
290 |
+
|
291 |
+
$parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
|
292 |
+
|
293 |
+
|
294 |
+
if(!isset($parsedResponseArr['good'])){
|
295 |
+
return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 006)"));
|
296 |
+
}
|
297 |
+
if($parsedResponseArr['good'] == false){
|
298 |
+
if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
|
299 |
+
$fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
|
300 |
+
$errorMsg = '';
|
301 |
+
foreach($fieldErrorsArr as $field => $fError){
|
302 |
+
$errorMsg .= "<br />";
|
303 |
+
$errorMsg .= $this->__($field).": ".$this->__($fError);
|
304 |
+
}
|
305 |
+
$errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
|
306 |
+
return array('error' => $errorMsg);
|
307 |
+
}elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
|
308 |
+
return array('error' =>$parsedResponseArr['globalError']);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
return array('error'=> false, 'data' => $parsedResponseArr['data']);
|
312 |
+
}catch(Exception $e){
|
313 |
+
return array('error' => $this->__($e->getMessage()));
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
/*
|
318 |
+
* get a code of the first store in the magento installation
|
319 |
+
*/
|
320 |
+
public function getFirstStoreCode(){
|
321 |
+
if(!$this->_firstStore){
|
322 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
323 |
+
foreach ($website->getGroups() as $group) {
|
324 |
+
$stores = $group->getStores();
|
325 |
+
foreach ($stores as $store) {
|
326 |
+
$this->_firstStore = $store->getCode();
|
327 |
+
break;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
return $this->_firstStore;
|
333 |
+
}
|
334 |
}
|
app/code/local/Commercesciences/Base/Model/Observer.php
CHANGED
@@ -1,168 +1,168 @@
|
|
1 |
-
<?php
|
2 |
-
class Commercesciences_Base_Model_Observer
|
3 |
-
{
|
4 |
-
private $_putcommercesciences = false;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* retrieve the module helper
|
8 |
-
* @return Commercesciences_Base_Helper_Data
|
9 |
-
*/
|
10 |
-
protected function getCsHelper(){
|
11 |
-
if(!$this->_csHelper){
|
12 |
-
$this->_csHelper = Mage::helper("commercesciences_base");
|
13 |
-
}
|
14 |
-
return $this->_csHelper;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* observer for the event core_block_abstract_to_html_after
|
19 |
-
* adds the tag of commercescience to the block html
|
20 |
-
*
|
21 |
-
* @param $observer
|
22 |
-
* @return mixed
|
23 |
-
*/
|
24 |
-
public function addCommercesciencesHtml($observer)
|
25 |
-
{
|
26 |
-
if($this->_putcommercesciences){
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
|
30 |
-
$request = Mage::app()->getRequest();
|
31 |
-
if(($request->getRouteName() == "adminhtml")){
|
32 |
-
return;
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$commercesciencesTag = Mage::helper("commercesciences_base")->getTag();
|
38 |
-
if(!$commercesciencesTag){
|
39 |
-
return;
|
40 |
-
}
|
41 |
-
|
42 |
-
$block = $observer->getBlock();
|
43 |
-
$transport = $observer->getTransport();
|
44 |
-
|
45 |
-
if($block->getNameInLayout() == "footer"){
|
46 |
-
$transportHTML = $transport->getHtml();
|
47 |
-
$transport->setHtml($transportHTML.$commercesciencesTag);
|
48 |
-
$this->_putcommercesciences = true;
|
49 |
-
return;
|
50 |
-
}
|
51 |
-
|
52 |
-
if($block->getNameInLayout() == "before_body_end"){
|
53 |
-
$transportHTML = $transport->getHtml();
|
54 |
-
$transport->setHtml($transportHTML.$commercesciencesTag);
|
55 |
-
$this->_putcommercesciences = true;
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
/**
|
63 |
-
* observer for event model_config_data_save_before:
|
64 |
-
* before the configurations are saved on the admin panel,
|
65 |
-
* perform the logic of the flow
|
66 |
-
*
|
67 |
-
* @param $observer
|
68 |
-
* @return void
|
69 |
-
*/
|
70 |
-
public function performStepLogic($observer){
|
71 |
-
$request = Mage::app()->getRequest();
|
72 |
-
$params = $request->getParams();
|
73 |
-
$savedConfigSection = $params['section'];
|
74 |
-
if($savedConfigSection != 'commercesciences'){
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$step = $this->getCsHelper()->getStep();
|
81 |
-
$csHelper = $this->getCsHelper();
|
82 |
-
|
83 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
84 |
-
if(!$csConfig || !$csConfig->getId()){
|
85 |
-
$csConfig = Mage::getModel("commercesciences_base/config");
|
86 |
-
$csConfig->save();
|
87 |
-
}
|
88 |
-
|
89 |
-
$firstStoreCode = $csHelper->getFirstStoreCode();
|
90 |
-
$storeUrl = Mage::app()->getStore($firstStoreCode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
91 |
-
|
92 |
-
if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
|
93 |
-
//check valid email
|
94 |
-
if(!isset($params['groups']['required_param']['fields']['email']['value'])
|
95 |
-
|| !trim($params['groups']['required_param']['fields']['email']['value'])){
|
96 |
-
$csHelper->handleError($csHelper->__('The email should not be empty'));
|
97 |
-
return;
|
98 |
-
}
|
99 |
-
$email = trim($params['groups']['required_param']['fields']['email']['value']);
|
100 |
-
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
|
101 |
-
if(!$email){
|
102 |
-
$csHelper->handleError($csHelper->__('The email %s is not valid', $email));
|
103 |
-
return;
|
104 |
-
}
|
105 |
-
|
106 |
-
//register
|
107 |
-
$result = $csHelper->register($email, $storeUrl);
|
108 |
-
if($result['error']){
|
109 |
-
$csHelper->handleError($result['error']);
|
110 |
-
return;
|
111 |
-
}
|
112 |
-
|
113 |
-
if($result['message']){
|
114 |
-
//Mage::log("ffff-".$result['message'], null, "debug6.log", true);
|
115 |
-
Mage::getSingleton('adminhtml/session')->addNotice($result['message']);
|
116 |
-
}
|
117 |
-
|
118 |
-
//customer registered - clear the cache
|
119 |
-
Mage::app()->cleanCache();
|
120 |
-
}
|
121 |
-
|
122 |
-
if($step == Commercesciences_Base_Helper_Data::STEP_ONE
|
123 |
-
|| $step == Commercesciences_Base_Helper_Data::STEP_TWO){
|
124 |
-
if(!isset($params['groups']['required_param']['fields']['is_active']['value'])){
|
125 |
-
return;
|
126 |
-
}
|
127 |
-
$newIsActiveConfig = $params['groups']['required_param']['fields']['is_active']['value'];
|
128 |
-
|
129 |
-
|
130 |
-
if($newIsActiveConfig==0){
|
131 |
-
$csHelper->deactivate();
|
132 |
-
}else{
|
133 |
-
$csHelper->activate();
|
134 |
-
}
|
135 |
-
}
|
136 |
-
return;
|
137 |
-
}
|
138 |
-
|
139 |
-
public function beforeTabLoaded($observer){
|
140 |
-
$controller_action = $observer->getControllerAction();
|
141 |
-
$request = $controller_action->getRequest();
|
142 |
-
if($controller_action->getFullActionName() == "adminhtml_system_config_edit"){
|
143 |
-
if($request->getParam('section') == 'commercesciences'){
|
144 |
-
$adminSession = Mage::getModel('customer/session');
|
145 |
-
//Mage::log("vvvv", null, "debug6.log", true);
|
146 |
-
if($adminSession->getCsUserId()
|
147 |
-
&& $adminSession->getCsSecurityToken()
|
148 |
-
&& $adminSession->getCsTag()){
|
149 |
-
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
150 |
-
if(!$csConfig || !$csConfig->getId()){
|
151 |
-
$csConfig = Mage::getModel("commercesciences_base/config");
|
152 |
-
}
|
153 |
-
$csConfig->setUserId($adminSession->getCsUserId());
|
154 |
-
$csConfig->setSecurityToken($adminSession->getCsSecurityToken());
|
155 |
-
$csConfig->setTag($adminSession->getCsTag());
|
156 |
-
$csConfig->save();
|
157 |
-
|
158 |
-
$adminSession->unsetData("cs_user_id");
|
159 |
-
$adminSession->unsetData("cs_security_token");
|
160 |
-
$adminSession->unsetData("cs_tag");
|
161 |
-
|
162 |
-
//Mage::log("ppp-".$csConfig->getUserId(), null, "debug6.log", true);
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
}
|
1 |
+
<?php
|
2 |
+
class Commercesciences_Base_Model_Observer
|
3 |
+
{
|
4 |
+
private $_putcommercesciences = false;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* retrieve the module helper
|
8 |
+
* @return Commercesciences_Base_Helper_Data
|
9 |
+
*/
|
10 |
+
protected function getCsHelper(){
|
11 |
+
if(!$this->_csHelper){
|
12 |
+
$this->_csHelper = Mage::helper("commercesciences_base");
|
13 |
+
}
|
14 |
+
return $this->_csHelper;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* observer for the event core_block_abstract_to_html_after
|
19 |
+
* adds the tag of commercescience to the block html
|
20 |
+
*
|
21 |
+
* @param $observer
|
22 |
+
* @return mixed
|
23 |
+
*/
|
24 |
+
public function addCommercesciencesHtml($observer)
|
25 |
+
{
|
26 |
+
if($this->_putcommercesciences){
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
$request = Mage::app()->getRequest();
|
31 |
+
if(($request->getRouteName() == "adminhtml")){
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
$commercesciencesTag = Mage::helper("commercesciences_base")->getTag();
|
38 |
+
if(!$commercesciencesTag){
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
|
42 |
+
$block = $observer->getBlock();
|
43 |
+
$transport = $observer->getTransport();
|
44 |
+
|
45 |
+
if($block->getNameInLayout() == "footer"){
|
46 |
+
$transportHTML = $transport->getHtml();
|
47 |
+
$transport->setHtml($transportHTML.$commercesciencesTag);
|
48 |
+
$this->_putcommercesciences = true;
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
|
52 |
+
if($block->getNameInLayout() == "before_body_end"){
|
53 |
+
$transportHTML = $transport->getHtml();
|
54 |
+
$transport->setHtml($transportHTML.$commercesciencesTag);
|
55 |
+
$this->_putcommercesciences = true;
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* observer for event model_config_data_save_before:
|
64 |
+
* before the configurations are saved on the admin panel,
|
65 |
+
* perform the logic of the flow
|
66 |
+
*
|
67 |
+
* @param $observer
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
public function performStepLogic($observer){
|
71 |
+
$request = Mage::app()->getRequest();
|
72 |
+
$params = $request->getParams();
|
73 |
+
$savedConfigSection = $params['section'];
|
74 |
+
if($savedConfigSection != 'commercesciences'){
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
$step = $this->getCsHelper()->getStep();
|
81 |
+
$csHelper = $this->getCsHelper();
|
82 |
+
|
83 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
84 |
+
if(!$csConfig || !$csConfig->getId()){
|
85 |
+
$csConfig = Mage::getModel("commercesciences_base/config");
|
86 |
+
$csConfig->save();
|
87 |
+
}
|
88 |
+
|
89 |
+
$firstStoreCode = $csHelper->getFirstStoreCode();
|
90 |
+
$storeUrl = Mage::app()->getStore($firstStoreCode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
91 |
+
|
92 |
+
if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
|
93 |
+
//check valid email
|
94 |
+
if(!isset($params['groups']['required_param']['fields']['email']['value'])
|
95 |
+
|| !trim($params['groups']['required_param']['fields']['email']['value'])){
|
96 |
+
$csHelper->handleError($csHelper->__('The email should not be empty'));
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
$email = trim($params['groups']['required_param']['fields']['email']['value']);
|
100 |
+
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
|
101 |
+
if(!$email){
|
102 |
+
$csHelper->handleError($csHelper->__('The email %s is not valid', $email));
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
//register
|
107 |
+
$result = $csHelper->register($email, $storeUrl);
|
108 |
+
if($result['error']){
|
109 |
+
$csHelper->handleError($result['error']);
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
if($result['message']){
|
114 |
+
//Mage::log("ffff-".$result['message'], null, "debug6.log", true);
|
115 |
+
Mage::getSingleton('adminhtml/session')->addNotice($result['message']);
|
116 |
+
}
|
117 |
+
|
118 |
+
//customer registered - clear the cache
|
119 |
+
Mage::app()->cleanCache();
|
120 |
+
}
|
121 |
+
|
122 |
+
if($step == Commercesciences_Base_Helper_Data::STEP_ONE
|
123 |
+
|| $step == Commercesciences_Base_Helper_Data::STEP_TWO){
|
124 |
+
if(!isset($params['groups']['required_param']['fields']['is_active']['value'])){
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
$newIsActiveConfig = $params['groups']['required_param']['fields']['is_active']['value'];
|
128 |
+
|
129 |
+
|
130 |
+
if($newIsActiveConfig==0){
|
131 |
+
$csHelper->deactivate();
|
132 |
+
}else{
|
133 |
+
$csHelper->activate();
|
134 |
+
}
|
135 |
+
}
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
+
public function beforeTabLoaded($observer){
|
140 |
+
$controller_action = $observer->getControllerAction();
|
141 |
+
$request = $controller_action->getRequest();
|
142 |
+
if($controller_action->getFullActionName() == "adminhtml_system_config_edit"){
|
143 |
+
if($request->getParam('section') == 'commercesciences'){
|
144 |
+
$adminSession = Mage::getModel('customer/session');
|
145 |
+
//Mage::log("vvvv", null, "debug6.log", true);
|
146 |
+
if($adminSession->getCsUserId()
|
147 |
+
&& $adminSession->getCsSecurityToken()
|
148 |
+
&& $adminSession->getCsTag()){
|
149 |
+
$csConfig = Mage::getModel("commercesciences_base/config")->load("1");
|
150 |
+
if(!$csConfig || !$csConfig->getId()){
|
151 |
+
$csConfig = Mage::getModel("commercesciences_base/config");
|
152 |
+
}
|
153 |
+
$csConfig->setUserId($adminSession->getCsUserId());
|
154 |
+
$csConfig->setSecurityToken($adminSession->getCsSecurityToken());
|
155 |
+
$csConfig->setTag($adminSession->getCsTag());
|
156 |
+
$csConfig->save();
|
157 |
+
|
158 |
+
$adminSession->unsetData("cs_user_id");
|
159 |
+
$adminSession->unsetData("cs_security_token");
|
160 |
+
$adminSession->unsetData("cs_tag");
|
161 |
+
|
162 |
+
//Mage::log("ppp-".$csConfig->getUserId(), null, "debug6.log", true);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
}
|
app/code/local/Commercesciences/Base/etc/config.xml
CHANGED
@@ -1,130 +1,130 @@
|
|
1 |
-
<config>
|
2 |
-
<modules>
|
3 |
-
<Commercesciences_Base>
|
4 |
-
<version>1.0.6</version>
|
5 |
-
</Commercesciences_Base>
|
6 |
-
</modules>
|
7 |
-
<frontend>
|
8 |
-
<routers>
|
9 |
-
<commercesciences_base>
|
10 |
-
<use>standard</use>
|
11 |
-
<args>
|
12 |
-
<module>Commercesciences_Base</module>
|
13 |
-
<frontName>commercesciences</frontName>
|
14 |
-
</args>
|
15 |
-
</commercesciences_base>
|
16 |
-
</routers>
|
17 |
-
</frontend>
|
18 |
-
<global>
|
19 |
-
<events>
|
20 |
-
<core_block_abstract_to_html_after>
|
21 |
-
<observers>
|
22 |
-
<commercesciences_core_block_abstract_to_html_after>
|
23 |
-
<type>singleton</type>
|
24 |
-
<class>Commercesciences_Base_Model_Observer</class>
|
25 |
-
<method>addCommercesciencesHtml</method>
|
26 |
-
</commercesciences_core_block_abstract_to_html_after>
|
27 |
-
</observers>
|
28 |
-
</core_block_abstract_to_html_after>
|
29 |
-
<core_config_data_save_before>
|
30 |
-
<observers>
|
31 |
-
<commercesciences_admin_system_config_changed_section_commercesciences>
|
32 |
-
<type>singleton</type>
|
33 |
-
<class>Commercesciences_Base_Model_Observer</class>
|
34 |
-
<method>performStepLogic</method>
|
35 |
-
</commercesciences_admin_system_config_changed_section_commercesciences>
|
36 |
-
</observers>
|
37 |
-
</core_config_data_save_before>
|
38 |
-
<controller_action_predispatch_adminhtml_system_config_edit>
|
39 |
-
<observers>
|
40 |
-
<commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
|
41 |
-
<type>singleton</type>
|
42 |
-
<class>Commercesciences_Base_Model_Observer</class>
|
43 |
-
<method>beforeTabLoaded</method>
|
44 |
-
</commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
|
45 |
-
</observers>
|
46 |
-
</controller_action_predispatch_adminhtml_system_config_edit>
|
47 |
-
</events>
|
48 |
-
<helpers>
|
49 |
-
<commercesciences_base>
|
50 |
-
<class>Commercesciences_Base_Helper</class>
|
51 |
-
</commercesciences_base>
|
52 |
-
</helpers>
|
53 |
-
<blocks>
|
54 |
-
<commercesciences_base>
|
55 |
-
<class>Commercesciences_Base_Block</class>
|
56 |
-
</commercesciences_base>
|
57 |
-
</blocks>
|
58 |
-
<models>
|
59 |
-
<commercesciences_base>
|
60 |
-
<class>Commercesciences_Base_Model</class>
|
61 |
-
<resourceModel>commercesciences_base_mysql4</resourceModel>
|
62 |
-
</commercesciences_base>
|
63 |
-
<commercesciences_base_mysql4>
|
64 |
-
<class>Commercesciences_Base_Model_Mysql4</class>
|
65 |
-
<entities>
|
66 |
-
<config>
|
67 |
-
<table>commercesciences_base_config</table>
|
68 |
-
</config>
|
69 |
-
</entities>
|
70 |
-
</commercesciences_base_mysql4>
|
71 |
-
</models>
|
72 |
-
<resources>
|
73 |
-
<commercesciences_base_setup>
|
74 |
-
<setup>
|
75 |
-
<module>Commercesciences_Base</module>
|
76 |
-
<class>Commercesciences_Base_Model_Resource_Setup</class>
|
77 |
-
</setup>
|
78 |
-
</commercesciences_base_setup>
|
79 |
-
</resources>
|
80 |
-
</global>
|
81 |
-
<default>
|
82 |
-
<commercesciences>
|
83 |
-
<required_param>
|
84 |
-
<is_active>1</is_active>
|
85 |
-
</required_param>
|
86 |
-
</commercesciences>
|
87 |
-
</default>
|
88 |
-
<admin>
|
89 |
-
<routers>
|
90 |
-
<commercesciences>
|
91 |
-
<use>admin</use>
|
92 |
-
<args>
|
93 |
-
<module>Commercesciences_Base</module>
|
94 |
-
<frontName>commercesciences</frontName>
|
95 |
-
</args>
|
96 |
-
</commercesciences>
|
97 |
-
</routers>
|
98 |
-
</admin>
|
99 |
-
<adminhtml>
|
100 |
-
<layout>
|
101 |
-
<updates>
|
102 |
-
<commercesciences>
|
103 |
-
<file>commercesciences.xml</file>
|
104 |
-
</commercesciences>
|
105 |
-
</updates>
|
106 |
-
</layout>
|
107 |
-
<acl>
|
108 |
-
<resources>
|
109 |
-
<all>
|
110 |
-
<title>Allow Everything</title>
|
111 |
-
</all>
|
112 |
-
<admin>
|
113 |
-
<children>
|
114 |
-
<system>
|
115 |
-
<children>
|
116 |
-
<config>
|
117 |
-
<children>
|
118 |
-
<commercesciences>
|
119 |
-
<title>CommerceSciences</title>
|
120 |
-
</commercesciences>
|
121 |
-
</children>
|
122 |
-
</config>
|
123 |
-
</children>
|
124 |
-
</system>
|
125 |
-
</children>
|
126 |
-
</admin>
|
127 |
-
</resources>
|
128 |
-
</acl>
|
129 |
-
</adminhtml>
|
130 |
</config>
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Commercesciences_Base>
|
4 |
+
<version>1.0.6</version>
|
5 |
+
</Commercesciences_Base>
|
6 |
+
</modules>
|
7 |
+
<frontend>
|
8 |
+
<routers>
|
9 |
+
<commercesciences_base>
|
10 |
+
<use>standard</use>
|
11 |
+
<args>
|
12 |
+
<module>Commercesciences_Base</module>
|
13 |
+
<frontName>commercesciences</frontName>
|
14 |
+
</args>
|
15 |
+
</commercesciences_base>
|
16 |
+
</routers>
|
17 |
+
</frontend>
|
18 |
+
<global>
|
19 |
+
<events>
|
20 |
+
<core_block_abstract_to_html_after>
|
21 |
+
<observers>
|
22 |
+
<commercesciences_core_block_abstract_to_html_after>
|
23 |
+
<type>singleton</type>
|
24 |
+
<class>Commercesciences_Base_Model_Observer</class>
|
25 |
+
<method>addCommercesciencesHtml</method>
|
26 |
+
</commercesciences_core_block_abstract_to_html_after>
|
27 |
+
</observers>
|
28 |
+
</core_block_abstract_to_html_after>
|
29 |
+
<core_config_data_save_before>
|
30 |
+
<observers>
|
31 |
+
<commercesciences_admin_system_config_changed_section_commercesciences>
|
32 |
+
<type>singleton</type>
|
33 |
+
<class>Commercesciences_Base_Model_Observer</class>
|
34 |
+
<method>performStepLogic</method>
|
35 |
+
</commercesciences_admin_system_config_changed_section_commercesciences>
|
36 |
+
</observers>
|
37 |
+
</core_config_data_save_before>
|
38 |
+
<controller_action_predispatch_adminhtml_system_config_edit>
|
39 |
+
<observers>
|
40 |
+
<commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
|
41 |
+
<type>singleton</type>
|
42 |
+
<class>Commercesciences_Base_Model_Observer</class>
|
43 |
+
<method>beforeTabLoaded</method>
|
44 |
+
</commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
|
45 |
+
</observers>
|
46 |
+
</controller_action_predispatch_adminhtml_system_config_edit>
|
47 |
+
</events>
|
48 |
+
<helpers>
|
49 |
+
<commercesciences_base>
|
50 |
+
<class>Commercesciences_Base_Helper</class>
|
51 |
+
</commercesciences_base>
|
52 |
+
</helpers>
|
53 |
+
<blocks>
|
54 |
+
<commercesciences_base>
|
55 |
+
<class>Commercesciences_Base_Block</class>
|
56 |
+
</commercesciences_base>
|
57 |
+
</blocks>
|
58 |
+
<models>
|
59 |
+
<commercesciences_base>
|
60 |
+
<class>Commercesciences_Base_Model</class>
|
61 |
+
<resourceModel>commercesciences_base_mysql4</resourceModel>
|
62 |
+
</commercesciences_base>
|
63 |
+
<commercesciences_base_mysql4>
|
64 |
+
<class>Commercesciences_Base_Model_Mysql4</class>
|
65 |
+
<entities>
|
66 |
+
<config>
|
67 |
+
<table>commercesciences_base_config</table>
|
68 |
+
</config>
|
69 |
+
</entities>
|
70 |
+
</commercesciences_base_mysql4>
|
71 |
+
</models>
|
72 |
+
<resources>
|
73 |
+
<commercesciences_base_setup>
|
74 |
+
<setup>
|
75 |
+
<module>Commercesciences_Base</module>
|
76 |
+
<class>Commercesciences_Base_Model_Resource_Setup</class>
|
77 |
+
</setup>
|
78 |
+
</commercesciences_base_setup>
|
79 |
+
</resources>
|
80 |
+
</global>
|
81 |
+
<default>
|
82 |
+
<commercesciences>
|
83 |
+
<required_param>
|
84 |
+
<is_active>1</is_active>
|
85 |
+
</required_param>
|
86 |
+
</commercesciences>
|
87 |
+
</default>
|
88 |
+
<admin>
|
89 |
+
<routers>
|
90 |
+
<commercesciences>
|
91 |
+
<use>admin</use>
|
92 |
+
<args>
|
93 |
+
<module>Commercesciences_Base</module>
|
94 |
+
<frontName>commercesciences</frontName>
|
95 |
+
</args>
|
96 |
+
</commercesciences>
|
97 |
+
</routers>
|
98 |
+
</admin>
|
99 |
+
<adminhtml>
|
100 |
+
<layout>
|
101 |
+
<updates>
|
102 |
+
<commercesciences>
|
103 |
+
<file>commercesciences.xml</file>
|
104 |
+
</commercesciences>
|
105 |
+
</updates>
|
106 |
+
</layout>
|
107 |
+
<acl>
|
108 |
+
<resources>
|
109 |
+
<all>
|
110 |
+
<title>Allow Everything</title>
|
111 |
+
</all>
|
112 |
+
<admin>
|
113 |
+
<children>
|
114 |
+
<system>
|
115 |
+
<children>
|
116 |
+
<config>
|
117 |
+
<children>
|
118 |
+
<commercesciences>
|
119 |
+
<title>CommerceSciences</title>
|
120 |
+
</commercesciences>
|
121 |
+
</children>
|
122 |
+
</config>
|
123 |
+
</children>
|
124 |
+
</system>
|
125 |
+
</children>
|
126 |
+
</admin>
|
127 |
+
</resources>
|
128 |
+
</acl>
|
129 |
+
</adminhtml>
|
130 |
</config>
|
app/code/local/Commercesciences/Base/etc/system.xml
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<config>
|
2 |
-
<tabs>
|
3 |
-
<commercesciences>
|
4 |
-
<label>Personal Bar</label>
|
5 |
-
<sort_order>800</sort_order>
|
6 |
-
</commercesciences>
|
7 |
-
</tabs>
|
8 |
-
<sections>
|
9 |
-
<commercesciences>
|
10 |
-
<class>separator-top</class>
|
11 |
-
<label><![CDATA[<span class="stadmin-csconfig_menu">Personal Bar Configuration</span>]]></label>
|
12 |
-
<tab>commercesciences</tab>
|
13 |
-
<frontend_type>text</frontend_type>
|
14 |
-
<sort_order>10</sort_order>
|
15 |
-
<show_in_default>1</show_in_default>
|
16 |
-
<show_in_website>1</show_in_website>
|
17 |
-
<show_in_store>1</show_in_store>
|
18 |
-
<groups>
|
19 |
-
<required_param>
|
20 |
-
<label>Personal Bar</label>
|
21 |
-
<frontend_type>text</frontend_type>
|
22 |
-
<sort_order>10</sort_order>
|
23 |
-
<show_in_default>1</show_in_default>
|
24 |
-
<show_in_website>1</show_in_website>
|
25 |
-
<show_in_store>1</show_in_store>
|
26 |
-
<expanded>1</expanded>
|
27 |
-
<fields>
|
28 |
-
<email>
|
29 |
-
<label></label>
|
30 |
-
<comment></comment>
|
31 |
-
<frontend_type>text</frontend_type>
|
32 |
-
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_campaignid</frontend_model>
|
33 |
-
<sort_order>0</sort_order>
|
34 |
-
<show_in_default>1</show_in_default>
|
35 |
-
<show_in_website>1</show_in_website>
|
36 |
-
<show_in_store>1</show_in_store>
|
37 |
-
</email>
|
38 |
-
<is_active>
|
39 |
-
<label>Is Active?</label>
|
40 |
-
<comment>[Activate/Deactivate CommerceSciences bar]</comment>
|
41 |
-
<frontend_type>select</frontend_type>
|
42 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
43 |
-
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_isactive</frontend_model>
|
44 |
-
<sort_order>1</sort_order>
|
45 |
-
<show_in_default>1</show_in_default>
|
46 |
-
<show_in_website>1</show_in_website>
|
47 |
-
<show_in_store>1</show_in_store>
|
48 |
-
</is_active>
|
49 |
-
</fields>
|
50 |
-
</required_param>
|
51 |
-
<about_the_bar>
|
52 |
-
<label>About the Personal Bar</label>
|
53 |
-
<frontend_type>text</frontend_type>
|
54 |
-
<sort_order>20</sort_order>
|
55 |
-
<show_in_default>1</show_in_default>
|
56 |
-
<show_in_website>1</show_in_website>
|
57 |
-
<show_in_store>1</show_in_store>
|
58 |
-
<expanded>1</expanded>
|
59 |
-
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_group_about</frontend_model>
|
60 |
-
<fields>
|
61 |
-
<email>
|
62 |
-
<label></label>
|
63 |
-
<comment></comment>
|
64 |
-
<frontend_type>text</frontend_type>
|
65 |
-
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_about</frontend_model>
|
66 |
-
<sort_order>0</sort_order>
|
67 |
-
<show_in_default>1</show_in_default>
|
68 |
-
<show_in_website>1</show_in_website>
|
69 |
-
<show_in_store>1</show_in_store>
|
70 |
-
</email>
|
71 |
-
</fields>
|
72 |
-
</about_the_bar>
|
73 |
-
</groups>
|
74 |
-
</commercesciences>
|
75 |
-
</sections>
|
76 |
</config>
|
1 |
+
<config>
|
2 |
+
<tabs>
|
3 |
+
<commercesciences>
|
4 |
+
<label>Personal Bar</label>
|
5 |
+
<sort_order>800</sort_order>
|
6 |
+
</commercesciences>
|
7 |
+
</tabs>
|
8 |
+
<sections>
|
9 |
+
<commercesciences>
|
10 |
+
<class>separator-top</class>
|
11 |
+
<label><![CDATA[<span class="stadmin-csconfig_menu">Personal Bar Configuration</span>]]></label>
|
12 |
+
<tab>commercesciences</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>10</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<required_param>
|
20 |
+
<label>Personal Bar</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>10</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<expanded>1</expanded>
|
27 |
+
<fields>
|
28 |
+
<email>
|
29 |
+
<label></label>
|
30 |
+
<comment></comment>
|
31 |
+
<frontend_type>text</frontend_type>
|
32 |
+
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_campaignid</frontend_model>
|
33 |
+
<sort_order>0</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</email>
|
38 |
+
<is_active>
|
39 |
+
<label>Is Active?</label>
|
40 |
+
<comment>[Activate/Deactivate CommerceSciences bar]</comment>
|
41 |
+
<frontend_type>select</frontend_type>
|
42 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
43 |
+
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_isactive</frontend_model>
|
44 |
+
<sort_order>1</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
</is_active>
|
49 |
+
</fields>
|
50 |
+
</required_param>
|
51 |
+
<about_the_bar>
|
52 |
+
<label>About the Personal Bar</label>
|
53 |
+
<frontend_type>text</frontend_type>
|
54 |
+
<sort_order>20</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
<expanded>1</expanded>
|
59 |
+
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_group_about</frontend_model>
|
60 |
+
<fields>
|
61 |
+
<email>
|
62 |
+
<label></label>
|
63 |
+
<comment></comment>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<frontend_model>commercesciences_base/adminhtml_config_form_renderer_about</frontend_model>
|
66 |
+
<sort_order>0</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>1</show_in_store>
|
70 |
+
</email>
|
71 |
+
</fields>
|
72 |
+
</about_the_bar>
|
73 |
+
</groups>
|
74 |
+
</commercesciences>
|
75 |
+
</sections>
|
76 |
</config>
|
app/etc/modules/Commercesciences_Base.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<config>
|
2 |
-
<modules>
|
3 |
-
<Commercesciences_Base>
|
4 |
-
<active>true</active>
|
5 |
-
<codePool>local</codePool>
|
6 |
-
</Commercesciences_Base>
|
7 |
-
</modules>
|
8 |
</config>
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Commercesciences_Base>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
</Commercesciences_Base>
|
7 |
+
</modules>
|
8 |
</config>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>commercesciences</name>
|
4 |
-
<version>0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>CSciences</name><user>auto-converted</user><email>avivr@commercesciences.com</email></author></authors>
|
13 |
<date>2012-10-31</date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>commercesciences</name>
|
4 |
+
<version>0.0.10</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>CommerceSciences1501</summary>
|
10 |
+
<description>CommerceSciences1501</description>
|
11 |
+
<notes>0.0.10</notes>
|
12 |
<authors><author><name>CSciences</name><user>auto-converted</user><email>avivr@commercesciences.com</email></author></authors>
|
13 |
<date>2012-10-31</date>
|
14 |
+
<time>20:39:02</time>
|
15 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="Commercesciences"><dir name="Base"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Renderer"><dir name="Group"><file name="About.php" hash="a16457268fe17d002e171059bae3c34f"/></dir><file name="About.php" hash="52d990b5450282c887f14c88e0bf143c"/><file name="Campaignid.php" hash="9b7e4d295f8f80a10df946e88de23e24"/><file name="Isactive.php" hash="2a25355d0f457f28a413d6a87ab45d2a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="219434a1266a281a2368f4a181e2f565"/></dir><dir name="Model"><dir name="Mysql4"><file name="Config.php" hash="4d66326f7313bbdf67ca8c16ed34e87d"/></dir><dir name="Resource"><file name="Setup.php" hash="fb19aa68ae9c60f3869247ca109904a4"/></dir><file name="Config.php" hash="5db637f6c8a9ed31c113dde29d87e9de"/><file name="Observer.php" hash="151cd8d802d14ae78c27b0c58588a5ff"/></dir><dir name="etc"><file name="config.xml" hash="9354c6d80e935edcfa1fea8e998411be"/><file name="system.xml" hash="7bd5559f2911cf82fc30a7c4a1cd8ca4"/></dir><dir name="sql"><dir name="commercesciences_base_setup"><file name="mysql4-install-0.0.1.php" hash="e7c5c8bd79dcd828c28daae5ee449ae0"/><file name="mysql4-upgrade-0.0.1-1.0.6.php" hash="e7c5c8bd79dcd828c28daae5ee449ae0"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Commercesciences_Base.xml" hash="3223d3e6acdeac74abe8b6f10d899522"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="commercesciences.xml" hash="85100232edb979c031e05c3977664781"/></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="commercesciences"><dir name="css"><file name="skin.css" hash="c958b0e9585f80e07311f994dc35d438"/></dir><dir name="images"><file name="CS-Logo-innerpage.png" hash="450dc4a05822cba236a3400bfa1535f7"/><file name="icons-boxed.png" hash="703749e7a6dd991cffc3767244f14887"/><file name="intro-img.png" hash="20f4193fef90371b49379e6df1e8d523"/><file name="setup-takes-2-minutes.png" hash="9b69dde5ccc771e6910adb3a153cf591"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
skin/adminhtml/default/default/commercesciences/css/skin.css
CHANGED
@@ -23,8 +23,7 @@
|
|
23 |
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
.csexp2, .csexp3, .csexp4{
|
28 |
width: 500px;
|
29 |
margin: 20px 0 0;
|
30 |
}
|
@@ -33,10 +32,6 @@
|
|
33 |
}
|
34 |
.csexp3{
|
35 |
height: 75px;
|
36 |
-
margin-top: 3px;
|
37 |
-
}
|
38 |
-
.csexp4{
|
39 |
-
|
40 |
}
|
41 |
.csexp2_left, .csexp3_left, .csexp12_left, .csexp24_left{
|
42 |
float: left;
|
@@ -137,18 +132,40 @@
|
|
137 |
color: #0064cd;
|
138 |
text-decoration: underline;
|
139 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
[class*="cs_span"] {
|
141 |
float: left;
|
142 |
margin-left: 20px;
|
143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
.cs_row {
|
145 |
margin-left: -20px;
|
146 |
*zoom: 1;
|
147 |
*zoom: 1;
|
148 |
}
|
149 |
-
.cs_row h3 {
|
150 |
-
font-weight: normal;
|
151 |
-
}
|
152 |
.cs_row:before,
|
153 |
.cs_row:after {
|
154 |
display: table;
|
@@ -160,6 +177,9 @@
|
|
160 |
.cs_container {
|
161 |
width: 940px;
|
162 |
}
|
|
|
|
|
|
|
163 |
.cs_span10 {
|
164 |
width: 780px;
|
165 |
}
|
23 |
|
24 |
}
|
25 |
|
26 |
+
.csexp2, .csexp3{
|
|
|
27 |
width: 500px;
|
28 |
margin: 20px 0 0;
|
29 |
}
|
32 |
}
|
33 |
.csexp3{
|
34 |
height: 75px;
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
.csexp2_left, .csexp3_left, .csexp12_left, .csexp24_left{
|
37 |
float: left;
|
132 |
color: #0064cd;
|
133 |
text-decoration: underline;
|
134 |
}
|
135 |
+
.cs_row {
|
136 |
+
margin-left: -20px;
|
137 |
+
*zoom: 1;
|
138 |
+
*zoom: 1;
|
139 |
+
}
|
140 |
+
.cs_row:before,
|
141 |
+
.cs_row:after {
|
142 |
+
display: table;
|
143 |
+
content: "";
|
144 |
+
}
|
145 |
+
.cs_row:after {
|
146 |
+
clear: both;
|
147 |
+
}
|
148 |
[class*="cs_span"] {
|
149 |
float: left;
|
150 |
margin-left: 20px;
|
151 |
}
|
152 |
+
.cs_container {
|
153 |
+
width: 940px;
|
154 |
+
}
|
155 |
+
.cs_span12 {
|
156 |
+
width: 940px;
|
157 |
+
}
|
158 |
+
.cs_span10 {
|
159 |
+
width: 780px;
|
160 |
+
}
|
161 |
+
.cs_span2 {
|
162 |
+
width: 140px;
|
163 |
+
}
|
164 |
.cs_row {
|
165 |
margin-left: -20px;
|
166 |
*zoom: 1;
|
167 |
*zoom: 1;
|
168 |
}
|
|
|
|
|
|
|
169 |
.cs_row:before,
|
170 |
.cs_row:after {
|
171 |
display: table;
|
177 |
.cs_container {
|
178 |
width: 940px;
|
179 |
}
|
180 |
+
.cs_span12 {
|
181 |
+
width: 940px;
|
182 |
+
}
|
183 |
.cs_span10 {
|
184 |
width: 780px;
|
185 |
}
|