loadForm('com_slogin.login', 'login', array('load_data' => $loadData)); if (empty($form)) { return false; } return $form; } /** * Method to get the data that should be injected in the form. * * @return array The default data is an empty array. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered login form data. $app = JFactory::getApplication(); $input = new JInput; $data = $app->getUserState('slogin.login.form.data', array()); // check for return URL from the request first if ($return = $input->Get('return', '', 'BASE64')) { $data['return'] = base64_decode($return); if (!JURI::isInternal($data['return'])) { $data['return'] = ''; } } // Set the return URL if empty. if (!isset($data['return']) || empty($data['return'])) { $data['return'] = 'index.php?option=com_users&view=profile'; } $app->setUserState('users.login.form.data', $data); return $data; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState() { // Get the application object. $params = JFactory::getApplication()->getParams('com_users'); // Load the parameters. $this->setState('params', $params); } /** * Method to allow derived classes to preprocess the form. * * @param object A form object. * @param mixed The data expected for the form. * @param string The name of the plugin group to import (defaults to "content"). * @throws Exception if there is an error in the form event. * @since 1.6 */ protected function preprocessForm(JForm $form, $data, $group = 'user') { // Import the approriate plugin group. JPluginHelper::importPlugin($group); // Get the dispatcher. $dispatcher = JDispatcher::getInstance(); // Trigger the form preparation event. $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data)); // Check for errors encountered while preparing the form. if (count($results) && in_array(false, $results, true)) { // Get the last error. $error = $dispatcher->getError(); // Convert to a JException if necessary. if (!JError::isError($error)) { throw new Exception($error); } } } static function getReturnURL($params, $type) { $app = JFactory::getApplication(); $router = $app->getRouter(); $url = null; if ($itemid = $params->get($type)) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('link')); $query->from($db->quoteName('#__menu')); $query->where($db->quoteName('published') . '=1'); $query->where($db->quoteName('id') . '=' . $db->quote($itemid)); $db->setQuery($query); if ($link = $db->loadResult()) { if ($router->getMode() == JROUTER_MODE_SEF) { $url = 'index.php?Itemid='.$itemid; } else { $url = $link.'&Itemid='.$itemid; } } } if (!$url) { $app = JFactory::getApplication(); $url = base64_decode($app->getUserState('com_slogin.return_url')); } if (!$url) { // stay on the same page $uri = clone JFactory::getURI(); $vars = $router->parse($uri); unset($vars['lang']); if ($router->getMode() == JROUTER_MODE_SEF) { if (isset($vars['Itemid'])) { $itemid = $vars['Itemid']; $menu = $app->getMenu(); $item = $menu->getItem($itemid); unset($vars['Itemid']); if (isset($item) && $vars == $item->query) { $url = 'index.php?Itemid='.$itemid; } else { $url = 'index.php?'.JURI::buildQuery($vars).'&Itemid='.$itemid; } } else { $url = 'index.php?'.JURI::buildQuery($vars); } } else { $url = 'index.php?'.JURI::buildQuery($vars); } } return base64_encode($url); } }