Jira_MageBridge - Version 1.0.2

Version Notes

This PEAR package can only be distributed with a valid MageBridge license.

Download this release

Release Info

Developer Magento Core Team
Extension Jira_MageBridge
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.2.1154 to 1.0.2

Files changed (49) hide show
  1. app/code/community/Jira/MageBridge/Block/License.php +1 -14
  2. app/code/community/Jira/MageBridge/Block/Menu.php +4 -4
  3. app/code/community/Jira/MageBridge/Block/Settings.php +33 -64
  4. app/code/community/Jira/MageBridge/Block/Settings/Events.php +0 -38
  5. app/code/community/Jira/MageBridge/Block/Settings/Joomla.php +0 -46
  6. app/code/community/Jira/MageBridge/Block/Settings/Other.php +0 -30
  7. app/code/community/Jira/MageBridge/Block/Updates.php +1 -1
  8. app/code/community/Jira/MageBridge/Helper/Data.php +0 -36
  9. app/code/community/Jira/MageBridge/Model/Api.php +0 -57
  10. app/code/community/Jira/MageBridge/Model/Block.php +0 -138
  11. app/code/community/Jira/MageBridge/Model/Breadcrumbs.php +0 -49
  12. app/code/community/Jira/MageBridge/Model/Category/Api.php +0 -64
  13. app/code/community/Jira/MageBridge/Model/Client.php +0 -107
  14. app/code/community/Jira/MageBridge/Model/Core.php +0 -540
  15. app/code/community/Jira/MageBridge/Model/Customer/Api.php +0 -54
  16. app/code/community/Jira/MageBridge/Model/Debug.php +0 -160
  17. app/code/community/Jira/MageBridge/Model/Dispatcher.php +0 -51
  18. app/code/community/Jira/MageBridge/Model/Email/Template/Filter.php +0 -53
  19. app/code/community/Jira/MageBridge/Model/Encryption.php +0 -71
  20. app/code/community/Jira/MageBridge/Model/Headers.php +0 -61
  21. app/code/community/Jira/MageBridge/Model/Listener.php +0 -716
  22. app/code/community/Jira/MageBridge/Model/Messages.php +0 -58
  23. app/code/community/Jira/MageBridge/Model/Order/Api.php +0 -54
  24. app/code/community/Jira/MageBridge/Model/Product/Api.php +0 -160
  25. app/code/community/Jira/MageBridge/Model/Search.php +0 -31
  26. app/code/community/Jira/MageBridge/Model/Session.php +0 -45
  27. app/code/community/Jira/MageBridge/Model/Storegroups/Api.php +0 -26
  28. app/code/community/Jira/MageBridge/Model/Storeviews/Api.php +0 -50
  29. app/code/community/Jira/MageBridge/Model/Tag/Api.php +0 -37
  30. app/code/community/Jira/MageBridge/Model/Update.php +15 -11
  31. app/code/community/Jira/MageBridge/Model/Url.php +0 -56
  32. app/code/community/Jira/MageBridge/Model/User.php +0 -323
  33. app/code/community/Jira/MageBridge/Model/User/Api.php +0 -135
  34. app/code/community/Jira/MageBridge/Model/Websites/Api.php +0 -31
  35. app/code/community/Jira/MageBridge/controllers/IndexController.php +4 -107
  36. app/code/community/Jira/MageBridge/etc/api.xml +0 -216
  37. app/code/community/Jira/MageBridge/etc/config.xml +2 -212
  38. app/code/community/Jira/MageBridge/etc/system.xml +0 -2
  39. app/design/adminhtml/default/default/template/magebridge/eula.phtml +0 -65
  40. app/design/adminhtml/default/default/template/magebridge/license.phtml +70 -46
  41. app/design/adminhtml/default/default/template/magebridge/settings.phtml +22 -6
  42. app/design/adminhtml/default/default/template/magebridge/settings/events.phtml +0 -36
  43. app/design/adminhtml/default/default/template/magebridge/settings/joomla.phtml +0 -38
  44. app/design/adminhtml/default/default/template/magebridge/settings/other.phtml +0 -37
  45. app/design/adminhtml/default/default/template/magebridge/updates.phtml +15 -13
  46. app/etc/modules/Jira_MageBridge.xml +3 -5
  47. magebridge.class.php +0 -287
  48. magebridge.php +0 -44
  49. package.xml +4 -4
app/code/community/Jira/MageBridge/Block/License.php CHANGED
@@ -20,20 +20,12 @@ class Jira_MageBridge_Block_License extends Mage_Core_Block_Template
20
  $this->setTemplate('magebridge/license.phtml');
21
  }
22
 
23
- /*
24
- * Helper method to get data from the Magento configuration
25
- */
26
- public function getLicenseKey()
27
- {
28
- return Mage::helper('magebridge')->getLicenseKey();
29
- }
30
-
31
  /*
32
  * Helper to return the header of this page
33
  */
34
  public function getHeader($title = null)
35
  {
36
- return 'MageBridge - '.$this->__($title);
37
  }
38
 
39
  /*
@@ -43,9 +35,4 @@ class Jira_MageBridge_Block_License extends Mage_Core_Block_Template
43
  {
44
  return $this->getLayout()->createBlock('magebridge/menu')->toHtml();
45
  }
46
-
47
- public function getSaveUrl()
48
- {
49
- return Mage::getModel('adminhtml/url')->getUrl('magebridge/index/save');
50
- }
51
  }
20
  $this->setTemplate('magebridge/license.phtml');
21
  }
22
 
 
 
 
 
 
 
 
 
23
  /*
24
  * Helper to return the header of this page
25
  */
26
  public function getHeader($title = null)
27
  {
28
+ return 'MageBridge Installer - '.$this->__($title);
29
  }
30
 
31
  /*
35
  {
36
  return $this->getLayout()->createBlock('magebridge/menu')->toHtml();
37
  }
 
 
 
 
 
38
  }
app/code/community/Jira/MageBridge/Block/Menu.php CHANGED
@@ -25,19 +25,19 @@ class Jira_MageBridge_Block_Menu extends Mage_Core_Block_Template
25
  */
26
  public function getMenuItems()
27
  {
28
- // Build the list of menu-items
29
  $items = array(
30
  array(
31
- 'action' => 'settings',
32
  'title' => 'Settings',
33
  ),
34
  array(
35
  'action' => 'updates',
36
- 'title' => 'Updates',
37
  ),
38
  array(
39
  'action' => 'license',
40
- 'title' => 'Licensing',
41
  ),
42
  );
43
 
25
  */
26
  public function getMenuItems()
27
  {
28
+
29
  $items = array(
30
  array(
31
+ 'action' => 'index',
32
  'title' => 'Settings',
33
  ),
34
  array(
35
  'action' => 'updates',
36
+ 'title' => 'Installation',
37
  ),
38
  array(
39
  'action' => 'license',
40
+ 'title' => 'License Agreement',
41
  ),
42
  );
43
 
app/code/community/Jira/MageBridge/Block/Settings.php CHANGED
@@ -21,90 +21,59 @@ class Jira_MageBridge_Block_Settings extends Mage_Core_Block_Template
21
  }
22
 
23
  /*
24
- * Helper to return the header of this page
25
  */
26
- public function getHeader($title = null)
27
  {
28
- return 'MageBridge - '.$this->__($title);
29
- }
 
 
 
 
 
30
 
31
- /*
32
- * Helper to return the menu
33
- */
34
- public function getMenu()
35
- {
36
- return $this->getLayout()->createBlock('magebridge/menu')->toHtml();
37
  }
38
 
39
  /*
40
- * Helper to return the save URL
41
  */
42
- public function getSaveUrl()
43
  {
44
- return Mage::getModel('adminhtml/url')->getUrl('magebridge/index/save');
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /*
48
- * Helper to reset some MageBridge values to their recommended value
49
  */
50
- public function getRecommendedUrl()
51
  {
52
- return Mage::getModel('adminhtml/url')->getUrl('magebridge/index/recommended');
53
  }
54
 
55
  /*
56
- * Helper to reset some MageBridge values to null
57
  */
58
- public function getResetUrl()
59
  {
60
- return Mage::getModel('adminhtml/url')->getUrl('magebridge/index/reset');
61
  }
62
 
63
- /**
64
- * Render block HTML
65
- */
66
- protected function _toHtml()
67
  {
68
- $accordion = $this->getLayout()->createBlock('adminhtml/widget_accordion')->setId('magebridge');
69
-
70
- $accordion->addItem('joomla', array(
71
- 'title' => Mage::helper('adminhtml')->__('Joomla! Connection'),
72
- 'content' => $this->getLayout()->createBlock('magebridge/settings_joomla')->toHtml(),
73
- 'open' => true,
74
- ));
75
-
76
- $accordion->addItem('events', array(
77
- 'title' => Mage::helper('adminhtml')->__('Event Forwarding'),
78
- 'content' => $this->getLayout()->createBlock('magebridge/settings_events')->toHtml(),
79
- 'open' => false,
80
- ));
81
-
82
- $accordion->addItem('other', array(
83
- 'title' => Mage::helper('adminhtml')->__('Other Settings'),
84
- 'content' => $this->getLayout()->createBlock('magebridge/settings_other')->toHtml(),
85
- 'open' => false,
86
- ));
87
-
88
- $this->setChild('accordion', $accordion);
89
-
90
- $this->setChild('recommended_button',
91
- $this->getLayout()->createBlock('adminhtml/widget_button')
92
- ->setData(array(
93
- 'label' => Mage::helper('catalog')->__('Reset to recommended'),
94
- 'onclick' => 'magebridgeForm.submit(\''.$this->getRecommendedUrl().'\')',
95
- 'class' => 'delete'
96
- ))
97
- );
98
-
99
- $this->setChild('reset_button',
100
- $this->getLayout()->createBlock('adminhtml/widget_button')
101
- ->setData(array(
102
- 'label' => Mage::helper('catalog')->__('Reset to default'),
103
- 'onclick' => 'magebridgeForm.submit(\''.$this->getResetUrl().'\')',
104
- 'class' => 'delete'
105
- ))
106
- );
107
-
108
- return parent::_toHtml();
109
  }
110
  }
21
  }
22
 
23
  /*
24
+ * Helper method to get data from the Magento configuration
25
  */
26
+ public function getSetting($key = '')
27
  {
28
+ static $data;
29
+ if(empty($data)) {
30
+ $data = array(
31
+ 'license_key' => Mage::helper('magebridge')->getLicenseKey(),
32
+ 'enabled' => Mage::helper('magebridge')->enabled(),
33
+ );
34
+ }
35
 
36
+ if(isset($data[$key])) {
37
+ return $data[$key];
38
+ } else {
39
+ return null;
40
+ }
 
41
  }
42
 
43
  /*
44
+ * Helper method to get list of all the forwarded events and their current status
45
  */
46
+ public function getEvents()
47
  {
48
+ $events = Mage::getModel('magebridge/listener')->getEvents();
49
+ $event_list = array();
50
+ foreach($events as $event) {
51
+ $event_list[] = array(
52
+ 'name' => $event,
53
+ 'value' => (int)Mage::getModel('magebridge/listener')->isEnabled($event),
54
+ );
55
+ }
56
+ return $event_list;
57
  }
58
 
59
  /*
60
+ * Helper to return the header of this page
61
  */
62
+ public function getHeader($title = null)
63
  {
64
+ return 'MageBridge Installer - '.$this->__($title);
65
  }
66
 
67
  /*
68
+ * Helper to return the menu
69
  */
70
+ public function getMenu()
71
  {
72
+ return $this->getLayout()->createBlock('magebridge/menu')->toHtml();
73
  }
74
 
75
+ public function getSaveUrl()
 
 
 
76
  {
77
+ return Mage::getModel('adminhtml/url')->getUrl('magebridge/index/save');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
  }
app/code/community/Jira/MageBridge/Block/Settings/Events.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Block_Settings_Events extends Mage_Core_Block_Template
13
- {
14
- /*
15
- * Constructor method
16
- */
17
- public function _construct()
18
- {
19
- parent::_construct();
20
- $this->setTemplate('magebridge/settings/events.phtml');
21
- }
22
-
23
- /*
24
- * Helper method to get list of all the forwarded events and their current status
25
- */
26
- public function getEvents()
27
- {
28
- $events = Mage::getModel('magebridge/listener')->getEvents();
29
- $event_list = array();
30
- foreach($events as $event) {
31
- $event_list[] = array(
32
- 'name' => $event[0],
33
- 'value' => (int)Mage::getStoreConfig('magebridge/settings/event_forwarding/'.$event[0]),
34
- );
35
- }
36
- return $event_list;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Block/Settings/Joomla.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Block_Settings_Joomla extends Mage_Core_Block_Template
13
- {
14
- /*
15
- * Constructor method
16
- */
17
- public function _construct()
18
- {
19
- parent::_construct();
20
- $this->setTemplate('magebridge/settings/joomla.phtml');
21
- }
22
-
23
- /*
24
- * Helper method to get the current value of the Joomla! XML-RPC host
25
- */
26
- public function getXmlrpcUrl()
27
- {
28
- return Mage::getStoreConfig('magebridge/settings/xmlrpc_url');
29
- }
30
-
31
- /*
32
- * Helper method to get the currently configured Joomla! API user
33
- */
34
- public function getApiUser()
35
- {
36
- return Mage::getStoreConfig('magebridge/settings/api_user');
37
- }
38
-
39
- /*
40
- * Helper method to get the currently configured Joomla! API key
41
- */
42
- public function getApiKey()
43
- {
44
- return Mage::getStoreConfig('magebridge/settings/api_key');
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Block/Settings/Other.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Block_Settings_Other extends Mage_Core_Block_Template
13
- {
14
- /*
15
- * Constructor method
16
- */
17
- public function _construct()
18
- {
19
- parent::_construct();
20
- $this->setTemplate('magebridge/settings/other.phtml');
21
- }
22
-
23
- /*
24
- * Helper method to get the current value of the bridge-all setting
25
- */
26
- public function getBridgeAll()
27
- {
28
- return Mage::getStoreConfig('magebridge/settings/bridge_all');
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Block/Updates.php CHANGED
@@ -45,7 +45,7 @@ class Jira_MageBridge_Block_Updates extends Mage_Core_Block_Template
45
  */
46
  public function getHeader($title = null)
47
  {
48
- return 'MageBridge - '.$this->__($title);
49
  }
50
 
51
  /*
45
  */
46
  public function getHeader($title = null)
47
  {
48
+ return 'MageBridge Installer - '.$this->__($title);
49
  }
50
 
51
  /*
app/code/community/Jira/MageBridge/Helper/Data.php CHANGED
@@ -20,40 +20,4 @@ class Jira_MageBridge_Helper_Data extends Mage_Core_Helper_Abstract
20
  {
21
  return Mage::getStoreConfig('magebridge/settings/license_key');
22
  }
23
-
24
- public function getXmlrpcUrl()
25
- {
26
- $value = Mage::getSingleton('magebridge/core')->getMetaData('xmlrpc_url');
27
- if(empty($value)) {
28
- $value = Mage::getStoreConfig('magebridge/settings/xmlrpc_url');
29
- }
30
- return $value;
31
- }
32
-
33
- public function getApiUser()
34
- {
35
- $value = Mage::getSingleton('magebridge/core')->getMetaData('api_user');
36
- if(empty($value)) {
37
- $value = Mage::getStoreConfig('magebridge/settings/api_user');
38
- }
39
- return $value;
40
- }
41
-
42
- public function getApiKey()
43
- {
44
- $value = Mage::getSingleton('magebridge/core')->getMetaData('api_key');
45
- if(empty($value)) {
46
- $value = Mage::getStoreConfig('magebridge/settings/api_key');
47
- }
48
- return $value;
49
- }
50
-
51
- public function debug($message, $variable = null)
52
- {
53
- if(!empty($variable)) {
54
- $message .= ': '.var_export($variable, true);
55
- }
56
- $message .= "\n";
57
- file_put_contents('/tmp/magebridge.debug', $message, FILE_APPEND);
58
- }
59
  }
20
  {
21
  return Mage::getStoreConfig('magebridge/settings/license_key');
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
app/code/community/Jira/MageBridge/Model/Api.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Api extends Mage_Core_Model_Abstract
13
- {
14
- public function getResult($resource, $arguments = null)
15
- {
16
- if(empty($resource)) {
17
- Mage::getSingleton('magebridge/debug')->warning('Empty API resource');
18
- return null;
19
- }
20
-
21
- try {
22
- // Parse the resource
23
- $resourceArray = explode( '.', $resource );
24
- $class = str_replace('_', '/', $resourceArray[0]).'_api';
25
- $method = $resourceArray[1];
26
-
27
- Mage::getSingleton('magebridge/debug')->notice('Calling API '.$class.'::'.$method);
28
- Mage::getSingleton('magebridge/debug')->trace('API arguments', $arguments);
29
-
30
- try {
31
- $model = Mage::getModel($class);
32
- } catch(Exception $e) {
33
- Mage::getSingleton('magebridge/debug')->error('Failed to instantiate API-class '.$class.': '.$e->getMessage());
34
- return false;
35
- }
36
-
37
- if(empty($model)) {
38
- Mage::getSingleton('magebridge/debug')->notice('API class returns empty object');
39
- return false;
40
-
41
- } elseif(method_exists($model, $method)) {
42
- return call_user_func(array($model, $method), $arguments);
43
-
44
- } elseif($method == 'list' && method_exists($model, 'items')) {
45
- return $model->items($arguments);
46
-
47
- } else {
48
- Mage::getSingleton('magebridge/debug')->notice('API class has no method '.$method);
49
- return false;
50
- }
51
-
52
- } catch(Exception $e) {
53
- Mage::getSingleton('magebridge/debug')->error('Failed to call API: '.$resource.': '.$e->getMessage());
54
- return false;
55
- }
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Block.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- * Class for outputting HTML-blocks from the Magento theme
14
- */
15
- class Jira_MageBridge_Model_Block extends Mage_Core_Model_Abstract
16
- {
17
- /*
18
- * Get the block
19
- */
20
- public function getBlock($block_name)
21
- {
22
- if(empty($block_name)) {
23
- Mage::getSingleton('magebridge/debug')->warning('Empty block-name');
24
- return null;
25
- }
26
-
27
- Mage::getSingleton('magebridge/debug')->notice('Building block "'.$block_name.'"');
28
-
29
- // Initialize the controller
30
- try {
31
- $controller = Mage::getSingleton('magebridge/core')->getController();
32
- $controller->getResponse()->clearBody();
33
-
34
- // @todo: Remove the messages from the content-block
35
- // @todo: Add a parameter to include the messages-block or not
36
- //$controller->getAction()->getLayout()->removeBlock('global_messages');
37
- //$controller->getAction()->getLayout()->removeBlock('messages');
38
-
39
- } catch(Exception $e) {
40
- Mage::getSingleton('magebridge/debug')->error('Failed to load controller: '.$e->getMessage());
41
- return false;
42
- }
43
-
44
- // Initialize the block
45
- try {
46
- $block = $controller->getAction()->getLayout()->getBlock($block_name);
47
-
48
- } catch(Exception $e) {
49
- Mage::getSingleton('magebridge/debug')->error('Failed to get block: '.$block_name.': '.$e->getMessage());
50
- return false;
51
- }
52
-
53
- if(empty($block)) {
54
- Mage::getSingleton('magebridge/debug')->warning('Empty block-name');
55
- return null;
56
- }
57
-
58
- return $block;
59
- }
60
-
61
- /*
62
- * Output
63
- */
64
- public function getOutput($block_name, $arguments = array())
65
- {
66
- // Choose between regular blocks and CMS-blocks
67
- if(isset($arguments['type']) && $arguments['type'] == 'cms') {
68
- $response = $this->getCmsOutput($block_name, $arguments);
69
- } else {
70
- $response = $this->getBlockOutput($block_name, $arguments);
71
- }
72
-
73
- // Prepare the response for the bridge
74
- if(!empty($response)) {
75
- $response = base64_encode(gzcompress($response));
76
- }
77
- return $response;
78
- }
79
-
80
- /*
81
- * CMS-block output
82
- */
83
- public function getCmsOutput($block_name, $arguments = array())
84
- {
85
- // Get the CMS-block
86
- $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($block_name);
87
-
88
- if($block->getIsActive()) {
89
-
90
- $response = $block->getContent();
91
- $response = Mage::getModel('core/email_template_filter')->filter($response);
92
- return $response;
93
- }
94
-
95
- return null;
96
- }
97
-
98
- /*
99
- * Regular block output
100
- */
101
- public function getBlockOutput($block_name, $arguments = array())
102
- {
103
- // Get the block-object
104
- $block = $this->getBlock($block_name);
105
- if(empty($block)) {
106
- return null;
107
- }
108
-
109
- // Get the HTML of the block-object
110
- try {
111
- return $block->toHtml();
112
-
113
- } catch( Exception $e) {
114
- Mage::getSingleton('magebridge/debug')->error('Failed to get html from block '.$block_name.': '.$e->getMessage());
115
- }
116
-
117
- return null;
118
- }
119
-
120
- /*
121
- * Method to get extra information on this block
122
- */
123
- public function getMeta($block_name)
124
- {
125
- $block = $this->getBlock($block_name);
126
- if(empty($block)) {
127
- return null;
128
- }
129
-
130
- return array(
131
- 'cache_key' => $block->getCacheKey(),
132
- 'has_cache_key' => (int)$block->hasData('cache_key'),
133
- 'cache_lifetime' => (int)$block->getCacheLifetime(),
134
- 'cache_tags' => $block->getCacheTags(),
135
- 'allow_caching' => (int)Mage::app()->useCache('block_html'),
136
- );
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Breadcrumbs.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Breadcrumbs extends Mage_Page_Block_Html_Breadcrumbs
13
- {
14
- public static function getBreadcrumbs()
15
- {
16
- try {
17
- $controller = Mage::getSingleton('magebridge/core')->getController();
18
- $controller->getResponse()->clearBody();
19
-
20
- } catch(Exception $e) {
21
- Mage::getSingleton('magebridge/debug')->error('Failed to load controller: '.$e->getMessage());
22
- return false;
23
- }
24
-
25
- try {
26
- $block = $controller->getAction()->getLayout()->getBlock('breadcrumbs');
27
-
28
- } catch(Exception $e) {
29
- Mage::getSingleton('magebridge/debug')->error('Failed to get breadcrumbs: '.$e->getMessage());
30
- return false;
31
- }
32
-
33
- try {
34
- if(!empty($block)) {
35
- $block->toHtml();
36
- return $block->getCrumbs();
37
- }
38
-
39
- } catch( Exception $e) {
40
- Mage::getSingleton('magebridge/debug')->error('Failed to set block: '.$e->getMessage());
41
- return false;
42
- }
43
- }
44
-
45
- public function getCrumbs()
46
- {
47
- return $this->_crumbs;
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Category/Api.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Category_Api extends Mage_Catalog_Model_Api_Resource
13
- {
14
- public function tree($parentId = null, $store = null)
15
- {
16
- // Get a tree of all categories
17
- $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
18
-
19
- if (is_null($parentId) && !is_null($store)) {
20
- $parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
21
- } elseif (is_null($parentId)) {
22
- $parentId = 1;
23
- }
24
-
25
- $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
26
-
27
- $root = $tree->getNodeById($parentId);
28
- if($root && $root->getId() == 1) {
29
- $root->setName(Mage::helper('catalog')->__('Root'));
30
- }
31
-
32
- $collection = Mage::getModel('catalog/category')->getCollection()
33
- ->setStoreId($this->_getStoreId($store))
34
- ->addUrlRewriteToResult()
35
- ->addAttributeToSelect('name')
36
- ->addAttributeToSelect('url_key')
37
- ->addAttributeToSelect('is_active')
38
- ;
39
-
40
- $tree->addCollectionData($collection, true);
41
- return $this->_nodeToArray($root);
42
- }
43
-
44
- protected function _nodeToArray(Varien_Data_Tree_Node $node)
45
- {
46
- $result = array();
47
- $result['category_id'] = $node->getId();
48
- $result['parent_id'] = $node->getParentId();
49
- $result['name'] = $node->getName();
50
- $result['is_active'] = $node->getIsActive();
51
- $result['is_anchor'] = $node->getIsAnchor();
52
- $result['url_key'] = $node->getUrlKey();
53
- $result['url'] = $node->getRequestPath();
54
- $result['position'] = $node->getPosition();
55
- $result['level'] = $node->getLevel();
56
- $result['children'] = array();
57
-
58
- foreach ($node->getChildren() as $child) {
59
- $result['children'][] = $this->_nodeToArray($child);
60
- }
61
-
62
- return $result;
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Client.php DELETED
@@ -1,107 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Client extends Mage_Core_Model_Abstract
13
- {
14
- /*
15
- *
16
- */
17
- private $calls = array();
18
-
19
- /*
20
- * Method to add a call
21
- */
22
- public function addCall($method, $arguments)
23
- {
24
- $this->calls[] = array($method, $arguments);
25
- return;
26
- }
27
-
28
- /*
29
- * Method to add all current debugging-data to a multicall
30
- */
31
- public function addDebug()
32
- {
33
- foreach(Mage::getSingleton('magebridge/debug')->getData() as $log) {
34
- foreach(array('type', 'message', 'section', 'time') as $index) {
35
- if(!isset($log[$index])) $log[$index] = '';
36
- }
37
- $this->addCall( 'magebridge.log', array($log['type'], $log['message'], $log['section'], $log['time']) );
38
- }
39
- Mage::getSingleton('magebridge/debug')->clean();
40
- }
41
-
42
- /*
43
- * Method to call multiple XML-RPC methods
44
- * @todo: Truely implement XML-RPC multi-call
45
- */
46
- public function multicall()
47
- {
48
- foreach($this->calls as $call) {
49
- $this->call($call[0], $call[1]);
50
- }
51
- }
52
-
53
- /*
54
- * Method to call a XML-RPC method
55
- */
56
- public function call($method, $params)
57
- {
58
- // Collect all the values from the bridge
59
- $xmlrpc_url = Mage::helper('magebridge')->getXmlrpcUrl();
60
- $auth = $this->getAPIAuthArray();
61
-
62
- // If these values are not set, we are unable to continue
63
- if(empty($xmlrpc_url) || $auth == false) {
64
- return false;
65
- }
66
-
67
- // Add the $auth-array as first
68
- array_unshift( $params, $auth );
69
-
70
- // Initialize the XML-RPC client
71
- require_once 'Zend/XmlRpc/Client.php';
72
- $client = new Zend_XmlRpc_Client($xmlrpc_url);
73
- $client->setSkipSystemLookup(true);
74
-
75
- // Call the XML-RPC server
76
- try {
77
- $client->call($method, $params);
78
- return true;
79
-
80
- } catch (Exception $e) {
81
- Mage::getSingleton('magebridge/debug')->warning('XML-RPC client to method "'.$method.'" failed: '.$e->getMessage());
82
- Mage::getSingleton('magebridge/debug')->trace('Joomla! host', $xmlrpc_url);
83
- Mage::getSingleton('magebridge/debug')->trace('Method arguments', $params);
84
- }
85
- return false;
86
- }
87
-
88
- /*
89
- * Method that returns API-authentication-data as a basic array
90
- */
91
- public function getAPIAuthArray()
92
- {
93
- $api_user = Mage::helper('magebridge')->getApiUser();
94
- $api_key = Mage::helper('magebridge')->getApiKey();
95
- if(empty($api_user) || empty($api_key)) {
96
- Mage::getSingleton('magebridge/debug')->warning('Listener getAPIAuthArray: api_user or api_key is missing');
97
- Mage::getSingleton('magebridge/debug')->trace('Listener: Meta data', Mage::getSingleton('magebridge/core')->getMetaData());
98
- return false;
99
- }
100
-
101
- $auth = array(
102
- 'api_user' => Mage::getSingleton('magebridge/encryption')->encrypt($api_user),
103
- 'api_key' => Mage::getSingleton('magebridge/encryption')->encrypt($api_key),
104
- );
105
- return $auth;
106
- }
107
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Core.php DELETED
@@ -1,540 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- * Main bridge-class which handles the Magento configuration
14
- */
15
- class Jira_MageBridge_Model_Core extends Mage_Core_Model_Abstract
16
- {
17
- /*
18
- * Bridge-request
19
- */
20
- protected $_request = array();
21
-
22
- /*
23
- * Bridge-request
24
- */
25
- protected $_response = array();
26
-
27
- /*
28
- * Meta-data
29
- */
30
- protected $_meta = array();
31
-
32
- /*
33
- * System messages
34
- */
35
- protected $_messages = array();
36
-
37
- /*
38
- * System events
39
- */
40
- protected $_events = array();
41
-
42
- /*
43
- * Initialize the bridge-core
44
- */
45
- public function init($meta = null, $request = null)
46
- {
47
- // Set meta and request
48
- $this->_meta = $meta;
49
- $this->_request = $request;
50
-
51
- // Fill the response with the current request
52
- $this->setResponseData($request);
53
-
54
- // Decrypt everything that needs decrypting
55
- $this->_meta['api_user'] = $this->decrypt($this->getMetaData('api_user'));
56
- $this->_meta['api_key'] = $this->decrypt($this->getMetaData('api_key'));
57
-
58
- //Mage::getSingleton('magebridge/debug')->trace('Dump of meta', $this->_meta);
59
- //Mage::getSingleton('magebridge/debug')->trace('Dump of GET', $_GET);
60
- //Mage::getSingleton('magebridge/debug')->trace('Dump of response', $this->_response);
61
-
62
- // Overwrite the default error-handling by routing all magebridge/debug
63
- set_error_handler('Jira_MageBridge_ErrorHandler');
64
- set_exception_handler('Jira_MageBridge_ExceptionHandler');
65
-
66
- // Set the magebridge-URLs
67
- $this->setConfig();
68
-
69
- // Set the current store of this request
70
- try {
71
- Mage::app()->setCurrentStore(Mage::app()->getStore($this->getStore()));
72
- } catch( Exception $e ) {
73
- Mage::getSingleton('magebridge/debug')->error('Failed to intialize store "'.$this->getStore().'":'.$e->getMessage());
74
- // Do not return, but just keep on going with the default configuration
75
- }
76
-
77
- // Try to initialize the session
78
- try {
79
- $session = Mage::getSingleton('core/session', array('name'=>'frontend'));
80
- } catch( Exception $e ) {
81
- Mage::getSingleton('magebridge/debug')->error('Unable to instantiate core/session: '.$e->getMessage());
82
- return false;
83
- }
84
-
85
- return true;
86
- }
87
-
88
- /*
89
- * Method to change the regular Magento configuration as needed
90
- */
91
- public function setConfig()
92
- {
93
- // To start with, check the Joomla! configuration
94
- $this->checkJoomlaConfig();
95
-
96
- // Initialize the Magento configuration
97
- try {
98
- // Get the current store
99
- $store = Mage::app()->getStore($this->getStore());
100
- Mage::getSingleton('magebridge/debug')->notice('Set URLs of store "'.$store->getName().'" to '.$this->getMageBridgeUrl());
101
-
102
- // Check if the Configuration Cache is enabled, and if so, empty it
103
- /*
104
- if(Mage::app()->useCache('config')) {
105
- Mage::getSingleton('magebridge/debug')->warning('Configuration Cache is enabled, which is NOT recommended');
106
- $store->resetConfig();
107
- }
108
- */
109
-
110
- // Get the URLs from the Configuration
111
- $base_url = $store->getConfig('web/unsecure/base_url');
112
- $base_media_url = $store->getConfig('web/unsecure/base_media_url');
113
- $base_skin_url = $store->getConfig('web/unsecure/base_skin_url');
114
- $base_js_url = $store->getConfig('web/unsecure/base_js_url');
115
- if($store->getConfig('magebridge/settings/bridge_all') == 1) {
116
- $proxy = 'index.php?option=com_magebridge&view=proxy&url=';
117
- $base_media_url = str_replace($base_url, $proxy, $base_media_url);
118
- $base_skin_url = str_replace($base_url, $proxy, $base_skin_url);
119
- $base_js_url = str_replace($base_url, $proxy, $base_js_url);
120
- }
121
-
122
- // Set the URLs to point to Joomla!
123
- $store->setConfig('web/unsecure/base_url', $this->getMageBridgeUrl());
124
- $store->setConfig('web/unsecure/base_link_url', $this->getMageBridgeUrl());
125
- $store->setConfig('web/unsecure/base_media_url', $base_media_url);
126
- $store->setConfig('web/unsecure/base_skin_url', $base_skin_url);
127
- $store->setConfig('web/unsecure/base_js_url', $base_js_url);
128
-
129
- $store->setConfig('web/secure/base_url', $this->getMageBridgeUrl());
130
- $store->setConfig('web/secure/base_link_url', $this->getMageBridgeUrl());
131
- $store->setConfig('web/secure/base_media_url', $base_media_url);
132
- $store->setConfig('web/secure/base_skin_url', $base_skin_url);
133
- $store->setConfig('web/secure/base_js_url', $base_js_url);
134
-
135
- // Other manual settings
136
- $store->setConfig('web/seo/use_rewrites', 1);
137
- $store->setConfig('web/session/use_remote_addr', 0);
138
- $store->setConfig('web/session/use_http_via', 0);
139
- $store->setConfig('web/session/use_http_x_forwarded_for', 0);
140
- $store->setConfig('web/session/use_http_user_agent', 0);
141
- $store->setConfig('web/cookie/cookie_domain', '');
142
- //$store->setConfig('catalog/seo/product_url_suffix', '');
143
- //$store->setConfig('catalog/seo/category_url_suffix', '');
144
-
145
- // Rewrite the session lifetime
146
- if($this->getMetaData('joomla_conf_lifetime') > 0) {
147
- $store->setConfig('admin/security/session_cookie_lifetime', $this->getMetaData('joomla_conf_lifetime'));
148
- $store->setConfig('web/cookie/cookie_lifetime', $this->getMetaData('joomla_conf_lifetime'));
149
- }
150
-
151
- // Make sure we do not use SID= in the URL
152
- Mage::getModel('core/url')->setUseSession(false);
153
- Mage::getModel('core/url')->setUseSessionVar(true);
154
-
155
- } catch(Exception $e) {
156
- Mage::getSingleton('magebridge/debug')->error('Unable to set URLs to '.$this->getMageBridgeUrl().': '.$e->getMessage());
157
- }
158
-
159
- return true;
160
- }
161
-
162
- /*
163
- * Method to authenticate usage of the MageBridge API
164
- */
165
- public function checkJoomlaConfig()
166
- {
167
- // List of keys (meta => conf)
168
- $keys = array(
169
- 'xmlrpc_url' => 'xmlrpc_url',
170
- 'api_user' => 'api_user',
171
- 'api_key' => 'api_key',
172
- );
173
-
174
- // Check the Joomla! settings
175
- foreach($keys as $meta_key => $conf_key) {
176
- $conf_value = Mage::getStoreConfig('magebridge/settings/'.$conf_key);
177
- $meta_value = $this->getMetaData($meta_key);
178
- if(empty($conf_value)) {
179
- Mage::getConfig()->saveConfig('magebridge/settings/'.$conf_key, $meta_value);
180
- }
181
- }
182
- }
183
-
184
- /*
185
- * Method to get the currently defined API-user
186
- */
187
- public function getApiUser()
188
- {
189
- $api_user_id = Mage::getStoreConfig('magebridge/settings/api_user_id');
190
-
191
- if(!$api_user_id > 0) {
192
- $collection = Mage::getResourceModel('api/user_collection');
193
- foreach($collection as $user) {
194
- $api_user_id = $user->getId();
195
- break;
196
- }
197
- }
198
-
199
- $api_user = Mage::getModel('api/user')->load($api_user_id);
200
- return $api_user;
201
- }
202
-
203
- /*
204
- * Method to authenticate usage of the MageBridge API
205
- */
206
- public function authenticate()
207
- {
208
- // Fetch the variables from the meta-data
209
- $api_session = $this->getMetaData('api_session');
210
- $api_user = $this->getMetaData('api_user');
211
- $api_key = $this->getMetaData('api_key');
212
-
213
- // If the API-session matches, we don't need authenticate any more
214
- if($api_session == md5(session_id().$api_user.$api_key)) {
215
- return true;
216
- }
217
-
218
- // If we still need authentication, authenticate against the Magento API-class
219
- try {
220
- $api = Mage::getModel('api/user');
221
- if( $api->authenticate($api_user, $api_key) == true ) {
222
- $this->setMetaData('api_session', md5(session_id().$api_user.$api_key));
223
- return true;
224
- }
225
-
226
- } catch(Exception $e) {
227
- Mage::getSingleton('magebridge/debug')->error('Exception while authorizing: '.$e->getMessage());
228
- }
229
- return false;
230
- }
231
-
232
- /*
233
- * Method to catch premature output in case of AJAX-stuff
234
- */
235
- public function preoutput()
236
- {
237
- // Initialize the frontcontroller
238
- $controller = Mage::getSingleton('magebridge/core')->getController();
239
-
240
- // Start the buffer and fetch the output from Magento
241
- $body = Mage::app()->getResponse()->getBody();
242
- if(!empty($body)) {
243
- $controller->getResponse()->clearBody();
244
- return true;
245
- }
246
-
247
- return false;
248
- }
249
-
250
- /*
251
- * Method to output the regular bridge-data through JSON
252
- */
253
- public function output($complete = true)
254
- {
255
- if($complete) {
256
- $this->closeBridge();
257
- } else {
258
- $this->addResponseData('meta', array(
259
- 'type' => 'meta',
260
- 'data' => array(
261
- 'state' => $this->getMetaData('state'),
262
- 'extra' => $this->getMetaData('extra'),
263
- )
264
- ));
265
- }
266
-
267
- $debug = Mage::getSingleton('magebridge/debug')->getData();
268
- if($this->getMetaData('debug') == 1 && !empty($debug)) {
269
- $this->addResponseData('debug', array(
270
- 'type' => 'debug',
271
- 'data' => $debug,
272
- ));
273
- }
274
-
275
- // Output the response
276
- return json_encode($this->getResponseData());
277
- }
278
-
279
- /*
280
- * Method to close the bridge and add the final data
281
- */
282
- public function closeBridge()
283
- {
284
- // Add extra information
285
- $this->setMetaData('magento_session', session_id());
286
- $this->setMetaData('magento_version', Mage::getVersion());
287
-
288
- // Append customer-data
289
- $customer = Mage::getSingleton('customer/session')->getCustomer();
290
- $this->setMetaData('magento_customer', array(
291
- 'fullname' => $customer->getName(),
292
- 'username' => $customer->getEmail(),
293
- 'email' => $customer->getEmail(),
294
- 'hash' => $customer->getPasswordHash(),
295
- ));
296
-
297
- // Append store-data
298
- $store = Mage::app()->getStore($this->getStore());
299
- $this->setMetaData('magento_config', array(
300
- 'catalog/seo/product_url_suffix' => $store->getConfig('catalog/seo/product_url_suffix'),
301
- 'catalog/seo/category_url_suffix' => $store->getConfig('catalog/seo/category_url_suffix'),
302
- 'admin/security/session_cookie_lifetime' => $store->getConfig('admin/security/session_cookie_lifetime'),
303
- 'web/cookie/cookie_lifetime' => $store->getConfig('web/cookie/cookie_lifetime'),
304
- 'magento_backend' => $this->getAdminPath(),
305
- 'root_template' => $this->getRootTemplate(),
306
- /*
307
- 'web/unsecure/base_url' => $store->getConfig('web/unsecure/base_url'),
308
- 'web/unsecure/base_link_url' => $store->getConfig('web/unsecure/base_link_url'),
309
- 'web/unsecure/base_media_url' => $store->getConfig('web/unsecure/base_media_url'),
310
- 'web/unsecure/base_skin_url' => $store->getConfig('web/unsecure/base_skin_url'),
311
- 'web/unsecure/base_js_url' => $store->getConfig('web/unsecure/base_js_url'),
312
- 'web/secure/base_url' => $store->getConfig('web/secure/base_url'),
313
- 'web/secure/base_link_url' => $store->getConfig('web/secure/base_link_url'),
314
- 'web/secure/base_media_url' => $store->getConfig('web/secure/base_media_url'),
315
- 'web/secure/base_skin_url' => $store->getConfig('web/secure/base_skin_url'),
316
- 'web/secure/base_js_url' => $store->getConfig('web/secure/base_js_url'),
317
- 'web/seo/use_rewrites' => $store->getConfig('web/seo/use_rewrites'),
318
- */
319
- ));
320
-
321
- // Start building the request
322
- $messages = $this->getMessages();
323
- if(!empty($messages)) {
324
- $this->addResponseData('messages', array(
325
- 'type' => 'messages',
326
- 'data' => $messages,
327
- ));
328
- }
329
-
330
- $events = $this->getEvents();
331
- if(!empty($events)) {
332
- $this->addResponseData('events', array(
333
- 'type' => 'events',
334
- 'data' => $events,
335
- ));
336
- }
337
-
338
- $metadata = $this->getMetaData();
339
- if(!empty($metadata)) {
340
- $this->addResponseData('meta', array(
341
- 'type' => 'meta',
342
- 'data' => $metadata,
343
- ));
344
- }
345
- }
346
-
347
- /*
348
- * Helper-function to parse Magento output for usage in Joomla!
349
- */
350
- public function parse($string)
351
- {
352
- $string = str_replace(Mage::getUrl(), $this->getMageBridgeUrl(), $string);
353
- return $string;
354
- }
355
-
356
- /*
357
- * Return the path to the Magento Admin Panel
358
- */
359
- public function getAdminPath()
360
- {
361
- $routeName = 'adminhtml';
362
- $route = Mage::app()->getFrontController()->getRouterByRoute($routeName);
363
- $backend = $route->getFrontNameByRoute($routeName);
364
- return $backend;
365
- }
366
-
367
- /*
368
- * Return the current page layout for the Magento theme
369
- */
370
- public function getRootTemplate()
371
- {
372
- $block = Mage::getModel('magebridge/block')->getBlock('root');
373
- if(!empty($block)) {
374
- return $block->getTemplate();
375
- }
376
- return 'none';
377
- }
378
-
379
- /*
380
- * Helper-method to get the Front-controller
381
- */
382
- public static function getController()
383
- {
384
- static $controller;
385
- if(empty($controller)) {
386
- $controller = Mage::app()->getFrontController()->setNoRender(true)->dispatch();
387
- $controller->getAction()->getLayout()->removeOutputBlock('root');
388
- }
389
- return $controller;
390
- }
391
-
392
- /*
393
- * Helper-method to get the bridge-request
394
- */
395
- public function getRequestData()
396
- {
397
- return $this->_request;
398
- }
399
-
400
- /*
401
- * Helper-method to get the bridge-response
402
- */
403
- public function getResponseData()
404
- {
405
- return $this->_response;
406
- }
407
-
408
- /*
409
- * Helper-method to set the bridge-response
410
- */
411
- public function setResponseData($data)
412
- {
413
- $this->_response = $data;
414
- return null;
415
- }
416
-
417
- /*
418
- * Helper-method to add some data to the bridge-response
419
- */
420
- public function addResponseData($name = null, $data)
421
- {
422
- $this->_response[$name] = $data;
423
- return true;
424
- }
425
-
426
- /*
427
- * Helper-method to get the meta-data
428
- */
429
- public function getMetaData($name = null)
430
- {
431
- if($name == null) {
432
- return $this->_meta;
433
- } elseif(isset($this->_meta[$name])) {
434
- return $this->_meta[$name];
435
- } else {
436
- return null;
437
- }
438
- }
439
-
440
- /*
441
- * Helper-method to set the meta-data
442
- */
443
- public function setMetaData($name = '', $value = '')
444
- {
445
- $this->_meta[$name] = $value;
446
- return null;
447
- }
448
-
449
- /*
450
- * Helper-method to get the system messages
451
- */
452
- public function getMessages()
453
- {
454
- return $this->_messages;
455
- }
456
-
457
- /*
458
- * Helper-method to set the system messages
459
- */
460
- public function setMessages($messages)
461
- {
462
- $this->_messages = $messages;
463
- return null;
464
- }
465
-
466
- /*
467
- * Helper-method to get the system events from the session and clean up afterwards
468
- */
469
- public function getEvents()
470
- {
471
- $events = Mage::getSingleton('magebridge/session')->getEvents();;
472
- Mage::getSingleton('magebridge/session')->cleanEvents();
473
- return $events;
474
- }
475
-
476
- /*
477
- * Helper-method to set the system events
478
- */
479
- public function setEvents($events)
480
- {
481
- $this->_events = $events;
482
- return null;
483
- }
484
-
485
- /*
486
- * Helper-method to get the Joomla! URL from the meta-data
487
- */
488
- public function getMageBridgeUrl()
489
- {
490
- return $this->getMetaData('joomla_url');
491
- }
492
-
493
- /*
494
- * Helper-method to get the Joomla! SEF URL from the meta-data
495
- */
496
- public function getMageBridgeSefUrl()
497
- {
498
- return $this->getMetaData('joomla_sef_url');
499
- }
500
-
501
- /*
502
- * Helper-method to get the requested store-name from the meta-data
503
- */
504
- public function getStore()
505
- {
506
- return $this->getMetaData('store');
507
- }
508
-
509
- /*
510
- * Return the configured license key
511
- */
512
- public function getLicenseKey()
513
- {
514
- return Mage::getStoreConfig('magebridge/settings/license_key');
515
- }
516
-
517
- /*
518
- * Return the current session ID
519
- */
520
- public function getMageSession()
521
- {
522
- return session_id();
523
- }
524
-
525
- /*
526
- * Encrypt data for security
527
- */
528
- public function encrypt($data)
529
- {
530
- return Mage::getSingleton('magebridge/encryption')->encrypt($data);
531
- }
532
-
533
- /*
534
- * Decrypt data after encryption
535
- */
536
- public function decrypt($data)
537
- {
538
- return Mage::getSingleton('magebridge/encryption')->decrypt($data);
539
- }
540
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Customer/Api.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Customer_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- /**
15
- * Retrieve list of customers with basic info
16
- *
17
- * @param array $filters
18
- * @return array
19
- */
20
- public function items($filters = null, $store = null)
21
- {
22
- $collection = Mage::getModel('customer/customer')->getCollection()
23
- //->setStoreId($this->_getStoreId($store))
24
- ->addAttributeToSelect('*')
25
- ->setOrder('created_at', 'desc')
26
- ->setPageSize(20)
27
- ->load()
28
- ;
29
-
30
- /*
31
- * @todo: This does not work, but is still needed: $filter = array( array('title' => array('nlike' => array('%a', '%b'))));
32
- */
33
- if (is_array($filters)) {
34
- try {
35
- foreach ($filters as $field => $value) {
36
- if (isset($this->_filtersMap[$field])) {
37
- $field = $this->_filtersMap[$field];
38
- }
39
-
40
- $collection->addFieldToFilter($field, $value);
41
- }
42
- } catch (Mage_Core_Exception $e) {
43
- $this->_fault('filters_invalid', $e->getMessage());
44
- }
45
- }
46
-
47
- $result = array();
48
- foreach ($collection as $customer) {
49
- $result[] = $customer->debug();
50
- }
51
-
52
- return $result;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Debug.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- if(!defined('MAGEBRIDGE_DEBUG_TRACE')) define( 'MAGEBRIDGE_DEBUG_TRACE', 1 );
13
- if(!defined('MAGEBRIDGE_DEBUG_NOTICE')) define( 'MAGEBRIDGE_DEBUG_NOTICE', 2 );
14
- if(!defined('MAGEBRIDGE_DEBUG_WARNING')) define( 'MAGEBRIDGE_DEBUG_WARNING', 3 );
15
- if(!defined('MAGEBRIDGE_DEBUG_ERROR')) define( 'MAGEBRIDGE_DEBUG_ERROR', 4 );
16
- if(!defined('MAGEBRIDGE_DEBUG_FEEDBACK')) define( 'MAGEBRIDGE_DEBUG_FEEDBACK', 5 );
17
-
18
- define( 'MAGEBRIDGE_DEBUG_TYPE_JOOMLA', 'joomla' );
19
- define( 'MAGEBRIDGE_DEBUG_TYPE_MAGENTO', 'magento' );
20
- define( 'MAGEBRIDGE_DEBUG_TYPE_XMLRPC', 'xmlrpc' );
21
-
22
-
23
- /*
24
- * Stand-alone function to override the default error-handler.
25
- * This function is called from magebridge/core.
26
- */
27
- function Jira_MageBridge_ErrorHandler($errno, $errstr, $errfile, $errline)
28
- {
29
- // Flag which decides to close the bridge or not
30
- $close_bridge = false;
31
-
32
- // Handle each error-type differently
33
- switch($errno) {
34
-
35
- // With errors, we need to close the bridge and exit
36
- case E_USER_ERROR:
37
- Mage::getSingleton('magebridge/debug')->error("PHP Fatal Error in $errfile - Line $errline: $errstr");
38
- $close_bridge = true;
39
- break;
40
-
41
- // Log warnings
42
- case E_USER_WARNING:
43
- Mage::getSingleton('magebridge/debug')->warning("PHP Warning in $errfile - Line $errline: $errstr");
44
- break;
45
-
46
- // E_WARNING also includes Autoload.php messages which are NOT interesting
47
- case E_WARNING:
48
- break;
49
-
50
- // Ignore notices
51
- case E_USER_NOTICE:
52
- break;
53
-
54
- // Log unknown errors also as warnings, because we are in a E_STRICT environment
55
- default:
56
- // @todo: Can we detect notices here?
57
- Mage::getSingleton('magebridge/debug')->warning("PHP Unknown in $errfile - Line $errline: [$errno] $errstr");
58
- break;
59
- }
60
-
61
- // Close the bridge if needed
62
- if($close_bridge == true) {
63
- $bridge = Mage::getSingleton('magebridge/core');
64
- $bridge->output();
65
- exit(1);
66
- }
67
-
68
- return true;
69
- }
70
-
71
- /*
72
- * Stand-alone function to override the default exception-handler.
73
- * This function is called from magebridge/core.
74
- */
75
- function Jira_MageBridge_ExceptionHandler($exception)
76
- {
77
- Mage::getSingleton('magebridge/debug')->error("PHP Fatal Error: ".$exception->getMessage());
78
- $bridge = Mage::getSingleton('magebridge/core');
79
- print $bridge->output(false);
80
- return;
81
- }
82
-
83
- /*
84
- * MageBridge Debug-class
85
- */
86
- class Jira_MageBridge_Model_Debug
87
- {
88
- protected static $_instance = null;
89
- private $_data = array();
90
-
91
- static public function getInstance()
92
- {
93
- if(null === self::$_instance) {
94
- self::$_instance = new self();
95
- }
96
- return self::$_instance;
97
- }
98
-
99
- public function getData()
100
- {
101
- return $this->_data;
102
- }
103
-
104
- public function clean()
105
- {
106
- $this->_data = array();
107
- }
108
-
109
- public function add($message = null, $type = MAGEBRIDGE_DEBUG_NOTICE, $time = null, $origin = null)
110
- {
111
- if(!empty($message)) {
112
- if(empty($time) || !$time > 0) $time = time();
113
- if(empty($origin)) $origin = 'Magento';
114
-
115
- $data = array(
116
- 'type' => $type,
117
- 'message' => $message,
118
- 'time' => $time,
119
- 'origin' => $origin,
120
- );
121
-
122
- $message = '['.$data['origin'].'] ';
123
- $message .= '('.date('Y-m-d H:i:s', $data['time']).') ';
124
- $message .= $data['type'] . ': ';
125
- $message .= $data['message'] . "\n";
126
-
127
- $this->_data[] = $data;
128
- }
129
- }
130
-
131
- public function notice($message = null, $time = null)
132
- {
133
- $this->add($message, MAGEBRIDGE_DEBUG_NOTICE, $time);
134
- }
135
-
136
- public function warning($message = null, $time = null)
137
- {
138
- $this->add($message, MAGEBRIDGE_DEBUG_WARNING, $time);
139
- }
140
-
141
- public function error($message = null, $time = null)
142
- {
143
- $this->add($message, MAGEBRIDGE_DEBUG_ERROR, $time);
144
- }
145
-
146
- public function trace($message = null, $variable = null, $time = null)
147
- {
148
- if(!empty($variable)) {
149
- $message = $message.': '.var_export($variable, true);
150
- } else {
151
- $message = $message.': NULL';
152
- }
153
- $this->add($message, MAGEBRIDGE_DEBUG_TRACE, $time);
154
- }
155
-
156
- public function feedback($message = null, $variable, $time = null)
157
- {
158
- $this->add($message, MAGEBRIDGE_DEBUG_FEEDBACK, $time);
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Dispatcher.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Dispatcher extends Mage_Core_Model_Abstract
13
- {
14
- /*
15
- * Method to fire a Joomla! event sent through the bridge
16
- */
17
- public function getResult($name, $arguments)
18
- {
19
- if(in_array($event, $this->getEvents())) {
20
-
21
- $event = 'joomla'.ucfirst($name);
22
- return Mage::dispatchEvent($event, $arguments);
23
-
24
- }
25
- return false;
26
- }
27
-
28
- public function getEvents()
29
- {
30
- return array(
31
- 'onAuthenticate',
32
- 'onPrepareContent',
33
- 'onAfterDisplayTitle',
34
- 'onBeforeDisplayContent',
35
- 'onAfterDisplayContent',
36
- 'onBeforeContentSave',
37
- 'onAfterContentSave',
38
- 'onSearch',
39
- 'onSearchAreas',
40
- 'onAfterInitialise',
41
- 'onAfterRender',
42
- 'onLoginFailure',
43
- 'onBeforeStoreUser',
44
- 'onAfterStoreUser',
45
- 'onBeforeDeleteUser',
46
- 'onAfterDeleteUser',
47
- 'onLoginUser',
48
- 'onLogoutUser',
49
- );
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Email/Template/Filter.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- * Override of the default class Mage_Core_Model_Email_Template_Filter
14
- */
15
- class Jira_MageBridge_Model_Email_Template_Filter extends Mage_Core_Model_Email_Template_Filter
16
- {
17
- /**
18
- * Use absolute links flag
19
- *
20
- * @var bool
21
- */
22
- protected $_useAbsoluteLinks = true;
23
-
24
- /*
25
- * Override the default constructor to make sure the URLs are SEF-ed in emails
26
- */
27
- public function storeDirective($construction)
28
- {
29
- // Get the bridge URLs
30
- $bridge = Mage::getSingleton('magebridge/core');
31
- $joomla_url = $bridge->getMageBridgeUrl();
32
- $joomla_sef_url = $bridge->getMageBridgeSefUrl();
33
-
34
- // Remove the .html suffix from the URL
35
- if(preg_match('/\.html$/', $joomla_sef_url)) {
36
- $url_suffix = true;
37
- $joomla_sef_url = preg_replace( '/\.html$/', '', $joomla_sef_url );
38
- } else {
39
- $url_suffix = false;
40
- }
41
-
42
- // Call the parent function
43
- $url = parent::storeDirective($construction);
44
- $store_code = Mage::app()->getStore(Mage::getDesign()->getStore())->getCode();
45
- $url = str_replace($joomla_url, $joomla_sef_url, $url);
46
- $url = preg_replace( '/___store='.$store_code.'/', '', $url );
47
- $url = preg_replace( '/\?$/', '', $url );
48
- $url = preg_replace( '/\&$/', '', $url );
49
-
50
- // Return the URL
51
- return $url;
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Encryption.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Encryption extends Mage_Core_Model_Abstract
13
- {
14
- /*
15
- * Get some kind of string that is specific for this host
16
- */
17
- public function getKey($string)
18
- {
19
- return md5(Mage::getSingleton('magebridge/core')->getLicenseKey().$string);
20
- }
21
-
22
- /*
23
- * Encrypt data for security
24
- */
25
- public function encrypt($data)
26
- {
27
- $data = trim($data);
28
- $random = str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
29
- $key = $this->getKey($random);
30
-
31
- $iv = substr($key, 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
32
-
33
- $encrypted = mcrypt_cfb (MCRYPT_CAST_256, $key, $data, MCRYPT_ENCRYPT, $iv);
34
- $encoded = base64_encode($encrypted);
35
- return $encoded.'|'.$random;
36
- }
37
-
38
- /*
39
- * Decrypt data after encryption
40
- */
41
- public function decrypt($data)
42
- {
43
- if(empty($data)) {
44
- return null;
45
- }
46
-
47
- // This is a serious bug: Base64-encoding can include plus-signs, but JSON thinks these are URL-encoded spaces.
48
- // We have to convert them back manually. Ouch! Another solution would be to migrate from JSON to another transport mechanism. Again ouch!
49
- $data = str_replace(' ', '+', $data);
50
-
51
- $array = explode( '|', $data);
52
- if(isset($array[0]) && isset($array[1])) {
53
- $encrypted = base64_decode($array[0], true);
54
- $key = $this->getKey($array[1]);
55
- $iv = substr($key, 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
56
- } else {
57
- return null;
58
- }
59
-
60
-
61
- try {
62
- $decrypted = mcrypt_cfb (MCRYPT_CAST_256, $key, $encrypted, MCRYPT_DECRYPT, $iv);
63
- $decrypted = trim($decrypted);
64
- return $decrypted;
65
-
66
- } catch(Exception $e) {
67
- Mage::getSingleton('magebridge/debug')->error("Error while decrypting: ".$e->getMessage());
68
- return null;
69
- }
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Headers.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Headers extends Jira_MageBridge_Model_Block
13
- {
14
- public static function getHeaders()
15
- {
16
- Mage::getSingleton('magebridge/debug')->notice('Load headers');
17
- try {
18
- $controller = Mage::getSingleton('magebridge/core')->getController();
19
- $controller->getAction()->renderLayout();
20
-
21
- } catch(Exception $e) {
22
- Mage::getSingleton('magebridge/debug')->error('Failed to load controller: '.$e->getMessage());
23
- return false;
24
- }
25
-
26
- try {
27
- $head = $controller->getAction()->getLayout()->getBlock('head');
28
- if(!empty($head)) {
29
- $headers = $head->getData();
30
- foreach($headers['items'] as $index => $item) {
31
-
32
- $item['path'] = null;
33
- switch($item['type']) {
34
-
35
- case 'js':
36
- case 'js_css':
37
- $item['path'] = 'js/'.$item['name'];
38
- break;
39
-
40
- case 'skin_js':
41
- case 'skin_css':
42
- $item['path'] = Mage::getDesign()->getSkinUrl($item['name']);
43
- break;
44
-
45
- default:
46
- $item['path'] = null;
47
- break;
48
- }
49
-
50
- $headers['items'][$index] = $item;
51
- }
52
- return $headers;
53
- }
54
- return false;
55
-
56
- } catch( Exception $e) {
57
- Mage::getSingleton('magebridge/debug')->error('Failed to get headers: '.$e->getMessage());
58
- return false;
59
- }
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Listener.php DELETED
@@ -1,716 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- @todo Use a more generic way to fetch arguments from the event-object (getArguments?)
14
- @todo New events:
15
- - sales_convert_quote_to_order
16
- - sales_order_invoice_cancel
17
- - sales_order_invoice_pay
18
- */
19
-
20
- class Jira_MageBridge_Model_Listener extends Mage_Core_Model_Abstract
21
- {
22
- /*
23
- * Method to list all current events
24
- */
25
- public function getEvents()
26
- {
27
- return array(
28
- array('address_save_after', 1),
29
- array('admin_session_user_login_success', 0),
30
- array('adminhtml_customer_save_after', 1),
31
- array('adminhtml_customer_delete_after', 1),
32
- array('catalog_product_save_after', 0),
33
- array('catalog_product_delete_after', 0),
34
- array('catalog_category_save_after', 0),
35
- array('catalog_category_delete_after', 0),
36
- array('catalog_product_status_update', 0),
37
- array('checkout_cart_add_product_complete', 0),
38
- array('checkout_controller_onepage_save_shipping_method', 0),
39
- array('checkout_onepage_controller_success_action', 1),
40
- array('checkout_type_onepage_save_order_after', 0),
41
- array('customer_delete_after', 1),
42
- array('customer_login', 0),
43
- array('customer_logout', 0),
44
- array('customer_save_after', 1),
45
- array('sales_convert_order_to_quote', 0),
46
- array('sales_quote_save_after', 0),
47
- array('sales_quote_place_after', 0),
48
- );
49
- }
50
-
51
- /*
52
- * Method fired on the event <address_save_after>
53
- */
54
- public function addressSaveAfter($observer)
55
- {
56
- // Check if this event is enabled
57
- if($this->isEnabled($observer->getEventName()) == false) {
58
- return $this;
59
- }
60
-
61
- $address = $observer->getEvent()->getObject();
62
- $arguments = array(
63
- 'address' => $this->_getAddressArray($address),
64
- );
65
-
66
- $this->fireEvent('address_save_after', $arguments);
67
- return $this;
68
- }
69
-
70
- /*
71
- * Method fired on the event <admin_session_user_login_success>
72
- */
73
- public function adminSessionUserLoginSuccess($observer)
74
- {
75
- // Check if this event is enabled
76
- if($this->isEnabled($observer->getEventName()) == false) {
77
- return $this;
78
- }
79
-
80
- $user = $observer->getEvent()->getUser();
81
- $arguments = array(
82
- 'user' => $this->_getUserArray($user),
83
- );
84
-
85
- $this->fireEvent('admin_session_user_login_success', $arguments);
86
- return $this;
87
- }
88
-
89
- /*
90
- * Method fired on the event <adminhtml_customer_save_after>
91
- */
92
- public function adminhtmlCustomerSaveAfter($observer)
93
- {
94
- // Check if this event is enabled
95
- if($this->isEnabled($observer->getEventName()) == false) {
96
- return $this;
97
- }
98
-
99
- $customer = $observer->getEvent()->getCustomer();
100
- $arguments = array(
101
- 'customer' => $this->_getCustomerArray($customer),
102
- );
103
-
104
- $this->fireEvent('customer_save_after', $arguments);
105
- return $this;
106
- }
107
-
108
- /*
109
- * Method fired on the event <adminhtml_customer_delete_after>
110
- */
111
- public function adminhtmlCustomerDeleteAfter($observer)
112
- {
113
- // Check if this event is enabled
114
- if($this->isEnabled($observer->getEventName()) == false) {
115
- return $this;
116
- }
117
-
118
- $customer = $observer->getEvent()->getCustomer();
119
- $arguments = array(
120
- 'customer' => $this->_getCustomerArray($customer),
121
- );
122
-
123
- $this->fireEvent('customer_delete_after', $arguments);
124
- return $this;
125
- }
126
-
127
- /*
128
- * Method fired on the event <catalog_product_save_after>
129
- */
130
- public function catalogProductSaveAfter($observer)
131
- {
132
- // Check if this event is enabled
133
- if($this->isEnabled($observer->getEventName()) == false) {
134
- return $this;
135
- }
136
-
137
- $product = $observer->getEvent()->getObject();
138
- $arguments = array(
139
- 'product' => $this->_getProductArray($product),
140
- );
141
-
142
- $this->fireEvent('catalog_product_save_after', $arguments);
143
- return $this;
144
- }
145
-
146
- /*
147
- * Method fired on the event <catalog_product_delete_after>
148
- */
149
- public function catalogProductDeleteAfter($observer)
150
- {
151
- // Check if this event is enabled
152
- if($this->isEnabled($observer->getEventName()) == false) {
153
- return $this;
154
- }
155
-
156
- $product = $observer->getEvent()->getObject();
157
- $arguments = array(
158
- 'product' => $this->_getProductArray($product),
159
- );
160
-
161
- $this->fireEvent('catalog_product_delete_after', $arguments);
162
- return $this;
163
- }
164
-
165
- /*
166
- * Method fired on the event <catalog_category_save_after>
167
- */
168
- public function catalogCategorySaveAfter($observer)
169
- {
170
- // Check if this event is enabled
171
- if($this->isEnabled($observer->getEventName()) == false) {
172
- return $this;
173
- }
174
-
175
- $category = $observer->getEvent()->getObject();
176
- $arguments = array(
177
- 'category' => $this->_getCategoryArray($category),
178
- );
179
-
180
- $this->fireEvent('catalog_category_save_after', $arguments);
181
- return $this;
182
- }
183
-
184
- /*
185
- * Method fired on the event <catalog_category_delete_after>
186
- */
187
- public function catalogCategoryDeleteAfter($observer)
188
- {
189
- // Check if this event is enabled
190
- if($this->isEnabled($observer->getEventName()) == false) {
191
- return $this;
192
- }
193
-
194
- $category = $observer->getEvent()->getObject();
195
- $arguments = array(
196
- 'category' => $this->_getCategoryArray($category),
197
- );
198
-
199
- $this->fireEvent('catalog_category_delete_after', $arguments);
200
- return $this;
201
- }
202
-
203
- /*
204
- * Method fired on the event <catalog_product_status_update>
205
- */
206
- public function catalogProductStatusUpdate($observer)
207
- {
208
- // Check if this event is enabled
209
- if($this->isEnabled($observer->getEventName()) == false) {
210
- return $this;
211
- }
212
-
213
- $product_id = $observer->getEvent()->getProductId();
214
- $store_id = $observer->getEvent()->getStoreId();
215
- $arguments = array(
216
- 'product' => $product_id,
217
- 'store_id' => $store_id,
218
- );
219
-
220
- $this->fireEvent('catalog_product_status_update', $arguments);
221
- return $this;
222
- }
223
-
224
- /*
225
- * Method fired on the event <checkout_cart_add_product_complete>
226
- */
227
- public function checkoutCartAddProductComplete($observer)
228
- {
229
- // Check if this event is enabled
230
- if($this->isEnabled($observer->getEventName()) == false) {
231
- return $this;
232
- }
233
-
234
- $product = $observer->getEvent()->getProduct();
235
- $request = $observer->getEvent()->getRequest();
236
-
237
- $arguments = array(
238
- 'product' => $this->_getProductArray($product),
239
- 'request' => $request->getParams(),
240
- );
241
-
242
- $this->fireEvent('checkout_cart_add_product_complete', $arguments);
243
- return $this;
244
- }
245
-
246
- /*
247
- * Method fired on the event <checkout_controller_onepage_save_shipping_method>
248
- */
249
- public function checkoutControllerOnepageSaveShippingMethod($observer)
250
- {
251
- // Check if this event is enabled
252
- if($this->isEnabled($observer->getEventName()) == false) {
253
- return $this;
254
- }
255
-
256
- $quote = $observer->getEvent()->getQuote();
257
- $request = $observer->getEvent()->getRequest();
258
-
259
- $arguments = array(
260
- 'quote' => $this->_getQuoteArray($quote),
261
- 'request' => $request->getParams(),
262
- );
263
-
264
- $this->fireEvent('checkout_controller_onepage_save_shipping_method', $arguments);
265
- return $this;
266
- }
267
-
268
- /*
269
- * Method fired on the event <checkout_onepage_controller_success_action>
270
- */
271
- public function checkoutOnepageControllerSuccessAction($observer)
272
- {
273
- // Check if this event is enabled
274
- if($this->isEnabled($observer->getEventName()) == false) {
275
- return $this;
276
- }
277
-
278
- $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
279
- $order = Mage::getModel('sales/order')->load($orderId);
280
- $arguments = array(
281
- 'order' => $this->_getOrderArray($order),
282
- );
283
-
284
- //file_put_contents( '/tmp/magebridge.debug', "checkoutOnepageControllerSuccessAction\r\n", FILE_APPEND );
285
- //file_put_contents( '/tmp/magebridge.debug', var_export($arguments,true)."\r\n", FILE_APPEND );
286
- $this->fireEvent('checkout_onepage_controller_success_action', $arguments);
287
- return $this;
288
- }
289
-
290
- /*
291
- * Method fired on the event <checkout_type_onepage_save_order_after>
292
- */
293
- public function checkoutTypeOnepageSaveOrderAfter($observer)
294
- {
295
- // Check if this event is enabled
296
- if($this->isEnabled($observer->getEventName()) == false) {
297
- return $this;
298
- }
299
-
300
- $order = $observer->getEvent()->getOrder();
301
- $quote = Mage::getSingleton('checkout/session')->getQuote();
302
-
303
- $arguments = array(
304
- 'order' => $this->_getOrderArray($order),
305
- 'quote' => $this->_getQuoteArray($quote),
306
- );
307
-
308
- $this->fireEvent('checkout_type_onepage_save_order_after', $arguments);
309
- return $this;
310
- }
311
-
312
- /*
313
- * Method fired on the event <customer_delete_after>
314
- */
315
- public function customerDeleteAfter($observer)
316
- {
317
- // Check if this event is enabled
318
- if($this->isEnabled($observer->getEventName()) == false) {
319
- return $this;
320
- }
321
-
322
- $customer = $observer->getEvent()->getCustomer();
323
- $arguments = array(
324
- 'customer' => $this->_getCustomerArray($customer),
325
- );
326
-
327
- $this->fireEvent('customer_delete_after', $arguments);
328
- return $this;
329
- }
330
-
331
- /*
332
- * Method fired on the event <customer_login>
333
- */
334
- public function customerLogin($observer)
335
- {
336
- // Check if this event is enabled
337
- if($this->isEnabled($observer->getEventName()) == false) {
338
- return $this;
339
- }
340
-
341
- $customer = $observer->getEvent()->getCustomer();
342
- $arguments = array(
343
- 'customer' => $this->_getCustomerArray($customer),
344
- );
345
-
346
- $this->fireEvent('customer_login', $arguments);
347
- $this->addEvent('magento', 'customer_login_after', $arguments);
348
- return $this;
349
- }
350
-
351
- /*
352
- * Method fired on the event <customer_logout>
353
- */
354
- public function customerLogout($observer)
355
- {
356
- // Check if this event is enabled
357
- if($this->isEnabled($observer->getEventName()) == false) {
358
- return $this;
359
- }
360
-
361
- $customer = $observer->getEvent()->getCustomer();
362
- $arguments = array(
363
- 'customer' => $this->_getCustomerArray($customer),
364
- );
365
-
366
- $this->fireEvent('customer_logout', $arguments);
367
- $this->addEvent('magento', 'customer_logout_after', $arguments);
368
- return $this;
369
- }
370
-
371
- /*
372
- * Method fired on the event <customer_save_after>
373
- */
374
- public function customerSaveAfter($observer)
375
- {
376
- // Check if this event is enabled
377
- if($this->isEnabled($observer->getEventName()) == false) {
378
- return $this;
379
- }
380
-
381
- return $this;
382
- $customer = $observer->getEvent()->getCustomer();
383
- $arguments = array(
384
- 'customer' => $this->_getCustomerArray($customer),
385
- );
386
-
387
- $this->fireEvent('customer_save_after', $arguments);
388
- return $this;
389
- }
390
-
391
- /*
392
- * Method fired on the event <joomla_on_after_delete_user>
393
- */
394
- public function joomlaOnAfterDeleteUser($arguments)
395
- {
396
- return $this;
397
- }
398
-
399
- /*
400
- * Method fired on the event <sales_convert_order_to_quote>
401
- */
402
- public function salesConvertOrderToQuote($observer)
403
- {
404
- // Check if this event is enabled
405
- if($this->isEnabled($observer->getEventName()) == false) {
406
- return $this;
407
- }
408
-
409
- $order = $observer->getEvent()->getOrder();
410
- $quote = $observer->getEvent()->getQuote();
411
-
412
- $arguments = array(
413
- 'order' => $this->_getOrderArray($order),
414
- 'quote' => $this->_getQuoteArray($quote),
415
- );
416
-
417
- $this->fireEvent('sales_convert_order_to_quote', $arguments);
418
- return $this;
419
- }
420
-
421
- /*
422
- * Method fired on the event <sales_order_place_after>
423
- */
424
- public function salesOrderPlaceAfter($observer)
425
- {
426
- // Check if this event is enabled
427
- if($this->isEnabled($observer->getEventName()) == false) {
428
- return $this;
429
- }
430
-
431
- $order = $observer->getEvent()->getOrder();
432
- $arguments = array(
433
- 'order' => $this->_getOrderArray($order),
434
- );
435
-
436
- $this->fireEvent('sales_order_place_after', $arguments);
437
- return $this;
438
- }
439
-
440
- /*
441
- * Method fired on the event <sales_order_save_after>
442
- */
443
- public function salesOrderSaveAfter($observer)
444
- {
445
- // Check if this event is enabled
446
- if($this->isEnabled($observer->getEventName()) == false) {
447
- return $this;
448
- }
449
-
450
- $order = $observer->getEvent()->getOrder();
451
- $arguments = array(
452
- 'order' => $this->_getOrderArray($order),
453
- );
454
-
455
- $this->fireEvent('sales_order_save_after', $arguments);
456
- return $this;
457
- }
458
-
459
- /*
460
- * Method that adds this event to the Joomla! bridge-reply
461
- */
462
- public function addEvent($group = null, $event = null, $arguments = null)
463
- {
464
- // Exit if the event-name is empty
465
- if(empty($event)) {
466
- Mage::getSingleton('magebridge/debug')->notice('Listener: Empty event');
467
- return false;
468
- }
469
-
470
- // Exit if forwarding of this event is disabled
471
- if($this->isEnabled($event) == false) {
472
- return false;
473
- }
474
-
475
- // Convert the lower-case event-name to camelCase
476
- $event = $this->_convertEventName($event);
477
-
478
- // Add this event to the response-data
479
- Mage::getSingleton('magebridge/debug')->notice('Listener: Adding event "'.$event.'" to the response-data');
480
- Mage::getSingleton('magebridge/session')->addEvent($group, $event, $arguments);
481
- }
482
-
483
- /*
484
- * Method that forwards the event to Joomla! straight-away through XML-RPC
485
- */
486
- public function fireEvent($event = null, $arguments = null)
487
- {
488
- // Exit if the event-name is empty
489
- if(empty($event)) {
490
- Mage::getSingleton('magebridge/debug')->notice('Listener: Empty event');
491
- return false;
492
- }
493
-
494
- // Exit if forwarding of this event is disabled
495
- if($this->isEnabled($event) == false) {
496
- Mage::getSingleton('magebridge/debug')->notice('Listener: Event "'.$event.'" is disabled');
497
- return false;
498
- }
499
-
500
- // Force the argument as struct
501
- if(!is_array($arguments)) {
502
- $arguments = array('null' => 'null');
503
- }
504
-
505
- Mage::getSingleton('magebridge/debug')->notice('Listener: Forwarding event "'.$event.'" through XML-RPC');
506
-
507
- // Convert the lower-case event-name to camelCase
508
- $event = $this->_convertEventName($event);
509
-
510
- // Initialize the multi-call array, add the event to it and make the call
511
- Mage::getSingleton('magebridge/client')->addDebug();
512
- Mage::getSingleton('magebridge/client')->addCall('magebridge.event', array($event, $arguments));
513
- Mage::getSingleton('magebridge/client')->multicall();
514
-
515
- // There should be no more debugging after this
516
- return true;
517
- }
518
-
519
- /*
520
- * Method to check if an event is enabled or not
521
- */
522
- public function isEnabled($event)
523
- {
524
- $enabled = Mage::getStoreConfig('magebridge/settings/event_forwarding/'.$event);
525
- if($enabled != null) {
526
- return (boolean)$enabled;
527
- }
528
- return true;
529
- }
530
-
531
- /*
532
- * Method to convert an underscore-based event-name to camelcase
533
- */
534
- public function _convertEventName($event)
535
- {
536
- $event_parts = explode('_', $event);
537
- $event = 'mage';
538
- foreach($event_parts as $part) {
539
- $event .= ucfirst($part);
540
- }
541
- return $event;
542
- }
543
-
544
- /*
545
- * Method that returns address-data as a basic array
546
- */
547
- private function _getAddressArray($address)
548
- {
549
- if(empty($address)) return;
550
-
551
- // Small hack to make sure we load the English country-name
552
- Mage::getSingleton('core/locale')->setLocale('en_US');
553
-
554
- $addressArray[] = array_merge($this->_cleanAssoc($address->debug()), $this->_cleanAssoc(array(
555
- 'country' => $address->getCountryModel()->getName(),
556
- 'is_subscribed' => $address->getIsSubscribed(),
557
- )));
558
-
559
- return $addressArray;
560
- }
561
-
562
- /*
563
- * Method that returns customer-data as a basic array
564
- */
565
- private function _getCustomerArray($customer)
566
- {
567
- if(empty($customer)) return;
568
-
569
- $addresses = $customer->getAddresses();
570
- $addressArray = array();
571
- if(!empty($addresses)) {
572
- foreach($addresses as $address) {
573
- $addressArray[] = $this->_getAddressArray($address);
574
- }
575
- }
576
-
577
- $customerArray = array_merge($this->_cleanAssoc($customer->debug()), $this->_cleanAssoc(array(
578
- 'customer_id' => $customer->getId(),
579
- 'name' => $customer->getName(),
580
- 'addresses' => $addressArray,
581
- 'session' => Mage::getSingleton('magebridge/core')->getMetaData('joomla_session'),
582
- )));
583
-
584
- if(!empty($customerArray['password'])) {
585
- $customerArray['password'] = Mage::getSingleton('magebridge/encryption')->encrypt($customerArray['password']);
586
- }
587
-
588
- return $customerArray;
589
- }
590
-
591
- /*
592
- * Method that returns order-data as a basic array
593
- */
594
- private function _getOrderArray($order)
595
- {
596
- if(empty($order)) return;
597
-
598
- $products = array();
599
- foreach ($order->getAllItems() as $item) {
600
- $product = $this->_cleanAssoc(array(
601
- 'id' => $item->getId(),
602
- 'sku' => $item->getSku(),
603
- 'name' => $item->getName(),
604
- 'product_type' => $item->getProductType(),
605
- ));
606
- $products[] = $product;
607
- }
608
-
609
- $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
610
-
611
- $orderArray = $this->_cleanAssoc($order->debug());
612
- $orderArray['order_id'] = $order->getId();
613
- $orderArray['customer'] = $this->_getCustomerArray($customer);
614
- $orderArray['products'] = $products;
615
-
616
- return $orderArray;
617
- }
618
-
619
- /*
620
- * Method that returns quote-data as a basic array
621
- */
622
- private function _getQuoteArray($quote)
623
- {
624
- if(empty($quote)) return;
625
-
626
- $products = array();
627
- foreach ($quote->getAllItems() as $item) {
628
- $product = $this->_cleanAssoc(array(
629
- 'id' => $item->getId(),
630
- 'sku' => $item->getSku(),
631
- 'name' => $item->getName(),
632
- 'product_type' => $item->getProductType(),
633
- ));
634
- $products[] = $product;
635
- }
636
-
637
- $quoteArray = $this->_cleanAssoc(array(
638
- 'quote_id' => $quote->getId(),
639
- 'quote' => $quote->debug(),
640
- 'customer' => $this->_getCustomerArray($quote->getCustomer()),
641
- 'products' => $products,
642
- ));
643
-
644
- return $quoteArray;
645
- }
646
-
647
- /*
648
- * Method that returns user-data as a basic array
649
- */
650
- private function _getUserArray($user)
651
- {
652
- if(empty($user)) return;
653
-
654
- $userArray = $this->_cleanAssoc(array(
655
- 'user_id' => $user->getId(),
656
- 'user' => $user->debug(),
657
- 'name' => $user->getName(),
658
- 'email' => $user->getEmail(),
659
- ));
660
-
661
- return $userArray;
662
- }
663
-
664
- /*
665
- * Method that returns product-data as a basic array
666
- */
667
- private function _getProductArray($product)
668
- {
669
- if(empty($product)) return;
670
-
671
- $productArray = $this->_cleanAssoc(array(
672
- 'product_id' => $product->getId(),
673
- 'sku' => $product->getSKU(),
674
- 'name' => $product->getName(),
675
- 'status' => $product->getStatus(),
676
- 'price' => $product->getFinalPrice(),
677
- 'category_id' => $product->getCategoryId(),
678
- 'category_ids' => $product->getCategoryIds(),
679
- 'product_type' => $product->getProductType(),
680
- 'product_url' => $product->getProductUrl(false),
681
- 'images' => $product->getMediaGallery('images'),
682
- 'debug' => $product->debug(),
683
- ));
684
-
685
- return $productArray;
686
- }
687
-
688
- /*
689
- * Method that returns category-data as a basic array
690
- */
691
- private function _getCategoryArray($category)
692
- {
693
- if(empty($category)) return;
694
-
695
- $categoryArray = $this->_cleanAssoc(array(
696
- 'category_id' => $category->getId(),
697
- 'name' => $category->getName(),
698
- 'debug' => $category->debug(),
699
- ));
700
-
701
- return $categoryArray;
702
- }
703
-
704
- /*
705
- * Helper-method that cleans an associative array to prevent empty values
706
- */
707
- private function _cleanAssoc($assoc)
708
- {
709
- if(!empty($assoc)) {
710
- foreach ($assoc as $name => $value) {
711
- if(empty($value)) unset($assoc[$name]);
712
- }
713
- }
714
- return $assoc;
715
- }
716
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Messages.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Messages extends Jira_MageBridge_Model_Block
13
- {
14
- public static function getMessages()
15
- {
16
- $classes = array(
17
- 'core/session',
18
- 'customer/session',
19
- 'checkout/session',
20
- 'catalog/session',
21
- 'tag/session',
22
- );
23
-
24
- $messages = array();
25
- try {
26
- foreach($classes as $class) {
27
- $messages = array_merge($messages, Mage::getModel('magebridge/messages')->_getMessages($class));
28
- }
29
-
30
- } catch(Exception $e) {
31
- Mage::getSingleton('magebridge/debug')->error('Failed to load messages: '.$e->getMessage());
32
- }
33
-
34
- return $messages;
35
- }
36
-
37
- public static function _getMessages($class)
38
- {
39
- try {
40
- $items = Mage::getSingleton($class)->getMessages()->getItems();
41
- $messages = array();
42
-
43
- foreach($items as $item) {
44
- $messages[] = array(
45
- 'type' => $item->getType(),
46
- 'message' => $item->getCode()
47
- );
48
- }
49
-
50
- return $messages;
51
-
52
- } catch( Exception $e) {
53
- Mage::getSingleton('magebridge/debug')->error('Failed to get messages: '.$e->getMessage());
54
-
55
- }
56
- return array();
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Order/Api.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Order_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- /**
15
- * Retrieve list of orders with basic info
16
- *
17
- * @param array $filters
18
- * @return array
19
- */
20
- public function items($filters = null, $store = null)
21
- {
22
- $collection = Mage::getModel('sales/order')->getCollection()
23
- ->addAttributeToSelect('*')
24
- ->setOrder('created_at', 'desc')
25
- ->setPageSize(20)
26
- ->load()
27
- ;
28
-
29
- /*
30
- * @todo: This does not work, but is still needed: $filter = array( array('title' => array('nlike' => array('%a', '%b'))));
31
- */
32
- if (is_array($filters)) {
33
- try {
34
- foreach ($filters as $field => $value) {
35
- if (isset($this->_filtersMap[$field])) {
36
- $field = $this->_filtersMap[$field];
37
- }
38
-
39
- $collection->addFieldToFilter($field, $value);
40
- }
41
- } catch (Mage_Core_Exception $e) {
42
- $this->_fault('filters_invalid', $e->getMessage());
43
- }
44
- }
45
-
46
- $result = array();
47
- foreach ($collection as $order) {
48
- $order->base_grand_total_formatted = $order->formatPrice($order->getBaseGrandTotal());
49
- $result[] = $order->debug();
50
- }
51
-
52
- return $result;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Product/Api.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Product_Api extends Mage_Catalog_Model_Product_Api
13
- {
14
- /**
15
- * Search for products
16
- *
17
- * @param array $options
18
- * @return array
19
- */
20
- public function search($options = array())
21
- {
22
- // Construct the API-arguments
23
- $arguments = array(
24
- 'store' => $options['store'],
25
- 'website' => $options['website'],
26
- 'count' => $options['search_limit'],
27
- 'page' => 0,
28
- 'visibility' => array(
29
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH,
30
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
31
- ),
32
- );
33
-
34
- // Construct the search-filters
35
- $text = $options['text'];
36
- $arguments['filters'] = array(
37
- // @todo: Currently it's only possible to use AND. Is it also possible to have OR?
38
- //'name' => array( 'like' => "%$text%" ),
39
- 'description' => array( 'like' => "%$text%" ),
40
- );
41
-
42
- // Return the list of products
43
- return Mage::getModel('magebridge/product_api')->items($arguments);
44
- }
45
-
46
- /**
47
- * Retrieve list of products with basic info (id, sku, type, set, name)
48
- *
49
- * @param array $filters
50
- * @param string|int $store
51
- * @return array
52
- */
53
- public function items($arguments = null, $store = null)
54
- {
55
- // Set the visibility
56
- if(isset($arguments['visibility'])) {
57
- $visibility = $arguments['visibility'];
58
- } else {
59
- $visibility = array(
60
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH,
61
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
62
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
63
- );
64
- }
65
-
66
- // Get the product-collection
67
- $collection = Mage::getModel('catalog/product')->getCollection()
68
- ->addAttributeToFilter('visibility', $visibility)
69
- ->addAttributeToSelect('*')
70
- ->addFieldToFilter('status', 1)
71
- ;
72
-
73
- // Set the website
74
- if(!empty($arguments['website'])) {
75
- $collection->addWebsiteFilter($arguments['website']);
76
- }
77
-
78
- // Set the store
79
- if(!empty($arguments['store'])) {
80
- $collection->addStoreFilter($arguments['store']);
81
- }
82
-
83
-
84
- // Add the category
85
- if(isset($arguments['category_id']) && $arguments['category_id'] > 0) {
86
- $collection->addAttributeToFilter('category_ids', array('finset' => $arguments['category_id']));
87
- }
88
-
89
- // Add a filter
90
- // Example 1: array('title' => array('nlike' => array('%a', '%b')))
91
- // Example 2: array( array('attribute'=>'name', 'like'=>'P%')))
92
- // Example 3: array(
93
- // array('attribute'=>'price','lt'=>'20'),
94
- // array('attribute'=>'name','like'=>'Product C')
95
- // ));
96
- if (isset($arguments['filters']) && is_array($arguments['filters'])) {
97
- $filters = $arguments['filters'];
98
- try {
99
- foreach ($filters as $field => $value) {
100
- $collection->addFieldToFilter($field, $value);
101
- }
102
- } catch (Mage_Core_Exception $e) {
103
- Mage::getSingleton('magebridge/debug')->error('Invalid search filter', $e->getMessage());
104
- }
105
- }
106
-
107
- // Set ordering
108
- if(isset($arguments['ordering'])) {
109
- switch($arguments['ordering']) {
110
- case 'newest':
111
- $collection->setOrder('created_at', 'desc');
112
- break;
113
- case 'oldest':
114
- $collection->setOrder('created_at', 'asc');
115
- break;
116
- case 'popular':
117
- $collection->setOrder('ordered_qty', 'desc');
118
- break;
119
- case 'random':
120
- $collection->getSelect()->order('rand()');
121
- break;
122
- }
123
- }
124
-
125
- // Add a list limit
126
- if(isset($arguments['count'])) {
127
- $collection->setPageSize($arguments['count']);
128
- }
129
-
130
- // Add a page number
131
- if(isset($arguments['page']) && $arguments['page'] > 0) {
132
- $collection->setCurPage($arguments['page']);
133
- }
134
-
135
- $result = array();
136
- foreach ($collection as $product) {
137
-
138
- $result[] = array( // Basic product data
139
- 'product_id' => $product->getId(),
140
- 'sku' => $product->getSku(),
141
- 'name' => $product->getName(),
142
- 'description' => $product->getShortDescription(),
143
- 'short_description' => $product->getShortDescription(),
144
- 'label' => htmlentities($product->getName()),
145
- 'author' => $product->getAuthor(),
146
- 'url_key' => $product->getUrlKey(),
147
- 'url' => $product->getProductUrl(false),
148
- 'category_ids' => $product->getCategoryIds(),
149
- 'thumbnail' => $product->getSmallImageUrl(),
150
- 'price' => Mage::app()->getStore()->formatPrice($product->getPrice()),
151
- 'special_price' => $product->getSpecialPrice(),
152
- 'special_from_date' => $product->getSpecialFromDate(),
153
- 'special_to_date' => $product->getSpecialToDate(),
154
- 'is_active' => 1,
155
- );
156
- }
157
-
158
- return $result;
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Search.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Search extends Jira_MageBridge_Model_Block
13
- {
14
- public static function getSearch($arguments)
15
- {
16
- $query = Mage::getModel('catalogsearch/query')
17
- ->loadByQuery($arguments)
18
- ->setQueryText($arguments);
19
-
20
- foreach($items as $item) {
21
- $messages[] = array(
22
- 'type' => $item->getType(),
23
- 'message' => $item->getCode()
24
- );
25
- }
26
-
27
- return $messages;
28
-
29
- return array();
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Session.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- * Class for importing and exporting data out of a session
14
- */
15
- class Jira_MageBridge_Model_Session extends Mage_Core_Model_Session_Abstract
16
- {
17
- public function __construct()
18
- {
19
- $this->init('magebridge');
20
- }
21
-
22
- public function addEvent($group, $event, $arguments)
23
- {
24
- $events = $this->getData('events');
25
- if(empty($events)) $events = array();
26
-
27
- $events[] = array(
28
- 'type' => 'magento',
29
- 'group' => $group,
30
- 'event' => $event,
31
- 'arguments' => $arguments,
32
- );
33
- $this->setData('events', $events);
34
- }
35
-
36
- public function getEvents()
37
- {
38
- return $this->getData('events');
39
- }
40
-
41
- public function cleanEvents()
42
- {
43
- $this->setData('events');
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Storegroups/Api.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Storegroups_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- public function items()
15
- {
16
- $groups = Mage::getModel('core/store_group')->getCollection();
17
-
18
- $res = array();
19
- foreach ($groups as $item) {
20
- $data['value'] = $item->getData('group_id');
21
- $data['label'] = $item->getData('name');
22
- $res[] = $data;
23
- }
24
- return $res;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Storeviews/Api.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Storeviews_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- public function items()
15
- {
16
- $views = Mage::getModel('core/store')->getCollection();
17
-
18
- $res = array();
19
- foreach ($views as $item) {
20
- $data = array();
21
- $data['value'] = $item->getData('code');
22
- $data['label'] = $item->getData('name');
23
- $res[] = $data;
24
- }
25
- return $res;
26
- }
27
-
28
- public function hierarchy()
29
- {
30
- $groups = Mage::getModel('core/store_group')->getCollection();
31
- $views = Mage::getModel('core/store')->getCollection();
32
-
33
- $res = array();
34
- foreach ($groups as $item) {
35
- $data['value'] = $item->getData('group_id');
36
- $data['label'] = $item->getData('name');
37
- $data['childs'] = array();
38
-
39
- foreach($views as $view) {
40
- $child = array(
41
- 'value' => $view->getData('code'),
42
- 'label' => $view->getData('name'),
43
- );
44
- $data['childs'][] = $child;
45
- }
46
- $res[] = $data;
47
- }
48
- return $res;
49
- }
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Tag/Api.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Tag_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- public function items($tags = array())
15
- {
16
- if(empty($tags) || !is_array($tags)) {
17
- return false;
18
- }
19
-
20
- $result = array();
21
-
22
- foreach($tags as $tag) {
23
-
24
- $tagModel = Mage::getModel('tag/tag')->loadByName((string)$tag);
25
- $products = $tagModel->getEntityCollection()->addTagFilter($tagModel->getTagId());
26
-
27
- foreach($products as $product) {
28
- $p = array();
29
- $p['name'] = $product->getName();
30
- $p['url'] = $product->getProductUrl(false);
31
- $result[$product->getId()] = $p;
32
- }
33
- }
34
-
35
- return $result;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Update.php CHANGED
@@ -41,8 +41,7 @@ class Jira_MageBridge_Model_Update extends Mage_Core_Model_Abstract
41
 
42
  public function upgradeNeeded()
43
  {
44
- // @todo: This doesn't work if version 111 is higher than 92
45
- if($this->getNewVersion() > $this->getCurrentVersion()) {
46
  return true;
47
  }
48
  return true;
@@ -64,7 +63,7 @@ class Jira_MageBridge_Model_Update extends Mage_Core_Model_Abstract
64
  require_once 'Maged/Pear.php';
65
 
66
  } catch(Exception $e) {
67
- return 'Failed to prepare PEAR: '.$e->getMessage();
68
  }
69
 
70
  $pear = new Maged_Pear();
@@ -75,7 +74,7 @@ class Jira_MageBridge_Model_Update extends Mage_Core_Model_Abstract
75
  );
76
 
77
  if(is_dir(dirname(__FILE__).DS.'.svn')) {
78
- return 'Updating Subversion environments is not allowed';
79
  }
80
 
81
  try {
@@ -88,15 +87,15 @@ class Jira_MageBridge_Model_Update extends Mage_Core_Model_Abstract
88
  // Reset the configuration cache
89
  Mage::getConfig()->removeCache();
90
 
91
- return 'PEAR result: '.(string)$result;
92
  } else {
93
- return 'Maged_Model_Pear_Request failed';
94
  }
95
  } catch(Exception $e) {
96
- return 'Failed to initialize PEAR: '.$e->getMessage();
97
  }
98
 
99
- return 'Upgrade failed by unknown error';
100
  }
101
 
102
  public function getCurrentVersion()
@@ -113,12 +112,17 @@ class Jira_MageBridge_Model_Update extends Mage_Core_Model_Abstract
113
  if(empty($this->_new_version)) {
114
  $arguments = array('resource' => 'versions', 'request' => 'downloads/magebridge');
115
  $url = $this->getApiLink($arguments);
116
- $this->_data = $this->_getRemote($url);
 
 
 
 
 
 
117
  try {
118
  $doc = new SimpleXMLElement($this->_data);
119
  } catch(Exception $e) {
120
- return 'Update check failed. Is your licensing correct?';
121
- //return 'XML-parsing failed in data: '.$this->_data.' :'.$e->getMessage();
122
  }
123
  $this->_new_version = (string)$doc->magento;
124
  }
41
 
42
  public function upgradeNeeded()
43
  {
44
+ if((int)$this->getNewVersion() > (int)$this->getCurrentVersion()) {
 
45
  return true;
46
  }
47
  return true;
63
  require_once 'Maged/Pear.php';
64
 
65
  } catch(Exception $e) {
66
+ return 'ERROR: Failed to prepare PEAR: '.$e->getMessage();
67
  }
68
 
69
  $pear = new Maged_Pear();
74
  );
75
 
76
  if(is_dir(dirname(__FILE__).DS.'.svn')) {
77
+ return 'ERROR: Updating Subversion environments is not allowed';
78
  }
79
 
80
  try {
87
  // Reset the configuration cache
88
  Mage::getConfig()->removeCache();
89
 
90
+ return 'ERROR: PEAR result: '.(string)$result;
91
  } else {
92
+ return 'ERROR: Maged_Model_Pear_Request failed';
93
  }
94
  } catch(Exception $e) {
95
+ return 'ERROR: Failed to initialize PEAR: '.$e->getMessage();
96
  }
97
 
98
+ return 'ERROR: Upgrade failed by unknown error';
99
  }
100
 
101
  public function getCurrentVersion()
112
  if(empty($this->_new_version)) {
113
  $arguments = array('resource' => 'versions', 'request' => 'downloads/magebridge');
114
  $url = $this->getApiLink($arguments);
115
+ $this->_data = trim($this->_getRemote($url));
116
+ if(preg_match('/^Restricted access/', $this->_data)) {
117
+ return 'ERROR: Restricted access. Is your licensing correct?';
118
+ } elseif(empty($this->_data)) {
119
+ return 'ERROR: Empty reply. Is CURL enabled?';
120
+ }
121
+
122
  try {
123
  $doc = new SimpleXMLElement($this->_data);
124
  } catch(Exception $e) {
125
+ return 'ERROR: Update check failed. Is your licensing correct?';
 
126
  }
127
  $this->_new_version = (string)$doc->magento;
128
  }
app/code/community/Jira/MageBridge/Model/Url.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Url extends Mage_Core_Model_Abstract
13
- {
14
- /**
15
- * Data
16
- *
17
- * @var mixed
18
- */
19
- var $_data = null;
20
-
21
- public function getData($type = 'product', $id = null)
22
- {
23
- static $urls = array();
24
- if(empty($urls[$type])) {
25
-
26
- $magebridge = Mage::getSingleton('magebridge/core');
27
- $urls[$type] = array();
28
-
29
- switch($type) {
30
-
31
- case 'category':
32
- $categories = Mage::getModel('catalog/category')->getTreeModel();
33
- $helper = Mage::helper('catalog/category');
34
- $categories = $helper->getStoreCategories('name', true, false);
35
- foreach($categories as $category) {
36
- $urls[$type][] = array( 'id' => $category->getId(), 'url' => $magebridge->parse($category->getUrl()));
37
- }
38
- break;
39
-
40
- case 'product':
41
- default:
42
- $products = Mage::getModel('catalog/product')->getCollection();
43
- foreach($products as $index => $product) {
44
- $urls[$type][] = array( 'id' => $product->getId(), 'url' => $magebridge->parse($product->getProductUrl()));
45
- }
46
- break;
47
- }
48
- }
49
-
50
- if($id > 0) {
51
- return $urls[$type][$id];
52
- } else {
53
- return (array)$urls[$type];
54
- }
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/User.php DELETED
@@ -1,323 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- define( 'MAGEBRIDGE_AUTHENTICATION_FAILURE', 0 );
13
- define( 'MAGEBRIDGE_AUTHENTICATION_SUCCESS', 1 );
14
- define( 'MAGEBRIDGE_AUTHENTICATION_ERROR', 2 );
15
-
16
- class Jira_MageBridge_Model_User extends Mage_Core_Model_Abstract
17
- {
18
- /**
19
- * Data
20
- */
21
- var $_data = null;
22
-
23
- /*
24
- * Perform a Single Sign On if told so in the bridge-request
25
- */
26
- public function doSSO()
27
- {
28
- // Get the SSO-flag from $_GET
29
- $sso = Mage::app()->getRequest()->getQuery('sso');
30
- $app = Mage::app()->getRequest()->getQuery('app');
31
-
32
- if(!empty($sso) && !empty($app)) {
33
-
34
- switch($sso) {
35
- case 'logout':
36
- $this->doSSOLogout($app);
37
- return true;
38
-
39
- case 'login':
40
- $this->doSSOLogin($app);
41
- return true;
42
- }
43
- }
44
-
45
- return false;
46
- }
47
-
48
- /*
49
- * Perform a Single Sign On logout
50
- */
51
- public function doSSOLogout($app) {
52
-
53
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin('.$app.'): '.session_id());
54
-
55
- // Initialize the session and end it
56
- if($app == 'admin') {
57
-
58
- Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
59
-
60
- $session = Mage::getSingleton('adminhtml/session');
61
- $session->unsetAll();
62
- setcookie( 'adminhtml', null );
63
- session_destroy();
64
-
65
- } else {
66
-
67
- Mage::getSingleton('core/session', array('name'=>'frontend'));
68
- Mage::getSingleton('customer/session')->logout();
69
- setcookie( 'frontend', null );
70
- session_destroy();
71
-
72
- }
73
-
74
- // Send the logs through XML-RPC before exiting
75
- Mage::getSingleton('magebridge/client')->addDebug();
76
- Mage::getSingleton('magebridge/client')->multicall();
77
-
78
- // Redirect
79
- header( 'HTTP/1.1 302');
80
- header( 'Location: '.base64_decode(Mage::app()->getRequest()->getQuery('redirect')));
81
- return true;
82
- }
83
-
84
- /*
85
- * Perform a Single Sign On login
86
- */
87
- public function doSSOLogin($app) {
88
-
89
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin ['.$app.']: '.session_id());
90
-
91
- // Construct the redirect back to Joomla!
92
- $host = null;
93
- $arguments = array(
94
- 'option=com_magebridge',
95
- 'task=login',
96
- );
97
-
98
- // Loop to detect other variables
99
- foreach(Mage::app()->getRequest()->getQuery() as $name => $value) {
100
- if($name == 'base') $host = base64_decode($value);
101
- if($name == 'token') $token = $value;
102
- }
103
- $hash = Mage::app()->getRequest()->getQuery('hash');
104
-
105
- // Backend / frontend login
106
- if($app == 'admin') {
107
- $newhash = $this->doSSOLoginAdmin($token, $hash);
108
- } else {
109
- $newhash = $this->doSSOLoginCustomer($token, $hash);
110
- }
111
-
112
- //$arguments[] = 'session='.session_id(); // Hand back the session-ID so we can adapt the Joomla!-Magento session as well
113
- $arguments[] = 'hash='.$newhash; // @todo: What is done with this?
114
- $arguments[] = $token.'=1';
115
-
116
- // Send the logs through XML-RPC before exiting
117
- Mage::getSingleton('magebridge/client')->addDebug();
118
- Mage::getSingleton('magebridge/client')->multicall();
119
-
120
- // Redirect
121
- header( 'HTTP/1.1 302');
122
- header( 'Location: '.$host.'index.php?'.implode('&', $arguments ));
123
- return true;
124
- }
125
-
126
- /*
127
- * Perform an customer SSO login
128
- */
129
- public function doSSOLoginCustomer($token, $hash) {
130
-
131
- // Initialize the session
132
- Mage::getSingleton('core/session', array('name'=>'frontend'));
133
- $session = Mage::getSingleton('customer/session');
134
-
135
- // Initialize the customer
136
- $customer = $session->getCustomer();
137
- $customer->loadByEmail(stripslashes(Mage::app()->getRequest()->getQuery('user')));
138
-
139
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin [frontend]: customer-name '.$customer->getName());
140
-
141
- // Save the customer in the actual data if this simple authentication succeeds
142
- $newhash = md5($token.$customer->getPasswordHash());
143
- if($hash == $newhash) {
144
- $session->setCustomerAsLoggedIn($customer);
145
- session_regenerate_id();
146
- setcookie('frontend', session_id());
147
-
148
- } else {
149
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin [frontend]: mismatch');
150
- }
151
-
152
- return $newhash;
153
- }
154
-
155
- /*
156
- * Perform an admin SSO login
157
- */
158
- public function doSSOLoginAdmin($token, $hash) {
159
-
160
- Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
161
- if(isset($_COOKIE['adminhtml'])) {
162
- Mage::getSingleton('adminhtml/session')->setSessionId($_COOKIE['adminhtml']);
163
- }
164
-
165
- $username = stripslashes(Mage::app()->getRequest()->getQuery('user'));
166
- $user = Mage::getSingleton('admin/user');
167
- $user->loadByUsername($username);
168
- $newhash = md5($token.md5($user->getPassword()));
169
-
170
- if($user->getId() && $hash == $newhash) {
171
-
172
- if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
173
- Mage::getSingleton('adminhtml/url')->renewSecretUrls();
174
- }
175
-
176
- // Initialize the session
177
- $session = Mage::getSingleton('admin/session');
178
- if($session->getAdmin() == null || $session->getAdmin()->getId() == false) {
179
-
180
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin [admin]: Session take-over for user '.$username);
181
- //$session->setIsFirstVisit(true); // @todo: Try this out.
182
- $session->setUser($user);
183
- $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
184
- //$session->revalidateCookie();
185
-
186
- session_regenerate_id();
187
- setcookie('adminhtml', session_id());
188
-
189
- }
190
-
191
- } else {
192
- Mage::getSingleton('magebridge/debug')->notice('doSSOLogin [admin]: mismatch');
193
- }
194
-
195
- return $newhash;
196
- }
197
-
198
- /*
199
- * Perform an user-login
200
- */
201
- public function login($data)
202
- {
203
- $data['username'] = Mage::getSingleton('magebridge/encryption')->decrypt($data['username'], 'customer username');
204
- $data['password'] = Mage::getSingleton('magebridge/encryption')->decrypt($data['password'], 'customer password');
205
-
206
- switch($data['application']) {
207
- case 'admin':
208
- return $this->loginAdmin($data);
209
-
210
- default:
211
- return $this->loginCustomer($data);
212
- }
213
- }
214
-
215
- /*
216
- * Perform an customer-login
217
- */
218
- public function loginCustomer($data) {
219
-
220
- $username = $data['username'];
221
- $password = $data['password'];
222
-
223
- try {
224
- $session = Mage::getSingleton('customer/session');
225
- } catch( Exception $e) {
226
- Mage::getSingleton('magebridge/debug')->error('Failed to start customer session');
227
- return $data;
228
- }
229
-
230
- try {
231
-
232
- if($session->login($username, $password)) {
233
-
234
- Mage::getSingleton('magebridge/debug')->notice('Login of '.$username);
235
- $customer = $session->getCustomer();
236
- $session->setCustomerAsLoggedIn($customer);
237
-
238
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_SUCCESS;
239
- $data['email'] = $customer->getEmail();
240
- $data['fullname'] = $customer->getName();
241
- $data['hash'] = $customer->getPasswordHash();
242
-
243
- } else {
244
-
245
- Mage::getSingleton('magebridge/debug')->error('Login failed');
246
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_FAILURE;
247
- }
248
-
249
- } catch( Exception $e) {
250
- Mage::getSingleton('magebridge/debug')->error('Failed to login customer "'.$username.'": '.$e->getMessage());
251
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_ERROR;
252
- return $data;
253
- }
254
-
255
- return $data;
256
- }
257
-
258
- /*
259
- * Perform an admin-login
260
- */
261
- public function loginAdmin($data) {
262
-
263
- $username = $data['username'];
264
- $password = $data['password'];
265
-
266
- try {
267
-
268
- Mage::getSingleton('magebridge/debug')->notice('Admin login of '.$username);
269
-
270
- $user = Mage::getSingleton('admin/user');
271
- $user->login($username, $password);
272
- if($user->getId()) {
273
-
274
- if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
275
- Mage::getSingleton('adminhtml/url')->renewSecretUrls();
276
- }
277
- $session = Mage::getSingleton('admin/session');
278
- $session->setIsFirstVisit(true);
279
- $session->setUser($user);
280
- $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
281
-
282
- session_regenerate_id();
283
-
284
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_SUCCESS;
285
- $data['email'] = null;
286
- $data['fullname'] = null;
287
- $data['hash'] = md5($user->getPassword());
288
-
289
- } else {
290
-
291
- Mage::getSingleton('magebridge/debug')->error('Admin login failed');
292
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_FAILURE;
293
- }
294
-
295
- } catch( Exception $e) {
296
- Mage::getSingleton('magebridge/debug')->error('Failed to login admin: '.$e->getMessage());
297
- $data['state'] = MAGEBRIDGE_AUTHENTICATION_ERROR;
298
- return $data;
299
- }
300
-
301
- return $data;
302
- }
303
-
304
- /*
305
- * Perform a logout
306
- */
307
- public function logout($data)
308
- {
309
- Mage::getSingleton('magebridge/debug')->notice('Logout customer');
310
- try {
311
- $session = Mage::getSingleton('customer/session');
312
- $session->logout();
313
- $data['state'] = 0;
314
-
315
- } catch( Exception $e) {
316
- Mage::getSingleton('magebridge/debug')->error('Failed to logout customer: '.$e->getMessage());
317
- $data['state'] = 2;
318
- }
319
-
320
- return $data;
321
- }
322
-
323
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/User/Api.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_User_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- /*
15
- * API-method to save a customer to the database
16
- */
17
- public function save($data = array())
18
- {
19
- if(empty($data) || !isset($data['email'])) {
20
- Mage::getSingleton('magebridge/debug')->warning('No email in data');
21
- return false;
22
- }
23
-
24
- try {
25
- // Initialize the session
26
- Mage::getSingleton('core/session', array('name'=>'frontend'));
27
- $session = Mage::getSingleton('customer/session');
28
-
29
- // Initialize the customer and its address
30
- $customer = $session->getCustomer();
31
- $customer->loadByEmail(stripslashes($data['username']));
32
- $address = $customer->getPrimaryBillingAddress();
33
-
34
- // Load the new data
35
- foreach($data as $name => $value) {
36
- if(isset($name)) {
37
- $method = 'set';
38
- $array = explode('_', $name);
39
- foreach($array as $i => $a) {
40
- if($a == 'address' && $i == 0 && count($array) > 1) continue;
41
- $method .= ucfirst($a);
42
- }
43
-
44
- if(preg_match('/^address_/', $name)) {
45
- $address->$method($value);
46
- } else {
47
- $customer->$method($value);
48
- }
49
- }
50
- }
51
-
52
- // Set the customer group
53
- if(!empty($data['customer_group'])) $customer->setGroupId($data['customer_group']);
54
-
55
- // Try to validate and save this customer
56
- try {
57
- $validation = $customer->validate();
58
- if(is_array($validation) && count($validation) > 0) {
59
- foreach($validation as $v) {
60
- Mage::getSingleton('magebridge/debug')->warning('Customer validation failed: '.$v);
61
- }
62
- return false;
63
- }
64
- } catch(Exception $e) {
65
- Mage::getSingleton('magebridge/debug')->error('Customer validation crashed: '.$e->getMessage());
66
- return false;
67
- }
68
-
69
- $customer->save();
70
- if($customer->save() == false) {
71
- Mage::getSingleton('magebridge/debug')->error('Failed to save customer '.$customer->getEmail());
72
- }
73
-
74
- // Try to validate and save this address
75
- try {
76
- $validation = $address->validate();
77
- if(is_array($validation) && count($validation) > 0) {
78
- foreach($validation as $v) {
79
- Mage::getSingleton('magebridge/debug')->warning('Address validation failed: '.$v);
80
- }
81
- return false;
82
- }
83
- } catch(Exception $e) {
84
- Mage::getSingleton('magebridge/debug')->error('Address validation crashed: '.$e->getMessage());
85
- return false;
86
- }
87
-
88
- $address->save();
89
- if($address->save() == false) {
90
- Mage::getSingleton('magebridge/debug')->error('Failed to save address '.$customer->getEmail());
91
- }
92
-
93
- // Save the password if needed
94
- if(isset($data['password_clear'])) {
95
- $data['password_clear'] = trim($data['password_clear']);
96
- if(!empty($data['password_clear'])) {
97
- $password = Mage::getSingleton('magebridge/encryption')->decrypt($data['password_clear']);
98
- $customer->changePassword($password);
99
- $data['hash'] = $customer->getPasswordHash();
100
- }
101
- }
102
-
103
- } catch(Exception $e) {
104
- Mage::getSingleton('magebridge/debug')->error('Failed to load customer: '.$e->getMessage());
105
- }
106
-
107
- return $data;
108
- }
109
-
110
- /*
111
- * API-method to delete a customer
112
- */
113
- public function delete($data = array())
114
- {
115
- // Use this, to make sure Magento thinks it's dealing with the right app.
116
- // Otherwise _protectFromNonAdmin() will make this fail.
117
- Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
118
-
119
- // Initialize the customer
120
- $customer = Mage::getModel('customer/customer');
121
- if(!empty($data['website_id'])) {
122
- Mage::getSingleton('magebridge/debug')->error('Set website-ID to: '.$data['website_id']);
123
- $customer->setWebsiteId($data['website_id']);
124
- }
125
- $customer->loadByEmail(stripslashes($data['username']));
126
-
127
- // Delete the customer
128
- if($customer->getId()) {
129
- $customer->delete();
130
- return true;
131
- }
132
-
133
- return false;
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/Model/Websites/Api.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- class Jira_MageBridge_Model_Websites_Api extends Mage_Api_Model_Resource_Abstract
13
- {
14
- public function items()
15
- {
16
- $websites = Mage::getModel('core/website')->getCollection();
17
-
18
- $res = array();
19
- foreach ($websites as $item) {
20
- $data['value'] = $item->getData('website_id');
21
- $data['label'] = $item->getData('name');
22
-
23
- $data['id'] = $item->getData('website_id');
24
- $data['name'] = $item->getData('name');
25
- $data['code'] = $item->getData('code');
26
- $res[] = $data;
27
- }
28
-
29
- return $res;
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/controllers/IndexController.php CHANGED
@@ -19,30 +19,11 @@ class Jira_MageBridge_IndexController extends Mage_Adminhtml_Controller_Action
19
  */
20
  protected function _initAction()
21
  {
22
- // Give a warning if Mage::getResourceModel('api/user_collection') returns zero
23
- $collection = Mage::getResourceModel('api/user_collection');
24
- if(!count($collection) > 0) {
25
- Mage::getModel('adminhtml/session')->addError('You have not configured any API-user yet.');
26
- }
27
-
28
- // Give a warning if Mage::getResourceModel('api/user_collection') returns zero
29
- $store = Mage::app()->getStore(Mage::getModel('magebridge/core')->getStore());
30
- if($store->getConfig('catalog/seo/product_url_suffix') == '.html' || $store->getConfig('catalog/seo/category_url_suffix') == '.html') {
31
- Mage::getModel('adminhtml/session')->addError('You have configured the URL-suffix ".html" which conflicts with Joomla!. Check out the Yireo-site for more information.');
32
- }
33
-
34
- // Give a warning if Configuration Cache is enabled
35
- if(Mage::app()->useCache('config')) {
36
- Mage::getModel('adminhtml/session')->addError('Please turn OFF the Configuration Cache. This degrades the performance of MageBridge.');
37
- }
38
-
39
- // Load the layout
40
  $this->loadLayout()
41
  ->_setActiveMenu('cms/magebridge')
42
  ->_addBreadcrumb(Mage::helper('adminhtml')->__('CMS'), Mage::helper('adminhtml')->__('CMS'))
43
  ->_addBreadcrumb(Mage::helper('adminhtml')->__('MageBridge'), Mage::helper('adminhtml')->__('MageBridge'))
44
  ;
45
-
46
  return $this;
47
  }
48
 
@@ -50,21 +31,6 @@ class Jira_MageBridge_IndexController extends Mage_Adminhtml_Controller_Action
50
  * Settings page
51
  */
52
  public function indexAction()
53
- {
54
- if(strlen(Mage::helper('magebridge')->getLicenseKey()) == '') {
55
- $block = 'license';
56
- } else {
57
- $block = 'settings';
58
- }
59
- $this->_initAction()
60
- ->_addContent($this->getLayout()->createBlock('magebridge/'.$block))
61
- ->renderLayout();
62
- }
63
-
64
- /**
65
- * Settings page
66
- */
67
- public function settingsAction()
68
  {
69
  $this->_initAction()
70
  ->_addContent($this->getLayout()->createBlock('magebridge/settings'))
@@ -91,16 +57,6 @@ class Jira_MageBridge_IndexController extends Mage_Adminhtml_Controller_Action
91
  ->renderLayout();
92
  }
93
 
94
- /**
95
- * Credits page
96
- */
97
- public function creditsAction()
98
- {
99
- $this->_initAction()
100
- ->_addContent($this->getLayout()->createBlock('magebridge/credits'))
101
- ->renderLayout();
102
- }
103
-
104
  /**
105
  * Perform an update through AJAX
106
  */
@@ -121,75 +77,16 @@ class Jira_MageBridge_IndexController extends Mage_Adminhtml_Controller_Action
121
 
122
  public function saveAction()
123
  {
124
- $page = 'magebridge/index/index';
125
  if ($data = $this->getRequest()->getPost()) {
126
-
127
- if(isset($data['license_key'])) {
128
- Mage::getConfig()->saveConfig('magebridge/settings/license_key', trim($data['license_key']));
129
- $page = 'magebridge/index/license';
130
- }
131
-
132
- if(isset($data['bridge_all'])) {
133
- Mage::getConfig()->saveConfig('magebridge/settings/bridge_all', (int)$data['bridge_all']);
134
- $page = 'magebridge/index/settings';
135
- }
136
 
137
- //if(isset($data['xmlrpc_url'])) {
138
- // Mage::getConfig()->saveConfig('magebridge/settings/xmlrpc_url', trim($data['xmlrpc_url']));
139
- //}
140
-
141
- if(!empty($data['event_forwarding'])) {
142
- foreach($data['event_forwarding'] as $name => $value) {
143
- Mage::getConfig()->saveConfig('magebridge/settings/event_forwarding/'.$name, $value);
144
- }
145
- }
146
-
147
- Mage::getModel('adminhtml/session')->addSuccess('Settings saved');
148
  Mage::getConfig()->removeCache();
 
149
 
150
  }
151
 
152
- $url = Mage::getModel('adminhtml/url')->getUrl($page);
153
- $this->getResponse()->setRedirect($url);
154
- }
155
-
156
- public function resetAction()
157
- {
158
- $page = 'magebridge/index/index';
159
-
160
- $config = Mage::getStoreConfig('magebridge/settings');
161
- if(!empty($config)) {
162
- foreach($config as $name => $value) {
163
- if($name != 'license_key') {
164
- if(is_array($value)) {
165
- // @todo: Reset events as well?
166
- } else {
167
- Mage::getConfig()->deleteConfig('magebridge/settings/'.$name);
168
- }
169
- }
170
- }
171
- }
172
-
173
- Mage::getConfig()->removeCache();
174
- Mage::getModel('adminhtml/session')->addSuccess('Settings are reset to default');
175
-
176
- $url = Mage::getModel('adminhtml/url')->getUrl($page);
177
- $this->getResponse()->setRedirect($url);
178
- }
179
-
180
- public function recommendedAction()
181
- {
182
- $page = 'magebridge/index/index';
183
-
184
- $events = Mage::getModel('magebridge/listener')->getEvents();
185
- foreach($events as $event) {
186
- Mage::getConfig()->saveConfig('magebridge/settings/event_forwarding/'.$event[0], $event[1]);
187
- }
188
-
189
- Mage::getConfig()->removeCache();
190
- Mage::getModel('adminhtml/session')->addSuccess('Settings are reset to their recommended value');
191
-
192
- $url = Mage::getModel('adminhtml/url')->getUrl($page);
193
  $this->getResponse()->setRedirect($url);
194
  }
195
  }
19
  */
20
  protected function _initAction()
21
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  $this->loadLayout()
23
  ->_setActiveMenu('cms/magebridge')
24
  ->_addBreadcrumb(Mage::helper('adminhtml')->__('CMS'), Mage::helper('adminhtml')->__('CMS'))
25
  ->_addBreadcrumb(Mage::helper('adminhtml')->__('MageBridge'), Mage::helper('adminhtml')->__('MageBridge'))
26
  ;
 
27
  return $this;
28
  }
29
 
31
  * Settings page
32
  */
33
  public function indexAction()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  {
35
  $this->_initAction()
36
  ->_addContent($this->getLayout()->createBlock('magebridge/settings'))
57
  ->renderLayout();
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * Perform an update through AJAX
62
  */
77
 
78
  public function saveAction()
79
  {
 
80
  if ($data = $this->getRequest()->getPost()) {
 
 
 
 
 
 
 
 
 
 
81
 
82
+ $data['license_key'] = trim($data['license_key']);
83
+ Mage::getConfig()->saveConfig('magebridge/settings/license_key', $data['license_key']);
 
 
 
 
 
 
 
 
 
84
  Mage::getConfig()->removeCache();
85
+ Mage::getModel('core/session')->addSuccess('Settings saved');
86
 
87
  }
88
 
89
+ $url = Mage::getModel('adminhtml/url')->getUrl('magebridge/index/index');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  $this->getResponse()->setRedirect($url);
91
  }
92
  }
app/code/community/Jira/MageBridge/etc/api.xml DELETED
@@ -1,216 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Magento Bridge
5
- *
6
- * @author Yireo
7
- * @package Magento Bridge
8
- * @copyright Copyright 2009
9
- * @license Yireo EULA (www.yireo.com)
10
- * @link http://www.yireo.com
11
- */
12
- -->
13
- <config>
14
- <api>
15
- <resources>
16
- <magebridge_websites translate="title" module="magebridge">
17
- <model>magebridge/websites_api</model>
18
- <title>Websites Api</title>
19
- <acl>magebridge/websites</acl>
20
- <methods>
21
- <list translate="title" module="magebridge">
22
- <title>List of websites</title>
23
- <method>items</method>
24
- </list>
25
- </methods>
26
- </magebridge_websites>
27
- <magebridge_storegroups translate="title" module="magebridge">
28
- <model>magebridge/storegroups_api</model>
29
- <title>StoreGroups Api</title>
30
- <acl>magebridge/storegroups</acl>
31
- <methods>
32
- <list translate="title" module="magebridge">
33
- <title>List of store groups</title>
34
- <method>items</method>
35
- </list>
36
- </methods>
37
- </magebridge_storegroups>
38
- <magebridge_storeviews translate="title" module="magebridge">
39
- <model>magebridge/storeviews_api</model>
40
- <title>StoreViews Api</title>
41
- <acl>magebridge/storeviews</acl>
42
- <methods>
43
- <list translate="title" module="magebridge">
44
- <title>List of store views</title>
45
- <method>items</method>
46
- </list>
47
- <hierarchy translate="title" module="magebridge">
48
- <title>Hierarchy of stores</title>
49
- <method>hierarchy</method>
50
- </hierarchy>
51
- </methods>
52
- </magebridge_storeviews>
53
- <magebridge_tag translate="title" module="magebridge">
54
- <model>magebridge/tag_api</model>
55
- <title>Tag Api</title>
56
- <acl>magebridge/tag</acl>
57
- <methods>
58
- <list translate="title" module="magebridge">
59
- <title>List of products by tag</title>
60
- <method>items</method>
61
- </list>
62
- </methods>
63
- </magebridge_tag>
64
- <magebridge_product translate="title" module="magebridge">
65
- <model>magebridge/product_api</model>
66
- <title>Product Api</title>
67
- <acl>magebridge/product</acl>
68
- <methods>
69
- <tree translate="title" module="magebridge">
70
- <title>List of products</title>
71
- <method>items</method>
72
- </tree>
73
- <search translate="title" module="magebridge">
74
- <title>Search for products</title>
75
- </search>
76
- </methods>
77
- </magebridge_product>
78
- <magebridge_category translate="title" module="magebridge">
79
- <model>magebridge/category_api</model>
80
- <title>Category Api</title>
81
- <acl>magebridge/category</acl>
82
- <methods>
83
- <tree translate="title" module="magebridge">
84
- <title>Tree of catalog category</title>
85
- <method>tree</method>
86
- </tree>
87
- </methods>
88
- </magebridge_category>
89
- <magebridge_headers translate="title" module="magebridge">
90
- <model>magebridge/headers_api</model>
91
- <title>Headers Api</title>
92
- <acl>magebridge/headers</acl>
93
- <methods>
94
- <get translate="title" module="magebridge">
95
- <title>Get HTML headers</title>
96
- <method>getList</method>
97
- </get>
98
- </methods>
99
- </magebridge_headers>
100
- <magebridge_block translate="title" module="magebridge">
101
- <model>magebridge/block_api</model>
102
- <title>Block Api</title>
103
- <acl>magebridge/block</acl>
104
- <methods>
105
- <get translate="title" module="magebridge">
106
- <title>Get Block</title>
107
- <method>items</method>
108
- </get>
109
- </methods>
110
- </magebridge_block>
111
- <magebridge_user translate="title" module="magebridge">
112
- <model>magebridge/user_api</model>
113
- <title>User Api</title>
114
- <acl>magebridge/user</acl>
115
- <methods>
116
- <info translate="title" module="magebridge">
117
- <title>Get an user</title>
118
- </info>
119
- <login translate="title" module="magebridge">
120
- <title>Login an user</title>
121
- </login>
122
- <logout translate="title" module="magebridge">
123
- <title>Logout an user</title>
124
- </logout>
125
- <list translate="title" module="magebridge">
126
- <title>Get a list of users</title>
127
- <method>items</method>
128
- </list>
129
- <save translate="title" module="magebridge">
130
- <title>Save the given user details</title>
131
- </save>
132
- </methods>
133
- </magebridge_user>
134
- <magebridge_customer translate="title" module="magebridge">
135
- <model>magebridge/customer_api</model>
136
- <title>Customer Api</title>
137
- <acl>magebridge/customer</acl>
138
- <methods>
139
- <tree translate="title" module="magebridge">
140
- <title>List of customers</title>
141
- <method>items</method>
142
- </tree>
143
- </methods>
144
- </magebridge_customer>
145
- <magebridge_order translate="title" module="magebridge">
146
- <model>magebridge/order_api</model>
147
- <title>Order Api</title>
148
- <acl>magebridge/order</acl>
149
- <methods>
150
- <tree translate="title" module="magebridge">
151
- <title>List of orders</title>
152
- <method>items</method>
153
- </tree>
154
- </methods>
155
- </magebridge_order>
156
- </resources>
157
-
158
- <acl>
159
- <resources>
160
- <!--
161
- <all>
162
- </all>
163
- -->
164
- <magebridge translate="title" module="magebridge">
165
- <sort_order>9</sort_order>
166
- <title>MageBridge</title>
167
- <websites translate="title" module="magebridge">
168
- <sort_order>1</sort_order>
169
- <title>Get Websites</title>
170
- </websites>
171
- <storegroups translate="title" module="magebridge">
172
- <sort_order>1</sort_order>
173
- <title>Get Store Groups</title>
174
- </storegroups>
175
- <storeviews translate="title" module="magebridge">
176
- <sort_order>1</sort_order>
177
- <title>Get Store Views</title>
178
- </storeviews>
179
- <tag translate="title" module="magebridge">
180
- <sort_order>1</sort_order>
181
- <title>Get Product Tags</title>
182
- </tag>
183
- <product translate="title" module="magebridge">
184
- <sort_order>1</sort_order>
185
- <title>Get Products</title>
186
- </product>
187
- <customer translate="title" module="magebridge">
188
- <sort_order>1</sort_order>
189
- <title>Get Customers</title>
190
- </customer>
191
- <order translate="title" module="magebridge">
192
- <sort_order>1</sort_order>
193
- <title>Get Orders</title>
194
- </order>
195
- <category translate="title" module="magebridge">
196
- <sort_order>1</sort_order>
197
- <title>Get Categories</title>
198
- </category>
199
- <headers translate="title" module="magebridge">
200
- <sort_order>2</sort_order>
201
- <title>Get HTML headers</title>
202
- </headers>
203
- <block translate="title" module="magebridge">
204
- <sort_order>3</sort_order>
205
- <title>Get Blocks</title>
206
- </block>
207
- <user translate="title" module="magebridge">
208
- <sort_order>4</sort_order>
209
- <title>User Synchronization</title>
210
- </user>
211
- </magebridge>
212
- </resources>
213
- </acl>
214
-
215
- </api>
216
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Jira/MageBridge/etc/config.xml CHANGED
@@ -14,7 +14,7 @@
14
 
15
  <modules>
16
  <Jira_MageBridge>
17
- <version>1.2.1154</version>
18
  </Jira_MageBridge>
19
  </modules>
20
 
@@ -24,11 +24,6 @@
24
  <magebridge>
25
  <class>Jira_MageBridge_Block</class>
26
  </magebridge>
27
- <page>
28
- <rewrite>
29
- <html_breadcrumbs>Jira_MageBridge_Model_Breadcrumbs</html_breadcrumbs>
30
- </rewrite>
31
- </page>
32
  </blocks>
33
 
34
  <helpers>
@@ -38,202 +33,11 @@
38
  </helpers>
39
 
40
  <models>
41
- <!-- Default MageBridge classes -->
42
  <magebridge>
43
  <class>Jira_MageBridge_Model</class>
44
  </magebridge>
45
-
46
- <!-- Override of Mage_Core classes -->
47
- <core>
48
- <rewrite>
49
- <email_template_filter>Jira_MageBridge_Model_Email_Template_Filter</email_template_filter>
50
- </rewrite>
51
- </core>
52
  </models>
53
 
54
- <events>
55
- <address_save_after>
56
- <observers>
57
- <magebridge_address_save_after>
58
- <type>singleton</type>
59
- <class>Jira_MageBridge_Model_Listener</class>
60
- <method>addressSaveAfter</method>
61
- </magebridge_address_save_after>
62
- </observers>
63
- </address_save_after>
64
- <admin_session_user_login_success>
65
- <observers>
66
- <magebridge_admin_session_user_login_success>
67
- <type>singleton</type>
68
- <class>Jira_MageBridge_Model_Listener</class>
69
- <method>adminSessionUserLoginSuccess</method>
70
- </magebridge_admin_session_user_login_success>
71
- </observers>
72
- </admin_session_user_login_success>
73
- <adminhtml_customer_save_after>
74
- <observers>
75
- <magebridge_adminhtml_customer_save_after>
76
- <type>singleton</type>
77
- <class>Jira_MageBridge_Model_Listener</class>
78
- <method>adminhtmlCustomerSaveAfter</method>
79
- </magebridge_adminhtml_customer_save_after>
80
- </observers>
81
- </adminhtml_customer_save_after>
82
- <adminhtml_customer_delete_after>
83
- <observers>
84
- <magebridge_adminhtml_customer_delete_after>
85
- <type>singleton</type>
86
- <class>Jira_MageBridge_Model_Listener</class>
87
- <method>adminhtmlCustomerDeleteAfter</method>
88
- </magebridge_adminhtml_customer_delete_after>
89
- </observers>
90
- </adminhtml_customer_delete_after>
91
- <catalog_product_save_after>
92
- <observers>
93
- <magebridge_catalog_product_save_after>
94
- <type>singleton</type>
95
- <class>Jira_MageBridge_Model_Listener</class>
96
- <method>catalogProductSaveAfter</method>
97
- </magebridge_catalog_product_save_after>
98
- </observers>
99
- </catalog_product_save_after>
100
- <catalog_product_delete_after>
101
- <observers>
102
- <magebridge_catalog_product_delete_after>
103
- <type>singleton</type>
104
- <class>Jira_MageBridge_Model_Listener</class>
105
- <method>catalogProductDeleteAfter</method>
106
- </magebridge_catalog_product_delete_after>
107
- </observers>
108
- </catalog_product_delete_after>
109
- <catalog_category_save_after>
110
- <observers>
111
- <magebridge_catalog_category_save_after>
112
- <type>singleton</type>
113
- <class>Jira_MageBridge_Model_Listener</class>
114
- <method>catalogCategorySaveAfter</method>
115
- </magebridge_catalog_category_save_after>
116
- </observers>
117
- </catalog_category_save_after>
118
- <catalog_category_delete_after>
119
- <observers>
120
- <magebridge_catalog_category_delete_after>
121
- <type>singleton</type>
122
- <class>Jira_MageBridge_Model_Listener</class>
123
- <method>catalogCategoryDeleteAfter</method>
124
- </magebridge_catalog_category_delete_after>
125
- </observers>
126
- </catalog_category_delete_after>
127
- <catalog_product_status_update>
128
- <observers>
129
- <magebridge_catalog_product_status_update>
130
- <type>singleton</type>
131
- <class>Jira_MageBridge_Model_Listener</class>
132
- <method>catalogProductStatusUpdate</method>
133
- </magebridge_catalog_product_status_update>
134
- </observers>
135
- </catalog_product_status_update>
136
- <checkout_cart_add_product_complete>
137
- <observers>
138
- <magebridge_checkout_cart_add_product_complete>
139
- <type>singleton</type>
140
- <class>Jira_MageBridge_Model_Listener</class>
141
- <method>checkoutCartAddProductComplete</method>
142
- </magebridge_checkout_cart_add_product_complete>
143
- </observers>
144
- </checkout_cart_add_product_complete>
145
- <checkout_controller_onepage_save_shipping_method>
146
- <observers>
147
- <magebridge_checkout_controller_onepage_save_shipping_method>
148
- <type>singleton</type>
149
- <class>Jira_MageBridge_Model_Listener</class>
150
- <method>checkoutControllerOnepageSaveShippingMethod</method>
151
- </magebridge_checkout_controller_onepage_save_shipping_method>
152
- </observers>
153
- </checkout_controller_onepage_save_shipping_method>
154
- <checkout_onepage_controller_success_action>
155
- <observers>
156
- <magebridge_checkout_onepage_controller_success_action>
157
- <type>singleton</type>
158
- <class>Jira_MageBridge_Model_Listener</class>
159
- <method>checkoutOnepageControllerSuccessAction</method>
160
- </magebridge_checkout_onepage_controller_success_action>
161
- </observers>
162
- </checkout_onepage_controller_success_action>
163
- <checkout_type_onepage_save_order_after>
164
- <observers>
165
- <magebridge_checkout_type_onepage_save_order_after>
166
- <type>singleton</type>
167
- <class>Jira_MageBridge_Model_Listener</class>
168
- <method>checkoutTypeOnepageSaveOrderAfter</method>
169
- </magebridge_checkout_type_onepage_save_order_after>
170
- </observers>
171
- </checkout_type_onepage_save_order_after>
172
- <customer_login>
173
- <observers>
174
- <magebridge_customer_login>
175
- <type>singleton</type>
176
- <class>Jira_MageBridge_Model_Listener</class>
177
- <method>customerLogin</method>
178
- </magebridge_customer_login>
179
- </observers>
180
- </customer_login>
181
- <customer_logout>
182
- <observers>
183
- <magebridge_customer_logout>
184
- <type>singleton</type>
185
- <class>Jira_MageBridge_Model_Listener</class>
186
- <method>customerLogout</method>
187
- </magebridge_customer_logout>
188
- </observers>
189
- </customer_logout>
190
- <customer_save_after>
191
- <observers>
192
- <magebridge_customer_save_after>
193
- <type>singleton</type>
194
- <class>Jira_MageBridge_Model_Listener</class>
195
- <method>customerSaveAfter</method>
196
- </magebridge_customer_save_after>
197
- </observers>
198
- </customer_save_after>
199
- <customer_delete_after>
200
- <observers>
201
- <magebridge_customer_delete_after>
202
- <type>singleton</type>
203
- <class>Jira_MageBridge_Model_Listener</class>
204
- <method>customerDeleteAfter</method>
205
- </magebridge_customer_delete_after>
206
- </observers>
207
- </customer_delete_after>
208
- <sales_convert_order_to_quote>
209
- <observers>
210
- <magebridge_sales_convert_order_to_quote>
211
- <type>singleton</type>
212
- <class>Jira_MageBridge_Model_Listener</class>
213
- <method>salesConvertOrderToQuote</method>
214
- </magebridge_sales_convert_order_to_quote>
215
- </observers>
216
- </sales_convert_order_to_quote>
217
- <sales_order_place_after>
218
- <observers>
219
- <magebridge_sales_order_place_after>
220
- <type>singleton</type>
221
- <class>Jira_MageBridge_Model_Listener</class>
222
- <method>salesOrderPlaceAfter</method>
223
- </magebridge_sales_order_place_after>
224
- </observers>
225
- </sales_order_place_after>
226
- <sales_order_save_after>
227
- <observers>
228
- <magebridge_sales_order_save_after>
229
- <type>singleton</type>
230
- <class>Jira_MageBridge_Model_Listener</class>
231
- <method>salesOrderSaveAfter</method>
232
- </magebridge_sales_order_save_after>
233
- </observers>
234
- </sales_order_save_after>
235
- </events>
236
-
237
  </global>
238
 
239
  <admin>
@@ -262,7 +66,7 @@
262
  <cms>
263
  <children>
264
  <magebridge translate="title" module="magebridge">
265
- <title>MageBridge settings</title>
266
  <action>magebridge/index</action>
267
  </magebridge>
268
  </children>
@@ -289,18 +93,4 @@
289
  </acl>
290
  </adminhtml>
291
 
292
- <!--
293
- <frontend>
294
- <routers>
295
- <magebridge>
296
- <use>standard</use>
297
- <args>
298
- <module>Jira_MageBridge</module>
299
- <frontName>magebridge</frontName>
300
- </args>
301
- </magebridge>
302
- </routers>
303
- </frontend>
304
- -->
305
-
306
  </config>
14
 
15
  <modules>
16
  <Jira_MageBridge>
17
+ <version>1.0.2</version>
18
  </Jira_MageBridge>
19
  </modules>
20
 
24
  <magebridge>
25
  <class>Jira_MageBridge_Block</class>
26
  </magebridge>
 
 
 
 
 
27
  </blocks>
28
 
29
  <helpers>
33
  </helpers>
34
 
35
  <models>
 
36
  <magebridge>
37
  <class>Jira_MageBridge_Model</class>
38
  </magebridge>
 
 
 
 
 
 
 
39
  </models>
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  </global>
42
 
43
  <admin>
66
  <cms>
67
  <children>
68
  <magebridge translate="title" module="magebridge">
69
+ <title>MageBridge Installer</title>
70
  <action>magebridge/index</action>
71
  </magebridge>
72
  </children>
93
  </acl>
94
  </adminhtml>
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  </config>
app/code/community/Jira/MageBridge/etc/system.xml CHANGED
@@ -12,7 +12,6 @@
12
  -->
13
  <config>
14
  <sections>
15
- <!--
16
  <magebridge translate="label" module="magebridge">
17
  <label>Jira MageBridge</label>
18
  <tab>service</tab>
@@ -43,6 +42,5 @@
43
  </settings>
44
  </groups>
45
  </magebridge>
46
- -->
47
  </sections>
48
  </config>
12
  -->
13
  <config>
14
  <sections>
 
15
  <magebridge translate="label" module="magebridge">
16
  <label>Jira MageBridge</label>
17
  <tab>service</tab>
42
  </settings>
43
  </groups>
44
  </magebridge>
 
45
  </sections>
46
  </config>
app/design/adminhtml/default/default/template/magebridge/eula.phtml DELETED
@@ -1,65 +0,0 @@
1
- THIS LICENSE AGREEMENT (HEREINAFTER AGREEMENT) IS AN AGREEMENT BETWEEN YOU (THE
2
- PERSON OR COMPANY WHO IS BEING LICENSED TO USE THE SOFTWARE OR DOCUMENTATION)
3
- AND JIRA ICT (HEREINAFTER WE/US/OUR). THE AGREEMENT APPLIES TO ALL PRODUCTS
4
- (SOFTWARE AND/OR SERVICES) YOU PURCHASE FROM US.
5
-
6
- 1. By purchasing the product you acknowledge that you have read this agreement,
7
- and that you agree to the content of the agreement and its terms, and agree
8
- to use the product in compliance with this agreement.
9
-
10
- 2. The agreement comes into legal force at the moment when you order our product
11
- from our site or receive it through email or on data medium at our
12
- discretion.
13
-
14
- 3. We are the copyright holder of the product. The product or a portion of it
15
- is a copyrightable matter and is liable to protection by the law. Any
16
- activity that infringes terms of this agreement violates copyright law and
17
- will be prosecuted according to the current law. We reserve the right to
18
- revoke the license of any user who is holding an invalid license.
19
-
20
- 4. This agreement gives you the right to use the product on one domain solely
21
- for your own personal or business use, subject to all other terms of this
22
- agreement. A separate license should be purchased for each other domain the
23
- product is deployed on. Any distribution of the product without our consent,
24
- including noncommercial distribution is regarded as violation of this
25
- agreement and entails liability, according to the current law.
26
-
27
- 5. You may not use any part of the code in whole or part in any other software
28
- or product or website. Such an action conflicts with this EULA.
29
-
30
- 6. You may not give, sell, distribute, sub-license, rent, lease or lend any
31
- portion of the product to anyone. You may not place the product on a server
32
- so that it is accessible via a public network such as the Internet for
33
- distribution purposes.
34
-
35
- 7. You are bound to preserve the copyright information intact, this includes the
36
- text/link at bottom.
37
-
38
- 8. We will not be liable to you for any damages (including any loss of profits
39
- or saving, either incidental or consequential) caused to you, your
40
- information and your business arising out of the use or inability to use
41
- this product.
42
-
43
- 9. We are not liable for prosecution arising from use of the product against
44
- law or for any illegal use.
45
-
46
- 10. If you fail to use the product in accordance with the terms and conditions
47
- of this license agreement, it constitutes a breach of the agreement, and
48
- your license to use the program is revoked.
49
-
50
- 11. We reserve the right to change this license agreement at any time and impose
51
- its clauses at any given time.
52
-
53
- 12. License agreement remains effective until terminated. We retain the right to
54
- terminate your license to use the product at any time, if in its sole
55
- discretion, you are not abiding by the terms of the agreement, including,
56
- but not limited to, obscuring or removing any link or copyright notice as
57
- specified in this agreement. You may terminate it at any time by destroying
58
- all copies of the product. Termination of this agreement does not bind us
59
- to return you the amount spent for purchase of the product.
60
-
61
- 13. If you continue to use the product after we give you notice of termination of
62
- your license, you hereby agree to accept an injunction to enjoin you from its
63
- further use and to pay all costs (including but not limited to reasonable
64
- attorney fees) to enforce our revocation of your license and any damages
65
- suffered by us because of your misuse of the product.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/magebridge/license.phtml CHANGED
@@ -10,7 +10,6 @@
10
  */
11
  ?>
12
 
13
- <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="magebridge_edit_form">
14
  <div class="columns ">
15
 
16
  <div class="side-col" id="page:left">
@@ -23,56 +22,81 @@
23
  <div class="content-header">
24
  <table cellspacing="0">
25
  <tr>
26
- <td style="width:50%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('Licensing'); ?></h3></td>
27
- <td class="formbuttons" align="right">
28
- <?php echo $this->getSaveButtonHtml(); ?>
29
- <button type="button" class="scalable" onclick="doSubmit();"><span><?php echo $this->__('Save'); ?></span></button>
30
- </td>
31
  </tr>
32
  </table>
33
  </div>
34
 
35
- <div class="entry-edit">
36
- <div class="entry-edit-head">
37
- <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('License key'); ?></h4>
38
- </div>
39
- <div class="fieldset ">
40
- <table cellspacing="5" class="form-list">
41
- <tbody>
42
- <tr>
43
- <td width="300"><label for="license_key"><?php echo $this->__('License key'); ?></label></td>
44
- <td><input type="text" class="input-text" size="40" name="license_key" id="license_key" value="<?php echo $this->getLicenseKey(); ?>" /></td>
45
- </tr>
46
- </tbody>
47
- </table>
48
- </div>
49
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- <div class="entry-edit">
52
- <div class="entry-edit-head">
53
- <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('MageBridge EULA'); ?></h4>
54
- </div>
55
- <div class="fieldset ">
56
- <table cellspacing="5" class="form-list">
57
- <tbody>
58
- <tr>
59
- <td>
60
- <pre><?php echo file_get_contents(dirname(__FILE__).'/eula.phtml'); ?></pre>
61
- </td>
62
- </tr>
63
- </tbody>
64
- </table>
65
- </div>
66
- </div>
67
  </div>
68
 
69
- <?php echo $this->getBlockHtml('formkey'); ?>
70
- </form>
71
 
72
- <script type="text/javascript">
73
- var magebridgeForm = new varienForm('magebridge_edit_form');
74
- function doSubmit() {
75
- magebridgeForm.submit();
76
- return true;
77
- }
78
- </script>
10
  */
11
  ?>
12
 
 
13
  <div class="columns ">
14
 
15
  <div class="side-col" id="page:left">
22
  <div class="content-header">
23
  <table cellspacing="0">
24
  <tr>
25
+ <td style="width:80%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('License Agreement'); ?></h3></td>
 
 
 
 
26
  </tr>
27
  </table>
28
  </div>
29
 
30
+ <h3><?php echo $this->__( 'MageBridge License Agreement' ); ?></h3>
31
+ <pre>
32
+ THIS LICENSE AGREEMENT (HEREINAFTER AGREEMENT) IS AN AGREEMENT BETWEEN YOU (THE
33
+ PERSON OR COMPANY WHO IS BEING LICENSED TO USE THE SOFTWARE OR DOCUMENTATION)
34
+ AND JIRA ICT (HEREINAFTER WE/US/OUR). THE AGREEMENT APPLIES TO ALL PRODUCTS
35
+ (SOFTWARE AND/OR SERVICES) YOU PURCHASE FROM US.
36
+
37
+ 1. By purchasing the product you acknowledge that you have read this agreement,
38
+ and that you agree to the content of the agreement and its terms, and agree
39
+ to use the product in compliance with this agreement.
40
+
41
+ 2. The agreement comes into legal force at the moment when you order our product
42
+ from our site or receive it through email or on data medium at our
43
+ discretion.
44
+
45
+ 3. We are the copyright holder of the product. The product or a portion of it
46
+ is a copyrightable matter and is liable to protection by the law. Any
47
+ activity that infringes terms of this agreement violates copyright law and
48
+ will be prosecuted according to the current law. We reserve the right to
49
+ revoke the license of any user who is holding an invalid license.
50
+
51
+ 4. This agreement gives you the right to use the product on one domain solely
52
+ for your own personal or business use, subject to all other terms of this
53
+ agreement. A separate license should be purchased for each other domain the
54
+ product is deployed on. Any distribution of the product without our consent,
55
+ including noncommercial distribution is regarded as violation of this
56
+ agreement and entails liability, according to the current law.
57
+
58
+ 5. You may not use any part of the code in whole or part in any other software
59
+ or product or website. Such an action conflicts with this EULA.
60
+
61
+ 6. You may not give, sell, distribute, sub-license, rent, lease or lend any
62
+ portion of the product to anyone. You may not place the product on a server
63
+ so that it is accessible via a public network such as the Internet for
64
+ distribution purposes.
65
+
66
+ 7. You are bound to preserve the copyright information intact, this includes the
67
+ text/link at bottom.
68
+
69
+ 8. We will not be liable to you for any damages (including any loss of profits
70
+ or saving, either incidental or consequential) caused to you, your
71
+ information and your business arising out of the use or inability to use
72
+ this product.
73
+
74
+ 9. We are not liable for prosecution arising from use of the product against
75
+ law or for any illegal use.
76
+
77
+ 10. If you fail to use the product in accordance with the terms and conditions
78
+ of this license agreement, it constitutes a breach of the agreement, and
79
+ your license to use the program is revoked.
80
+
81
+ 11. We reserve the right to change this license agreement at any time and impose
82
+ its clauses at any given time.
83
+
84
+ 12. License agreement remains effective until terminated. We retain the right to
85
+ terminate your license to use the product at any time, if in its sole
86
+ discretion, you are not abiding by the terms of the agreement, including,
87
+ but not limited to, obscuring or removing any link or copyright notice as
88
+ specified in this agreement. You may terminate it at any time by destroying
89
+ all copies of the product. Termination of this agreement does not bind us
90
+ to return you the amount spent for purchase of the product.
91
+
92
+ 13. If you continue to use the product after we give you notice of termination of
93
+ your license, you hereby agree to accept an injunction to enjoin you from its
94
+ further use and to pay all costs (including but not limited to reasonable
95
+ attorney fees) to enforce our revocation of your license and any damages
96
+ suffered by us because of your misuse of the product.
97
+ </pre>
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  </div>
100
 
101
+ </div>
 
102
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/magebridge/settings.phtml CHANGED
@@ -10,7 +10,7 @@
10
  */
11
  ?>
12
 
13
- <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="magebridge_edit_form" autocomplete="off">
14
  <div class="columns ">
15
 
16
  <div class="side-col" id="page:left">
@@ -23,11 +23,9 @@
23
  <div class="content-header">
24
  <table cellspacing="0">
25
  <tr>
26
- <td style="width:50%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('Settings'); ?></h3></td>
27
- <td class="formbuttons" align="right">
28
  <?php echo $this->getSaveButtonHtml(); ?>
29
- <?php echo $this->getChildHtml('reset_button'); ?>
30
- <?php echo $this->getChildHtml('recommended_button'); ?>
31
  <button type="button" class="scalable" onclick="doSubmit();"><span><?php echo $this->__('Save'); ?></span></button>
32
  </td>
33
  </tr>
@@ -35,7 +33,25 @@
35
  </div>
36
 
37
  <div class="entry-edit">
38
- <?php echo $this->getChildHtml('accordion') ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  </div>
40
  </div>
41
 
10
  */
11
  ?>
12
 
13
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="magebridge_edit_form">
14
  <div class="columns ">
15
 
16
  <div class="side-col" id="page:left">
23
  <div class="content-header">
24
  <table cellspacing="0">
25
  <tr>
26
+ <td style="width:80%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('Settings'); ?></h3></td>
27
+ <td class="formbuttons">
28
  <?php echo $this->getSaveButtonHtml(); ?>
 
 
29
  <button type="button" class="scalable" onclick="doSubmit();"><span><?php echo $this->__('Save'); ?></span></button>
30
  </td>
31
  </tr>
33
  </div>
34
 
35
  <div class="entry-edit">
36
+
37
+ <div class="entry-edit-head">
38
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('General'); ?></h4>
39
+ </div>
40
+
41
+ <div class="fieldset ">
42
+
43
+ <table cellspacing="5" class="form-list">
44
+ <tbody>
45
+ <tr>
46
+ <td width="300"><label for="license_key"><?php echo $this->__('License key'); ?></label></td>
47
+ <td><input type="text" class="input-text" size="40" name="license_key" id="license_key" value="<?php echo $this->getSetting('license_key'); ?>" /></td>
48
+ </tr>
49
+ </tbody>
50
+ </table>
51
+
52
+ </div>
53
+ </div>
54
+
55
  </div>
56
  </div>
57
 
app/design/adminhtml/default/default/template/magebridge/settings/events.phtml DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
- ?>
12
-
13
- <div class="fieldset ">
14
-
15
- <table cellspacing="5" class="form-list">
16
- <tbody>
17
- <?php foreach($this->getEvents() as $event) { ?>
18
- <tr>
19
- <td width="300"><label for="license_key"><?php echo $event['name']; ?></label></td>
20
- <td>
21
- <select name="event_forwarding[<?php echo $event['name']; ?>]" id="<?php echo $event['name']; ?>">
22
- <?php if($event['value'] == 1) { ?>
23
- <option value="0"><?php echo $this->__('Disabled'); ?></option>
24
- <option value="1" selected><?php echo $this->__('Enabled'); ?></option>
25
- <?php } else { ?>
26
- <option value="0" selected><?php echo $this->__('Disabled'); ?></option>
27
- <option value="1"><?php echo $this->__('Enabled'); ?></option>
28
- <?php } ?>
29
- </select>
30
- </td>
31
- </tr>
32
- <?php } ?>
33
- </tbody>
34
- </table>
35
-
36
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/magebridge/settings/joomla.phtml DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
- ?>
12
-
13
- <div class="fieldset ">
14
-
15
- <table cellspacing="5" class="form-list">
16
- <tbody>
17
- <tr>
18
- <td width="300"><label for="xmlrpc_url"><?php echo $this->__('XML-RPC host'); ?></label></td>
19
- <td>
20
- <input type="text" name="xmlrpc_url" value="<?php echo $this->getXmlrpcUrl(); ?>" size="40" disabled />
21
- </td>
22
- </tr>
23
- <tr>
24
- <td width="300"><label for="api_user"><?php echo $this->__('API-user'); ?></label></td>
25
- <td>
26
- <input type="text" name="api_user" value="<?php echo $this->getApiUser(); ?>" size="40" disabled />
27
- </td>
28
- </tr>
29
- <tr>
30
- <td width="300"><label for="api_key"><?php echo $this->__('API-key'); ?></label></td>
31
- <td>
32
- <input type="password" name="api_key" value="<?php echo $this->getApiKey(); ?>" size="40" disabled />
33
- </td>
34
- </tr>
35
- </tbody>
36
- </table>
37
-
38
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/magebridge/settings/other.phtml DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
- ?>
12
-
13
- <div class="fieldset ">
14
-
15
- <table cellspacing="5" class="form-list">
16
- <tbody>
17
- <tr>
18
- <td width="300"><label for="bridge_all"><?php echo $this->__('Bridge all HTTP-content'); ?></label></td>
19
- <td>
20
- <select name="bridge_all" id="bridge_all">
21
- <?php
22
- $options = array(
23
- 0 => 'No',
24
- 1 => 'Yes',
25
- );
26
- foreach( $options as $value => $label) {
27
- $selected = ($value == $this->getBridgeAll()) ? 'selected' : '';
28
- echo '<option value="'.$value.'" '.$selected.'>'.$label.'</option>';
29
- }
30
- ?>
31
- </select>
32
- </td>
33
- </tr>
34
- </tbody>
35
- </table>
36
-
37
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/magebridge/updates.phtml CHANGED
@@ -29,14 +29,7 @@ div#mbajax-updater {
29
  <div class="content-header">
30
  <table cellspacing="0">
31
  <tr>
32
- <td style="width:40%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('Update'); ?></h3></td>
33
- <td class="formbuttons" align="right">
34
- <?php if($this->upgradeNeeded() == true) { ?>
35
- <button type="button" class="scalable" onclick="doUpdate();"><span><?php echo $this->__('Update MageBridge extension'); ?></span></button>
36
- <?php } else { ?>
37
- <?php echo $this->__('No update needed'); ?>
38
- <?php } ?>
39
- </td>
40
  </tr>
41
  </table>
42
  </div>
@@ -48,22 +41,31 @@ div#mbajax-updater {
48
  </div>
49
 
50
  <div class="fieldset ">
51
- <div id="mbajax-updater" style="display:none;"><h3><?php echo $this->__('Please wait while MageBridge is being upgraded'); ?></h3></div>
52
  <div id="mbajax-table">
53
  <table cellspacing="5" class="form-list">
54
- <tr>
55
  <td width="150"><?php echo $this->__('Current version'); ?></td>
56
  <td><?php echo $this->getCurrentVersion(); ?></td>
57
- </tr>
58
  <tr>
59
- <td><?php echo $this->__('New version'); ?></td>
60
- <td><span id="mbajax-version"><?php echo $this->getNewVersion(); ?></span></td>
 
 
 
 
61
  </tr>
62
  </table>
63
  </div>
64
  </div>
65
  </div>
66
 
 
 
 
 
 
67
 
68
  </div>
69
  </div>
29
  <div class="content-header">
30
  <table cellspacing="0">
31
  <tr>
32
+ <td style="width:80%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('Update'); ?></h3></td>
 
 
 
 
 
 
 
33
  </tr>
34
  </table>
35
  </div>
41
  </div>
42
 
43
  <div class="fieldset ">
44
+ <div id="mbajax-updater" style="display:none;"><h3><?php echo $this->__('Please wait while MageBridge is being installed'); ?></h3></div>
45
  <div id="mbajax-table">
46
  <table cellspacing="5" class="form-list">
47
+ <!--<tr>
48
  <td width="150"><?php echo $this->__('Current version'); ?></td>
49
  <td><?php echo $this->getCurrentVersion(); ?></td>
50
+ </tr>-->
51
  <tr>
52
+ <?php $newversion = $this->getNewVersion(); if(preg_match('/^ERROR/', $newversion)) { ?>
53
+ <td colspan="2" id="mbajax-version"><?php echo $newversion; ?></td>
54
+ <?php } else { ?>
55
+ <td><?php echo $this->__('Full version'); ?></td>
56
+ <td><span id="mbajax-version"><?php echo $newversion; ?></span></td>
57
+ <?php } ?>
58
  </tr>
59
  </table>
60
  </div>
61
  </div>
62
  </div>
63
 
64
+ <?php if($this->upgradeNeeded() == true) { ?>
65
+ <button type="button" class="scalable" onclick="doUpdate();"><span><?php echo $this->__('Install'); ?></span></button>
66
+ <?php } else { ?>
67
+ <?php echo $this->__('No update needed'); ?>
68
+ <?php } ?>
69
 
70
  </div>
71
  </div>
app/etc/modules/Jira_MageBridge.xml CHANGED
@@ -3,9 +3,10 @@
3
  /**
4
  * MageBridge-module for Magento
5
  *
 
6
  * @package Jira_MageBridge
7
- * @author Yireo (https://www.yireo.com/)
8
- * @copyright Copyright (c) 2009 Yireo (https://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
@@ -14,9 +15,6 @@
14
  <Jira_MageBridge>
15
  <active>true</active>
16
  <codePool>community</codePool>
17
- <depends>
18
- <Mage_Api />
19
- </depends>
20
  </Jira_MageBridge>
21
  </modules>
22
  </config>
3
  /**
4
  * MageBridge-module for Magento
5
  *
6
+ * @category design_default
7
  * @package Jira_MageBridge
8
+ * @author Jisse Reitsma (Jira ICT)
9
+ * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
10
  * @license Open Software License
11
  */
12
  -->
15
  <Jira_MageBridge>
16
  <active>true</active>
17
  <codePool>community</codePool>
 
 
 
18
  </Jira_MageBridge>
19
  </modules>
20
  </config>
magebridge.class.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- /*
13
- * MageBridge-class that acts like proxy between bridge-classes and the API
14
- */
15
- class MageBridge
16
- {
17
- /*
18
- * The current request
19
- */
20
- private $request = array();
21
-
22
- /*
23
- * Constructor
24
- */
25
- public function __construct()
26
- {
27
- // Decode all the POST-values with JSON
28
- if(!empty($_POST)) {
29
- foreach($_POST as $index => $post) {
30
- $this->request[$index] = json_decode(stripslashes($post), true);
31
- }
32
- } elseif(!empty($_GET)) {
33
- foreach($_GET as $index => $get) {
34
- $this->request[$index] = json_decode(stripslashes($get), true);
35
- }
36
- }
37
-
38
- // Decode extra string values with Base64
39
- if(!empty($this->request['meta']['arguments']) && is_array($this->request['meta']['arguments'])) {
40
- foreach($this->request['meta']['arguments'] as $name => $value) {
41
- if(is_string($value)) {
42
- $this->request['meta']['arguments'][$name] = base64_decode($value);
43
- }
44
- }
45
- }
46
-
47
- return $this->request;
48
- }
49
-
50
- /*
51
- * Get the request-data
52
- */
53
- public function getRequest()
54
- {
55
- return $this->request;
56
- }
57
-
58
- /*
59
- * Helper-function to get the meta-data from the request
60
- */
61
- public function getMeta($name = null)
62
- {
63
- if(!empty( $this->request['meta']['arguments'] )) {
64
- if($name != null) {
65
- if(isset($this->request['meta']['arguments'][$name])) {
66
- return $this->request['meta']['arguments'][$name];
67
- }
68
- } else {
69
- return $this->request['meta']['arguments'];
70
- }
71
- }
72
- return null;
73
- }
74
-
75
- /*
76
- * Mask this request by using the data sent along with this request
77
- */
78
- public function premask()
79
- {
80
- $data = $this->getMeta();
81
-
82
- // Initialize the right session
83
- if(!empty($data['magento_session'])) {
84
- session_name('frontend');
85
- session_id($data['magento_session']);
86
- $_COOKIE['frontend'] = $data['magento_session'];
87
-
88
- } elseif(!empty($_GET['sso']) && !empty($_GET['app'])) {
89
-
90
- if($_GET['app'] == 'admin' && !empty($_COOKIE['adminhtml'])) {
91
- session_name('adminhtml');
92
- session_id($_COOKIE['adminhtml']);
93
-
94
- } elseif(!empty($_COOKIE['frontend'])) {
95
- session_name('frontend');
96
- session_id($_COOKIE['frontend']);
97
- }
98
-
99
- } elseif(empty($_COOKIE['frontend'])) {
100
- $_COOKIE = array();
101
- }
102
-
103
- // Mask the POST
104
- if(!empty($data['post'])) {
105
- $_POST = $data['post'];
106
- } elseif(!isset($_POST['mbtest'])) {
107
- $_POST = array();
108
- }
109
-
110
- // Mask the REQUEST_URI and the GET
111
- if(!empty($data['request_uri']) && strlen($data['request_uri']) > 0) {
112
-
113
- // Set the REQUEST_URI
114
- $data['request_uri'] = preg_replace( '/^\//', '', $data['request_uri']);
115
- $_SERVER['REQUEST_URI'] = $data['request_uri'];
116
-
117
- // Set the GET variables
118
- $data['request_uri'] = preg_replace( '/^\//', '', $data['request_uri']);
119
- $query = preg_replace( '/^([^\?]+)\?/', '', $data['request_uri'] );
120
- if($query != $data['request_uri']) {
121
- parse_str(rawurldecode($query), $parts);
122
- foreach($parts as $name => $value) {
123
- $_GET[$name] = $value;
124
- }
125
- }
126
-
127
- } else {
128
- $_SERVER['REQUEST_URI'] = null;
129
- }
130
-
131
- // Mask the HTTP_USER_AGENT
132
- if(!empty($data['user_agent'])) {
133
- $_SERVER['HTTP_USER_AGENT'] = $data['user_agent'];
134
- }
135
-
136
- // Mask the HTTP_REFERER
137
- if(!empty($data['http_referer'])) {
138
- $_SERVER['HTTP_REFERER'] = $data['http_referer'];
139
- }
140
-
141
- return true;
142
- }
143
-
144
- /*
145
- * Run the bridge-core
146
- */
147
- public function run()
148
- {
149
- Mage::getSingleton('magebridge/debug')->notice('Session: '.session_id());
150
-
151
- // Handle SSO
152
- if(Mage::getSingleton('magebridge/user')->doSSO() == true) {
153
- exit;
154
- }
155
-
156
- // Now Magento is initialized, we can load the MageBridge core-class
157
- $bridge = Mage::getSingleton('magebridge/core');
158
- $bridge->init($this->getMeta(), $this->getRequest());
159
-
160
- // Handle tests
161
- if(Mage::app()->getRequest()->getQuery('mbtest') == 1) {
162
- $bridge->setMetaData('state', 'test');
163
- $bridge->setMetaData('extra', 'get');
164
- print $bridge->output(false);
165
- exit;
166
- } elseif(Mage::app()->getRequest()->getPost('mbtest') == 1) {
167
- $bridge->setMetaData('state', 'test');
168
- $bridge->setMetaData('extra', 'post');
169
- print $bridge->output(false);
170
- exit;
171
- }
172
-
173
- // Match the license
174
- if($this->getMeta('license') != $bridge->getLicenseKey()) {
175
- $bridge->setMetaData('state', 'license failed');
176
- print $bridge->output(false);
177
- exit;
178
- }
179
-
180
- // Authorize this request using the API credentials (set in the meta-data)
181
- if($this->authenticate() == false) {
182
- $bridge->setMetaData('state', 'authentication failed');
183
- print $bridge->output(false);
184
- exit;
185
- }
186
-
187
- // Pre-fetch all the current messages, because the Magento bootstrap might clear them later
188
- $bridge->setMessages( Mage::getSingleton('magebridge/messages')->getMessages() );
189
-
190
- // Check if there's any output already set (for instance JSON, AJAX, XML, PDF) and output it right away
191
- if($bridge->preoutput() == true) {
192
- exit;
193
- }
194
-
195
- // Fetch the actual request
196
- $data = $bridge->getRequestData();
197
- if(is_array($data) && !empty($data)) {
198
-
199
- // Dispatch the request to the appropriate classes
200
- Mage::getSingleton('magebridge/debug')->notice('Dispatching the request');
201
- $data = $this->dispatch($data);
202
-
203
- // Set the completed request as response
204
- $bridge->setResponseData($data);
205
-
206
- } else {
207
- Mage::getSingleton('magebridge/debug')->notice('Empty request');
208
- }
209
-
210
- Mage::getSingleton('magebridge/debug')->notice('Done with session: '.session_id());
211
- //Mage::getSingleton('magebridge/debug')->trace('Session dump', $_SESSION);
212
- //Mage::getSingleton('magebridge/debug')->trace('Cookie dump', $_COOKIE);
213
- //Mage::getSingleton('magebridge/debug')->trace('GET dump', $_GET);
214
- //Mage::getSingleton('magebridge/debug')->trace('POST dump', $_POST);
215
-
216
- ini_set('display_errors', 0);
217
- $bridge->setMetaData('state', null);
218
- print $bridge->output();
219
- exit;
220
- }
221
-
222
- /*
223
- * Authorize access to the bridge
224
- */
225
- public function authenticate()
226
- {
227
- // Authorize against the bridge-core
228
- $bridge = Mage::getSingleton('magebridge/core');
229
-
230
- if($bridge->authenticate() == false) {
231
- session_regenerate_id();
232
- Mage::getSingleton('magebridge/debug')->error('API authorization failed for user '.$bridge->getMetaData('api_user'));
233
- return false;
234
-
235
- } else {
236
- Mage::getSingleton('magebridge/debug')->notice('API authorization succeeded');
237
- }
238
- return true;
239
- }
240
-
241
- /*
242
- * Dispatch the bridge-request to the appropriate classes
243
- */
244
- public function dispatch($data)
245
- {
246
- // Loop through the posted data, complete it and send it back
247
- foreach($data as $index => $segment) {
248
-
249
- switch($segment['type']) {
250
-
251
- case 'authenticate':
252
- $segment['data'] = Mage::getSingleton('magebridge/user')->login($segment['arguments']);
253
- break;
254
-
255
- case 'urls':
256
- $segment['data'] = Mage::getSingleton('magebridge/url')->getData($segment['name']);
257
- break;
258
-
259
- case 'block':
260
- $segment['data'] = Mage::getSingleton('magebridge/block')->getOutput($segment['name'], $segment['arguments']);
261
- $segment['meta'] = Mage::getSingleton('magebridge/block')->getMeta($segment['name']);
262
- break;
263
-
264
- case 'breadcrumbs':
265
- $segment['data'] = Mage::getSingleton('magebridge/breadcrumbs')->getBreadcrumbs();
266
- break;
267
-
268
- case 'api':
269
- $segment['data'] = Mage::getSingleton('magebridge/api')->getResult($segment['name'], $segment['arguments']);
270
- break;
271
-
272
- case 'event':
273
- $segment['data'] = Mage::getSingleton('magebridge/dispatcher')->getResult($segment['name'], $segment['arguments']);
274
- break;
275
-
276
- case 'headers':
277
- $segment['data'] = Mage::getSingleton('magebridge/headers')->getHeaders();
278
- break;
279
- }
280
-
281
- $data[$index] = $segment;
282
- }
283
- return $data;
284
- }
285
- }
286
-
287
- // End
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
magebridge.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Bridge
4
- *
5
- * @author Yireo
6
- * @package Magento Bridge
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
- * @link http://www.yireo.com
10
- */
11
-
12
- // Use this for profiling
13
- $init_time = time();
14
-
15
- // Initialize the bridge
16
- require_once 'magebridge.class.php';
17
- $magebridge = new MageBridge();
18
-
19
- // Mask this request
20
- $magebridge->premask();
21
-
22
- // Initialize the Magento application
23
- require_once 'app/Mage.php';
24
- try {
25
- $app_value = $magebridge->getMeta('app_value');
26
- $app_type = $magebridge->getMeta('app_type');
27
- $app_time = time();
28
-
29
- if($app_type == 'website') {
30
- $app_value = (int)$app_value;
31
- }
32
-
33
- Mage::app($app_value, $app_type);
34
- Mage::getSingleton('magebridge/debug')->notice('Initializing', $init_time);
35
- Mage::getSingleton('magebridge/debug')->notice("Mage::app($app_value,$app_type)", $app_time);
36
-
37
- } catch(Exception $e) {
38
- die("Mage::app('$app_value','$app_type') failed: ".$e->getMessage());
39
- }
40
-
41
- // Run the bridge
42
- $magebridge->run();
43
-
44
- // End
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Jira_MageBridge</name>
4
- <version>1.2.1154</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.yireo.com/">MageBridge EULA</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>This module integrates Magento with Joomla!</description>
11
  <notes>This PEAR package can only be distributed with a valid MageBridge license.</notes>
12
  <authors><author><name>Jisse Reitsma</name><user>auto-converted</user><email>info@jira.nl</email></author></authors>
13
- <date>2009-11-10</date>
14
- <time>10:38:57</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magebridge"><dir name="settings"><file name="events.phtml" hash="08f13b14e8a8b1b77155f32c4e8e4581"/><file name="joomla.phtml" hash="de7f31cf6d02e3c25546018cf7ea4ce0"/><file name="other.phtml" hash="c00e9697eed97096478fe800e05c5ee6"/></dir><file name="license.phtml" hash="65992f83974c30f0e3412442c03a1c96"/><file name="eula.phtml" hash="6d19f073a08b98a7b46d2202b5d0be7d"/><file name="menu.phtml" hash="3524d7e9dcc64cc2b17881a5ca9b335c"/><file name="settings.phtml" hash="a718862e99651c86587210a720ec54a6"/><file name="updates.phtml" hash="a9118464dfc15a1d51613df22d13e458"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Jira"><dir name="MageBridge"><dir name="controllers"><file name="IndexController.php" hash="f6baff34e0c1e5b696c714d4bd937ae4"/></dir><dir name="Block"><dir name="Settings"><file name="Events.php" hash="05cf8ec663c5c1a60998916c5d71bdf8"/><file name="Joomla.php" hash="8e075e078f3f6141a323954ed62527cb"/><file name="Other.php" hash="d8b617bbb45672b77f31ea0730a0d8eb"/></dir><file name="License.php" hash="9064a3325267d4ea640082b6a9297b7b"/><file name="Menu.php" hash="68550d63944a918b910272fe66947316"/><file name="Settings.php" hash="a5a52ef6b6f4122d06747ad0fe0c0e20"/><file name="Updates.php" hash="ae028a89270baced5f6ee329e0170b3b"/></dir><dir name="etc"><file name="api.xml" hash="62089980f7de8ff108019fb4bc54d257"/><file name="config.xml" hash="db6ca370b86ee706a00dc7799b6fe091"/><file name="system.xml" hash="0b843176e9303a6c840c6ee49f8d0acc"/></dir><dir name="Helper"><file name="Data.php" hash="accc40735be2db48cc417941760031b0"/></dir><dir name="Model"><dir name="Category"><file name="Api.php" hash="0a5bc510abf88a1843451463ab6e4305"/></dir><dir name="Customer"><file name="Api.php" hash="363b497eaedb3d885d45a17b5520ba4b"/></dir><dir name="Email"><dir name="Template"><file name="Filter.php" hash="f91254cf383d4e04f659aebf2d7062dd"/></dir></dir><dir name="Order"><file name="Api.php" hash="24448567462c91deba07c2d3be6b0399"/></dir><dir name="Product"><file name="Api.php" hash="046959a353a84d58efaa5917fff78f03"/></dir><dir name="Storegroups"><file name="Api.php" hash="6da9ac138653017ca8cfd45889f3d3a8"/></dir><dir name="Storeviews"><file name="Api.php" hash="a8ceb29545abfced22cb40ea2d40ca1d"/></dir><dir name="Tag"><file name="Api.php" hash="91afae8b344d9351971cfebe227312c8"/></dir><dir name="User"><file name="Api.php" hash="c5b36b8f812c0ad36571c7578cda38f7"/></dir><dir name="Websites"><file name="Api.php" hash="cc2a394036a8aa1407edfc03f4f673d3"/></dir><file name="Api.php" hash="7fd0e01ea42b0ab1871d1db74b00ed3c"/><file name="Block.php" hash="a2aedf04f31f967ea4c1911081d1ac54"/><file name="Breadcrumbs.php" hash="ee8cf677ccff81d2e11a7c3a90c0f6ac"/><file name="Client.php" hash="af2a2b9dd381ac342bec5620d3089925"/><file name="Core.php" hash="33873254a81ac833a0fb3b2d3a741822"/><file name="Debug.php" hash="996a24ea4e3f55da246ac08bd4acc37f"/><file name="Dispatcher.php" hash="38d4337c46c03396a79fc32d4a8a2fa6"/><file name="Encryption.php" hash="236d3598790a0497c38aee1472dbcb46"/><file name="Headers.php" hash="012ec8f61f46123a4848849085d3781c"/><file name="Listener.php" hash="55e24419d581e54efff2e877d8265a45"/><file name="Messages.php" hash="cd67d45fe61f0a288a0bc0cb7f7f9b0e"/><file name="Search.php" hash="01e49bc76dd13056ac6b64413385a29a"/><file name="Session.php" hash="a13295e3bf8e6d7f78273884008bafe5"/><file name="Update.php" hash="6a511b85daab8c766cf3e86bcff46be5"/><file name="Url.php" hash="5f104108dcc01bb84fc9e23362d44fe6"/><file name="User.php" hash="67ce7c97561c1463a73bd8f79b8569f9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jira_MageBridge.xml" hash="4655c62ea30de67ad2def5cdeed0f41a"/></dir></target><target name="mage"><dir name="."><file name="magebridge.php" hash="aef19390531b621f08664d3b15a3b139"/><file name="magebridge.class.php" hash="8c847606165ca81cc88ec11c26e9286a"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Jira_MageBridge</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.yireo.com/">MageBridge EULA</license>
7
  <channel>community</channel>
10
  <description>This module integrates Magento with Joomla!</description>
11
  <notes>This PEAR package can only be distributed with a valid MageBridge license.</notes>
12
  <authors><author><name>Jisse Reitsma</name><user>auto-converted</user><email>info@jira.nl</email></author></authors>
13
+ <date>2009-11-19</date>
14
+ <time>11:40:57</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magebridge"><file name="license.phtml" hash="7f87df8053557e777a9c6c733eb8aef0"/><file name="menu.phtml" hash="3524d7e9dcc64cc2b17881a5ca9b335c"/><file name="settings.phtml" hash="4daaee62f56eebb827761d895631875a"/><file name="updates.phtml" hash="415236a9b403d2960b1eb181a8dbb540"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Jira"><dir name="MageBridge"><dir name="controllers"><file name="IndexController.php" hash="ef5925a4cabb013cca315f1221e9c938"/></dir><dir name="Block"><file name="License.php" hash="f7b55c605964dcbaf8fd74c606c9d4e9"/><file name="Menu.php" hash="2f3675cb4f4c2406e97cde577ac855ca"/><file name="Settings.php" hash="d50bfe4a62931764c70747b47c8d234d"/><file name="Updates.php" hash="2e5cfea03dbe0cbc1b08ed09d91fb2f2"/></dir><dir name="etc"><file name="config.xml" hash="91fc17039644389a3e93d7cfbc043556"/><file name="system.xml" hash="fd6013af4f857472a4be5a72ebe6ffc0"/></dir><dir name="Helper"><file name="Data.php" hash="25b3a5b0ff8841c9e655680a7b6eafec"/></dir><dir name="Model"><file name="Update.php" hash="1c1a272597bb1621dee7a59e78477524"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jira_MageBridge.xml" hash="c572b0ef802d01dbb221a7a61b5fae21"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>