Ejemplo n.º 1
0
 /**
  * The main method of the Plugin
  *
  * @return	Mixed		Either returns an error or sends a redirect header
  */
 function main()
 {
     // Declare globals
     global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
     if (empty($BE_USER->user['tx_fbmagento_group'])) {
         $this->accessDenied();
     }
     // get Extension Config
     $this->emConf = tx_fbmagento_tools::getExtConfig();
     // get an Magento Instance
     $this->mage = tx_fbmagento_interface::getInstance($this->emConf);
     /*@var $mageUser Mage_Admin_Model_User */
     $mageUser = Mage::getSingleton('admin/user');
     $mageUser->loadByUsername($BE_USER->user['username']);
     if ($mageUser->getId()) {
         if ($mageUser->getRole()->getId() != $BE_USER->user['tx_fbmagento_group']) {
             $this->accessDenied('different Roles are set!');
         }
     } else {
         $mageUser->setData(array('username' => $BE_USER->user['username'], 'password' => $BE_USER->user['password'], 'firstname' => $BE_USER->user['realName'], 'lastname' => $BE_USER->user['realName'], 'email' => $BE_USER->user['email'], 'is_active' => true));
         $mageUser->save();
         $mageUser->setRoleIds(array($BE_USER->user['tx_fbmagento_group']))->setRoleUserId($mageUser->getUserId())->saveRelations();
     }
     /*@var $mageSession Mage_Admin_Model_Session */
     $mageSession = Mage::getSingleton('admin/session');
     // login User
     $this->loginMageUser($BE_USER->user['username']);
 }
Ejemplo n.º 2
0
 /**
  * init function
  *
  * @param string $type
  */
 protected function init($type)
 {
     switch ($type) {
         case "memory":
             $config = tx_fbmagento_tools::getExtConfig();
             require_once $config['path'] . 'lib/Zend/Registry.php';
             $this->_handler = Zend_Registry::getInstance();
             break;
     }
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }
 /**
  * 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));
 }