Пример #1
0
 /**
  * Helper method to sync the user
  *
  * @access private
  * @param object JUser
  * @return bool
  */
 private function syncUser($user = null)
 {
     // Check if we can run this event or not
     if (MageBridgePluginHelper::allowEvent('onUserDetailsUpdate') == false) {
         return;
     }
     // Copy the username to the email address
     if (JFactory::getApplication()->isSite() == true && $this->getUserParams()->get('username_from_email', 1) == 1 && $user->username != $user->email) {
         if ($this->getUser()->allowSynchronization($user, 'save') == true) {
             MageBridgeModelDebug::getInstance()->notice("onUserDetailsUpdate::bind on user " . $user->username);
             // Change the record in the database
             $user->email = $user->username;
             $user->save();
         }
     }
     // Synchronize this user-record with Magento
     if ($this->getUserParams()->get('user_sync', 1) == 1) {
         MageBridgeModelDebug::getInstance()->notice("onUserDetailsUpdate::usersync on user " . $user->username);
         // Convert this object to an array
         if (!is_array($user)) {
             jimport('joomla.utilities.arrayhelper');
             $user = JArrayHelper::fromObject($user, false);
         }
         // Sync this user-record with the bridge
         MageBridge::getUser()->synchronize($user);
     }
     return true;
 }
 /**
  * Event onUserLogout
  * 
  * @access public
  * @param array $user
  * @param array $options
  * @return bool
  */
 public function onUserLogout($user = null, $options = array())
 {
     // Check if we can run this event or not
     if (MageBridgePluginHelper::allowEvent('onUserLogout', $options) == false) {
         return;
     }
     // Get system variables
     $application = JFactory::getApplication();
     $session = JFactory::getSession();
     $bridge = MageBridgeModelBridge::getInstance();
     $register = MageBridgeModelRegister::getInstance();
     // Remove the frontend-cookie
     setcookie('frontend', NULL, -1);
     $session->set('magento_session', null);
     // Build the bridge and fetch the result
     $arguments = array('disable_events' => 1);
     $id = $register->add('logout', null, $arguments);
     $bridge->build();
     // Check whether SSO is enabled
     if ($this->getParam('enable_sso') == 1 && isset($user['username'])) {
         if ($application->isSite() && $this->getParam('enable_auth_frontend') == 1) {
             MageBridgeModelUserSSO::doSSOLogout($user['username']);
         } else {
             if ($application->isAdmin() && $this->getParam('enable_auth_backend') == 1) {
                 MageBridgeModelUserSSO::doSSOLogout($user['username']);
             }
         }
     }
     return true;
 }
Пример #3
0
 /**
  * Event onUserAfterLogout
  *
  * @param array $options
  *
  * @return bool
  */
 public function onUserAfterLogout($options = array())
 {
     $application = JFactory::getApplication();
     // Check if we can run this event or not
     if (MageBridgePluginHelper::allowEvent('onUserLogout', $options) == false) {
         return true;
     }
     // Check whether SSO is enabled
     if ($this->getParam('enable_sso') == 1 && isset($options['username'])) {
         if ($application->isSite() && $this->getParam('enable_auth_frontend') == 1) {
             MageBridgeModelUserSSO::doSSOLogout($options['username']);
         } else {
             if ($application->isAdmin() && $this->getParam('enable_auth_backend') == 1) {
                 MageBridgeModelUserSSO::doSSOLogout($options['username']);
             }
         }
     }
     return true;
 }