Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for existing users logging from frontend #72

Merged
merged 5 commits into from
Apr 16, 2018
Merged

fix for existing users logging from frontend #72

merged 5 commits into from
Apr 16, 2018

Conversation

alikon
Copy link

@alikon alikon commented Apr 14, 2018

Pull Request for Issue # .
joomla#20051 (comment)

Testing Instructions

for existing users
when logging with an existing user you are redirected to the edit profile
when you click on I agree on the privacy field
now the profile submission is saved

@sandewt
Copy link

sandewt commented Apr 15, 2018

I have tried this: see comment joomla#20051.

The trailing is not correct.

Sorry this is not the correct way to show the code.

public function onContentPrepareForm($form, $data)
	{
		if (!($form instanceof JForm))
		{
			$this->_subject->setError('JERROR_NOT_A_FORM');

			return false;
		}

		// Check we are manipulating a valid form - we do not display this in the admin users form or profile view.
		$name   = $form->getName();
		$layout = $this->app->input->get('layout', 'default');
		$view   = $this->app->input->get('view', 'default');

		if (!in_array($name, array('com_admin.profile', 'com_users.profile', 'com_users.registration')) || $layout != "edit" && $view != "registration")
		{
			return true;
		}

		// Add the registration fields to the form.
		JForm::addFormPath(__DIR__ . '/privacyconsent');
		$form->loadFile('privacyconsent');

		$fields = array(
			'privacy',
		);

		if (is_object($data))
		{
			$userId = isset($data->id) ? $data->id : 0;

			if ($userId > 0)
			{
				// Load the profile data from the database.
				$db = JFactory::getDbo();

				$query = $db->getQuery(true)
					->select($db->quoteName('profile_value'))
					->from($db->quoteName('#__user_profiles'))
					->where($db->quoteName('user_id') . ' = ' . (int) $userId)
					->where($db->quoteName('profile_key') . ' LIKE ' . $db->quote('consent'))
					->order($db->quoteName('ordering') . ' ASC');
				$db->setQuery($query);

				try
				{
					$results = $db->loadRowList();
				}
				catch (RuntimeException $e)
				{
					$this->_subject->setError($e->getMessage());

					return false;
				}

				if (!empty($results[0]) == 1)
				{
					$form->removeField('privacy', 'privacyconsent');

					return true;
				}
			}
		}

		$privacyarticle = $this->params->get('privacy_article');
		$privacynote    = $this->params->get('privacy_note');

		// Push the privacy article ID into the privacy field.
		$form->setFieldAttribute('privacy', 'article', $privacyarticle, 'privacyconsent');
		$form->setFieldAttribute('privacy', 'note', $privacynote, 'privacyconsent');
	}

@alikon
Copy link
Author

alikon commented Apr 15, 2018

@sandewt doesn't matter
added to this pr
thanks

@@ -85,6 +85,44 @@ public function onContentPrepareForm($form, $data)
'privacy',
);

if (is_object($data))
{

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sandewt
Copy link

sandewt commented Apr 15, 2018

Thanks @alikon and @Quy .

Line 117:

if (!empty($results[0]) == 1)

Should be (better)

if (!empty($results[0]))

@alikon
Copy link
Author

alikon commented Apr 15, 2018

@sandewt changed the query a little bit

@sandewt
Copy link

sandewt commented Apr 15, 2018

@alikon / @brianteeman

At first this seemed to be a solution, but the problem is only being moved. Sad.

But when you (re) save (Edit Your Profile) the $form variable is emptied, after which the known warning message appears.

@sandewt
Copy link

sandewt commented Apr 15, 2018

better check

Thanks @alikon , works fine.

Rule 148: $option is not used anymore.

$option = $this->app->input->getCmd('option');

(The tooltip does not display the text correctly. )

@brianteeman brianteeman merged commit a02aa72 into brianteeman:privacy Apr 16, 2018
@brianteeman
Copy link
Owner

I have merged this code. my feeling was that it is not correct to only show the privacyconsent field on the edit profile field when the user has previously consented and that they should consent each time they update their information. However I am not that bothered about that so I have left it with your code

THANKS!!!

@alikon alikon deleted the patch-73 branch April 16, 2018 17:40
@alikon
Copy link
Author

alikon commented Apr 16, 2018

thanks for your patience

we can always make a new pr after the things become running in the wild

brianteeman pushed a commit that referenced this pull request May 19, 2018
…gins/installer/packageinstaller/tmpl/default.php

remove-inline-scripts/plugins/installer/packageinstaller/tmpl/default.php
brianteeman pushed a commit that referenced this pull request Aug 15, 2019
Scss refactoring with improved z-index
brianteeman pushed a commit that referenced this pull request May 26, 2020
Implement onBeforeDisplay plugin trigger
Implement onAfterDisplay plugin trigger
Disable publish calls via workflow plugin
brianteeman pushed a commit that referenced this pull request Dec 4, 2020
…orrect-font-name-fira-sans

Use the right font name "fira-sans" and not just "fira" for the scss file name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants