/**
  * logoff Hook
  * 
  * @param array $params
  * @param t3lib_userAuth $pObj
  */
 public function logoff($params, &$pObj)
 {
     if (t3lib_div::GPvar('logintype') != 'logout' or $pObj->loginType != 'FE') {
         return;
     }
     // get Extension Config
     $this->emConf = tx_fbmagento_tools::getExtConfig();
     // get an Magento Instance
     $this->mage = tx_fbmagento_interface::getInstance($this->emConf);
     $this->mage->connector->logout();
 }
 /**
  * Set/Get attribute wrapper
  *
  * @param   string $method
  * @param   array $args
  * @return  mixed
  */
 public function __call($method, $args)
 {
     switch (substr($method, 0, 3)) {
         case 'get':
             $key = $this->_underscore(substr($method, 3));
             return $this->getData($key);
         case 'set':
             $key = $this->_underscore(substr($method, 3));
             return $this->setData($key, $args[0]);
         case 'uns':
             $key = $this->_underscore(substr($method, 3));
             return $this->unsData($key);
         case 'has':
             $key = $this->_underscore(substr($method, 3));
             return $this->hasData($key);
     }
     tx_fbmagento_tools::throwException("Invalid method " . get_class($this) . "::" . $method . "(" . print_r($args, 1) . ")");
 }
 /**
  * translates an Id to an Alias
  *
  * @param array $cfg
  * @param int $value
  * @return string alias
  */
 protected function id2alias($cfg, $value)
 {
     if (!$value) {
         return 0;
     }
     // is allready an Alias Cached then return it
     $lookupResult = $this->lookUp_idToUniqAlias($cfg, $value, 0);
     if ($lookupResult) {
         return $lookupResult;
     }
     // get Extension Config
     $conf = tx_fbmagento_tools::getExtConfig();
     // do Soap Call
     try {
         $soapClient = new tx_fbmagento_soapinterface($conf['url'], $conf['username'], $conf['password']);
         $soapClient->enableCache(isset($cfg['cache']) ? $cfg['cache'] : null);
         switch ($cfg['type']) {
             case 'idList':
                 $result = $soapClient->call($cfg['table']);
                 $newValue = $result[$value];
                 break;
             default:
                 $result = $soapClient->call($cfg['table'], array($value));
                 $newValue = $result[$cfg['alias_field']];
                 break;
         }
     } catch (Exception $e) {
         if ($this->getRealurlRef()->enableDevLog) {
             t3lib_div::devLog('Typogento Soap Error: ' . $e->getMessage(), 'realurl', -1);
         }
         return $value;
     }
     return $this->lookUp_newAlias($cfg, $newValue, $value, 0);
 }
 /**
  * Authenticate a user
  *
  * @param    array     Data of user.
  * @return    boolean
  */
 function authUser($user)
 {
     // get Extension Config
     $this->emConf = tx_fbmagento_tools::getExtConfig();
     // get an Magento Instance
     $this->mage = tx_fbmagento_interface::getInstance($this->emConf);
     if (empty($user['tx_fbmagento_id'])) {
         return 100;
     }
     $customer = Mage::getSingleton('customer/customer')->setWebsiteId($this->emConf['website'])->load($user['tx_fbmagento_id']);
     if ($customer->getConfirmation() && $customer->isConfirmationRequired() or !$customer->validatePassword($this->login['uident']) or $customer->getId() != $user['tx_fbmagento_id']) {
         return 100;
     }
     try {
         Mage::getSingleton('customer/session')->login($this->login['uname'], $this->login['uident']);
     } catch (Exeption $e) {
         return 100;
     }
     return 200;
 }
 /**
  * init Interface
  *
  * @param array emConf
  */
 public function init($config)
 {
     // init Config Array
     $this->config = $config;
     // include Mage
     if (!class_exists('Mage', false)) {
         require_once $this->config['path'] . 'app/Mage.php';
     }
     // disable Notices
     error_reporting(E_ALL & ~E_NOTICE);
     // overwrite Magento Autoload Funktion
     if (class_exists('Varien_Autoload', false)) {
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
     }
     spl_autoload_register(array(&$this, 'autoload'));
     // Init Mage
     $store = tx_fbmagento_tools::getFELangStoreCode();
     Mage::app()->setCurrentStore(Mage::app()->getStore($store));
     restore_error_handler();
     if ($GLOBALS['TSFE']->cObj instanceof tslib_cObj) {
         $cObj = $GLOBALS['TSFE']->cObj;
         $baseUrl = $cObj->getTypoLink_URL($GLOBALS['TSFE']->id);
         // get rid of trailing .html because of Real URL
         $pos = strrpos($baseUrl, '.');
         $extension = substr($baseUrl, $pos);
         if (strpos($extension, '/') === false) {
             $baseUrl = substr($baseUrl, 0, $pos);
         }
     }
     // Init Typo3connect
     $params = array('enabled' => true);
     if ('' != $baseUrl) {
         $params['_typo3BaseUrl'] = t3lib_div::locationHeaderUrl($baseUrl);
     }
     $this->connector = Mage::getSingleton('Flagbit_Typo3connect/Core', $params);
     if (null !== $cObj) {
         $this->connector->setcObj($cObj);
     }
 }
 /**
  * generates HMENU Array
  *
  * @param string $content
  * @param array $conf
  * @return array
  */
 public function categories($content, $conf)
 {
     $this->emConf = tx_fbmagento_tools::getExtConfig();
     $this->conf = $conf;
     $mage = tx_fbmagento_interface::getInstance($this->emConf);
     $categories = $this->getStoreCategories($this->conf['startcategory']);
     $menu = array();
     foreach ($categories as $category) {
         $item = $this->createMenuArrayItem($category);
         if (!$item) {
             continue;
         }
         $menu[] = $item;
     }
     return $menu;
 }
 /**
  * The main method of the PlugIn
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  * @return	The content that is displayed on the website
  */
 public function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_loadLL();
     $this->pi_USER_INT_obj = 1;
     // Flexform
     $this->pi_initPIflexForm();
     // get Extension Config
     $this->emConf = tx_fbmagento_tools::getExtConfig();
     // route throw piVars
     if ($this->piVars['shop']['route']) {
         $params = $this->piVars['shop'];
         // route throw Typoscript
     } elseif (isset($this->conf['params.']['route'])) {
         $params = $this->conf['params.'];
         // route throw Flexform
     } else {
         $params = array();
         if (!$this->view) {
             $this->getRoutingDataFromPage();
         }
         switch ($this->view) {
             case "SINGLEPRODUCT":
                 $product_id = $this->pi_getFFvalue($this->cObj->data["pi_flexform"], 'product_id', 'main');
                 $params = array('route' => 'catalog', 'controller' => 'product', 'action' => 'view', 'id' => $product_id);
                 break;
             case "PRODUCTLIST":
                 $category_id = $this->pi_getFFvalue($this->cObj->data["pi_flexform"], 'category_id', 'main');
                 $params = array('route' => 'catalog', 'controller' => 'category', 'action' => 'view', 'id' => $category_id);
                 break;
             case "USER":
                 $route = $this->pi_getFFvalue($this->cObj->data["pi_flexform"], 'route', 'main');
                 $controller = $this->pi_getFFvalue($this->cObj->data["pi_flexform"], 'controller', 'main');
                 $action = $this->pi_getFFvalue($this->cObj->data["pi_flexform"], 'action', 'main');
                 $params = array('route' => $route, 'controller' => $controller, 'action' => $action);
                 break;
         }
         $params = t3lib_div::array_merge_recursive_overrule($params, (array) $this->piVars['shop']);
     }
     // get an Magento Instance
     $this->mage = tx_fbmagento_interface::getInstance($this->emConf);
     $this->mage->setTsConfig($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_fbmagento_pi1.']);
     $this->mage->dispatch($params);
     // if Magento reports 404 error -> use TYPO3 page not found behavior
     if (isset($this->conf['useTYPO3pageNotFound']) && $this->conf['useTYPO3pageNotFound'] && strpos(serialize((array) Mage::app()->getResponse()->getHeaders()), '404 File not found')) {
         $GLOBALS['TSFE']->pageNotFoundAndExit();
     }
     // set Page Title
     $objHead = $this->mage->getBlock('head');
     if ($objHead instanceof Mage_Page_Block_Html_Head) {
         $GLOBALS['TSFE']->page['title'] = $objHead->getTitle();
     }
     // render Block specified by Typoscript
     if (isset($this->conf['block'])) {
         if ($this->conf['block'] == 'typo3header') {
             return $this->mage->getHeaderData();
         } elseif ($this->conf['block'] == 'pagetitle') {
             return $objHead->getTitle();
         } elseif ($this->conf['block'] == '__responseBody') {
             $content .= $this->mage->getBodyData();
         } elseif ($this->mage->getBlock($this->conf['block']) !== null) {
             $block = $this->mage->getBlock($this->conf['block']);
             // if Mage_Core_Block_Text
             if ($block instanceof Mage_Core_Block_Text) {
                 $block->setText('');
             }
             $content .= $block->toHtml();
         }
         // render default Blocks
     } else {
         // header
         if ($this->emConf['auto_header'] && $this->mage->getBlock('head') !== null) {
             $GLOBALS['TSFE']->additionalHeaderData[] = $this->mage->getHeaderData();
             $GLOBALS['TSFE']->page['title'] = $this->mage->getBlock('head')->getTitle();
         }
         // get Content
         if ($this->mage->getBlock('content') !== null) {
             $content .= $this->mage->getBlock('content')->toHtml();
         }
     }
     return isset($this->conf['nowrap']) && $this->conf['nowrap'] ? $content : $this->pi_wrapInBaseClass($content);
 }
Example #8
0
 /**
  * access Denied
  * 
  * @param string $msg
  */
 public function accessDenied($msg = null)
 {
     if ($msg === null) {
         $msg = 'Access denied!';
     }
     tx_fbmagento_tools::displayError($msg, true);
 }
 /**
  * generates an Category as Array for TCA Select fields
  *
  * @param array $params
  * @param object $pObj
  */
 public function itemsProcFunc_categories(&$params, &$pObj)
 {
     $conf = tx_fbmagento_tools::getExtConfig();
     try {
         $soapClient = new tx_fbmagento_soapinterface($conf['url'], $conf['username'], $conf['password']);
         $categories = $soapClient->catalog_category()->tree();
     } catch (Exception $e) {
         tx_fbmagento_tools::displayError('SOAP API Error: ' . $e->getMessage());
     }
     $this->getCategoryItems($params['items'], array($categories));
 }