input; $provider = $input->getCmd('provider', null); if (!$provider) $app->redirect('index.php'); $provider = JFBCFactory::provider($provider); $providerUserId = $provider->getProviderUserId(); $profile = $provider->profile->fetchProfile($providerUserId, array('first_name', 'last_name', 'email', 'full_name')); if ($providerUserId == null) $app->redirect('index.php'); $args = array($provider->systemName); $profileFields = $app->triggerEvent('onSocialProfilesOnShowRegisterForm', $args); // Get previously filled in values $postData = $app->getUserState('com_jfbconnect.registration.data', array()); $email1 = ''; $email2 = ''; JFBConnectUtilities::getDisplayEmail($postData, $profile->get('email'), $email1, $email2); $config = JFBCFactory::config(); $providerUsername = ''; $postUsername = JFBConnectUtilities::getPostData($postData, 'username'); if ($postUsername != '') $providerUsername = $postUsername; else if (JFBCFactory::config()->get('registration_show_username') > USERNAME_LEAVE_BLANK) { $usernamePrefixFormat = $config->get('auto_username_format'); $providerUsername = JFBConnectUtilities::getAutoUsername($profile->get('first_name'), $profile->get('last_name'), $profile->get('email'), $provider->usernamePrefix, $providerUserId, $usernamePrefixFormat); } $providerMemberName = JFBConnectUtilities::getDisplayNameByFullName($postData, $profile->get('full_name')); if(JVERSION < 4.0) { Form::addFormPath(JPATH_SITE . '/components/com_users/models/forms'); Form::addFieldPath(JPATH_SITE . '/components/com_users/models/fields'); } else { Form::addFormPath(JPATH_SITE . '/components/com_users/forms'); } $language = Factory::getApplication()->getLanguage(); $language->load('com_users'); BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_users/models'); $userModel = BaseDatabaseModel::getInstance('Registration', 'UsersModel'); $this->data = $userModel->getData(); $this->form = $userModel->getForm(); // Setup the fields we can pre-populate // To do: Give option to show/hide the name on the form $this->form->setValue('name', null, $providerMemberName); if($config->get('registration_show_name') == NAME_HIDE && $providerMemberName != '') { $this->form->setFieldAttribute('name', 'type', 'hidden'); } $this->form->setValue('username', null, $providerUsername); if ($providerUsername != '') { if ($config->get('registration_show_username') == USERNAME_GENERATE_HIDE) $this->form->setFieldAttribute('username', 'type', 'hidden'); else if ($config->get('registration_show_username') == USERNAME_GENERATE_DISABLE) $this->form->setFieldAttribute('username', 'readonly', 'true'); } $this->form->setValue('email1', null, $email1); $this->form->setValue('email2', null, $email2); if ($email1 != '' && $email2 != '') { if ($config->get('registration_show_email') == EMAIL_HIDE) { $this->form->setFieldAttribute('email1', 'type', 'hidden'); $this->form->setFieldAttribute('email2', 'type', 'hidden'); } else if ($config->get('registration_show_email') == EMAIL_SHOW_DISABLE) { $this->form->setFieldAttribute('email1', 'readonly', 'true'); $this->form->setFieldAttribute('email2', 'readonly', 'true'); } } if ($config->get('registration_show_password') == 1) { $password_length = $config->get('random_password_length'); $password = UserHelper::genRandomPassword($password_length); $this->form->setValue('password1', null, $password); $this->form->setValue('password2', null, $password); $this->form->setFieldAttribute('password1', 'type', 'hidden'); $this->form->setFieldAttribute('password2', 'type', 'hidden'); } // Set an inputbox style on all the input elements so that inherited template styles look better $this->form->setFieldAttribute('name', 'class', 'inputbox required'); $this->form->setFieldAttribute('username', 'class', 'validate-username inputbox required'); $this->form->setFieldAttribute('email1', 'class', 'inputbox required'); $this->form->setFieldAttribute('email2', 'class', 'inputbox required'); $this->form->setFieldAttribute('password1', 'class', 'validate-password inputbox required'); $this->form->setFieldAttribute('password2', 'class', 'validate-password inputbox required'); //Check for form validation from each of the plugins $areProfilesValidating = $app->triggerEvent('onSocialProfilesAddFormValidation'); $defaultValidationNeeded = true; foreach ($areProfilesValidating as $hasDoneValidation) { if ($hasDoneValidation == true) { $defaultValidationNeeded = false; break; } } // Setup the view appearance // TODO: Make the addStyleSheet into a Utilities function to be used elsewhere. $displayType = $config->get('registration_display_mode');; $css = Path::find($this->_path['template'], 'loginregister.css'); $css = str_replace(JPATH_SITE, '', $css); $css = Uri::root().$css; $css = str_replace('\\', "/", $css); //Windows support for file separators $doc = Factory::getApplication()->getDocument(); $doc->addStyleSheet($css); // get the other providers, for showing their login buttons $altParams = array(); $allProviders = JFBCFactory::getAllProviders(); $altProviders = array(); foreach ($allProviders as $p) { if ($p->name != $provider->name) $altParams['providers'][] = $p->systemName; } $altParams['image'] = 'icon.png'; // Set the session bit to check for a new login on next page load //JFBConnectUtilities::setJFBCNewMappingEnabled(); $this->altParams = $altParams; $this->providerUserId = $providerUserId; $this->profile = $profile; $this->configModel = $config; $this->profileFields = $profileFields; $this->defaultValidationNeeded = $defaultValidationNeeded; $this->displayType = $displayType; $this->providerName = $provider->name; $this->altProviders = $altProviders; $captchaValue = ComponentHelper::getParams('com_users')->get('captcha', Factory::getApplication()->get('captcha', null)); Factory::getApplication()->set('captcha', $captchaValue); parent::display($tpl); } }