Skip to content

fix for existing users logging from frontend#72

Merged
brianteeman merged 5 commits intobrianteeman:privacyfrom
alikon:patch-73
Apr 16, 2018
Merged

fix for existing users logging from frontend#72
brianteeman merged 5 commits intobrianteeman:privacyfrom
alikon:patch-73

Conversation

@alikon
Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown
Author

alikon commented Apr 15, 2018

@sandewt doesn't matter
added to this pr
thanks


if (is_object($data))
{

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Author

alikon commented Apr 15, 2018

@sandewt changed the query a little bit

@sandewt
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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