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

insert privacy consent note only one #75

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 46 additions & 38 deletions plugins/user/privacyconsent/privacyconsent.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,48 +202,56 @@ public function onUserAfterSave($data, $isNew, $result, $error)
return;
}

// Get the user's ID
$userId = ArrayHelper::getValue($data, 'id', 0, 'int');

// Get the user's IP address
$ip = $this->app->input->server->get('REMOTE_ADDR', '', 'string');

// Get the user agent string
$userAgent = $this->app->input->server->get('HTTP_USER_AGENT', '', 'string');

// Create the user note
$userNote = (object) array(
'user_id' => $userId,
'catid' => 0,
'subject' => Text::_('PLG_USER_PRIVACYCONSENT_SUBJECT'),
'body' => Text::sprintf('PLG_USER_PRIVACYCONSENT_BODY', $ip, $userAgent),
'state' => 1,
'created_time' => Factory::getDate()->toSql(),
);
$form = $this->app->input->post->get('jform', array(), 'array');

try
{
$this->db->insertObject('#__user_notes', $userNote);
}
catch (Exception $e)
if (isset($form['privacyconsent']['privacy']) && ($form['privacyconsent']['privacy']))
{
// Do nothing if the save fails
}
// Get the user's ID
$userId = ArrayHelper::getValue($data, 'id', 0, 'int');

// Create the consent confirmation
$confirm = (object) array(
'user_id' => $userId,
'profile_key' => 'consent',
'profile_value' => 1
);
// Get the user's IP address
$ip = $this->app->input->server->get('REMOTE_ADDR');
Copy link
Owner

Choose a reason for hiding this comment

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

can you revert the change on this line please


try
{
$this->db->insertObject('#__user_profiles', $confirm);
}
catch (Exception $e)
{
// Do nothing if the save fails
// Get the user agent string
$user_agent = $this->app->input->server->get('HTTP_USER_AGENT');
Copy link
Owner

Choose a reason for hiding this comment

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

and here


// Get the date in DB format
$now = JFactory::getDate()->toSql();
Copy link
Owner

Choose a reason for hiding this comment

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

why this change


// Create the user note
$userNote = (object) array(
'user_id' => $userId,
'catid' => 0,
'subject' => JText::_('PLG_USER_PRIVACY_SUBJECT'),
'body' => JText::sprintf('PLG_USER_PRIVACY_BODY', $ip, $user_agent),
'state' => 1,
'created_time' => $now
);

try
{
$result = JFactory::getDbo()->insertObject('#__user_notes', $userNote);
}
catch (Exception $e)
{
// Do nothing if the save fails
}

// Create the consent confirmation
$confirm = (object) array(
'user_id' => $userId,
'profile_key' => 'consent',
'profile_value' => 1
);

try
{
$result = JFactory::getDbo()->insertObject('#__user_profiles', $confirm);
}
catch (Exception $e)
{
// Do nothing if the save fails
}
}

return true;
Expand Down