Пример #1
0
 public function isEnabled()
 {
     if (MageBridgeHelper::isJoomla15()) {
         return false;
     }
     return true;
 }
 public function overrideModuleHelper()
 {
     // Detect whether we can load the module-helper
     $classes = get_declared_classes();
     if (!in_array('JModuleHelper', $classes) && !in_array('jmodulehelper', $classes)) {
         $loadModuleHelper = true;
     } else {
         $loadModuleHelper = false;
     }
     // Import the custom module helper - this is needed to make it possible to flush certain positions
     if ($loadModuleHelper == true) {
         $rewrite_path = __DIR__ . '/';
         if (MageBridgeHelper::isJoomlaVersion('2.5')) {
             @(include_once $rewrite_path . '25/joomla/application/module/helper.php');
         } else {
             if (MageBridgeHelper::isJoomlaVersion('3.0')) {
                 @(include_once $rewrite_path . '30/joomla/application/module/helper.php');
             } else {
                 if (MageBridgeHelper::isJoomlaVersion('3.1')) {
                     @(include_once $rewrite_path . '31/cms/application/module/helper.php');
                 } elseif (MageBridgeHelper::isJoomlaVersion(array('3.2', '3.3'))) {
                     @(include_once $rewrite_path . '32/cms/application/module/helper.php');
                 }
             }
         }
     }
 }
Пример #3
0
 public function onPurchase($gid = null, $user = null, $status = null)
 {
     // Get common records
     $db = JFactory::getDBO();
     // Joomla! 1.5 method
     if (MageBridgeHelper::isJoomla15()) {
         // Set the user-type
         $query = 'SELECT `name` FROM `#__core_acl_aro_groups` WHERE `id`=' . (int) $gid;
         $db->setQuery($query);
         $usertype = $db->loadResult();
         $query = 'UPDATE `#__users` SET `gid`=' . (int) $gid . ', `usertype`=' . $db->Quote($usertype) . ' WHERE `id`=' . (int) $user->id;
         $db->setQuery($query);
         $db->query();
         $query = 'UPDATE `#__core_acl_groups_aro_map` SET `group_id`=' . (int) $gid . ' WHERE `aro_id` = (SELECT id FROM `#__core_acl_aro` WHERE value = ' . (int) $user->id . ' LIMIT 1)';
         $db->setQuery($query);
         $db->query();
         // Joomla! 1.6 method
     } else {
         // See if the user is already listed
         $query = 'SELECT user_id FROM `#__user_usergroup_map` WHERE `user_id`=' . (int) $user->id . ' AND `group_id`=' . (int) $gid . ' LIMIT 1';
         $db->setQuery($query);
         $result = $db->loadResult();
         // Add the user
         if (empty($result)) {
             $query = 'INSERT INTO `#__user_usergroup_map` SET `user_id`=' . (int) $user->id . ', `group_id`=' . (int) $gid;
             $db->setQuery($query);
             $db->query();
         }
     }
     return true;
 }
Пример #4
0
 public function onPurchase($list_id = null, $user = null, $status = null)
 {
     $db = JFactory::getDBO();
     // See if the user is already there
     $query = 'SELECT * FROM `#__mkpostman_subscribers` WHERE `email`=' . $db->Quote($user->email) . ' LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     // Add the customer email to the subscribers table
     if (empty($row)) {
         $now = JFactory::getDate()->toMySQL();
         $fields = array('user_id' => (int) $user->id, 'name' => $db->Quote($user->name), 'email' => $db->Quote($user->email), 'status' => 1, 'registration_date' => $db->Quote($now), 'confirmation_date' => $db->Quote($now));
         $query = 'INSERT INTO `#__mkpostman_subscribers` SET ' . MageBridgeHelper::arrayToSql($fields);
         $db->setQuery($query);
         $db->query();
         // See if the user is already there
         $query = 'SELECT * FROM `#__mkpostman_subscribers` WHERE `email`=' . $db->Quote($user->email) . ' LIMIT 1';
         $db->setQuery($query);
         $row = $db->loadObject();
     }
     // Continue to add the subscriber to the actual list
     if (!empty($row->id)) {
         $subscriber_id = $row->id;
         $query = 'SELECT * FROM `#__mkpostman_subscribers_lists` WHERE `subscriber_id`=' . (int) $subscriber_id . ' AND `list_id`=' . (int) $list_id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (empty($row)) {
             $query = 'INSERT INTO `#__mkpostman_subscribers_lists` SET `subscriber_id`=' . (int) $subscriber_id . ', `list_id`=' . (int) $list_id;
             $db->setQuery($query);
             $db->query();
         }
     }
     return true;
 }
Пример #5
0
 /**
  * Method to upgrade all registered packages at once
  *
  * @package MageBridge
  * @access public
  * @param int $allow_update
  * @return bool
  */
 public function updateAll($allow_update = array())
 {
     // Fetch all the available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     $count = 0;
     foreach ($packages as $package) {
         // Skip optional packages which are not yet installed and not selected in the list
         if (!in_array($package['name'], $allow_update)) {
             continue;
         }
         // Skip packages that are not available
         if ($package['available'] == 0) {
             continue;
         }
         // Update the package and add an error if something goes wrong
         if ($this->update($package['name']) == false) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FAILED', $package['name']));
             // Only crash when installing the component, continue for all other extensions
             if ($package['name'] == 'com_magebridge') {
                 return false;
             }
             continue;
         } else {
             $count++;
         }
     }
     // Run the helper to remove obsolete files
     YireoHelperInstall::remove();
     // Simple notices as feedback
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_SUCCESS', $count));
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_CHANGELOG', MageBridgeHelper::getHelpLink('changelog')));
     return true;
 }
Пример #6
0
 /**
  * Method to get the meta-data
  *
  * @return array
  */
 public function getRequestData()
 {
     // Compile the meta-data
     if (empty($this->_meta_data) || !is_array($this->_meta_data)) {
         $application = JFactory::getApplication();
         $input = $application->input;
         $user = JFactory::getUser();
         $uri = JURI::getInstance();
         $session = JFactory::getSession();
         $config = JFactory::getConfig();
         $storeHelper = MageBridgeStoreHelper::getInstance();
         $bridge = MageBridgeModelBridge::getInstance();
         $app_type = $storeHelper->getAppType();
         $app_value = $storeHelper->getAppValue();
         $arguments = array('api_session' => $bridge->getApiSession(), 'api_user' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_user')), 'api_key' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_key')), 'api_url' => JURI::root() . 'component/magebridge/?controller=jsonrpc&task=call', 'app' => $application->getClientId(), 'app_type' => $app_type, 'app_value' => $app_value, 'storeview' => MagebridgeModelConfig::load('storeview'), 'storegroup' => MagebridgeModelConfig::load('storegroup'), 'website' => MagebridgeModelConfig::load('website'), 'customer_group' => MagebridgeModelConfig::load('customer_group'), 'joomla_url' => $bridge->getJoomlaBridgeUrl(), 'joomla_sef_url' => $bridge->getJoomlaBridgeSefUrl(), 'joomla_sef_suffix' => (int) MageBridgeUrlHelper::hasUrlSuffix(), 'joomla_user_email' => $application->isSite() && !empty($user->email) ? $user->email : null, 'joomla_current_url' => $uri->current(), 'modify_url' => MagebridgeModelConfig::load('modify_url'), 'enforce_ssl' => MagebridgeModelConfig::load('enforce_ssl'), 'has_ssl' => (int) $uri->isSSL(), 'payment_urls' => MagebridgeModelConfig::load('payment_urls'), 'enable_messages' => MagebridgeModelConfig::load('enable_messages'), 'joomla_session' => session_id(), 'joomla_conf_caching' => $config->get('caching', 60), 'joomla_conf_lifetime' => $config->get('lifetime', 60) * 60, 'magento_session' => $bridge->getMageSession(), 'magento_persistent_session' => $bridge->getMagentoPersistentSession(), 'magento_user_allowed_save_cookie' => isset($_COOKIE['user_allowed_save_cookie']) ? $_COOKIE['user_allowed_save_cookie'] : null, 'request_uri' => MageBridgeUrlHelper::getRequest(), 'request_id' => md5(JURI::current() . serialize($input->get->getArray())), 'post' => !empty($_POST) ? $_POST : null, 'http_referer' => $bridge->getHttpReferer(), 'http_host' => $uri->toString(array('host')), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'remote_addr' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'supportkey' => MagebridgeModelConfig::load('supportkey'), 'debug' => (int) MageBridgeModelDebug::isDebug(), 'debug_level' => MagebridgeModelConfig::load('debug_level'), 'debug_display_errors' => MagebridgeModelConfig::load('debug_display_errors'), 'protocol' => MagebridgeModelConfig::load('protocol'), 'state' => 'initializing', 'ajax' => (int) $bridge->isAjax(), 'disable_css' => MageBridgeHelper::getDisableCss(), 'disable_js' => MageBridgeHelper::getDisableJs());
         if (MageBridgeTemplateHelper::isMobile()) {
             $arguments['theme'] = MagebridgeModelConfig::load('mobile_magento_theme');
         } else {
             $arguments['theme'] = MagebridgeModelConfig::load('magento_theme');
         }
         foreach ($arguments as $name => $value) {
             if (is_string($value)) {
                 $arguments[$name] = MageBridgeEncryptionHelper::base64_encode($value);
             }
         }
         $this->_meta_data = $arguments;
     }
     return $this->_meta_data;
 }
Пример #7
0
 public function getScript($block, $element, $url = null)
 {
     // Set the default AJAX-URL
     if (empty($url)) {
         $url = self::getUrl($block);
     }
     // Load ProtoType
     if (MageBridgeTemplateHelper::hasPrototypeJs() == true) {
         $script = "Event.observe(window,'load',function(){new Ajax.Updater('{$element}','{$url}',{method:'get'});});";
         // Load jQuery
     } else {
         if (JFactory::getApplication()->get('jquery') == true) {
             $script = "jQuery(document).ready(function(){\n" . "    jQuery('#" . $element . "').load('" . $url . "');" . "});\n";
             // Load MooTools (Joomla!)
         } else {
             if (MageBridgeHelper::isJoomla15()) {
                 JHTML::_('behavior.mootools');
                 $script = "window.addEvent('domready', function(){\n" . "    var MBajax = new Ajax( '" . $url . "', {onSuccess: function(r){\n" . "        \$('" . $element . "').innerHTML = r;\n" . "    }});\n" . "    MBajax.request();\n" . "});\n";
                 // Load MooTools (Joomla! 1.6)
             } else {
                 JHTML::_('behavior.mootools');
                 $script = "window.addEvent('domready', function(){\n" . "    var MBajax = new Request({\n" . "        url: '" . $url . "', \n" . "        onComplete: function(r){\n" . "            \$('" . $element . "').innerHTML = r;\n" . "        }\n" . "    }).send();\n" . "});\n";
             }
         }
     }
     return $script;
 }
 /**
  * Load the parameters
  *
  * @access private
  * @param null
  * @return JParameter
  */
 private function getParams()
 {
     if (MageBridgeHelper::isJoomla16()) {
         return $this->params;
     } else {
         $plugin = JPluginHelper::getPlugin('system', 'magebridgeyoo');
         $params = new JParameter($plugin->params);
         return $params;
     }
 }
 /**
  * Load the parameters
  *
  * @access private
  * @param null
  * @return JParameter
  */
 private function getParams()
 {
     if (!MageBridgeHelper::isJoomla15()) {
         return $this->params;
     } else {
         jimport('joomla.html.parameter');
         $plugin = JPluginHelper::getPlugin('system', 'magebridgepre');
         $params = new JParameter($plugin->params);
         return $params;
     }
 }
Пример #10
0
 public static function getUsergroupOptions()
 {
     if (MageBridgeHelper::isJoomla15()) {
         $query = 'SELECT `id` AS `value`, `name` AS `text` FROM `#__core_acl_aro_groups` WHERE `parent_id` NOT IN (0, 17, 28)';
     } else {
         $query = 'SELECT `id` AS `value`, `title` AS `text` FROM `#__usergroups` WHERE `parent_id` > 0';
     }
     $db = JFactory::getDBO();
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Пример #11
0
 public function ajax($url, $div)
 {
     JHTML::_('behavior.mootools');
     if (MageBridgeHelper::isJoomla15()) {
         $script = "<script type=\"text/javascript\">\n" . "window.addEvent('domready', function(){\n" . "    var MBajax = new Ajax( '" . $url . "', {onSuccess: function(r){\n" . "        \$('" . $div . "').setHTML(r);\n" . "    }});\n" . "    MBajax.request();\n" . "});\n" . "</script>";
     } else {
         $script = "<script type=\"text/javascript\">\n" . "window.addEvent('domready', function(){\n" . "    var MBajax = new Request.HTML({\n" . "        method: 'get',\n" . "        url: '" . $url . "', \n" . "        update: '" . $div . "'\n" . "    }).send();\n" . "});\n" . "</script>";
     }
     $document = JFactory::getDocument();
     $document->addCustomTag($script);
 }
 /**
  * Load the parameters
  * 
  * @access private
  * @param null
  * @return JParameter
  */
 private function getParams()
 {
     if (MageBridgeHelper::isJoomla15() == false) {
         return $this->params;
     } else {
         jimport('joomla.html.parameter');
         $plugin = JPluginHelper::getPlugin('magebridge.newsletter', 'ccnewsletter');
         $params = new JParameter($plugin->params);
         return $params;
     }
 }
Пример #13
0
 public function display($tpl = null)
 {
     // Load the bridge
     $bridge = MageBridgeModelBridge::getInstance();
     // Load the parameters
     $layout = $this->getLayout();
     $params = MageBridgeHelper::getParams();
     // Set the request based upon the choosen category
     $request = $params->get('request', false) ? $params->get('request') : MageBridgeUrlHelper::getRequest();
     $prefix = preg_replace('/\\?(.*)/', '', $request);
     $suffix = preg_replace('/(.*)\\?/', '', $request);
     // Check if this a non-URL-optimized request
     if (is_numeric($prefix)) {
         $request = MageBridgeUrlHelper::getLayoutUrl($layout, $prefix);
     } else {
         // Determine the suffix
         if ($layout == 'product') {
             $suffix = $bridge->getMageConfig('catalog/seo/product_url_suffix');
         } else {
             if ($layout == 'category') {
                 $suffix = $bridge->getMageConfig('catalog/seo/category_url_suffix');
             }
         }
         // Add the suffix, if this is set in the Magento configuration
         if (!empty($suffix) && !preg_match('/' . $suffix . '$/', $request)) {
             $request .= $suffix;
         }
     }
     // Add the
     $mode = $params->get('mode');
     if (!empty($mode)) {
         $request .= '?mode=' . $mode;
     }
     // Set the request in the bridge
     $this->setRequest($request);
     // Handle the redirect request
     $redirect = JRequest::getString('redirect');
     if (!empty($redirect)) {
         $bridge->setHttpReferer($redirect);
     }
     // Reuse this request to set the Canonical URL
     if (MagebridgeModelConfig::load('enable_canonical') == 1) {
         $uri = MageBridgeUrlHelper::route($request);
         $document = JFactory::getDocument();
         $document->setMetaData('canonical', $uri);
     }
     // Set which block to display
     $this->setBlock('content');
     parent::display($tpl);
 }
Пример #14
0
 public function onPurchase($level_id = null, $user = null, $status = null)
 {
     $db = JFactory::getDBO();
     // See if the user is already there
     $query = 'SELECT * FROM `#__akeebasubs_subscriptions` WHERE `user_id`=' . (int) $user->id . ' AND `akeebasubs_level_id`=' . (int) $level_id . ' LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     if (empty($row)) {
         $values = array('user_id' => (int) $user->id, 'akeebasubs_level_id' => (int) $level_id, 'enabled' => 1, 'processor' => 'none', 'processor_key' => 'magento', 'state' => 'X');
         $query = 'INSERT INTO `#__akeebasubs_subscriptions` SET ' . MageBridgeHelper::arrayToSql($values);
         $db->setQuery($query);
         $db->query();
     }
     return true;
 }
 public function getSelectHTML($options)
 {
     $name = 'disable_css_mage';
     $value = MageBridgeHelper::getDisableCss();
     $current = MagebridgeModelConfig::load('disable_css_all');
     if ($current == 1 || $current == 0) {
         $disabled = ' disabled="disabled"';
     } else {
         $disabled = null;
     }
     if (!empty($options) && is_array($options)) {
         array_unshift($options, array('value' => '', 'label' => '- ' . JText::_('None') . ' -'));
         return JHTML::_('select.genericlist', $options, $name . '[]', 'multiple' . $disabled, 'value', 'label', $value);
     }
     return '<input type="text" name="' . $name . '" value="' . implode(',', $value) . '" />';
 }
Пример #16
0
 public function onPurchase($event_id = null, $user = null, $status = null)
 {
     $db = JFactory::getDBO();
     // See if the user is already there
     $query = 'SELECT id FROM `#__eventlist_register` WHERE `event`=' . (int) $event_id . ' AND `uid`=' . (int) $user->id . ' LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     // Add the customer email to the subscribers list
     if (empty($row)) {
         $values = array('event' => (int) $event_id, 'uid' => (int) $user->id, 'uip' => '127.0.0.1');
         $query = 'INSERT INTO `#__eventlist_register` SET ' . MageBridgeHelper::arrayToSql($values) . ', `uregdate`=NOW()';
         $db->setQuery($query);
         $db->query();
     }
     return true;
 }
Пример #17
0
 public function display($tpl = null)
 {
     // Load the parameters
     $params = MageBridgeHelper::getParams();
     $request = $params->get('request');
     $this->setRequest($request);
     // Reuse this request to set the Canonical URL
     if (MagebridgeModelConfig::load('enable_canonical') == 1) {
         $uri = MageBridgeUrlHelper::route($request);
         $document = JFactory::getDocument();
         $document->setMetaData('canonical', $uri);
     }
     // Set which block to display
     $this->setBlock('content');
     parent::display($tpl);
 }
 public function onPurchase($list_id = null, $user = null, $status = null)
 {
     $db = JFactory::getDBO();
     // See if the user is already there
     $query = 'SELECT * FROM `#__communicator_subscribers` WHERE `email`=' . $db->Quote($user->email) . ' LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     // Add the customer email to the subscribers table
     if (empty($row)) {
         $now = JFactory::getDate()->toMySQL();
         $fields = array('user_id' => (int) $user->id, 'subscriber_name' => $db->Quote($user->name), 'subscriber_email' => $db->Quote($user->email), 'confirmed' => 1, 'subscribe_date' => $db->Quote($now));
         $query = 'INSERT INTO `#__communicator_subscribers` SET ' . MageBridgeHelper::arrayToSql($fields);
         $db->setQuery($query);
         $db->query();
     }
     return true;
 }
Пример #19
0
 public function checkCondition($condition = null)
 {
     $user = JFactory::getUser();
     $condition = (int) $condition;
     if (!$condition > 0) {
         return false;
     }
     if (MageBridgeHelper::isJoomla15()) {
         if ($user->get('gid', 0) == $condition) {
             return true;
         }
     } else {
         if (is_array($user->groups) && in_array($condition, $user->groups)) {
             return true;
         }
     }
     return false;
 }
Пример #20
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // Add CSS-code
     $this->addCss('backend.css', 'media/com_magebridge/css/');
     if (MageBridgeHelper::isJoomla25()) {
         $this->addCss('backend-j25.css', 'media/com_magebridge/css/');
     }
     if (MageBridgeHelper::isJoomla35()) {
         $this->addCss('backend-j35.css', 'media/com_magebridge/css/');
     }
     // If we detect the API is down, report it
     $bridge = MageBridgeModelBridge::getInstance();
     if ($bridge->getApiState() != null) {
         $message = null;
         switch (strtoupper($bridge->getApiState())) {
             case 'EMPTY METADATA':
                 $message = JText::_('COM_MAGEBRIDGE_VIEW_API_ERROR_EMPTY_METADATA');
                 break;
             case 'SUPPORTKEY FAILED':
                 $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_KEY_FAILED', $bridge->getApiExtra());
                 break;
             case 'AUTHENTICATION FAILED':
                 $message = JText::_('COM_MAGEBRIDGE_VIEW_API_ERROR_AUTHENTICATION_FAILED');
                 break;
             case 'INTERNAL ERROR':
                 $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_INTERNAL_ERROR', MageBridgeHelper::getHelpLink('troubleshooting'));
                 break;
             case 'FAILED LOAD':
                 $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_FAILED_LOAD', MageBridgeHelper::getHelpLink('faq-troubleshooting:api-widgets'));
                 break;
             default:
                 $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_GENERIC', $bridge->getApiState());
                 break;
         }
         MageBridgeModelDebug::getInstance()->feedback($message);
     }
     // If debugging is enabled report it
     if (MagebridgeModelConfig::load('debug') == 1 && JFactory::getApplication()->input->getCmd('tmpl') != 'component' && in_array(JFactory::getApplication()->input->getCmd('view'), array('config', 'home'))) {
         MageBridgeModelDebug::getInstance()->feedback('COM_MAGEBRIDGE_VIEW_API_DEBUGGING_ENABLED');
     }
     parent::display($tpl);
 }
Пример #21
0
 /**
  * Method to get the HTML of this element
  *
  * @param null
  * @return string
  */
 protected function getInput()
 {
     $name = $this->name;
     $fieldName = $name;
     $value = $this->value;
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         $cache = JFactory::getCache('com_magebridge.admin');
         $options = $cache->call(array('MagebridgeFormFieldScripts', 'getResult'));
         // Parse the result into an HTML form-field
         if (!empty($options) && is_array($options)) {
             $current_options = MageBridgeHelper::getDisableJs();
             $size = count($options) > 10 ? 10 : count($options);
             array_unshift($options, array('value' => '', 'label' => '- ' . JText::_('None') . ' -'));
             return JHTML::_('select.genericlist', $options, $name . '[]', 'multiple="multiple" size="' . $size . '"', 'value', 'label', $current_options);
         } else {
             MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "scripts": ' . var_export($options, true));
         }
     }
     return '<input type="text" name="' . $name . '" value="' . $value . '" />';
 }
Пример #22
0
 /**
  * Helper-method to initialize YireoCommonView-based views
  *
  * @param string $name
  * @return mixed
  */
 public static function initialize($title)
 {
     // Load important variables
     $document = JFactory::getDocument();
     $view = JFactory::getApplication()->input->getCmd('view');
     // Add CSS-code
     $document->addStyleSheet(JURI::root() . 'media/com_magebridge/css/backend.css');
     $document->addStyleSheet(JURI::root() . 'media/com_magebridge/css/backend-view-' . $view . '.css');
     if (MageBridgeHelper::isJoomla25()) {
         $document->addStyleSheet(JURI::root() . 'media/com_magebridge/css/backend-j25.css');
     }
     if (MageBridgeHelper::isJoomla35()) {
         $document->addStyleSheet(JURI::root() . 'media/com_magebridge/css/backend-j35.css');
     }
     // Page title
     $title = JText::_('COM_MAGEBRIDGE_VIEW_' . strtoupper(str_replace(' ', '_', $title)));
     JToolBarHelper::title('MageBridge: ' . $title, 'logo.png');
     // Add the menu
     self::addMenuItems();
 }
Пример #23
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         $cache = JFactory::getCache('com_magebridge_admin');
         $cache->setCaching(0);
         $options = $cache->call(array('JElementScripts', 'getResult'));
         // Parse the result into an HTML form-field
         if (!empty($options) && is_array($options)) {
             $current_options = MageBridgeHelper::getDisableJs();
             array_unshift($options, array('value' => 'all', 'label' => '- ' . JText::_('All scripts') . ' -'));
             array_unshift($options, array('value' => '', 'label' => '- ' . JText::_('No scripts') . ' -'));
             $size = count($options);
             if ($size > 10) {
                 $size = 10;
             }
             return JHTML::_('select.genericlist', $options, $name . '[]', 'multiple size="' . $size . '"', 'value', 'label', $current_options);
         } else {
             MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "scripts": ' . var_export($options, true));
         }
     }
     return '<input type="text" name="' . $name . '" value="' . $value . '" />';
 }
Пример #24
0
 public function getMagentoGroupId($user)
 {
     static $rows = null;
     if (!is_array($rows)) {
         $db = JFactory::getDBO();
         $db->setQuery('SELECT * FROM #__magebridge_usergroups WHERE `published`=1 ORDER BY `ordering`');
         $rows = $db->loadObjectList();
     }
     if (!empty($rows)) {
         if (MageBridgeHelper::isJoomla15()) {
             $usergroups = isset($user['gid']) ? array($user['gid']) : array();
         } else {
             $usergroups = isset($user['groups']) ? $user['groups'] : array();
         }
         foreach ($rows as $row) {
             if (in_array($row->joomla_group, $usergroups)) {
                 return $row->magento_group;
             }
         }
     }
     return null;
 }
Пример #25
0
 /**
  * Method to display the requested view
  */
 public function display($tpl = null)
 {
     // Load the parameters
     $params = MageBridgeHelper::getParams();
     // Load the request
     $request = $params->get('request');
     if (empty($request)) {
         $request = JFactory::getApplication()->input->getString('request');
     }
     // Remove the dummy ID from the request
     $request = preg_replace('/^([0-9]+)\\:/', '', $request);
     // Set the request
     $this->setRequest($request);
     // Reuse this request to set the Canonical URL
     if (MagebridgeModelConfig::load('enable_canonical') == 1) {
         $uri = MageBridgeUrlHelper::route($request);
         $document = JFactory::getDocument();
         $document->setMetaData('canonical', $uri);
     }
     // Set which block to display
     $this->setBlock('content');
     parent::display($tpl);
 }
Пример #26
0
 /**
  * Handle the event that is generated after a customer logs out (bridge-response)
  *
  * @param array $arguments
  *
  * @return bool
  */
 public function mageCustomerLogoutAfter($arguments = array())
 {
     // Abort if the input is invalid
     if (empty($arguments) || empty($arguments['customer']['email'])) {
         return false;
     }
     // Joomla! expects more parameters, so we need to fetch those first
     $customer = $arguments['customer'];
     $user = $this->getUser()->loadByEmail($customer['email']);
     $customer['username'] = $customer['email'];
     $customer['id'] = $user->id;
     // Add options for our own user-plugin
     // @todo: options:
     // - action = core.login.site
     // - remember = 1
     // - return = {URL}
     // - entry_url = {URL}
     $options = array('disable_bridge' => true, 'action' => 'core.login.site');
     // Call the Joomla! event "onLogoutUser"
     $eventName = MageBridgeHelper::isJoomla15() ? 'onLogoutUser' : 'onUserLogout';
     JPluginHelper::importPlugin('user');
     JFactory::getApplication()->triggerEvent($eventName, array($customer, $options));
     return true;
 }
Пример #27
0
 public static function filterContent($content)
 {
     // Allow to disable this filtering
     if (MagebridgeModelConfig::load('filter_content') == 0) {
         return $content;
     }
     // Get common variables
     $bridge = MageBridgeModelBridge::getInstance();
     // Convert all remaining Magento links to Joomla! links
     $content = str_replace($bridge->getMagentoUrl() . 'index.php/', $bridge->getJoomlaBridgeUrl(), $content);
     $content = str_replace($bridge->getMagentoUrl() . 'magebridge.php/', $bridge->getJoomlaBridgeUrl(), $content);
     // Implement a very dirty hack because PayPal converts URLs "&" to "and"
     $current = MageBridgeUrlHelper::current();
     if (strstr($current, 'paypal') && strstr($current, 'redirect')) {
         // Try to find the distorted URLs
         $matches = array();
         if (preg_match_all('/([^\\"\']+)com_magebridgeand([^\\"\']+)/', $content, $matches)) {
             foreach ($matches[0] as $match) {
                 // Replace the wrong "and" words with "&" again
                 $url = str_replace('com_magebridgeand', 'com_magebridge&', $match);
                 $url = str_replace('rootand', 'root&', $url);
                 // Replace the wrong URL with its correction
                 $content = str_replace($match, $url, $content);
             }
         }
     }
     // Replace all uenc-URLs from Magento with URLs parsed through JRoute
     $matches = array();
     $replaced = array();
     if (preg_match_all('/\\/uenc\\/([a-zA-Z0-9\\-\\_\\,]+)/', $content, $matches)) {
         foreach ($matches[1] as $match) {
             // Decode the match
             $original_url = MageBridgeEncryptionHelper::base64_decode($match);
             $url = $original_url;
             $url = MageBridgeUrlHelper::stripUrl($url);
             // Convert the non-SEF URL to a SEF URL
             if (preg_match('/^index.php\\?option=com_magebridge/', $url)) {
                 // Parse the URL but do NOT turn it into SEF because of Mage_Core_Controller_Varien_Action::_isUrlInternal()
                 $url = MageBridgeHelper::filterUrl(str_replace('/', urldecode('/'), $url), false);
                 $url = $bridge->getJoomlaBridgeSefUrl($url);
             } else {
                 if (!preg_match('/^(http|https)/', $url)) {
                     $url = $bridge->getJoomlaBridgeSefUrl($url);
                 }
                 $url = preg_replace('/\\?SID=([a-zA-Z0-9\\-\\_]{12,42})/', '', $url);
             }
             // Extra check on HTTPS
             if (JURI::getInstance()->isSSL() == true) {
                 $url = str_replace('http://', 'https://', $url);
             } else {
                 $url = str_replace('https://', 'http://', $url);
             }
             // Replace the URL in the content
             if ($original_url != $url && $original_url . '/' != $url && !in_array($match, $replaced)) {
                 MageBridgeModelDebug::getInstance()->notice('Translating uenc-URL from ' . $original_url . ' to ' . $url);
                 $base64_url = MageBridgeEncryptionHelper::base64_encode($url);
                 $content = str_replace($match, $base64_url, $content);
                 $replaced[] = $match;
             }
         }
     }
     // Match all URLs and filter them
     $matches = array();
     if (preg_match_all('/index.php\\?option=com_magebridge([^\'\\"\\<]+)([\'\\"\\<]{1})/', $content, $matches)) {
         for ($i = 0; $i < count($matches[0]); $i++) {
             $oldurl = 'index.php?option=com_magebridge' . $matches[1][$i];
             $end = $matches[2][$i];
             $newurl = MageBridgeHelper::filterUrl($oldurl);
             if (!empty($newurl)) {
                 $content = str_replace($oldurl . $end, $newurl . $end, $content);
             }
         }
     }
     // Clean-up left-overs
     $content = str_replace('?___SID=U', '', $content);
     $content = str_replace('?___SID=S', '', $content);
     $content = preg_replace('/\\?___store=([a-zA-Z0-9]+)/', '', $content);
     $content = preg_replace('/\\?SID=([a-zA-Z0-9\\-\\_]{12,42})/', '', $content);
     // Remove double-slashes
     //$basedir = preg_replace('/^([\/]?)(.*)([\/]?)$/', '\2', JURI::base(true));
     //$content = str_replace(JURI::base().$basedir, JURI::base(), $content);
     $content = str_replace(JURI::base() . '/', JURI::base(), $content);
     // Adjust wrong media-URLs
     if (JURI::getInstance()->isSSL() == true) {
         $non_https = preg_replace('/^https:/', 'http:', $bridge->getMagentoUrl());
         $https = preg_replace('/^http:/', 'https:', $bridge->getMagentoUrl());
         $content = str_replace($non_https, $https, $content);
     }
     // Adjust incorrect URLs with parameters starting with &
     if (preg_match_all('/(\'|\\")(http|https):\\/\\/([^\\&\\?\'\\"]+)\\&/', $content, $matches)) {
         foreach ($matches[0] as $index => $match) {
             $content = str_replace($matches[3][$index] . '&', $matches[3][$index] . '?', $content);
         }
     }
     return $content;
 }
<?php

/*
 * Joomla! component MageBridge
 *
 * @author Yireo (info@yireo.com)
 * @package MageBridge
 * @copyright Copyright 2012
 * @license GNU Public License
 * @link http://www.yireo.com
 */
defined('_JEXEC') or die('Restricted access');
?>

<?php 
echo MageBridgeHelper::help('Before configuring things in this tab, make sure the API is up and running');
?>

<fieldset class="adminform">
<legend><?php 
echo JText::_('Website');
?>
</legend>
<table class="admintable">
    <?php 
if ($this->mode == 'advanced') {
    ?>
    <tr>
        <td class="key" valign="top">
            <?php 
    echo JText::_('Backend');
Пример #29
0
 /**
  * Method to do all plugin checks
  *
  * @package MageBridge
  * @access public
  * @param null
  * @return null
  */
 public function doPluginChecks()
 {
     $application = JFactory::getApplication();
     $db = JFactory::getDBO();
     $plugins = array(array('authentication', 'magebridge', 'Authentication - MageBridge', 'CHECK_PLUGIN_AUTHENTICATION'), array('magento', 'magebridge', 'Magento - MageBridge', 'CHECK_PLUGIN_MAGENTO'), array('magebridge', 'magebridge', 'MageBridge - Core', 'CHECK_PLUGIN_MAGEBRIDGE'), array('user', 'magebridge', 'User - MageBridge', 'CHECK_PLUGIN_USER'), array('system', 'magebridge', 'System - MageBridge', 'CHECK_PLUGIN_SYSTEM'), array('system', 'magebridgepre', 'System - MageBridge Preloader', 'CHECK_PLUGIN_PRELOADER'));
     foreach ($plugins as $plugin) {
         $group = $plugin[0];
         $name = $plugin[1];
         $title = $plugin[2];
         $description = $plugin[3];
         if (MageBridgeHelper::isJoomla15()) {
             $result = file_exists(JPATH_SITE . '/plugins/' . $group . '/' . $name . '.php') ? self::CHECK_OK : self::CHECK_ERROR;
         } else {
             $result = file_exists(JPATH_SITE . '/plugins/' . $group . '/' . $name . '/' . $name . '.php') ? self::CHECK_OK : self::CHECK_ERROR;
         }
         if ($result == self::CHECK_ERROR) {
             $description = JText::_('CHECK_PLUGIN_NOT_INSTALLED');
             $this->addResult('extensions', $title, self::CHECK_ERROR, $description);
         } else {
             $pluginObject = JPluginHelper::getPlugin($group, 'magebridge');
             if (MageBridgeHelper::isJoomla15()) {
                 $db->setQuery('SELECT id,published AS enabled FROM #__plugins WHERE `element`="magebridge" AND `folder`="' . $group . '" LIMIT 1');
             } else {
                 $db->setQuery('SELECT extension_id AS id,enabled FROM #__extensions WHERE `type`="plugin" AND `element`="magebridge" AND `folder`="' . $group . '" LIMIT 1');
             }
             $row = $db->loadObject();
             if (empty($row)) {
                 $description = JText::_('CHECK_PLUGIN_NOT_INSTALLED');
                 $this->addResult('extensions', $title, self::CHECK_ERROR, $description);
                 continue;
             }
             $url = 'index.php?option=com_plugins';
             if ($row->enabled == 0) {
                 $description = JText::sprintf('CHECK_PLUGIN_DISABLED', $url);
                 $this->addResult('extensions', $title, self::CHECK_ERROR, $description);
                 continue;
             }
             $this->addResult('extensions', $plugin[2], (bool) $pluginObject, JText::_('CHECK_PLUGIN_ENABLED'));
         }
     }
     return;
 }
Пример #30
0
 /**
  * Method to get a User-Agent string for MageBridge
  *
  * @return string
  */
 public function getUserAgentBySystem()
 {
     $user_agent = 'MageBridge ' . MageBridgeUpdateHelper::getComponentVersion();
     $user_agent .= ' (Joomla! ' . MageBridgeHelper::getJoomlaVersion() . ')';
     return $user_agent;
 }