Esempio n. 1
0
 /**
  * Method to see whether a given page is a secure page
  *
  * @param string $request
  *
  * @return boolean
  */
 public static function isSSLPage($request = null)
 {
     $app = JFactory::getApplication();
     // Check current page
     if ($app->input->getCmd('option') == 'com_magebridge' && $app->input->getCmd('view') == 'content') {
         if (in_array($app->input->getCmd('layout'), array('checkout', 'cart'))) {
             return true;
         }
     }
     // Default pages to be served with SSL
     $pages = array('checkout/*', 'customer/*', 'wishlist/*');
     // Extra payment-pages to be served with SSL
     $payment_urls = explode(',', MagebridgeModelConfig::load('payment_urls'));
     if (!empty($payment_urls)) {
         foreach ($payment_urls as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $pages[] = $url . '/*';
             }
         }
     }
     return MageBridgeTemplateHelper::isPage($pages, $request);
 }
Esempio n. 2
0
 public function postlogin($user_email = null, $user_id = null, $throw_event = true)
 {
     // Check if the arguments are set
     if (empty($user_email) && $user_id > 0 == false) {
         return false;
     }
     // Check if this is the frontend
     $application = JFactory::getApplication();
     if ($application->isSite() == false) {
         return false;
     }
     // Check if this current request is actually a POST-request
     $post = JRequest::get('post');
     if (!empty($post)) {
         return false;
     }
     // Fetch the current user
     $user = JFactory::getUser();
     // Set the changed-flag
     $changed = false;
     // Check whether the Joomla! ID is different
     if ($user_id > 0 && $user->id != $user_id) {
         $db = JFactory::getDBO();
         $query = "SELECT id FROM #__users WHERE `id` = " . (int) $user_id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $user->load($user_id);
             $changed = true;
         }
     }
     // Double-check whether the Joomla! email is different
     if (!empty($user_email) && $user->email != $user_email) {
         $user = $this->loadByEmail($user_email);
         $changed = true;
     }
     // Check whether the Joomla! ID is set, but guest is still 1
     if ($user->id > 0 && $user->guest == 1) {
         $changed = true;
     }
     // If there is still no valid user, autocreate it
     // @note: Removed because this makes things overly complex
     /*if (!empty($user_email) && empty($user->email)) {
           $data = array(
               'name' => $user_email,
               'username' => $user_email,
               'email' => $user_email,
           );
           $user = $this->create($data);
           $changed = true;
       }*/
     // Do not fire the event when using the onepage-checkout
     if (MageBridgeTemplateHelper::isPage('checkout/onepage') == true && MageBridgeTemplateHelper::isPage('checkout/onepage/success') == false) {
         $throw_event = false;
     }
     if ($changed == true) {
         MageBridgeModelDebug::getInstance()->notice("Postlogin on user = "******"Firing event " . $eventName);
         JPluginHelper::importPlugin('user');
         JFactory::getApplication()->triggerEvent($eventName, array($user, $options));
     } else {
         // Update the user-session
         if (!empty($user)) {
             $this->updateSession($user);
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Method to postlogin a Magento customer
  *
  * @param string $user_email
  * @param int $user_id
  * @param bool $throw_event
  * @param bool $allow_post
  * @return bool
  */
 public function postlogin($user_email = null, $user_id = null, $throw_event = true, $allow_post = false)
 {
     // Check if the arguments are set
     if (empty($user_email) && $user_id > 0 == false) {
         return false;
     }
     // Bugfix for malformed email
     if (strstr($user_email, '%40')) {
         $user_email = urldecode($user_email);
     }
     // Check on the email
     if ($this->isValidEmail($user_email) == false) {
         return false;
     }
     // Check if this is the frontend
     $application = JFactory::getApplication();
     if ($application->isSite() == false) {
         return false;
     }
     // Check if this current request is actually a POST-request
     $post = JFactory::getApplication()->input->post->getArray();
     if (!empty($post) && $allow_post == false) {
         return false;
     }
     // Fetch the current user
     $user = JFactory::getUser();
     // Set the changed-flag
     $changed = false;
     // Check whether the Joomla! ID is different
     if ($user_id > 0 && $user->id != $user_id) {
         $db = JFactory::getDBO();
         $query = "SELECT id FROM #__users WHERE `id` = " . (int) $user_id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $user = JFactory::getUser($user_id);
             $changed = true;
         }
     }
     // Double-check whether the Joomla! email is different
     if (!empty($user_email) && $user->email != $user_email) {
         $user = $this->loadByEmail($user_email);
         $changed = true;
     }
     // Check whether the Joomla! ID is set, but guest is still 1
     if (!empty($user) && $user->id > 0 && isset($user->guest) && $user->guest == 1) {
         $changed = true;
     }
     // If there is still no valid user, autocreate it
     if (!empty($user_email) && (empty($user) || empty($user->email))) {
         $data = array('name' => $user_email, 'username' => $user_email, 'email' => $user_email);
         $user = $this->create($data);
         $changed = true;
     }
     // Do not fire the event when using the onepage-checkout
     if (MageBridgeTemplateHelper::isPage('checkout/onepage') == true && MageBridgeTemplateHelper::isPage('checkout/onepage/success') == false) {
         $throw_event = false;
     } elseif (MageBridgeTemplateHelper::isPage('firecheckout') == true) {
         $throw_event = false;
     }
     // Give a simple log-entry
     if ($changed == true) {
         MageBridgeModelDebug::getInstance()->notice("Postlogin on user = " . $user_email);
     }
     // If there are changes, throw the onLoginUser event
     $throw_event = true;
     if ($throw_event == true && $changed == true && !empty($user)) {
         // Add options for our own user-plugin
         $options = array('disable_bridge' => true, 'action' => 'core.login.site', 'return' => null);
         $options['remember'] = 1;
         // Convert the user-object to an array
         $user = JArrayHelper::fromObject($user);
         // Fire the event
         MageBridgeModelDebug::getInstance()->notice('Firing event onUserLogin');
         JPluginHelper::importPlugin('user');
         JFactory::getApplication()->triggerEvent('onUserLogin', array($user, $options));
     }
     return true;
 }
Esempio n. 4
0
 /**
  * Method to see whether a given page is a secure page
  * 
  * @access public
  * @param string $request
  * @return boolean
  */
 public static function isSSLPage($request = null)
 {
     // Default pages to be served with SSL
     $pages = array('checkout/*', 'customer/*', 'wishlist/*');
     // Extra payment-pages to be served with SSL
     $payment_urls = explode(',', MagebridgeModelConfig::load('payment_urls'));
     if (!empty($payment_urls)) {
         foreach ($payment_urls as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $pages[] = $url . '/*';
             }
         }
     }
     return MageBridgeTemplateHelper::isPage($pages, $request);
 }