Exemplo n.º 1
0
 /**
  * Event onAfterInitialise
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Perform actions on the frontend
     $application = JFactory::getApplication();
     // Check for postlogin-cookie
     if (isset($_COOKIE['mb_postlogin']) && !empty($_COOKIE['mb_postlogin'])) {
         // If the user is already logged in, remove the cookie
         if (JFactory::getUser()->id > 0) {
             setcookie('mb_postlogin', '', time() - 3600, '/', '.' . JURI::getInstance()->toString(array('host')));
         }
         // Otherwise decrypt the cookie and use it here
         $data = MageBridgeEncryptionHelper::decrypt($_COOKIE['mb_postlogin']);
         if (!empty($data)) {
             $customer_email = $data;
         }
     }
     // Perform a postlogin if needed
     if (YireoHelper::isJoomla35()) {
         $post = $application->input->post->getArray();
     }
     if (empty($post)) {
         $postlogin_userevents = $this->params->get('postlogin_userevents', 0) == 1 ? true : false;
         if (empty($customer_email)) {
             $customer_email = MageBridgeModelBridge::getInstance()->getSessionData('customer/email');
         }
         if (!empty($customer_email)) {
             MageBridge::getUser()->postlogin($customer_email, null, $postlogin_userevents);
         }
     }
 }